Skip to content

Commit 7128b67

Browse files
committed
Allow empty regions
1 parent ccfe061 commit 7128b67

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

singlestoredb/management/workspace.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class WorkspaceGroup(object):
197197
def __init__(
198198
self, name: str, id: str,
199199
created_at: Union[str, datetime.datetime],
200-
region: Region,
200+
region: Optional[Region],
201201
firewall_ranges: List[str],
202202
terminated_at: Optional[Union[str, datetime.datetime]],
203203
):
@@ -248,10 +248,14 @@ def from_dict(
248248
:class:`WorkspaceGroup`
249249
250250
"""
251+
try:
252+
region = [x for x in manager.regions if x.id == obj['regionID']][0]
253+
except IndexError:
254+
region = None
251255
out = cls(
252256
name=obj['name'], id=obj['workspaceGroupID'],
253257
created_at=obj['createdAt'],
254-
region=[x for x in manager.regions if x.id == obj['regionID']][0],
258+
region=region,
255259
firewall_ranges=obj.get('firewallRanges', []),
256260
terminated_at=obj.get('terminatedAt'),
257261
)

0 commit comments

Comments
 (0)