@autorest/python 5.16.0 → 5.17.0
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.
- package/ChangeLog.md +43 -3
- package/README.md +30 -4
- package/autorest/__init__.py +1 -1
- package/autorest/codegen/__init__.py +48 -209
- package/autorest/codegen/models/__init__.py +116 -83
- package/autorest/codegen/models/base_builder.py +49 -88
- package/autorest/codegen/models/base_model.py +1 -1
- package/autorest/codegen/models/{base_schema.py → base_type.py} +56 -40
- package/autorest/codegen/models/client.py +157 -48
- package/autorest/codegen/models/code_model.py +108 -254
- package/autorest/codegen/models/combined_type.py +107 -0
- package/autorest/codegen/models/{constant_schema.py → constant_type.py} +49 -40
- package/autorest/codegen/models/credential_types.py +224 -0
- package/autorest/codegen/models/{dictionary_schema.py → dictionary_type.py} +41 -31
- package/autorest/codegen/models/enum_type.py +195 -0
- package/autorest/codegen/models/imports.py +23 -0
- package/autorest/codegen/models/list_type.py +134 -0
- package/autorest/codegen/models/lro_operation.py +77 -156
- package/autorest/codegen/models/lro_paging_operation.py +28 -11
- package/autorest/codegen/models/model_type.py +239 -0
- package/autorest/codegen/models/operation.py +303 -269
- package/autorest/codegen/models/operation_group.py +48 -89
- package/autorest/codegen/models/paging_operation.py +80 -123
- package/autorest/codegen/models/parameter.py +289 -396
- package/autorest/codegen/models/parameter_list.py +348 -360
- package/autorest/codegen/models/primitive_types.py +544 -0
- package/autorest/codegen/models/property.py +109 -139
- package/autorest/codegen/models/request_builder.py +105 -88
- package/autorest/codegen/models/request_builder_parameter.py +112 -100
- package/autorest/codegen/models/response.py +325 -0
- package/autorest/codegen/models/utils.py +12 -19
- package/autorest/codegen/serializers/__init__.py +46 -37
- package/autorest/codegen/serializers/builder_serializer.py +604 -1146
- package/autorest/codegen/serializers/client_serializer.py +83 -88
- package/autorest/codegen/serializers/general_serializer.py +5 -64
- package/autorest/codegen/serializers/import_serializer.py +7 -4
- package/autorest/codegen/serializers/metadata_serializer.py +15 -104
- package/autorest/codegen/serializers/model_base_serializer.py +40 -32
- package/autorest/codegen/serializers/model_generic_serializer.py +8 -6
- package/autorest/codegen/serializers/model_init_serializer.py +2 -4
- package/autorest/codegen/serializers/model_python3_serializer.py +22 -16
- package/autorest/codegen/serializers/operation_groups_serializer.py +4 -13
- package/autorest/codegen/serializers/parameter_serializer.py +174 -0
- package/autorest/codegen/serializers/request_builders_serializer.py +12 -29
- package/autorest/codegen/serializers/utils.py +0 -142
- package/autorest/codegen/templates/MANIFEST.in.jinja2 +1 -0
- package/autorest/codegen/templates/{service_client.py.jinja2 → client.py.jinja2} +7 -7
- package/autorest/codegen/templates/config.py.jinja2 +13 -13
- package/autorest/codegen/templates/enum.py.jinja2 +4 -4
- package/autorest/codegen/templates/enum_container.py.jinja2 +1 -1
- package/autorest/codegen/templates/init.py.jinja2 +2 -2
- package/autorest/codegen/templates/lro_operation.py.jinja2 +4 -1
- package/autorest/codegen/templates/lro_paging_operation.py.jinja2 +4 -1
- package/autorest/codegen/templates/metadata.json.jinja2 +33 -33
- package/autorest/codegen/templates/model.py.jinja2 +23 -24
- package/autorest/codegen/templates/model_container.py.jinja2 +2 -1
- package/autorest/codegen/templates/model_init.py.jinja2 +3 -5
- package/autorest/codegen/templates/operation.py.jinja2 +6 -8
- package/autorest/codegen/templates/operation_group.py.jinja2 +7 -7
- package/autorest/codegen/templates/operation_groups_container.py.jinja2 +1 -1
- package/autorest/codegen/templates/operation_tools.jinja2 +8 -2
- package/autorest/codegen/templates/paging_operation.py.jinja2 +2 -2
- package/autorest/codegen/templates/request_builder.py.jinja2 +13 -11
- package/autorest/codegen/templates/setup.py.jinja2 +9 -3
- package/autorest/codegen/templates/vendor.py.jinja2 +1 -1
- package/autorest/jsonrpc/server.py +15 -3
- package/autorest/m4reformatter/__init__.py +1108 -0
- package/autorest/multiapi/models/code_model.py +1 -1
- package/autorest/multiapi/serializers/__init__.py +4 -4
- package/autorest/multiapi/templates/multiapi_config.py.jinja2 +3 -3
- package/autorest/multiapi/templates/multiapi_init.py.jinja2 +2 -2
- package/autorest/multiapi/templates/multiapi_operations_mixin.py.jinja2 +3 -3
- package/autorest/multiapi/templates/multiapi_service_client.py.jinja2 +9 -9
- package/autorest/postprocess/__init__.py +202 -0
- package/autorest/postprocess/get_all.py +19 -0
- package/autorest/postprocess/venvtools.py +73 -0
- package/autorest/preprocess/__init__.py +209 -0
- package/autorest/preprocess/helpers.py +54 -0
- package/autorest/{namer → preprocess}/python_mappings.py +21 -16
- package/package.json +2 -2
- package/autorest/codegen/models/credential_model.py +0 -55
- package/autorest/codegen/models/credential_schema.py +0 -95
- package/autorest/codegen/models/credential_schema_policy.py +0 -73
- package/autorest/codegen/models/enum_schema.py +0 -225
- package/autorest/codegen/models/list_schema.py +0 -135
- package/autorest/codegen/models/object_schema.py +0 -303
- package/autorest/codegen/models/primitive_schemas.py +0 -495
- package/autorest/codegen/models/request_builder_parameter_list.py +0 -249
- package/autorest/codegen/models/schema_request.py +0 -55
- package/autorest/codegen/models/schema_response.py +0 -141
- package/autorest/namer/__init__.py +0 -23
- package/autorest/namer/name_converter.py +0 -509
|
@@ -3,37 +3,19 @@
|
|
|
3
3
|
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
|
-
import
|
|
7
|
-
|
|
6
|
+
from typing import Dict, List, Any, TYPE_CHECKING
|
|
7
|
+
|
|
8
|
+
from autorest.codegen.models.utils import OrderedSet
|
|
8
9
|
|
|
9
10
|
from .base_model import BaseModel
|
|
10
|
-
from .operation import
|
|
11
|
-
from .lro_operation import LROOperation
|
|
12
|
-
from .paging_operation import PagingOperation
|
|
13
|
-
from .lro_paging_operation import LROPagingOperation
|
|
11
|
+
from .operation import OperationBase, get_operation
|
|
14
12
|
from .imports import FileImport, ImportType, TypingSection
|
|
13
|
+
from .utils import add_to_pylint_disable
|
|
15
14
|
|
|
16
15
|
if TYPE_CHECKING:
|
|
17
16
|
from .code_model import CodeModel
|
|
18
17
|
|
|
19
18
|
|
|
20
|
-
_LOGGER = logging.getLogger(__name__)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def _get_operation(yaml_data: Dict[str, Any], code_model: "CodeModel") -> Operation:
|
|
24
|
-
lro_operation = yaml_data.get("extensions", {}).get("x-ms-long-running-operation")
|
|
25
|
-
paging_operation = yaml_data.get("extensions", {}).get("x-ms-pageable")
|
|
26
|
-
operation_schema = Operation
|
|
27
|
-
if lro_operation and paging_operation:
|
|
28
|
-
operation_schema = LROPagingOperation
|
|
29
|
-
elif lro_operation:
|
|
30
|
-
operation_schema = LROOperation
|
|
31
|
-
elif paging_operation:
|
|
32
|
-
operation_schema = PagingOperation
|
|
33
|
-
operation = operation_schema.from_yaml(yaml_data, code_model=code_model)
|
|
34
|
-
return operation
|
|
35
|
-
|
|
36
|
-
|
|
37
19
|
class OperationGroup(BaseModel):
|
|
38
20
|
"""Represent an operation group."""
|
|
39
21
|
|
|
@@ -41,14 +23,12 @@ class OperationGroup(BaseModel):
|
|
|
41
23
|
self,
|
|
42
24
|
yaml_data: Dict[str, Any],
|
|
43
25
|
code_model: "CodeModel",
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
operations: List[Operation],
|
|
47
|
-
api_versions: Set[str],
|
|
26
|
+
operations: List[OperationBase],
|
|
27
|
+
api_versions: List[str],
|
|
48
28
|
) -> None:
|
|
49
29
|
super().__init__(yaml_data, code_model)
|
|
50
|
-
self.
|
|
51
|
-
self.
|
|
30
|
+
self.class_name: str = yaml_data["className"]
|
|
31
|
+
self.property_name: str = yaml_data["propertyName"]
|
|
52
32
|
self.operations = operations
|
|
53
33
|
self.api_versions = api_versions
|
|
54
34
|
|
|
@@ -58,7 +38,7 @@ class OperationGroup(BaseModel):
|
|
|
58
38
|
|
|
59
39
|
def base_class(self, async_mode: bool) -> str:
|
|
60
40
|
base_classes: List[str] = []
|
|
61
|
-
if self.
|
|
41
|
+
if self.is_mixin and self.code_model.need_mixin_abc:
|
|
62
42
|
base_classes.append("MixinABC")
|
|
63
43
|
if not (async_mode or self.code_model.options["python3_only"]):
|
|
64
44
|
base_classes.append("object")
|
|
@@ -69,48 +49,43 @@ class OperationGroup(BaseModel):
|
|
|
69
49
|
def imports_for_multiapi(self, async_mode: bool) -> FileImport:
|
|
70
50
|
file_import = FileImport()
|
|
71
51
|
for operation in self.operations:
|
|
72
|
-
file_import.merge(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
52
|
+
file_import.merge(
|
|
53
|
+
operation.imports_for_multiapi(
|
|
54
|
+
async_mode, relative_path=".." if async_mode else "."
|
|
55
|
+
)
|
|
56
|
+
)
|
|
76
57
|
return file_import
|
|
77
58
|
|
|
59
|
+
@property
|
|
60
|
+
def pylint_disable(self) -> str:
|
|
61
|
+
retval: str = ""
|
|
62
|
+
if self.has_abstract_operations:
|
|
63
|
+
retval = add_to_pylint_disable(retval, "abstract-class-instantiated")
|
|
64
|
+
return retval
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def mypy_ignore(self) -> str:
|
|
68
|
+
if self.has_abstract_operations:
|
|
69
|
+
return " # type: ignore"
|
|
70
|
+
return ""
|
|
71
|
+
|
|
78
72
|
def imports(self, async_mode: bool, is_python3_file: bool) -> FileImport:
|
|
79
73
|
file_import = FileImport()
|
|
80
74
|
|
|
75
|
+
relative_path = "..." if async_mode else ".."
|
|
81
76
|
for operation in self.operations:
|
|
82
|
-
file_import.merge(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
file_import.add_submodule_import(
|
|
86
|
-
local_path, "models", ImportType.LOCAL, alias="_models"
|
|
87
|
-
)
|
|
88
|
-
if self.code_model.options["builders_visibility"] == "embedded" and async_mode:
|
|
89
|
-
if not self.code_model.options["combine_operation_files"]:
|
|
90
|
-
operation_group_name = (
|
|
91
|
-
"" if self.is_empty_operation_group else self.name
|
|
92
|
-
)
|
|
93
|
-
operation_group_builders = [
|
|
94
|
-
r
|
|
95
|
-
for r in self.code_model.request_builders
|
|
96
|
-
if r.operation_group_name == operation_group_name
|
|
97
|
-
]
|
|
98
|
-
else:
|
|
99
|
-
operation_group_builders = self.code_model.request_builders
|
|
100
|
-
for request_builder in operation_group_builders:
|
|
101
|
-
if request_builder.abstract:
|
|
102
|
-
continue
|
|
103
|
-
python3_only = self.code_model.options["python3_only"]
|
|
104
|
-
typed_sync_operation_file = self.code_model.options[
|
|
105
|
-
"add_python3_operation_files"
|
|
106
|
-
]
|
|
107
|
-
suffix = (
|
|
108
|
-
"_py3" if typed_sync_operation_file and not python3_only else ""
|
|
77
|
+
file_import.merge(
|
|
78
|
+
operation.imports(
|
|
79
|
+
async_mode, is_python3_file, relative_path=relative_path
|
|
109
80
|
)
|
|
81
|
+
)
|
|
82
|
+
# for multiapi
|
|
83
|
+
if not self.code_model.options["version_tolerant"]:
|
|
84
|
+
if (
|
|
85
|
+
self.code_model.model_types or self.code_model.enums
|
|
86
|
+
) and self.code_model.options["models_mode"]:
|
|
110
87
|
file_import.add_submodule_import(
|
|
111
|
-
|
|
112
|
-
request_builder.name,
|
|
113
|
-
import_type=ImportType.LOCAL,
|
|
88
|
+
relative_path, "models", ImportType.LOCAL, alias="_models"
|
|
114
89
|
)
|
|
115
90
|
if self.code_model.need_mixin_abc:
|
|
116
91
|
file_import.add_submodule_import(".._vendor", "MixinABC", ImportType.LOCAL)
|
|
@@ -126,41 +101,25 @@ class OperationGroup(BaseModel):
|
|
|
126
101
|
|
|
127
102
|
@property
|
|
128
103
|
def filename(self) -> str:
|
|
129
|
-
|
|
130
|
-
if self.is_empty_operation_group:
|
|
131
|
-
basename = self.code_model.module_name
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
basename == "operations"
|
|
135
|
-
or self.code_model.options["combine_operation_files"]
|
|
136
|
-
):
|
|
137
|
-
return f"_operations"
|
|
138
|
-
return f"_{basename}_operations"
|
|
104
|
+
return self.operations[0].filename
|
|
139
105
|
|
|
140
106
|
@property
|
|
141
|
-
def
|
|
107
|
+
def is_mixin(self) -> bool:
|
|
142
108
|
"""The operation group with no name is the direct client methods."""
|
|
143
|
-
return
|
|
109
|
+
return self.property_name == ""
|
|
144
110
|
|
|
145
111
|
@classmethod
|
|
146
112
|
def from_yaml(
|
|
147
113
|
cls, yaml_data: Dict[str, Any], code_model: "CodeModel"
|
|
148
114
|
) -> "OperationGroup":
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
for operation_yaml in yaml_data["operations"]:
|
|
155
|
-
operation = _get_operation(operation_yaml, code_model)
|
|
156
|
-
operations.append(operation)
|
|
157
|
-
api_versions.update(operation.api_versions)
|
|
158
|
-
|
|
115
|
+
operations = [get_operation(o, code_model) for o in yaml_data["operations"]]
|
|
116
|
+
api_versions: OrderedSet[str] = {}
|
|
117
|
+
for operation in operations:
|
|
118
|
+
for api_version in operation.api_versions:
|
|
119
|
+
api_versions[api_version] = None
|
|
159
120
|
return cls(
|
|
160
121
|
yaml_data=yaml_data,
|
|
161
122
|
code_model=code_model,
|
|
162
|
-
name=name,
|
|
163
|
-
class_name=yaml_data["language"]["python"]["className"],
|
|
164
123
|
operations=operations,
|
|
165
|
-
api_versions=api_versions,
|
|
124
|
+
api_versions=list(api_versions.keys()),
|
|
166
125
|
)
|
|
@@ -3,140 +3,110 @@
|
|
|
3
3
|
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
from .
|
|
10
|
-
from .
|
|
11
|
-
|
|
6
|
+
from typing import Dict, List, Any, Optional, Union, TYPE_CHECKING, cast, TypeVar
|
|
7
|
+
|
|
8
|
+
from .operation import Operation, OperationBase
|
|
9
|
+
from .response import PagingResponse, LROPagingResponse, Response
|
|
10
|
+
from .request_builder import (
|
|
11
|
+
OverloadedRequestBuilder,
|
|
12
|
+
RequestBuilder,
|
|
13
|
+
get_request_builder,
|
|
14
|
+
)
|
|
12
15
|
from .imports import ImportType, FileImport, TypingSection
|
|
13
|
-
from .object_schema import ObjectSchema
|
|
14
|
-
from .schema_request import SchemaRequest
|
|
15
16
|
from .parameter_list import ParameterList
|
|
17
|
+
from .model_type import ModelType
|
|
16
18
|
|
|
17
19
|
if TYPE_CHECKING:
|
|
18
20
|
from .code_model import CodeModel
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
PagingResponseType = TypeVar(
|
|
23
|
+
"PagingResponseType", bound=Union[PagingResponse, LROPagingResponse]
|
|
24
|
+
)
|
|
21
25
|
|
|
22
26
|
|
|
23
|
-
class
|
|
27
|
+
class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
24
28
|
def __init__(
|
|
25
29
|
self,
|
|
26
30
|
yaml_data: Dict[str, Any],
|
|
27
31
|
code_model: "CodeModel",
|
|
28
|
-
request_builder: RequestBuilder,
|
|
29
32
|
name: str,
|
|
30
|
-
|
|
31
|
-
api_versions: Set[str],
|
|
33
|
+
request_builder: RequestBuilder,
|
|
32
34
|
parameters: ParameterList,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
summary: Optional[str] = None,
|
|
36
|
-
responses: Optional[List[SchemaResponse]] = None,
|
|
37
|
-
exceptions: Optional[List[SchemaResponse]] = None,
|
|
38
|
-
want_description_docstring: bool = True,
|
|
39
|
-
want_tracing: bool = True,
|
|
35
|
+
responses: List[PagingResponseType],
|
|
36
|
+
exceptions: List[Response],
|
|
40
37
|
*,
|
|
38
|
+
overloads: Optional[List[Operation]] = None,
|
|
39
|
+
public: bool = True,
|
|
40
|
+
want_tracing: bool = True,
|
|
41
41
|
abstract: bool = False,
|
|
42
42
|
override_success_response_to_200: bool = False,
|
|
43
43
|
) -> None:
|
|
44
44
|
super().__init__(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
summary,
|
|
55
|
-
responses,
|
|
56
|
-
exceptions,
|
|
57
|
-
want_description_docstring,
|
|
45
|
+
code_model=code_model,
|
|
46
|
+
yaml_data=yaml_data,
|
|
47
|
+
name=name,
|
|
48
|
+
request_builder=request_builder,
|
|
49
|
+
parameters=parameters,
|
|
50
|
+
responses=responses,
|
|
51
|
+
exceptions=exceptions,
|
|
52
|
+
overloads=overloads,
|
|
53
|
+
public=public,
|
|
58
54
|
want_tracing=want_tracing,
|
|
59
55
|
abstract=abstract,
|
|
60
56
|
)
|
|
61
|
-
self.
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
self.next_request_builder: Optional[
|
|
58
|
+
Union[RequestBuilder, OverloadedRequestBuilder]
|
|
59
|
+
] = (
|
|
60
|
+
get_request_builder(self.yaml_data["nextOperation"], code_model)
|
|
61
|
+
if self.yaml_data.get("nextOperation")
|
|
62
|
+
else None
|
|
64
63
|
)
|
|
65
|
-
self.operation_name: str = yaml_data["extensions"]["x-ms-pageable"].get(
|
|
66
|
-
"operationName"
|
|
67
|
-
)
|
|
68
|
-
self.next_operation: Optional[Operation] = None
|
|
69
64
|
self.override_success_response_to_200 = override_success_response_to_200
|
|
65
|
+
self.pager_sync: str = yaml_data["pagerSync"]
|
|
66
|
+
self.pager_async: str = yaml_data["pagerAsync"]
|
|
70
67
|
|
|
71
|
-
def
|
|
72
|
-
response = self.responses[0]
|
|
73
|
-
if not isinstance(response.schema, ObjectSchema):
|
|
74
|
-
raise ValueError(
|
|
75
|
-
"The response of a paging operation must be of type "
|
|
76
|
-
+ f"ObjectSchema but {response.schema} is not"
|
|
77
|
-
)
|
|
78
|
-
return response
|
|
79
|
-
|
|
80
|
-
def _find_python_name(self, rest_api_name: str, log_name: str) -> str:
|
|
68
|
+
def _get_attr_name(self, rest_api_name: str) -> str:
|
|
81
69
|
response = self.responses[0]
|
|
82
|
-
response_schema = cast(ObjectSchema, response.schema)
|
|
83
|
-
if response_schema:
|
|
84
|
-
for prop in response_schema.properties:
|
|
85
|
-
if prop.original_swagger_name == rest_api_name:
|
|
86
|
-
return prop.name
|
|
87
|
-
raise ValueError(
|
|
88
|
-
f"While scanning x-ms-pageable, was unable to find "
|
|
89
|
-
+ f"{log_name}:{rest_api_name} in model {response_schema.name}"
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
def _get_paging_extension(self, extension_name):
|
|
93
|
-
return self.yaml_data["extensions"][extension_name]
|
|
94
|
-
|
|
95
|
-
def item_name(self, code_model) -> str:
|
|
96
|
-
item_name = self._item_name or "value"
|
|
97
70
|
try:
|
|
98
|
-
return (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
71
|
+
return next(
|
|
72
|
+
p.client_name
|
|
73
|
+
for p in cast(ModelType, response.type).properties
|
|
74
|
+
if p.rest_api_name == rest_api_name
|
|
102
75
|
)
|
|
103
|
-
except
|
|
104
|
-
response = self._get_response()
|
|
76
|
+
except StopIteration:
|
|
105
77
|
raise ValueError(
|
|
106
|
-
f"
|
|
107
|
-
+ f" {cast(ObjectSchema, response.schema).name} has no array called 'value'"
|
|
78
|
+
f"Can't find a matching property in response for {rest_api_name}"
|
|
108
79
|
)
|
|
109
80
|
|
|
81
|
+
def get_pager(self, async_mode: bool) -> str:
|
|
82
|
+
return self.responses[0].get_pager(async_mode)
|
|
83
|
+
|
|
110
84
|
@property
|
|
111
|
-
def
|
|
112
|
-
|
|
85
|
+
def continuation_token_name(self) -> Optional[str]:
|
|
86
|
+
rest_api_name = self.yaml_data["continuationTokenName"]
|
|
87
|
+
if not rest_api_name:
|
|
113
88
|
# That's an ok scenario, it just means no next page possible
|
|
114
89
|
return None
|
|
115
90
|
if self.code_model.options["models_mode"]:
|
|
116
|
-
return self.
|
|
117
|
-
return
|
|
91
|
+
return self._get_attr_name(rest_api_name)
|
|
92
|
+
return rest_api_name
|
|
118
93
|
|
|
119
94
|
@property
|
|
120
|
-
def
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
extension_name = "pager-async" if async_mode else "pager-sync"
|
|
126
|
-
return self._get_paging_extension(extension_name)
|
|
127
|
-
|
|
128
|
-
def get_pager(self, async_mode: bool) -> str:
|
|
129
|
-
return self.get_pager_path(async_mode).split(".")[-1]
|
|
95
|
+
def item_name(self) -> str:
|
|
96
|
+
rest_api_name = self.yaml_data["itemName"]
|
|
97
|
+
if self.code_model.options["models_mode"]:
|
|
98
|
+
return self._get_attr_name(rest_api_name)
|
|
99
|
+
return rest_api_name
|
|
130
100
|
|
|
131
101
|
@property
|
|
132
|
-
def
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return
|
|
102
|
+
def operation_type(self) -> str:
|
|
103
|
+
return "paging"
|
|
104
|
+
|
|
105
|
+
def cls_type_annotation(self, *, async_mode: bool) -> str:
|
|
106
|
+
return f"ClsType[{Response.type_annotation(self.responses[0], async_mode=async_mode)}]"
|
|
137
107
|
|
|
138
|
-
def _imports_shared(self, async_mode: bool) -> FileImport:
|
|
139
|
-
file_import = super()._imports_shared(async_mode)
|
|
108
|
+
def _imports_shared(self, async_mode: bool, **kwargs: Any) -> FileImport:
|
|
109
|
+
file_import = super()._imports_shared(async_mode, **kwargs)
|
|
140
110
|
if async_mode:
|
|
141
111
|
file_import.add_submodule_import(
|
|
142
112
|
"typing", "AsyncIterable", ImportType.STDLIB, TypingSection.CONDITIONAL
|
|
@@ -153,41 +123,28 @@ class PagingOperation(Operation):
|
|
|
153
123
|
file_import.merge(self.next_request_builder.imports())
|
|
154
124
|
return file_import
|
|
155
125
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
pager = self.get_pager(async_mode)
|
|
160
|
-
|
|
161
|
-
file_import.add_submodule_import(
|
|
162
|
-
pager_import_path, pager, ImportType.AZURECORE, TypingSection.CONDITIONAL
|
|
163
|
-
)
|
|
164
|
-
|
|
165
|
-
return file_import
|
|
166
|
-
|
|
167
|
-
def imports(self, async_mode: bool, is_python3_file: bool) -> FileImport:
|
|
168
|
-
file_import = self._imports_base(async_mode, is_python3_file)
|
|
169
|
-
# operation adds an import for distributed_trace_async, we don't want it
|
|
170
|
-
file_import.imports = [
|
|
171
|
-
i
|
|
172
|
-
for i in file_import.imports
|
|
173
|
-
if not i.submodule_name == "distributed_trace_async"
|
|
174
|
-
]
|
|
175
|
-
|
|
176
|
-
pager_import_path = ".".join(self.get_pager_path(async_mode).split(".")[:-1])
|
|
177
|
-
pager = self.get_pager(async_mode)
|
|
178
|
-
|
|
179
|
-
file_import.add_submodule_import(pager_import_path, pager, ImportType.AZURECORE)
|
|
180
|
-
|
|
181
|
-
if async_mode:
|
|
182
|
-
file_import.add_submodule_import(
|
|
183
|
-
"azure.core.async_paging", "AsyncList", ImportType.AZURECORE
|
|
184
|
-
)
|
|
126
|
+
@property
|
|
127
|
+
def has_optional_return_type(self) -> bool:
|
|
128
|
+
return False
|
|
185
129
|
|
|
130
|
+
def imports(
|
|
131
|
+
self, async_mode: bool, is_python3_file: bool, **kwargs: Any
|
|
132
|
+
) -> FileImport:
|
|
133
|
+
file_import = self._imports_shared(async_mode, **kwargs)
|
|
134
|
+
file_import.merge(super().imports(async_mode, is_python3_file, **kwargs))
|
|
186
135
|
if self.code_model.options["tracing"] and self.want_tracing:
|
|
187
136
|
file_import.add_submodule_import(
|
|
188
137
|
"azure.core.tracing.decorator",
|
|
189
138
|
"distributed_trace",
|
|
190
139
|
ImportType.AZURECORE,
|
|
191
140
|
)
|
|
141
|
+
if self.next_request_builder:
|
|
142
|
+
file_import.merge(
|
|
143
|
+
self.get_request_builder_import(self.next_request_builder, async_mode)
|
|
144
|
+
)
|
|
192
145
|
|
|
193
146
|
return file_import
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class PagingOperation(PagingOperationBase[PagingResponse]):
|
|
150
|
+
...
|