@@ -73,7 +73,7 @@ def __init__(self, sp):
73
73
"workspaces" : {
74
74
"keys" : ["name" , "organization" ],
75
75
"method_args" : self ._get_workspace_args ,
76
- "name_key" : "workspaceId " ,
76
+ "name_key" : "workspaceName " ,
77
77
},
78
78
}
79
79
@@ -101,7 +101,6 @@ def handle_overwrite(self, block, args, overwrite=False, destroy=False):
101
101
self .block_operations ["participants" ]["name_key" ] = "teamName"
102
102
else :
103
103
self .block_operations ["participants" ]["name_key" ] = "email"
104
-
105
104
if self .check_resource_exists (operation ["name_key" ], sp_args ):
106
105
# if resource exists and overwrite is true, delete
107
106
if overwrite :
@@ -169,11 +168,7 @@ def _get_workspace_args(self, args):
169
168
workspaceId used to delete will be retrieved using the _find_workspace_id()
170
169
method.
171
170
"""
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" ])
177
172
return ("delete" , "--id" , str (workspace_id ))
178
173
179
174
def _get_generic_deletion_args (self , args ):
@@ -267,12 +262,12 @@ def _find_workspace_id(self, organization, workspace_name):
267
262
organization name and workspace name. This ID will be used to delete the
268
263
workspace.
269
264
"""
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" )
278
273
return None
0 commit comments