@autorest/python 6.7.4 → 6.7.6

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.
@@ -85,8 +85,6 @@ class Client(_ClientConfigBase[ClientGlobalParameterList]):
85
85
  request_builders: List[Union[RequestBuilder, OverloadedRequestBuilder]] = []
86
86
  for og_group in self.yaml_data["operationGroups"]:
87
87
  for operation_yaml in og_group["operations"]:
88
- if operation_yaml["discriminator"] in ("lro", "lropaging"):
89
- continue
90
88
  request_builder = get_request_builder(
91
89
  operation_yaml,
92
90
  code_model=self.code_model,
@@ -146,10 +146,6 @@ class LROOperationBase(OperationBase[LROResponseType]):
146
146
  file_import.add_submodule_import("typing", "cast", ImportType.STDLIB)
147
147
  return file_import
148
148
 
149
- @classmethod
150
- def get_request_builder(cls, yaml_data: Dict[str, Any], client: "Client"):
151
- return client.lookup_request_builder(id(yaml_data["initialOperation"]))
152
-
153
149
 
154
150
  class LROOperation(LROOperationBase[LROResponse]):
155
151
  ...
@@ -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 self.is_host and (
410
- self.code_model.options["version_tolerant"]
411
- or self.code_model.options["low_level_client"]
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
@@ -57,6 +57,10 @@ class RequestBuilderBase(BaseBuilder[ParameterListType]):
57
57
  self.method: str = yaml_data["method"]
58
58
  self.want_tracing = False
59
59
 
60
+ @property
61
+ def is_lro(self) -> bool:
62
+ return self.yaml_data.get("discriminator") in ("lro", "lropaging")
63
+
60
64
  @property
61
65
  def pylint_disable(self) -> str:
62
66
  if len(self.name) > NAME_LENGTH_LIMIT:
@@ -48,6 +48,7 @@ class OperationGroupsSerializer:
48
48
  and r.group_name == operation_group.property_name
49
49
  and not r.is_overload
50
50
  and not r.abstract
51
+ and not r.is_lro # lro has already initial builder
51
52
  ]
52
53
 
53
54
  def serialize(self) -> str:
@@ -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=None, defaultday=None)
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 p["wireName"] == "client-request-id"
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
- o["hasEtag"] = True
322
- yaml_data["hasEtag"] = True
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]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autorest/python",
3
- "version": "6.7.4",
3
+ "version": "6.7.6",
4
4
  "description": "The Python extension for generators in AutoRest.",
5
5
  "main": "index.js",
6
6
  "repository": {