@@ -124,24 +124,23 @@ def _create_request_message(self, http_method, location_id, route_values=None,
124
124
route_values = {}
125
125
route_values ['area' ] = location .area
126
126
route_values ['resource' ] = location .resource_name
127
- route_template = self ._remove_optional_route_parameters (location .route_template ,
128
- route_values )
127
+ url = self ._transform_route_template (location .route_template , route_values )
129
128
logger .debug ('Route template: %s' , location .route_template )
130
- url = self ._client .format_url (route_template , ** route_values )
131
129
request = ClientRequest (method = http_method , url = self ._client .format_url (url ))
132
130
if query_parameters :
133
131
request .format_parameters (query_parameters )
134
132
return request
135
133
136
134
@staticmethod
137
- def _remove_optional_route_parameters (route_template , route_values ):
135
+ def _transform_route_template (route_template , route_values ):
138
136
new_template = ''
139
137
route_template = route_template .replace ('{*' , '{' )
140
138
for path_segment in route_template .split ('/' ):
141
139
if (len (path_segment ) <= 2 or not path_segment [0 ] == '{'
142
- or not path_segment [len (path_segment ) - 1 ] == '}'
143
- or path_segment [1 :len (path_segment ) - 1 ] in route_values ):
140
+ or not path_segment [len (path_segment ) - 1 ] == '}' ):
144
141
new_template = new_template + '/' + path_segment
142
+ elif path_segment [1 :len (path_segment ) - 1 ] in route_values :
143
+ new_template = new_template + '/' + route_values [path_segment [1 :len (path_segment ) - 1 ]]
145
144
return new_template
146
145
147
146
def _get_resource_location (self , location_id ):
@@ -222,7 +221,7 @@ def _negotiate_request_version(location, version):
222
221
else :
223
222
# We can send at the requested api version. Make sure the resource version
224
223
# is not bigger than what the server supports
225
- negotiated_version = str ( requested_api_version )
224
+ negotiated_version = match . group ( 1 )
226
225
is_preview = match .group (3 ) is not None
227
226
if is_preview :
228
227
negotiated_version += '-preview'
@@ -267,7 +266,7 @@ def _handle_error(self, request, response):
267
266
raise AzureDevOpsAuthenticationError (full_message_format .format (error_message = error_message ,
268
267
url = request .url ))
269
268
else :
270
- full_message_format = '{error_message}Operation returned an invalid status code of {status_code} .'
269
+ full_message_format = '{error_message}Operation returned a {status_code} status code.'
271
270
raise AzureDevOpsClientRequestError (full_message_format .format (error_message = error_message ,
272
271
status_code = response .status_code ))
273
272
0 commit comments