99
1010class Workspace (AlpineObject ):
1111 """
12- A class for interacting with workspaces. Top -level methods deals with workspace properties. The subclass
13- Members can be used to interact with member lists.
12+ A class for interacting with workspaces. The top -level methods deal with workspace properties. The subclass
13+ `Member` can be used to interact with member lists.
1414
1515 """
1616 member = None
@@ -29,7 +29,7 @@ def __init__(self, base_url, session, token):
2929
3030 def create (self , workspace_name , public = False , summary = None ):
3131 """
32- Creates a workspace. Will fail if the workspace_name already exists.
32+ Creates a workspace. Will fail if the workspace name already exists.
3333
3434 :param str workspace_name: Unique workspace name.
3535 :param bool public: Allow the workspace to be viewable by non-members and non-admins.
@@ -62,8 +62,8 @@ def delete(self, workspace_id):
6262 """
6363 Attempts to delete the given workspace. Will fail if the workspace does not exist.
6464
65- :param str workspace_id: ID number of the workspace to be deleted.
66- :return: None
65+ :param str workspace_id: ID of the workspace to be deleted.
66+ :return: None.
6767 :rtype: NoneType
6868 :exception WorkspaceNotFoundException: The workspace does not exist.
6969
@@ -78,31 +78,31 @@ def delete(self, workspace_id):
7878 url = "{0}/workspaces/{1}" .format (self .base_url , workspace_id )
7979 url = self ._add_token_to_url (url )
8080
81- self .logger .debug ("Deleting workspace with ID: {0}" .format (workspace_id ))
81+ self .logger .debug ("Deleting workspace with ID: < {0}> " .format (workspace_id ))
8282 response = self .session .delete (url )
8383 self .logger .debug ("Received response code {0} with reason {1}"
8484 .format (response .status_code , response .reason ))
8585 if response .status_code == 200 :
8686 self .logger .debug ("Workspace successfully deleted." )
8787 else :
88- raise InvalidResponseCodeException ("Response Code Invalid , the expected Response Code is {0}, "
89- "the actual Response Code is {1}" .format (200 , response .status_code ))
88+ raise InvalidResponseCodeException ("Response code invalid , the expected response code is {0}, "
89+ "the actual response code is {1}" .format (200 , response .status_code ))
9090 return None
9191 except WorkspaceNotFoundException as err :
9292 self .logger .debug ("Workspace not found, error {0}" .format (err ))
9393
9494 def get_list (self , user_id = None , active = None , per_page = 50 ):
9595 """
96- Get a list of metadata for each workspace. If username is provided, only workspaces that the user \
96+ Gets a list of metadata for each workspace. If a user ID is provided, only workspaces that the user \
9797 is a member of will be returned.
9898
99- :param str user_id: ID number of the user.
100- :param bool active: Optionally only return active workspaces. True will return only the active spaces.
101- :param int per_page: How many workspaces to return in each page .
99+ :param str user_id: ID of the user.
100+ :param bool active: Return only active workspaces (optional) . True will only return the active spaces.
101+ :param int per_page: Maximum number to fetch with each API call .
102102
103103 :return: List of workspace metadata.
104104 :rtype: list of dict
105- :exception UserNotFoundException: The username does not exist.
105+ :exception UserNotFoundException: The user does not exist.
106106
107107 Example::
108108
@@ -150,10 +150,10 @@ def get_list(self, user_id=None, active=None, per_page=50):
150150
151151 def get (self , workspace_id ):
152152 """
153- Get one workspace's metadata.
153+ Gets a workspace's metadata.
154154
155155 :param str workspace_id: Unique workspace name.
156- :return: Single workspace's data
156+ :return: Selected workspace's data
157157 :rtype: dict
158158 :exception WorkspaceNotFoundException: The workspace does not exist.
159159
@@ -173,7 +173,7 @@ def get(self, workspace_id):
173173 workspace_response = r .json ()
174174 try :
175175 if workspace_response ['response' ]:
176- self .logger .debug ("Found workspace ID: <{0}> in list... " .format (workspace_id ))
176+ self .logger .debug ("Found workspace ID: <{0}> in list" .format (workspace_id ))
177177 return workspace_response ['response' ]
178178 else :
179179 raise WorkspaceNotFoundException ("Workspace ID: <{0}> not found" .format (workspace_id ))
@@ -182,11 +182,11 @@ def get(self, workspace_id):
182182
183183 def get_id (self , workspace_name , user_id = None ):
184184 """
185- Get the ID number of the workspace. Will throw an exception if the workspace does not exist.
185+ Get the ID of the workspace. Will throw an exception if the workspace does not exist.
186186
187187 :param str workspace_name: Unique workspace name.
188- :param int user_id: ID number of a user.
189- :return: ID number of the workspace.
188+ :param int user_id: ID of a user.
189+ :return: ID of the workspace.
190190 :rtype: int
191191 :exception WorkspaceNotFoundException: The workspace does not exist.
192192
@@ -201,22 +201,22 @@ def get_id(self, workspace_name, user_id=None):
201201 if workspace ['name' ] == workspace_name :
202202 return workspace ['id' ]
203203 # return None
204- raise WorkspaceNotFoundException ("The workspace with name < {0}> is not found for user <{1}>" .format (
204+ raise WorkspaceNotFoundException ("The workspace with name ' {0}' is not found for user ID: <{1}>" .format (
205205 workspace_name , user_id ))
206206
207207 def update (self , workspace_id , is_public = None , is_active = None , name = None ,
208208 summary = None , stage = None , owner_id = None ):
209209 """
210210 Update a workspace's metadata. Only included fields will be changed.
211211
212- :param int workspace_id: ID number of the workspace.
212+ :param int workspace_id: ID of the workspace.
213213 :param bool is_public: Allow the workspace to be viewable by non-members and non-admins.
214- :param bool is_active: Sets active vs. archived status.
214+ :param bool is_active: Set active vs. archived status.
215215 :param str name: New name for the workspace.
216216 :param str summary: New description of the workspace.
217- :param int stage: Stage ID number . Use the Workspace.Stage object for convenience.
218- :param int owner_id: ID number of the new workspace owner. Must also be a member of the workspace.
219- :return: Updated workspace metadata
217+ :param int stage: Stage ID. Use the ` Workspace.Stage` object for convenience.
218+ :param int owner_id: ID of the new workspace owner. This owner must also be a member of the workspace.
219+ :return: Updated workspace metadata.
220220 :rtype: dict
221221
222222 Example::
@@ -257,11 +257,11 @@ def update(self, workspace_id, is_public=None, is_active=None, name=None,
257257 for member in members :
258258 if member ['id' ] == owner_id :
259259 is_member = True
260- self .logger .debug ("User with ID: <{0}> is a member of the workspace Id : <{1}>, OK to update owner"
260+ self .logger .debug ("User with ID: <{0}> is a member of the workspace ID : <{1}>, OK to update owner"
261261 .format (owner_id , workspace_id ))
262262 payload ["owner_id" ] = owner_id
263263 if not is_member :
264- raise WorkspaceMemberNotFoundException ("The user with Id : <{0}> is not a member of workspace ID: <{1}> "
264+ raise WorkspaceMemberNotFoundException ("The user with ID : <{0}> is not a member of workspace ID: <{1}> "
265265 "Cannot assign as the new owner."
266266 .format (owner_id , workspace_id )
267267 )
@@ -287,7 +287,7 @@ def get_list(self, workspace_id, per_page=100):
287287 """
288288 Gets metadata about all the users who are members of the workspace.
289289
290- :param str workspace_id: ID number of the workspace.
290+ :param str workspace_id: ID of the workspace.
291291 :param int int per_page: Maximum number to fetch with each API call.
292292 :return: A list of user data.
293293 :rtype: list of dict
@@ -323,15 +323,15 @@ def get_list(self, workspace_id, per_page=100):
323323
324324 def add (self , workspace_id , user_id , role = None ):
325325 """
326- Add a new user to the workspace member list.
326+ Adds a new user to the workspace member list.
327327
328- :param int workspace_id: ID number of the workspace.
329- :param int user_id: ID number of member to add to the workspace.
330- :param str role: Role for the user. Use Workspace.MemberRole for convenience.
328+ :param int workspace_id: ID of the workspace.
329+ :param int user_id: ID of member to add to the workspace.
330+ :param str role: Role for the user. Use ` Workspace.MemberRole` for convenience.
331331 :return: Updated member list.
332332 :rtype: list of dict
333- :exception WorkspaceNotFoundException: The workspace ID number does not exist.
334- :exception UserNotFoundException: The user ID number does not exist.
333+ :exception WorkspaceNotFoundException: The workspace does not exist.
334+ :exception UserNotFoundException: The user does not exist.
335335
336336 Example::
337337
@@ -356,14 +356,14 @@ def add(self, workspace_id, user_id, role=None):
356356
357357 def remove (self , workspace_id , user_id ):
358358 """
359- Remove a user from the workspace member list.
359+ Removes a user from the workspace member list.
360360
361- :param int workspace_id: ID number of the workspace.
362- :param int user_id: ID number of member to add to the workspace.
361+ :param int workspace_id: ID of the workspace.
362+ :param int user_id: ID of member to add to the workspace.
363363 :return: Updated member list.
364364 :rtype: list of dict
365- :exception WorkspaceNotFoundException: The workspace Id number does not exist.
366- :exception UserNotFoundException: The user Id number does not exist.
365+ :exception WorkspaceNotFoundException: The workspace does not exist.
366+ :exception UserNotFoundException: The user does not exist.
367367
368368 Example::
369369
@@ -378,7 +378,7 @@ def remove(self, workspace_id, user_id):
378378 for member in members :
379379 if member ['id' ] == user_id :
380380 self .logger .debug (
381- "Remove the user with ID: <{0}> from workspace with ID <{1}>" .format (user_id , workspace_id )
381+ "Removing the user ID: <{0}> from workspace ID: <{1}>" .format (user_id , workspace_id )
382382 )
383383 continue
384384 else :
@@ -387,14 +387,14 @@ def remove(self, workspace_id, user_id):
387387
388388 def update_role (self , workspace_id , user_id , new_role ):
389389 """
390- Update a user's role in a workspace. If the user is not a member of the workspace then no change will be
390+ Updates a user's role in a workspace. If the user is not a member of the workspace, then no change will be
391391 made.
392392
393- :param int workspace_id: ID number of the workspace.
394- :param int user_id: ID number of member to update.
395- :param str new_role: New role for the user. Use Workspace.MemberRole for convenience.
393+ :param int workspace_id: ID of the workspace.
394+ :param int user_id: ID of member to update.
395+ :param str new_role: New role for the user. Use ` Workspace.MemberRole` for convenience.
396396
397- :return: Updated member list
397+ :return: Updated member list.
398398 :rtype: list of dict
399399 :exception WorkspaceNotFoundException: The workspace does not exist.
400400
@@ -420,7 +420,7 @@ def __update(self, workspace_id, members):
420420 """
421421 General update member method. Mostly for internal use. Used by add, remove, and update.
422422
423- :param int workspace_id: ID number of the workspace.
423+ :param int workspace_id: ID of the workspace.
424424 :param list members: A formatted member list.
425425 :return: member list or error.
426426 """
0 commit comments