Skip to content

Commit 1af042c

Browse files
Fix IBM Schematics API compatibility issue (#1006)
* Fix IBM Schematics API compatibility issue The list_locations() method was removed from IBM Schematics SDK. Replace dynamic location discovery with hardcoded known IBM Cloud regions. Fixes AttributeError: 'SchematicsV1' object has no attribute 'list_locations' * Improve error handling for Schematics region failures - Track failed regions instead of silently ignoring all errors - Raise RuntimeError if ALL regions fail (prevents silent failures) - Include detailed error messages for debugging - Addresses CodeRabbit review feedback Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 157c4e1 commit 1af042c

1 file changed

Lines changed: 30 additions & 9 deletions

File tree

cloud_governance/common/clouds/ibm/developer_tools/schematic_operations.py

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,43 @@ def get_workspaces(self):
3434
def get_supported_locations(self):
3535
"""
3636
This method lists supported locations
37+
DEPRECATED: list_locations() was removed from IBM Schematics SDK
3738
:return:
3839
"""
39-
response = self.__client.list_locations().get_result()
40-
return response['locations']
40+
# Method no longer available in IBM Schematics SDK
41+
# Use known regions in get_all_workspaces() instead
42+
raise NotImplementedError("list_locations() is no longer available in IBM Schematics SDK")
4143

4244
def get_all_workspaces(self):
4345
"""
4446
This method lists all available schematics workspaces
4547
:return:
48+
:raises: RuntimeError if unable to query any region
4649
"""
47-
locations = self.get_supported_locations()
50+
# list_locations() was removed from IBM Schematics SDK
51+
# Use known IBM Cloud regions instead
52+
known_regions = ['us-south', 'us-east', 'eu-de', 'eu-gb']
4853
resources_list = {}
49-
for location in locations:
50-
region = location['region']
51-
geography_code = location['geography_code']
52-
self.set_service_url(region)
53-
if geography_code not in resources_list:
54-
resources_list[geography_code] = self.get_workspaces()
54+
failed_regions = []
55+
56+
for region in known_regions:
57+
try:
58+
self.set_service_url(region)
59+
workspaces = self.get_workspaces()
60+
if workspaces:
61+
resources_list[region] = workspaces
62+
except Exception as exc:
63+
# Track failed regions for debugging
64+
failed_regions.append((region, str(exc)))
65+
continue
66+
67+
# If all regions failed, raise error instead of returning empty dict
68+
if not resources_list and len(failed_regions) == len(known_regions):
69+
failed_details = '; '.join(f"{region}: {error}" for region, error in failed_regions)
70+
raise RuntimeError(
71+
f"Unable to list Schematics workspaces in any region. "
72+
f"All {len(known_regions)} regions failed. "
73+
f"Check credentials and permissions. Details: {failed_details}"
74+
)
75+
5576
return resources_list

0 commit comments

Comments
 (0)