|
14 | 14 | from .v5_0.client_factory import ClientFactoryV5_0 |
15 | 15 | from .v5_1.client_factory import ClientFactoryV5_1 |
16 | 16 |
|
17 | | - |
18 | 17 | logger = logging.getLogger(__name__) |
19 | 18 |
|
20 | 19 |
|
@@ -75,10 +74,25 @@ def _get_url_for_client_instance(self, client_class): |
75 | 74 | for resource_area in resource_areas: |
76 | 75 | if resource_area.id.lower() == resource_id.lower(): |
77 | 76 | return resource_area.location_url |
| 77 | + |
| 78 | + # Check SPS deployment level for the resource area |
| 79 | + resource_area = self._get_deployment_resource_area_from_sps(resource_id) |
| 80 | + if resource_area is not None: |
| 81 | + return resource_area.location_url |
| 82 | + |
78 | 83 | raise AzureDevOpsClientRequestError(('Could not find information for resource area {id} ' |
79 | 84 | + 'from server: {url}').format(id=resource_id, |
80 | 85 | url=self.base_url)) |
81 | 86 |
|
| 87 | + def _get_deployment_resource_area_from_sps(self, resource_id): |
| 88 | + resource_id = resource_id.lower() |
| 89 | + if resource_id in _deployment_level_resource_areas: |
| 90 | + return _deployment_level_resource_areas[resource_id] |
| 91 | + location_client = LocationClient(sps_url, self._creds) |
| 92 | + resource_area = location_client.get_resource_area(area_id=resource_id) |
| 93 | + _deployment_level_resource_areas[resource_id] = resource_area |
| 94 | + return resource_area |
| 95 | + |
82 | 96 | def authenticate(self): |
83 | 97 | self._get_resource_areas(force=True) |
84 | 98 |
|
@@ -110,3 +124,7 @@ def _get_resource_areas(self, force=False): |
110 | 124 | @staticmethod |
111 | 125 | def _combine_url(part1, part2): |
112 | 126 | return part1.rstrip('/') + '/' + part2.strip('/') |
| 127 | + |
| 128 | + |
| 129 | +_deployment_level_resource_areas = {} |
| 130 | +sps_url = 'https://app.vssps.visualstudio.com' |
0 commit comments