@autorest/python 6.7.4 → 6.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -406,9 +406,13 @@ class ClientParameter(Parameter):
|
|
|
406
406
|
def method_location(self) -> ParameterMethodLocation:
|
|
407
407
|
if self.constant:
|
|
408
408
|
return ParameterMethodLocation.KWARG
|
|
409
|
-
if
|
|
410
|
-
self.
|
|
411
|
-
|
|
409
|
+
if (
|
|
410
|
+
self.is_host
|
|
411
|
+
and (
|
|
412
|
+
self.code_model.options["version_tolerant"]
|
|
413
|
+
or self.code_model.options["low_level_client"]
|
|
414
|
+
)
|
|
415
|
+
and not self.code_model.options["azure_arm"]
|
|
412
416
|
):
|
|
413
417
|
# this means i am the base url
|
|
414
418
|
return ParameterMethodLocation.KEYWORD_ONLY
|
|
@@ -1918,7 +1918,7 @@ class Deserializer(object):
|
|
|
1918
1918
|
if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore
|
|
1919
1919
|
raise DeserializationError("Date must have only digits and -. Received: %s" % attr)
|
|
1920
1920
|
# This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception.
|
|
1921
|
-
return isodate.parse_date(attr, defaultmonth=
|
|
1921
|
+
return isodate.parse_date(attr, defaultmonth=0, defaultday=0)
|
|
1922
1922
|
|
|
1923
1923
|
@staticmethod
|
|
1924
1924
|
def deserialize_time(attr):
|
|
@@ -201,6 +201,10 @@ HEADERS_CONVERT_IN_METHOD = {
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
|
|
204
|
+
def get_wire_name_lower(parameter: Dict[str, Any]) -> str:
|
|
205
|
+
return (parameter.get("wireName") or "").lower()
|
|
206
|
+
|
|
207
|
+
|
|
204
208
|
def headers_convert(yaml_data: Dict[str, Any], replace_data: Any) -> None:
|
|
205
209
|
if isinstance(replace_data, dict):
|
|
206
210
|
for k, v in replace_data.items():
|
|
@@ -307,19 +311,41 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
|
|
|
307
311
|
yaml_data["builderPadName"] = to_snake_case(prop_name)
|
|
308
312
|
for og in yaml_data["operationGroups"]:
|
|
309
313
|
for o in og["operations"]:
|
|
314
|
+
property_if_match = None
|
|
315
|
+
property_if_none_match = None
|
|
310
316
|
for p in o["parameters"]:
|
|
317
|
+
wire_name_lower = get_wire_name_lower(p)
|
|
311
318
|
if (
|
|
312
319
|
p["location"] == "header"
|
|
313
|
-
and
|
|
314
|
-
):
|
|
315
|
-
yaml_data["requestIdHeaderName"] = p["wireName"]
|
|
316
|
-
if (
|
|
317
|
-
self.version_tolerant
|
|
318
|
-
and p["location"] == "header"
|
|
319
|
-
and p["clientName"] in ("if_match", "if_none_match")
|
|
320
|
+
and wire_name_lower == "client-request-id"
|
|
320
321
|
):
|
|
321
|
-
|
|
322
|
-
|
|
322
|
+
yaml_data["requestIdHeaderName"] = wire_name_lower
|
|
323
|
+
if self.version_tolerant and p["location"] == "header":
|
|
324
|
+
if wire_name_lower == "if-match":
|
|
325
|
+
property_if_match = p
|
|
326
|
+
elif wire_name_lower == "if-none-match":
|
|
327
|
+
property_if_none_match = p
|
|
328
|
+
# pylint: disable=line-too-long
|
|
329
|
+
# some service(e.g. https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cosmos-db/data-plane/Microsoft.Tables/preview/2019-02-02/table.json)
|
|
330
|
+
# only has one, so we need to add "if-none-match" or "if-match" if it's missing
|
|
331
|
+
if not property_if_match and property_if_none_match:
|
|
332
|
+
property_if_match = property_if_none_match.copy()
|
|
333
|
+
property_if_match["wireName"] = "if-match"
|
|
334
|
+
if not property_if_none_match and property_if_match:
|
|
335
|
+
property_if_none_match = property_if_match.copy()
|
|
336
|
+
property_if_none_match["wireName"] = "if-none-match"
|
|
337
|
+
|
|
338
|
+
if property_if_match and property_if_none_match:
|
|
339
|
+
# arrange if-match and if-none-match to the end of parameters
|
|
340
|
+
o["parameters"] = [
|
|
341
|
+
item
|
|
342
|
+
for item in o["parameters"]
|
|
343
|
+
if get_wire_name_lower(item)
|
|
344
|
+
not in ("if-match", "if-none-match")
|
|
345
|
+
] + [property_if_match, property_if_none_match]
|
|
346
|
+
|
|
347
|
+
o["hasEtag"] = True
|
|
348
|
+
yaml_data["hasEtag"] = True
|
|
323
349
|
|
|
324
350
|
def get_operation_updater(
|
|
325
351
|
self, yaml_data: Dict[str, Any]
|