@@ -73,7 +73,7 @@ def __init__(self, sp):
7373 "workspaces" : {
7474 "keys" : ["name" , "organization" ],
7575 "method_args" : self ._get_workspace_args ,
76- "name_key" : "workspaceId " ,
76+ "name_key" : "workspaceName " ,
7777 },
7878 }
7979
@@ -101,7 +101,6 @@ def handle_overwrite(self, block, args, overwrite=False, destroy=False):
101101 self .block_operations ["participants" ]["name_key" ] = "teamName"
102102 else :
103103 self .block_operations ["participants" ]["name_key" ] = "email"
104-
105104 if self .check_resource_exists (operation ["name_key" ], sp_args ):
106105 # if resource exists and overwrite is true, delete
107106 if overwrite :
@@ -169,11 +168,7 @@ def _get_workspace_args(self, args):
169168 workspaceId used to delete will be retrieved using the _find_workspace_id()
170169 method.
171170 """
172- workspace_id = self ._find_workspace_id (
173- json .loads (self .sp .workspaces .list ("-o" , "json" )),
174- args ["organization" ],
175- args ["name" ],
176- )
171+ workspace_id = self ._find_workspace_id (args ["organization" ], args ["name" ])
177172 return ("delete" , "--id" , str (workspace_id ))
178173
179174 def _get_generic_deletion_args (self , args ):
@@ -267,12 +262,12 @@ def _find_workspace_id(self, organization, workspace_name):
267262 organization name and workspace name. This ID will be used to delete the
268263 workspace.
269264 """
270- if "workspaces" in self .cached_jsondata :
271- workspaces = self . cached_jsondata ["workspaces" ]
272- for workspace in workspaces :
273- if (
274- workspace .get ("orgName" ) == organization
275- and workspace .get ("workspaceName" ) == workspace_name
276- ):
277- return workspace .get ("workspaceId" )
265+ jsondata = json . loads ( self .cached_jsondata )
266+ workspaces = jsondata ["workspaces" ]
267+ for workspace in workspaces :
268+ if (
269+ workspace .get ("orgName" ) == organization
270+ and workspace .get ("workspaceName" ) == workspace_name
271+ ):
272+ return workspace .get ("workspaceId" )
278273 return None
0 commit comments