Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,43 @@ def get_workspaces(self):
def get_supported_locations(self):
"""
This method lists supported locations
DEPRECATED: list_locations() was removed from IBM Schematics SDK
:return:
"""
response = self.__client.list_locations().get_result()
return response['locations']
# Method no longer available in IBM Schematics SDK
# Use known regions in get_all_workspaces() instead
raise NotImplementedError("list_locations() is no longer available in IBM Schematics SDK")

def get_all_workspaces(self):
"""
This method lists all available schematics workspaces
:return:
:raises: RuntimeError if unable to query any region
"""
locations = self.get_supported_locations()
# list_locations() was removed from IBM Schematics SDK
# Use known IBM Cloud regions instead
known_regions = ['us-south', 'us-east', 'eu-de', 'eu-gb']
resources_list = {}
for location in locations:
region = location['region']
geography_code = location['geography_code']
self.set_service_url(region)
if geography_code not in resources_list:
resources_list[geography_code] = self.get_workspaces()
failed_regions = []

for region in known_regions:
try:
self.set_service_url(region)
workspaces = self.get_workspaces()
if workspaces:
resources_list[region] = workspaces
except Exception as exc:
# Track failed regions for debugging
failed_regions.append((region, str(exc)))
continue
Comment thread
coderabbitai[bot] marked this conversation as resolved.

# If all regions failed, raise error instead of returning empty dict
if not resources_list and len(failed_regions) == len(known_regions):
failed_details = '; '.join(f"{region}: {error}" for region, error in failed_regions)
raise RuntimeError(
f"Unable to list Schematics workspaces in any region. "
f"All {len(known_regions)} regions failed. "
f"Check credentials and permissions. Details: {failed_details}"
)

return resources_list