Workspace¶
-
class
alpine.workspace.
Workspace
(base_url, session, token)¶ A class for interacting with workspaces. The top-level methods deal with workspace properties. The subclass Member can be used to interact with member lists.
-
class
Member
(base_url, session, token)¶ A class for interacting with workspace membership.
-
add
(workspace_id, user_id, role=None)¶ Adds a new user to the workspace member list.
Parameters: - workspace_id (int) – ID of the workspace.
- user_id (int) – ID of member to add to the workspace.
- role (str) – Role for the user. Use Workspace.MemberRole for convenience.
Returns: Updated member list.
Return type: list of dict
Raises: - WorkspaceNotFoundException – The workspace does not exist.
- UserNotFoundException – The user does not exist.
Example:
>>> session.workspace.member.add(workspace_id = 1672, user_id = 7, >>> role = session.workspace.memberRole.DataScientist)
-
get_list
(workspace_id, per_page=100)¶ Gets metadata about all the users who are members of the workspace.
Parameters: - workspace_id (str) – ID of the workspace.
- int per_page (int) – Maximum number to fetch with each API call.
Returns: A list of user data.
Return type: list of dict
Raises: WorkspaceNotFoundException – The workspace does not exist.
Example:
>>> session.workspace.member.get_list(workspace_id = 1672)
-
remove
(workspace_id, user_id)¶ Removes a user from the workspace member list.
Parameters: - workspace_id (int) – ID of the workspace.
- user_id (int) – ID of member to add to the workspace.
Returns: Updated member list.
Return type: list of dict
Raises: - WorkspaceNotFoundException – The workspace does not exist.
- UserNotFoundException – The user does not exist.
Example:
>>> session.workspace.member.remove(workspace_id = 1672, user_id = 7)
-
update_role
(workspace_id, user_id, new_role)¶ Updates a user’s role in a workspace. If the user is not a member of the workspace, then no change will be made.
Parameters: - workspace_id (int) – ID of the workspace.
- user_id (int) – ID of member to update.
- new_role (str) – New role for the user. Use Workspace.MemberRole for convenience.
Returns: Updated member list.
Return type: list of dict
Raises: WorkspaceNotFoundException – The workspace does not exist.
Example:
>>> session.workspace.member.update(workspace_id = 1672, user_id = 7, >>> new_role = session.workspace.memberRole.DataScientist)
-
-
class
MemberRole
¶ Convenience strings for user workspace member roles.
-
class
Stage
¶ Convenience IDs for workspace stages.
-
create
(workspace_name, public=False, summary=None)¶ Creates a workspace. Will fail if the workspace name already exists.
Parameters: - workspace_name (str) – Unique workspace name.
- public (bool) – Allow the workspace to be viewable by non-members and non-admins.
- summary (str) – Description of new workspace.
Returns: Created workspace information or error message.
Return type: dict
Example:
>>> session.workspace.create(workspace_name = "Public Data ETL", public = True)
-
delete
(workspace_id)¶ Attempts to delete the given workspace. Will fail if the workspace does not exist.
Parameters: workspace_id (str) – ID of the workspace to be deleted. Returns: None. Return type: NoneType Raises: WorkspaceNotFoundException – The workspace does not exist. Example:
>>> session.workspace.delete(workspace_id = 1671)
-
get
(workspace_id)¶ Gets a workspace’s metadata.
Parameters: workspace_id (str) – Unique workspace name. Returns: Selected workspace’s data Return type: dict Raises: WorkspaceNotFoundException – The workspace does not exist. Example:
>>> session.workspace.get(workspace_id = 1761)
-
get_id
(workspace_name, user_id=None)¶ Get the ID of the workspace. Will throw an exception if the workspace does not exist.
Parameters: - workspace_name (str) – Unique workspace name.
- user_id (int) – ID of a user.
Returns: ID of the workspace.
Return type: int
Raises: WorkspaceNotFoundException – The workspace does not exist.
Example:
>>> session.workspace.get_id("Public Data ETL") 1672
-
get_list
(user_id=None, active=None, per_page=50)¶ Gets a list of metadata for each workspace. If a user ID is provided, only workspaces that the user is a member of will be returned.
Parameters: - user_id (str) – ID of the user.
- active (bool) – Return only active workspaces (optional). True will only return the active spaces.
- per_page (int) – Maximum number to fetch with each API call.
Returns: List of workspace metadata.
Return type: list of dict
Raises: UserNotFoundException – The user does not exist.
Example:
>>> my_workspaces = session.workspace.get_list(user_id = my_user_id) >>> len(my_workspaces) 8
-
update
(workspace_id, is_public=None, is_active=None, name=None, summary=None, stage=None, owner_id=None)¶ Update a workspace’s metadata. Only included fields will be changed.
Parameters: - workspace_id (int) – ID of the workspace.
- is_public (bool) – Allow the workspace to be viewable by non-members and non-admins.
- is_active (bool) – Set active vs. archived status.
- name (str) – New name for the workspace.
- summary (str) – New description of the workspace.
- stage (int) – Stage ID. Use the Workspace.Stage object for convenience.
- owner_id (int) – ID of the new workspace owner. This owner must also be a member of the workspace.
Returns: Updated workspace metadata.
Return type: dict
Example:
>>> session.workspace.update(workspace_id = 1672, summary = "New focus of project is ML!", >>> stage = session.workspace.stage.Model)
-
class