Skip to content

Commit e20dbfc

Browse files
author
SDKAuto
committed
CodeGen from PR 31078 in Azure/azure-rest-api-specs
Merge c5cf50d9026244cf8a3e96442e97b7bb92efaa3f into 3890d974c2822a6f0f2d91e20cec7fa8b5fdda95
1 parent 1820bd0 commit e20dbfc

File tree

93 files changed

+16886
-15027
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+16886
-15027
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"commit": "8336683a1bde665f90135ed754f96ae466059c1a",
3+
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4+
"typespec_src": "specification/loadtestservice/LoadTestService",
5+
"@azure-tools/typespec-python": "0.37.2"
6+
}
Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
1-
# -------------------------------------------------------------------------
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
23
# Copyright (c) Microsoft Corporation. All rights reserved.
3-
# Licensed under the MIT License. See License.txt in the project root for
4-
# license information.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
57
# --------------------------------------------------------------------------
6-
from ._client import LoadTestAdministrationClient, LoadTestRunClient
8+
# pylint: disable=wrong-import-position
9+
10+
from typing import TYPE_CHECKING
11+
12+
if TYPE_CHECKING:
13+
from ._patch import * # pylint: disable=unused-wildcard-import
14+
15+
from ._client import LoadTestAdministrationClient # type: ignore
16+
from ._client import LoadTestRunClient # type: ignore
717
from ._version import VERSION
818

919
__version__ = VERSION
10-
__all__ = ["LoadTestAdministrationClient", "LoadTestRunClient"]
20+
21+
try:
22+
from ._patch import __all__ as _patch_all
23+
from ._patch import *
24+
except ImportError:
25+
_patch_all = []
26+
from ._patch import patch_sdk as _patch_sdk
27+
28+
__all__ = [
29+
"LoadTestAdministrationClient",
30+
"LoadTestRunClient",
31+
]
32+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
33+
34+
_patch_sdk()
Lines changed: 116 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,67 @@
1-
# -------------------------------------------------------------------------
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
23
# Copyright (c) Microsoft Corporation. All rights reserved.
3-
# Licensed under the MIT License. See License.txt in the project root for
4-
# license information.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
57
# --------------------------------------------------------------------------
8+
69
from copy import deepcopy
710
from typing import Any, TYPE_CHECKING
11+
from typing_extensions import Self
812

913
from azure.core import PipelineClient
14+
from azure.core.pipeline import policies
1015
from azure.core.rest import HttpRequest, HttpResponse
1116

12-
from ._generated._configuration import LoadTestingClientConfiguration
13-
from ._generated._serialization import Deserializer, Serializer
14-
from ._generated.operations import AdministrationOperations, TestRunOperations
17+
from ._configuration import LoadTestAdministrationClientConfiguration, LoadTestRunClientConfiguration
18+
from ._operations import LoadTestAdministrationClientOperationsMixin, LoadTestRunClientOperationsMixin
19+
from ._serialization import Deserializer, Serializer
1520

1621
if TYPE_CHECKING:
17-
# pylint: disable=unused-import,ungrouped-imports
1822
from azure.core.credentials import TokenCredential
1923

20-
class _BaseClient:
24+
25+
class LoadTestAdministrationClient(LoadTestAdministrationClientOperationsMixin):
26+
"""LoadTestAdministrationClient.
27+
28+
:param endpoint: Required.
29+
:type endpoint: str
30+
:param credential: Credential used to authenticate requests to the service. Required.
31+
:type credential: ~azure.core.credentials.TokenCredential
32+
:keyword api_version: The API version to use for this operation. Default value is
33+
"2024-12-01-preview". Note that overriding this default value may result in unsupported
34+
behavior.
35+
:paramtype api_version: str
36+
"""
37+
2138
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
22-
_endpoint = "https://{Endpoint}"
23-
self._config = LoadTestingClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
24-
self._client = PipelineClient(base_url=_endpoint, config=self._config, **kwargs)
39+
_endpoint = "https://{endpoint}"
40+
self._config = LoadTestAdministrationClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
41+
_policies = kwargs.pop("policies", None)
42+
if _policies is None:
43+
_policies = [
44+
policies.RequestIdPolicy(**kwargs),
45+
self._config.headers_policy,
46+
self._config.user_agent_policy,
47+
self._config.proxy_policy,
48+
policies.ContentDecodePolicy(**kwargs),
49+
self._config.redirect_policy,
50+
self._config.retry_policy,
51+
self._config.authentication_policy,
52+
self._config.custom_hook_policy,
53+
self._config.logging_policy,
54+
policies.DistributedTracingPolicy(**kwargs),
55+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
56+
self._config.http_logging_policy,
57+
]
58+
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
2559

2660
self._serialize = Serializer()
2761
self._deserialize = Deserializer()
2862
self._serialize.client_side_validation = False
29-
super().__init__(self._client, self._config, self._serialize, self._deserialize)
3063

31-
def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
64+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
3265
"""Runs the network request through the client's chained policies.
3366
3467
>>> from azure.core.rest import HttpRequest
@@ -48,50 +81,94 @@ def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
4881

4982
request_copy = deepcopy(request)
5083
path_format_arguments = {
51-
"Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
84+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str"),
5285
}
5386

5487
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
55-
return self._client.send_request(request_copy, **kwargs)
88+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
5689

57-
def close(self):
58-
# type: () -> None
90+
def close(self) -> None:
5991
self._client.close()
6092

61-
def __exit__(self, *exc_details):
62-
# type: (Any) -> None
93+
def __enter__(self) -> Self:
94+
self._client.__enter__()
95+
return self
96+
97+
def __exit__(self, *exc_details: Any) -> None:
6398
self._client.__exit__(*exc_details)
6499

65100

66-
class LoadTestAdministrationClient(_BaseClient, AdministrationOperations): # pylint: disable=client-accepts-api-version-keyword
67-
"""These APIs allow end users to do various administrative operations on Azure Load Test Service.
101+
class LoadTestRunClient(LoadTestRunClientOperationsMixin):
102+
"""LoadTestRunClient.
68103
69-
:param endpoint: URL to perform data plane API operations on the resource. Required.
104+
:param endpoint: Required.
70105
:type endpoint: str
71-
:param credential: Credential needed for the client to connect to Azure. Required.
106+
:param credential: Credential used to authenticate requests to the service. Required.
72107
:type credential: ~azure.core.credentials.TokenCredential
73-
:keyword api_version: Api Version. Default value is "2022-11-01". Note that overriding this
74-
default value may result in unsupported behavior.
108+
:keyword api_version: The API version to use for this operation. Default value is
109+
"2024-12-01-preview". Note that overriding this default value may result in unsupported
110+
behavior.
75111
:paramtype api_version: str
76112
"""
77113

78-
def __enter__(self) -> "LoadTestAdministrationClient":
79-
self._client.__enter__()
80-
return self
114+
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
115+
_endpoint = "https://{endpoint}"
116+
self._config = LoadTestRunClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
117+
_policies = kwargs.pop("policies", None)
118+
if _policies is None:
119+
_policies = [
120+
policies.RequestIdPolicy(**kwargs),
121+
self._config.headers_policy,
122+
self._config.user_agent_policy,
123+
self._config.proxy_policy,
124+
policies.ContentDecodePolicy(**kwargs),
125+
self._config.redirect_policy,
126+
self._config.retry_policy,
127+
self._config.authentication_policy,
128+
self._config.custom_hook_policy,
129+
self._config.logging_policy,
130+
policies.DistributedTracingPolicy(**kwargs),
131+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
132+
self._config.http_logging_policy,
133+
]
134+
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
81135

82-
class LoadTestRunClient(_BaseClient, TestRunOperations): # pylint: disable=client-accepts-api-version-keyword
83-
"""These APIs allow end users to run Azure Load Test and manage test run.
136+
self._serialize = Serializer()
137+
self._deserialize = Deserializer()
138+
self._serialize.client_side_validation = False
84139

85-
:param endpoint: URL to perform data plane API operations on the resource. Required.
86-
:type endpoint: str
87-
:param credential: Credential needed for the client to connect to Azure. Required.
88-
:type credential: ~azure.core.credentials.TokenCredential
89-
:keyword api_version: Api Version. Default value is "2022-11-01". Note that overriding this
90-
default value may result in unsupported behavior.
91-
:paramtype api_version: str
92-
"""
140+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
141+
"""Runs the network request through the client's chained policies.
93142
94-
def __enter__(self) -> "LoadTestRunClient":
143+
>>> from azure.core.rest import HttpRequest
144+
>>> request = HttpRequest("GET", "https://www.example.org/")
145+
<HttpRequest [GET], url: 'https://www.example.org/'>
146+
>>> response = client.send_request(request)
147+
<HttpResponse: 200 OK>
148+
149+
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
150+
151+
:param request: The network request you want to make. Required.
152+
:type request: ~azure.core.rest.HttpRequest
153+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
154+
:return: The response of your network call. Does not do error handling on your response.
155+
:rtype: ~azure.core.rest.HttpResponse
156+
"""
157+
158+
request_copy = deepcopy(request)
159+
path_format_arguments = {
160+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str"),
161+
}
162+
163+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
164+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
165+
166+
def close(self) -> None:
167+
self._client.close()
168+
169+
def __enter__(self) -> Self:
95170
self._client.__enter__()
96171
return self
97172

173+
def __exit__(self, *exc_details: Any) -> None:
174+
self._client.__exit__(*exc_details)
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from typing import Any, TYPE_CHECKING
10+
11+
from azure.core.pipeline import policies
12+
13+
from ._version import VERSION
14+
15+
if TYPE_CHECKING:
16+
from azure.core.credentials import TokenCredential
17+
18+
19+
class LoadTestAdministrationClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
20+
"""Configuration for LoadTestAdministrationClient.
21+
22+
Note that all parameters used to create this instance are saved as instance
23+
attributes.
24+
25+
:param endpoint: Required.
26+
:type endpoint: str
27+
:param credential: Credential used to authenticate requests to the service. Required.
28+
:type credential: ~azure.core.credentials.TokenCredential
29+
:keyword api_version: The API version to use for this operation. Default value is
30+
"2024-12-01-preview". Note that overriding this default value may result in unsupported
31+
behavior.
32+
:paramtype api_version: str
33+
"""
34+
35+
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
36+
api_version: str = kwargs.pop("api_version", "2024-12-01-preview")
37+
38+
if endpoint is None:
39+
raise ValueError("Parameter 'endpoint' must not be None.")
40+
if credential is None:
41+
raise ValueError("Parameter 'credential' must not be None.")
42+
43+
self.endpoint = endpoint
44+
self.credential = credential
45+
self.api_version = api_version
46+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://cnt-prod.loadtesting.azure.com/.default"])
47+
kwargs.setdefault("sdk_moniker", "developer-loadtesting/{}".format(VERSION))
48+
self.polling_interval = kwargs.get("polling_interval", 30)
49+
self._configure(**kwargs)
50+
51+
def _configure(self, **kwargs: Any) -> None:
52+
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
53+
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
54+
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
55+
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
56+
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
57+
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
58+
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
59+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
60+
self.authentication_policy = kwargs.get("authentication_policy")
61+
if self.credential and not self.authentication_policy:
62+
self.authentication_policy = policies.BearerTokenCredentialPolicy(
63+
self.credential, *self.credential_scopes, **kwargs
64+
)
65+
66+
67+
class LoadTestRunClientConfiguration: # pylint: disable=too-many-instance-attributes
68+
"""Configuration for LoadTestRunClient.
69+
70+
Note that all parameters used to create this instance are saved as instance
71+
attributes.
72+
73+
:param endpoint: Required.
74+
:type endpoint: str
75+
:param credential: Credential used to authenticate requests to the service. Required.
76+
:type credential: ~azure.core.credentials.TokenCredential
77+
:keyword api_version: The API version to use for this operation. Default value is
78+
"2024-12-01-preview". Note that overriding this default value may result in unsupported
79+
behavior.
80+
:paramtype api_version: str
81+
"""
82+
83+
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
84+
api_version: str = kwargs.pop("api_version", "2024-12-01-preview")
85+
86+
if endpoint is None:
87+
raise ValueError("Parameter 'endpoint' must not be None.")
88+
if credential is None:
89+
raise ValueError("Parameter 'credential' must not be None.")
90+
91+
self.endpoint = endpoint
92+
self.credential = credential
93+
self.api_version = api_version
94+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://cnt-prod.loadtesting.azure.com/.default"])
95+
kwargs.setdefault("sdk_moniker", "developer-loadtesting/{}".format(VERSION))
96+
self.polling_interval = kwargs.get("polling_interval", 30)
97+
self._configure(**kwargs)
98+
99+
def _configure(self, **kwargs: Any) -> None:
100+
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
101+
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
102+
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
103+
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
104+
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
105+
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
106+
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
107+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
108+
self.authentication_policy = kwargs.get("authentication_policy")
109+
if self.credential and not self.authentication_policy:
110+
self.authentication_policy = policies.BearerTokenCredentialPolicy(
111+
self.credential, *self.credential_scopes, **kwargs
112+
)

0 commit comments

Comments
 (0)