@typespec/http-client-python 0.12.0-dev.2 → 0.12.0-dev.4
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/dist/emitter/code-model.d.ts.map +1 -1
- package/dist/emitter/code-model.js +3 -0
- package/dist/emitter/code-model.js.map +1 -1
- package/dist/emitter/emitter.d.ts.map +1 -1
- package/dist/emitter/emitter.js +2 -12
- package/dist/emitter/emitter.js.map +1 -1
- package/dist/emitter/http.d.ts.map +1 -1
- package/dist/emitter/http.js +13 -0
- package/dist/emitter/http.js.map +1 -1
- package/dist/emitter/lib.d.ts +2 -17
- package/dist/emitter/lib.d.ts.map +1 -1
- package/dist/emitter/lib.js +0 -6
- package/dist/emitter/lib.js.map +1 -1
- package/emitter/src/code-model.ts +3 -0
- package/emitter/src/emitter.ts +2 -13
- package/emitter/src/http.ts +13 -0
- package/emitter/src/lib.ts +0 -6
- package/emitter/temp/tsconfig.tsbuildinfo +1 -1
- package/eng/scripts/ci/mypy.ini +1 -1
- package/eng/scripts/ci/regenerate.ts +12 -7
- package/eng/scripts/ci/run_pyright.py +4 -0
- package/eng/scripts/setup/__pycache__/venvtools.cpython-39.pyc +0 -0
- package/generator/build/lib/pygen/codegen/models/code_model.py +1 -0
- package/generator/build/lib/pygen/codegen/models/paging_operation.py +14 -2
- package/generator/build/lib/pygen/codegen/models/response.py +1 -1
- package/generator/build/lib/pygen/codegen/serializers/__init__.py +8 -0
- package/generator/build/lib/pygen/codegen/serializers/builder_serializer.py +11 -0
- package/generator/build/lib/pygen/codegen/serializers/general_serializer.py +1 -1
- package/generator/build/lib/pygen/codegen/templates/operation_group.py.jinja2 +2 -2
- package/generator/build/lib/pygen/codegen/templates/operation_groups_container.py.jinja2 +0 -1
- package/generator/build/lib/pygen/codegen/templates/packaging_templates/README.md.jinja2 +1 -1
- package/generator/component-detection-pip-report.json +8 -7
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/codegen/models/code_model.py +1 -0
- package/generator/pygen/codegen/models/paging_operation.py +14 -2
- package/generator/pygen/codegen/models/response.py +1 -1
- package/generator/pygen/codegen/serializers/__init__.py +8 -0
- package/generator/pygen/codegen/serializers/builder_serializer.py +11 -0
- package/generator/pygen/codegen/serializers/general_serializer.py +1 -1
- package/generator/pygen/codegen/templates/operation_group.py.jinja2 +2 -2
- package/generator/pygen/codegen/templates/operation_groups_container.py.jinja2 +0 -1
- package/generator/pygen/codegen/templates/packaging_templates/README.md.jinja2 +1 -1
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_core_page_async.py +10 -0
- package/generator/test/azure/mock_api_tests/test_azure_core_page.py +9 -0
- package/package.json +33 -31
|
@@ -263,6 +263,7 @@ async function executeCommand(tspCommand: TspCommand): Promise<void> {
|
|
|
263
263
|
}
|
|
264
264
|
const execFileAsync = promisify(execFile);
|
|
265
265
|
try {
|
|
266
|
+
console.log(chalk.green(`start tsp ${tspCommand.command.join(" ")}`));
|
|
266
267
|
await execFileAsync("tsp", tspCommand.command, { shell: true });
|
|
267
268
|
console.log(chalk.green(`tsp ${tspCommand.command.join(" ")} succeeded`));
|
|
268
269
|
} catch (err) {
|
|
@@ -404,16 +405,20 @@ function _getCmdList(spec: string, flags: RegenerateFlags): TspCommand[] {
|
|
|
404
405
|
}
|
|
405
406
|
|
|
406
407
|
async function runTaskPool(tasks: Array<() => Promise<void>>, poolLimit: number): Promise<void> {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
const index = currentIndex++;
|
|
412
|
-
await tasks[index]();
|
|
408
|
+
async function worker(start: number, end: number) {
|
|
409
|
+
while (start < end) {
|
|
410
|
+
await tasks[start]();
|
|
411
|
+
start++;
|
|
413
412
|
}
|
|
414
413
|
}
|
|
415
414
|
|
|
416
|
-
const workers =
|
|
415
|
+
const workers = [];
|
|
416
|
+
let start = 0;
|
|
417
|
+
while (start < tasks.length) {
|
|
418
|
+
const end = Math.min(start + poolLimit, tasks.length);
|
|
419
|
+
workers.push((async () => await worker(start, end))());
|
|
420
|
+
start = end;
|
|
421
|
+
}
|
|
417
422
|
await Promise.all(workers);
|
|
418
423
|
}
|
|
419
424
|
|
|
@@ -31,6 +31,10 @@ def _single_dir_pyright(mod):
|
|
|
31
31
|
retries = 3
|
|
32
32
|
while retries:
|
|
33
33
|
try:
|
|
34
|
+
# After fully support client hierarchy, we can remove this check
|
|
35
|
+
if "azure-client-generator-core-client-initialization" in str(inner_class.absolute()):
|
|
36
|
+
return True
|
|
37
|
+
|
|
34
38
|
check_output(
|
|
35
39
|
[
|
|
36
40
|
sys.executable,
|
|
Binary file
|
|
@@ -98,6 +98,7 @@ class CodeModel: # pylint: disable=too-many-public-methods, disable=too-many-in
|
|
|
98
98
|
self.has_subnamespace = False
|
|
99
99
|
self._operations_folder_name: Dict[str, str] = {}
|
|
100
100
|
self._relative_import_path: Dict[str, str] = {}
|
|
101
|
+
self.metadata: Dict[str, Any] = yaml_data.get("metadata", {})
|
|
101
102
|
|
|
102
103
|
@staticmethod
|
|
103
104
|
def get_imported_namespace_for_client(imported_namespace: str, async_mode: bool = False) -> str:
|
|
@@ -16,6 +16,7 @@ from .imports import ImportType, FileImport, TypingSection
|
|
|
16
16
|
from .parameter_list import ParameterList
|
|
17
17
|
from .model_type import ModelType
|
|
18
18
|
from .list_type import ListType
|
|
19
|
+
from .parameter import Parameter
|
|
19
20
|
|
|
20
21
|
if TYPE_CHECKING:
|
|
21
22
|
from .code_model import CodeModel
|
|
@@ -59,6 +60,9 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
|
59
60
|
self.pager_sync: str = yaml_data.get("pagerSync") or f"{self.code_model.core_library}.paging.ItemPaged"
|
|
60
61
|
self.pager_async: str = yaml_data.get("pagerAsync") or f"{self.code_model.core_library}.paging.AsyncItemPaged"
|
|
61
62
|
self.continuation_token: Dict[str, Any] = yaml_data.get("continuationToken", {})
|
|
63
|
+
self.next_link_reinjected_parameters: List[Parameter] = [
|
|
64
|
+
Parameter.from_yaml(p, code_model) for p in yaml_data.get("nextLinkReInjectedParameters", [])
|
|
65
|
+
]
|
|
62
66
|
|
|
63
67
|
@property
|
|
64
68
|
def has_continuation_token(self) -> bool:
|
|
@@ -118,9 +122,17 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
|
118
122
|
def _imports_shared(self, async_mode: bool, **kwargs: Any) -> FileImport:
|
|
119
123
|
file_import = super()._imports_shared(async_mode, **kwargs)
|
|
120
124
|
if async_mode:
|
|
121
|
-
|
|
125
|
+
default_paging_submodule = f"{'async_' if self.code_model.is_azure_flavor else ''}paging"
|
|
126
|
+
file_import.add_submodule_import(
|
|
127
|
+
f"{self.code_model.core_library}.{default_paging_submodule}",
|
|
128
|
+
"AsyncItemPaged",
|
|
129
|
+
ImportType.SDKCORE,
|
|
130
|
+
TypingSection.CONDITIONAL,
|
|
131
|
+
)
|
|
122
132
|
else:
|
|
123
|
-
file_import.add_submodule_import(
|
|
133
|
+
file_import.add_submodule_import(
|
|
134
|
+
f"{self.code_model.core_library}.paging", "ItemPaged", ImportType.SDKCORE, TypingSection.CONDITIONAL
|
|
135
|
+
)
|
|
124
136
|
if (
|
|
125
137
|
self.next_request_builder
|
|
126
138
|
and self.code_model.options["builders_visibility"] == "embedded"
|
|
@@ -186,7 +186,7 @@ class PagingResponse(Response):
|
|
|
186
186
|
return self.get_pager_path(async_mode).split(".")[-1]
|
|
187
187
|
|
|
188
188
|
def type_annotation(self, **kwargs: Any) -> str:
|
|
189
|
-
iterable = "
|
|
189
|
+
iterable = "AsyncItemPaged" if kwargs["async_mode"] else "ItemPaged"
|
|
190
190
|
return f"{iterable}[{self.item_type.type_annotation(**kwargs)}]"
|
|
191
191
|
|
|
192
192
|
def docstring_text(self, **kwargs: Any) -> str:
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
import logging
|
|
7
|
+
import json
|
|
7
8
|
from collections import namedtuple
|
|
8
9
|
import re
|
|
9
10
|
from typing import List, Any, Union
|
|
@@ -143,6 +144,13 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
143
144
|
self._serialize_and_write_sample(env, namespace=client_namespace)
|
|
144
145
|
if self.code_model.options["generate_test"]:
|
|
145
146
|
self._serialize_and_write_test(env, namespace=client_namespace)
|
|
147
|
+
|
|
148
|
+
# add _metadata.json
|
|
149
|
+
if self.code_model.metadata:
|
|
150
|
+
self.write_file(
|
|
151
|
+
exec_path / Path("_metadata.json"),
|
|
152
|
+
json.dumps(self.code_model.metadata, indent=2),
|
|
153
|
+
)
|
|
146
154
|
elif client_namespace_type.clients:
|
|
147
155
|
# add clients folder if there are clients in this namespace
|
|
148
156
|
self._serialize_client_and_config_files(client_namespace, client_namespace_type.clients, env)
|
|
@@ -1276,6 +1276,17 @@ class _PagingOperationSerializer(_OperationSerializer[PagingOperationType]):
|
|
|
1276
1276
|
else api_version_param.full_client_name
|
|
1277
1277
|
)
|
|
1278
1278
|
retval.append(f'_next_request_params["api-version"] = {api_version}')
|
|
1279
|
+
if builder.next_link_reinjected_parameters:
|
|
1280
|
+
for param in builder.next_link_reinjected_parameters:
|
|
1281
|
+
if param.location == ParameterLocation.QUERY:
|
|
1282
|
+
retval.extend(
|
|
1283
|
+
self.parameter_serializer.serialize_query_header(
|
|
1284
|
+
param,
|
|
1285
|
+
"next_request_params",
|
|
1286
|
+
self.serializer_name,
|
|
1287
|
+
self.code_model.is_legacy,
|
|
1288
|
+
)
|
|
1289
|
+
)
|
|
1279
1290
|
query_str = ", params=_next_request_params"
|
|
1280
1291
|
next_link_str = "urllib.parse.urljoin(next_link, _parsed_next_link.path)"
|
|
1281
1292
|
except StopIteration:
|
|
@@ -63,7 +63,7 @@ class GeneralSerializer(BaseSerializer):
|
|
|
63
63
|
"token_credential": token_credential,
|
|
64
64
|
"pkgutil_names": [".".join(package_parts[: i + 1]) for i in range(len(package_parts))],
|
|
65
65
|
"init_names": ["/".join(package_parts[: i + 1]) + "/__init__.py" for i in range(len(package_parts))],
|
|
66
|
-
"client_name": self.code_model.clients[0].name,
|
|
66
|
+
"client_name": self.code_model.clients[0].name if self.code_model.clients else "",
|
|
67
67
|
"VERSION_MAP": VERSION_MAP,
|
|
68
68
|
"MIN_PYTHON_VERSION": MIN_PYTHON_VERSION,
|
|
69
69
|
"MAX_PYTHON_VERSION": MAX_PYTHON_VERSION,
|
|
@@ -29,7 +29,7 @@ class {{ operation_group.class_name }}: {{ operation_group.pylint_disable() }}
|
|
|
29
29
|
models = _models
|
|
30
30
|
|
|
31
31
|
{% endif %}
|
|
32
|
-
def __init__(self, *args, **kwargs)
|
|
32
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
33
33
|
input_args = list(args)
|
|
34
34
|
self._client: {{ 'Async' if async_mode else ''}}PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
|
|
35
35
|
self._config: {{ operation_group.client.name }}Configuration = input_args.pop(0) if input_args else kwargs.pop("config")
|
|
@@ -48,7 +48,7 @@ class {{ operation_group.class_name }}: {{ operation_group.pylint_disable() }}
|
|
|
48
48
|
{{ check_abstract_methods() }}
|
|
49
49
|
{% elif operation_group.has_abstract_operations %}
|
|
50
50
|
|
|
51
|
-
def __init__(self)
|
|
51
|
+
def __init__(self) -> None:
|
|
52
52
|
{{ check_abstract_methods() }}
|
|
53
53
|
{% endif %}
|
|
54
54
|
{% if operation_group.is_mixin and code_model.options["multiapi"] %}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{% import 'operation_tools.jinja2' as op_tools %}
|
|
2
2
|
{% set operations_description = "async operations" if async_mode else "operations" %}
|
|
3
|
-
{% set return_none_type_annotation = " -> None" if async_mode else "" %}
|
|
4
3
|
# coding=utf-8
|
|
5
4
|
{% if code_model.license_header %}
|
|
6
5
|
{{ code_model.license_header }}
|
|
@@ -40,7 +40,7 @@ python -m pip install {{ package_name }}
|
|
|
40
40
|
- You need an [Azure subscription][azure_sub] to use this package.
|
|
41
41
|
- An existing {{ package_pprint_name }} instance.
|
|
42
42
|
|
|
43
|
-
{% if token_credential %}
|
|
43
|
+
{% if token_credential and client_name %}
|
|
44
44
|
#### Create with an Azure Active Directory Credential
|
|
45
45
|
To use an [Azure Active Directory (AAD) token credential][authenticate_with_token],
|
|
46
46
|
provide an instance of the desired credential type obtained from the
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "1",
|
|
3
|
-
"pip_version": "25.
|
|
3
|
+
"pip_version": "25.1.1",
|
|
4
4
|
"install": [
|
|
5
5
|
{
|
|
6
6
|
"download_info": {
|
|
7
|
-
"url": "https://files.pythonhosted.org/packages/
|
|
7
|
+
"url": "https://files.pythonhosted.org/packages/a1/18/0e835c3a557dc5faffc8f91092f62fc337c1dab1066715842e7a4b318ec4/setuptools-80.7.1-py3-none-any.whl",
|
|
8
8
|
"archive_info": {
|
|
9
|
-
"hash": "sha256=
|
|
9
|
+
"hash": "sha256=ca5cc1069b85dc23070a6628e6bcecb3292acac802399c7f8edc0100619f9009",
|
|
10
10
|
"hashes": {
|
|
11
|
-
"sha256": "
|
|
11
|
+
"sha256": "ca5cc1069b85dc23070a6628e6bcecb3292acac802399c7f8edc0100619f9009"
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
},
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"metadata": {
|
|
19
19
|
"metadata_version": "2.4",
|
|
20
20
|
"name": "setuptools",
|
|
21
|
-
"version": "
|
|
21
|
+
"version": "80.7.1",
|
|
22
22
|
"dynamic": [
|
|
23
23
|
"license-file"
|
|
24
24
|
],
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"management"
|
|
34
34
|
],
|
|
35
35
|
"author_email": "Python Packaging Authority <distutils-sig@python.org>",
|
|
36
|
+
"license_expression": "MIT",
|
|
36
37
|
"license_file": [
|
|
37
38
|
"LICENSE"
|
|
38
39
|
],
|
|
@@ -125,9 +126,9 @@
|
|
|
125
126
|
"implementation_version": "3.9.21",
|
|
126
127
|
"os_name": "posix",
|
|
127
128
|
"platform_machine": "x86_64",
|
|
128
|
-
"platform_release": "5.15.0-
|
|
129
|
+
"platform_release": "5.15.0-1088-azure",
|
|
129
130
|
"platform_system": "Linux",
|
|
130
|
-
"platform_version": "#
|
|
131
|
+
"platform_version": "#97~20.04.1-Ubuntu SMP Wed Apr 23 13:25:03 UTC 2025",
|
|
131
132
|
"python_full_version": "3.9.21",
|
|
132
133
|
"platform_python_implementation": "CPython",
|
|
133
134
|
"python_version": "3.9",
|
|
Binary file
|
|
@@ -98,6 +98,7 @@ class CodeModel: # pylint: disable=too-many-public-methods, disable=too-many-in
|
|
|
98
98
|
self.has_subnamespace = False
|
|
99
99
|
self._operations_folder_name: Dict[str, str] = {}
|
|
100
100
|
self._relative_import_path: Dict[str, str] = {}
|
|
101
|
+
self.metadata: Dict[str, Any] = yaml_data.get("metadata", {})
|
|
101
102
|
|
|
102
103
|
@staticmethod
|
|
103
104
|
def get_imported_namespace_for_client(imported_namespace: str, async_mode: bool = False) -> str:
|
|
@@ -16,6 +16,7 @@ from .imports import ImportType, FileImport, TypingSection
|
|
|
16
16
|
from .parameter_list import ParameterList
|
|
17
17
|
from .model_type import ModelType
|
|
18
18
|
from .list_type import ListType
|
|
19
|
+
from .parameter import Parameter
|
|
19
20
|
|
|
20
21
|
if TYPE_CHECKING:
|
|
21
22
|
from .code_model import CodeModel
|
|
@@ -59,6 +60,9 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
|
59
60
|
self.pager_sync: str = yaml_data.get("pagerSync") or f"{self.code_model.core_library}.paging.ItemPaged"
|
|
60
61
|
self.pager_async: str = yaml_data.get("pagerAsync") or f"{self.code_model.core_library}.paging.AsyncItemPaged"
|
|
61
62
|
self.continuation_token: Dict[str, Any] = yaml_data.get("continuationToken", {})
|
|
63
|
+
self.next_link_reinjected_parameters: List[Parameter] = [
|
|
64
|
+
Parameter.from_yaml(p, code_model) for p in yaml_data.get("nextLinkReInjectedParameters", [])
|
|
65
|
+
]
|
|
62
66
|
|
|
63
67
|
@property
|
|
64
68
|
def has_continuation_token(self) -> bool:
|
|
@@ -118,9 +122,17 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
|
118
122
|
def _imports_shared(self, async_mode: bool, **kwargs: Any) -> FileImport:
|
|
119
123
|
file_import = super()._imports_shared(async_mode, **kwargs)
|
|
120
124
|
if async_mode:
|
|
121
|
-
|
|
125
|
+
default_paging_submodule = f"{'async_' if self.code_model.is_azure_flavor else ''}paging"
|
|
126
|
+
file_import.add_submodule_import(
|
|
127
|
+
f"{self.code_model.core_library}.{default_paging_submodule}",
|
|
128
|
+
"AsyncItemPaged",
|
|
129
|
+
ImportType.SDKCORE,
|
|
130
|
+
TypingSection.CONDITIONAL,
|
|
131
|
+
)
|
|
122
132
|
else:
|
|
123
|
-
file_import.add_submodule_import(
|
|
133
|
+
file_import.add_submodule_import(
|
|
134
|
+
f"{self.code_model.core_library}.paging", "ItemPaged", ImportType.SDKCORE, TypingSection.CONDITIONAL
|
|
135
|
+
)
|
|
124
136
|
if (
|
|
125
137
|
self.next_request_builder
|
|
126
138
|
and self.code_model.options["builders_visibility"] == "embedded"
|
|
@@ -186,7 +186,7 @@ class PagingResponse(Response):
|
|
|
186
186
|
return self.get_pager_path(async_mode).split(".")[-1]
|
|
187
187
|
|
|
188
188
|
def type_annotation(self, **kwargs: Any) -> str:
|
|
189
|
-
iterable = "
|
|
189
|
+
iterable = "AsyncItemPaged" if kwargs["async_mode"] else "ItemPaged"
|
|
190
190
|
return f"{iterable}[{self.item_type.type_annotation(**kwargs)}]"
|
|
191
191
|
|
|
192
192
|
def docstring_text(self, **kwargs: Any) -> str:
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
import logging
|
|
7
|
+
import json
|
|
7
8
|
from collections import namedtuple
|
|
8
9
|
import re
|
|
9
10
|
from typing import List, Any, Union
|
|
@@ -143,6 +144,13 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
143
144
|
self._serialize_and_write_sample(env, namespace=client_namespace)
|
|
144
145
|
if self.code_model.options["generate_test"]:
|
|
145
146
|
self._serialize_and_write_test(env, namespace=client_namespace)
|
|
147
|
+
|
|
148
|
+
# add _metadata.json
|
|
149
|
+
if self.code_model.metadata:
|
|
150
|
+
self.write_file(
|
|
151
|
+
exec_path / Path("_metadata.json"),
|
|
152
|
+
json.dumps(self.code_model.metadata, indent=2),
|
|
153
|
+
)
|
|
146
154
|
elif client_namespace_type.clients:
|
|
147
155
|
# add clients folder if there are clients in this namespace
|
|
148
156
|
self._serialize_client_and_config_files(client_namespace, client_namespace_type.clients, env)
|
|
@@ -1276,6 +1276,17 @@ class _PagingOperationSerializer(_OperationSerializer[PagingOperationType]):
|
|
|
1276
1276
|
else api_version_param.full_client_name
|
|
1277
1277
|
)
|
|
1278
1278
|
retval.append(f'_next_request_params["api-version"] = {api_version}')
|
|
1279
|
+
if builder.next_link_reinjected_parameters:
|
|
1280
|
+
for param in builder.next_link_reinjected_parameters:
|
|
1281
|
+
if param.location == ParameterLocation.QUERY:
|
|
1282
|
+
retval.extend(
|
|
1283
|
+
self.parameter_serializer.serialize_query_header(
|
|
1284
|
+
param,
|
|
1285
|
+
"next_request_params",
|
|
1286
|
+
self.serializer_name,
|
|
1287
|
+
self.code_model.is_legacy,
|
|
1288
|
+
)
|
|
1289
|
+
)
|
|
1279
1290
|
query_str = ", params=_next_request_params"
|
|
1280
1291
|
next_link_str = "urllib.parse.urljoin(next_link, _parsed_next_link.path)"
|
|
1281
1292
|
except StopIteration:
|
|
@@ -63,7 +63,7 @@ class GeneralSerializer(BaseSerializer):
|
|
|
63
63
|
"token_credential": token_credential,
|
|
64
64
|
"pkgutil_names": [".".join(package_parts[: i + 1]) for i in range(len(package_parts))],
|
|
65
65
|
"init_names": ["/".join(package_parts[: i + 1]) + "/__init__.py" for i in range(len(package_parts))],
|
|
66
|
-
"client_name": self.code_model.clients[0].name,
|
|
66
|
+
"client_name": self.code_model.clients[0].name if self.code_model.clients else "",
|
|
67
67
|
"VERSION_MAP": VERSION_MAP,
|
|
68
68
|
"MIN_PYTHON_VERSION": MIN_PYTHON_VERSION,
|
|
69
69
|
"MAX_PYTHON_VERSION": MAX_PYTHON_VERSION,
|
|
@@ -29,7 +29,7 @@ class {{ operation_group.class_name }}: {{ operation_group.pylint_disable() }}
|
|
|
29
29
|
models = _models
|
|
30
30
|
|
|
31
31
|
{% endif %}
|
|
32
|
-
def __init__(self, *args, **kwargs)
|
|
32
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
33
33
|
input_args = list(args)
|
|
34
34
|
self._client: {{ 'Async' if async_mode else ''}}PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
|
|
35
35
|
self._config: {{ operation_group.client.name }}Configuration = input_args.pop(0) if input_args else kwargs.pop("config")
|
|
@@ -48,7 +48,7 @@ class {{ operation_group.class_name }}: {{ operation_group.pylint_disable() }}
|
|
|
48
48
|
{{ check_abstract_methods() }}
|
|
49
49
|
{% elif operation_group.has_abstract_operations %}
|
|
50
50
|
|
|
51
|
-
def __init__(self)
|
|
51
|
+
def __init__(self) -> None:
|
|
52
52
|
{{ check_abstract_methods() }}
|
|
53
53
|
{% endif %}
|
|
54
54
|
{% if operation_group.is_mixin and code_model.options["multiapi"] %}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{% import 'operation_tools.jinja2' as op_tools %}
|
|
2
2
|
{% set operations_description = "async operations" if async_mode else "operations" %}
|
|
3
|
-
{% set return_none_type_annotation = " -> None" if async_mode else "" %}
|
|
4
3
|
# coding=utf-8
|
|
5
4
|
{% if code_model.license_header %}
|
|
6
5
|
{{ code_model.license_header }}
|
|
@@ -40,7 +40,7 @@ python -m pip install {{ package_name }}
|
|
|
40
40
|
- You need an [Azure subscription][azure_sub] to use this package.
|
|
41
41
|
- An existing {{ package_pprint_name }} instance.
|
|
42
42
|
|
|
43
|
-
{% if token_credential %}
|
|
43
|
+
{% if token_credential and client_name %}
|
|
44
44
|
#### Create with an Azure Active Directory Credential
|
|
45
45
|
To use an [Azure Active Directory (AAD) token credential][authenticate_with_token],
|
|
46
46
|
provide an instance of the desired credential type obtained from the
|
|
@@ -56,3 +56,13 @@ async def test_two_models_as_page_item(client: aio.PageClient):
|
|
|
56
56
|
result = [item async for item in client.two_models_as_page_item.list_second_item()]
|
|
57
57
|
assert len(result) == 1
|
|
58
58
|
assert result[0].name == "Madge"
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@pytest.mark.asyncio
|
|
62
|
+
async def test_list_with_parameterized_next_link(client: aio.PageClient):
|
|
63
|
+
result = [item async for item in client.with_parameterized_next_link(select="name", include_pending=True)]
|
|
64
|
+
assert len(result) == 2
|
|
65
|
+
assert result[0].id == 1
|
|
66
|
+
assert result[0].name == "User1"
|
|
67
|
+
assert result[1].id == 2
|
|
68
|
+
assert result[1].name == "User2"
|
|
@@ -49,3 +49,12 @@ def test_two_models_as_page_item(client: PageClient):
|
|
|
49
49
|
result = list(client.two_models_as_page_item.list_second_item())
|
|
50
50
|
assert len(result) == 1
|
|
51
51
|
assert result[0].name == "Madge"
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_list_with_parameterized_next_link(client: PageClient):
|
|
55
|
+
result = list(client.with_parameterized_next_link(select="name", include_pending=True))
|
|
56
|
+
assert len(result) == 2
|
|
57
|
+
assert result[0].id == 1
|
|
58
|
+
assert result[0].name == "User1"
|
|
59
|
+
assert result[1].id == 2
|
|
60
|
+
assert result[1].name == "User2"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/http-client-python",
|
|
3
|
-
"version": "0.12.0-dev.
|
|
3
|
+
"version": "0.12.0-dev.4",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec emitter for Python SDKs",
|
|
6
6
|
"homepage": "https://typespec.io",
|
|
@@ -54,20 +54,20 @@
|
|
|
54
54
|
"emitter"
|
|
55
55
|
],
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@azure-tools/typespec-autorest": ">=0.
|
|
58
|
-
"@azure-tools/typespec-azure-core": ">=0.
|
|
59
|
-
"@azure-tools/typespec-azure-resource-manager": ">=0.
|
|
60
|
-
"@azure-tools/typespec-azure-rulesets": ">=0.
|
|
61
|
-
"@azure-tools/typespec-client-generator-core": ">=0.
|
|
62
|
-
"@typespec/compiler": "^1.0.0
|
|
63
|
-
"@typespec/http": "^1.0.0
|
|
64
|
-
"@typespec/openapi": "^1.0.0
|
|
65
|
-
"@typespec/rest": ">=0.
|
|
66
|
-
"@typespec/versioning": ">=0.
|
|
67
|
-
"@typespec/events": ">=0.
|
|
68
|
-
"@typespec/sse": ">=0.
|
|
69
|
-
"@typespec/streams": ">=0.
|
|
70
|
-
"@typespec/xml": ">=0.
|
|
57
|
+
"@azure-tools/typespec-autorest": ">=0.56.0 <1.0.0",
|
|
58
|
+
"@azure-tools/typespec-azure-core": ">=0.56.0 <1.0.0",
|
|
59
|
+
"@azure-tools/typespec-azure-resource-manager": ">=0.56.0 <1.0.0",
|
|
60
|
+
"@azure-tools/typespec-azure-rulesets": ">=0.56.0 <1.0.0",
|
|
61
|
+
"@azure-tools/typespec-client-generator-core": ">=0.56.1 <1.0.0",
|
|
62
|
+
"@typespec/compiler": "^1.0.0",
|
|
63
|
+
"@typespec/http": "^1.0.0",
|
|
64
|
+
"@typespec/openapi": "^1.0.0",
|
|
65
|
+
"@typespec/rest": ">=0.70.0 <1.0.0",
|
|
66
|
+
"@typespec/versioning": ">=0.70.0 <1.0.0",
|
|
67
|
+
"@typespec/events": ">=0.70.0 <1.0.0",
|
|
68
|
+
"@typespec/sse": ">=0.70.0 <1.0.0",
|
|
69
|
+
"@typespec/streams": ">=0.70.0 <1.0.0",
|
|
70
|
+
"@typespec/xml": ">=0.70.0 <1.0.0"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"js-yaml": "~4.1.0",
|
|
@@ -77,22 +77,24 @@
|
|
|
77
77
|
"tsx": "~4.19.1"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@azure-tools/typespec-autorest": "~0.
|
|
81
|
-
"@azure-tools/typespec-azure-core": "~0.
|
|
82
|
-
"@azure-tools/typespec-azure-resource-manager": "~0.
|
|
83
|
-
"@azure-tools/typespec-azure-rulesets": "~0.
|
|
84
|
-
"@azure-tools/typespec-client-generator-core": "~0.
|
|
85
|
-
"@azure-tools/azure-http-specs": "0.1.0-alpha.
|
|
86
|
-
"@typespec/compiler": "^1.0.0
|
|
87
|
-
"@typespec/http": "^1.0.0
|
|
88
|
-
"@typespec/openapi": "^1.0.0
|
|
89
|
-
"@typespec/rest": "~0.
|
|
90
|
-
"@typespec/versioning": "~0.
|
|
91
|
-
"@typespec/events": "~0.
|
|
92
|
-
"@typespec/
|
|
93
|
-
"@typespec/
|
|
94
|
-
"@typespec/
|
|
95
|
-
"@typespec/
|
|
80
|
+
"@azure-tools/typespec-autorest": "~0.56.0",
|
|
81
|
+
"@azure-tools/typespec-azure-core": "~0.56.0",
|
|
82
|
+
"@azure-tools/typespec-azure-resource-manager": "~0.56.0",
|
|
83
|
+
"@azure-tools/typespec-azure-rulesets": "~0.56.0",
|
|
84
|
+
"@azure-tools/typespec-client-generator-core": "~0.56.1",
|
|
85
|
+
"@azure-tools/azure-http-specs": "0.1.0-alpha.17",
|
|
86
|
+
"@typespec/compiler": "^1.0.0",
|
|
87
|
+
"@typespec/http": "^1.0.0",
|
|
88
|
+
"@typespec/openapi": "^1.0.0",
|
|
89
|
+
"@typespec/rest": "~0.70.0",
|
|
90
|
+
"@typespec/versioning": "~0.70.0",
|
|
91
|
+
"@typespec/events": "~0.70.0",
|
|
92
|
+
"@typespec/spector": "0.1.0-alpha.13",
|
|
93
|
+
"@typespec/spec-api": "0.1.0-alpha.6",
|
|
94
|
+
"@typespec/sse": "~0.70.0",
|
|
95
|
+
"@typespec/streams": "~0.70.0",
|
|
96
|
+
"@typespec/xml": "~0.70.0",
|
|
97
|
+
"@typespec/http-specs": "0.1.0-alpha.22",
|
|
96
98
|
"@types/js-yaml": "~4.0.5",
|
|
97
99
|
"@types/node": "~22.13.14",
|
|
98
100
|
"@types/semver": "7.5.8",
|