Lock or Unlock a Workspace
API Endpoint: lock_workspace
Locks and unlocks a workspace to restrict certain actions
Important
An API Key is required for ALL private workspace activities
The API Key name component can be added to your header using any of the following ways, “X-CKAN-API-Key”, “EDX-API-Key”, or “Authorization”.
Attention
Add the
"User-Agent":
parameter within theheaders
of the API requestSet
"User-Agent":
to the value"EDX-USER"
Workspace Lock Key Features
A workspace can be lock and unlocked within the EDX UI and via API script
Locking a Workspace
- ONLY the following roles can lock a workspace
System Administrator
Workspace Administrator
Unlocking a Workspace
- ONLY the following roles can unlock a workspace
System Administrator
Workspace Administrator who locked the workspace
Feature Functionaility in a Locked Workspace
When a user locks a workspace, functionality within the workspace is limited
The user who locks the workspace will have no restrictions of features within a workspace
Note
If the Lock Restriction
field in the tables below are True
, the feature is restricted when a workspace is locked
Parameters for Workspace Lock
Feature Name |
Lock Restriction |
---|---|
|
True |
|
True |
|
True |
|
True |
|
True |
|
False |
|
False |
|
False |
|
True |
|
True |
|
True |
|
True |
|
True |
|
True |
|
True |
|
True |
Feature Name |
Lock Restriction |
---|---|
|
True |
|
False |
|
False |
|
True |
|
True |
|
False |
|
True |
|
True |
|
True |
|
True |
|
True |
|
True |
|
True |
Feature Name |
Lock Restriction |
---|---|
|
True |
|
False |
|
False |
|
False |
|
False |
|
False |
|
True |
|
True |
|
True |
|
True |
Parameter Definitions
Parameter Name |
Description |
Required Fields |
---|---|---|
|
ID associated with the workspace |
Required |
|
API key associated with the the user |
Required |
|
Boolean grabbed from database table to identify if workspace is locked |
N/A |
Example: Lock and Unlock a Workspace
Attention
Add the
"User-Agent":
parameter within theheaders
of the API requestSet
"User-Agent":
to the value"EDX-USER"
Note
- The
is_locked
output parameter’s value is gathered from the workspace lock database table If
is_locked
value isTrue
, the workspace is lockedIf
is_locked
value isFalse
, the workspace is unlocked
import requests
headers = {
"EDX-API-Key": 'YOUR_API_KEY_HERE',
"User-Agent": 'EDX-USER',
'Content-Type': 'application/json',
'Accept':'application/json'
}
data = {
'workspace_id': 'WORKSPACE-ID-HERE'
}
url = 'https://edx.netl.doe.gov/api/3/action/lock_workspace'
r = requests.post(
url, # URL to API endpoint
headers=headers, # Headers dictionary
json=data, # Dictionary of data params
)
r_json = r.json()
print (r.json())
{'help': '/api/3/action/help_show?name=workspace_lock_api', 'success': True, 'result': {'is_locked': True}}
{'help': '/api/3/action/help_show?name=workspace_lock_api', 'success': True, 'result': {'is_locked': False}}
Example: Error Message Output when Perfoming a Lock Restricted Action
Attention
Add the
"User-Agent":
parameter within theheaders
of the API requestSet
"User-Agent":
to the value"EDX-USER"
Note
- The
is_locked
output parameter’s value is gathered from the workspace lock database table If
is_locked
value isTrue
, the workspace is lockedIf
is_locked
value isFalse
, the workspace is unlocked
import requests
headers = {
"EDX-API-Key": 'YOUR-API-KEY-HERE',
"User-Agent": "EDX-USER"
}
data = {
"workspace_id": 'YOUR-WORKSPACE-NAME-OR-ID-HERE',
"folder_name": 'Test Folder 123',
"parent_id": 'ID-OF-DESTINATION-FOLDER-HERE'
}
url = 'https://edx.netl.doe.gov/api/3/action/create_folder'
r = requests.post(
url, # URL to API endpoint
headers=headers, # Headers dictionary
data=data, # Dictionary of data params
)
print (r.json())
print("End results")
{'help': '/api/3/action/help_show?name=resource_delete', 'error': {'message': 'This workspace was locked by <EDX-USERNAME-WHO-LOCKED-WORKSPACE> (<EDX-USER-EMAIL>)
and you cannot perform this action. It must be unlocked by the user who locked it.', '__type': 'Validation Error'}, 'success': False}