Workspace names map onto Kubernetes objects, and must be DNS compliant. Workspace names must be ASCII alpha-numeric characters or dash (-) only. .
and _
are not allowed.
List the workspaces for a specific user.
Example: In this example, the workspaces for all users will be displayed.
# List workspaces
# Retrieve the token
headers = wl.auth.auth_header()
api_request = f"{APIURL}/v1/api/workspaces/list"
data = {
}
response = requests.post(api_request, json=data, headers=headers, verify=True).json()
response
{'workspaces': [{'id': 1,
'name': 'john.hummel@wallaroo.ai - Default Workspace',
'created_at': '2023-05-17T20:36:36.312003+00:00',
'created_by': '028c8b48-c39b-4578-9110-0b5bdd3824da',
'archived': False,
'models': [],
'pipelines': []},
{'id': 5,
'name': 'housepricedrift',
'created_at': '2023-05-17T20:41:50.351766+00:00',
'created_by': '028c8b48-c39b-4578-9110-0b5bdd3824da',
'archived': False,
'models': [1],
'pipelines': [1]},
{'id': 6,
'name': 'sdkquickworkspace',
'created_at': '2023-05-17T20:43:36.727099+00:00',
'created_by': '028c8b48-c39b-4578-9110-0b5bdd3824da',
'archived': False,
'models': [2, 3],
'pipelines': [3]}]}
A new workspace will be created in the Wallaroo instance. Upon creating, the workspace owner will be assigned as the user making the MLOps API request.
Example: In this example, a workspace with the name testapiworkspace
will be created, and the newly created workspace’s workspace_id
saved as the variable example_workspace_id
for use in other code examples. After the request is complete, the List Workspaces command will be issued to demonstrate the new workspace has been created.
# Create workspace
# Retrieve the token
headers = wl.auth.auth_header()
api_request = f"{APIURL}/v1/api/workspaces/create"
data = {
"workspace_name": example_workspace_name
}
response = requests.post(api_request, json=data, headers=headers, verify=True).json()
display(response)
# Stored for future examples
example_workspace_id = response['workspace_id']
{'workspace_id': 7}
## List workspaces
# Retrieve the token
headers = wl.auth.auth_header()
api_request = f"{APIURL}/v1/api/workspaces/list"
data = {
}
response = requests.post(api_request, json=data, headers=headers, verify=True).json()
response
{'workspaces': [{'id': 1,
'name': 'john.hummel@wallaroo.ai - Default Workspace',
'created_at': '2023-05-17T20:36:36.312003+00:00',
'created_by': '028c8b48-c39b-4578-9110-0b5bdd3824da',
'archived': False,
'models': [],
'pipelines': []},
{'id': 5,
'name': 'housepricedrift',
'created_at': '2023-05-17T20:41:50.351766+00:00',
'created_by': '028c8b48-c39b-4578-9110-0b5bdd3824da',
'archived': False,
'models': [1],
'pipelines': [1]},
{'id': 6,
'name': 'sdkquickworkspace',
'created_at': '2023-05-17T20:43:36.727099+00:00',
'created_by': '028c8b48-c39b-4578-9110-0b5bdd3824da',
'archived': False,
'models': [2, 3],
'pipelines': [3]},
{'id': 7,
'name': 'apiworkspaces',
'created_at': '2023-05-17T20:50:36.298217+00:00',
'created_by': '028c8b48-c39b-4578-9110-0b5bdd3824da',
'archived': False,
'models': [],
'pipelines': []}]}
Existing users of the Wallaroo instance can be added to an existing workspace.
Example: The following example adds the user created in Invite Users request to the workspace created in the Create Workspace request.
# Add existing user to existing workspace
# Retrieve the token
headers = wl.auth.auth_header()
api_request = f"{APIURL}/v1/api/workspaces/add_user"
data = {
"email":new_user,
"workspace_id": example_workspace_id
}
response = requests.post(api_request, json=data, headers=headers, verify=True).json()
response
{}
Lists the users who are either owners or collaborators of a workspace.
Example: The following example will list all users part of the workspace created in the Create Workspace request.
# List users in a workspace
# Retrieve the token
headers = wl.auth.auth_header()
api_request = f"{APIURL}/v1/api/workspaces/list_users"
data = {
"workspace_id": example_workspace_id
}
response = requests.post(api_request, json=data, headers=headers, verify=True).json()
response
{'users': [{'user_id': '028c8b48-c39b-4578-9110-0b5bdd3824da',
'user_type': 'OWNER'},
{'user_id': 'c64d26bc-5d30-4d0d-9ae9-9c0089bc4b80',
'user_type': 'COLLABORATOR'}]}
Removes the user from the given workspace. In this request, either the user’s Keycloak ID is required OR the user’s email address is required.
email
is not provided, then this parameter is REQUIRED.user_id
is not provided, then this parameter is REQUIRED.Example: The following example will remove the newUser
from workspace created in the Create Workspace request. Then the users for that workspace will be listed to verify newUser
has been removed.
# Remove existing user from an existing workspace
# Retrieve the token
headers = wl.auth.auth_header()
api_request = f"{APIURL}/v1/api/workspaces/remove_user"
data = {
"email":new_user,
"workspace_id": example_workspace_id
}
response = requests.post(api_request, json=data, headers=headers, verify=True).json()
response
{'affected_rows': 1}
## List users in a workspace
# Retrieve the token
headers = wl.auth.auth_header()
api_request = f"{APIURL}/v1/api/users/query"
data = {
"workspace_id": example_workspace_id
}
response = requests.post(api_request, json=data, headers=headers, verify=True).json()
response
{'users': {'de777519-2963-423a-92d2-e6e26d687527': {'access': {'mapRoles': True,
'view': True,
'manageGroupMembership': True,
'impersonate': False,
'manage': True},
'createdTimestamp': 1684355337295,
'disableableCredentialTypes': [],
'emailVerified': False,
'enabled': True,
'id': 'de777519-2963-423a-92d2-e6e26d687527',
'notBefore': 0,
'requiredActions': [],
'username': 'admin'},
'c64d26bc-5d30-4d0d-9ae9-9c0089bc4b80': {'access': {'manage': True,
'mapRoles': True,
'manageGroupMembership': True,
'impersonate': False,
'view': True},
'createdTimestamp': 1684356685177,
'disableableCredentialTypes': [],
'email': 'john.hansarick@wallaroo.ai',
'emailVerified': True,
'enabled': True,
'firstName': 'John',
'id': 'c64d26bc-5d30-4d0d-9ae9-9c0089bc4b80',
'lastName': 'Hansarick',
'notBefore': 0,
'requiredActions': [],
'username': 'john.hansarick@wallaroo.ai'},
'028c8b48-c39b-4578-9110-0b5bdd3824da': {'access': {'mapRoles': True,
'view': True,
'impersonate': False,
'manage': True,
'manageGroupMembership': True},
'createdTimestamp': 1684355671859,
'disableableCredentialTypes': [],
'email': 'john.hummel@wallaroo.ai',
'emailVerified': False,
'enabled': True,
'firstName': 'John',
'id': '028c8b48-c39b-4578-9110-0b5bdd3824da',
'lastName': 'Hansarick',
'notBefore': 0,
'requiredActions': [],
'username': 'john.hummel@wallaroo.ai'}}}