Skip to content

Commit ff4aef8

Browse files
author
SDKAuto
committed
CodeGen from PR 29464 in Azure/azure-rest-api-specs
Merge 2ff6a88d42afbfe0d46d93ae4f9a4734ae3f93b3 into 0629824cb7947f5b349c7602675432b2f29da1cb
1 parent fc5648d commit ff4aef8

Some content is hidden

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

49 files changed

+10143
-14873
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"commit": "6597534fa6ac4a7b27bc59f2b4f5781bf9f8e9ac",
3+
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4+
"typespec_src": "specification/loadtestservice/LoadTestService",
5+
"@azure-tools/typespec-python": "0.29.0"
6+
}
Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
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+
9+
from ._client import LoadTestAdministrationClient
10+
from ._client import LoadTestRunClient
711
from ._version import VERSION
812

913
__version__ = VERSION
10-
__all__ = ["LoadTestAdministrationClient", "LoadTestRunClient"]
14+
15+
try:
16+
from ._patch import __all__ as _patch_all
17+
from ._patch import * # pylint: disable=unused-wildcard-import
18+
except ImportError:
19+
_patch_all = []
20+
from ._patch import patch_sdk as _patch_sdk
21+
22+
__all__ = [
23+
"LoadTestAdministrationClient",
24+
"LoadTestRunClient",
25+
]
26+
__all__.extend([p for p in _patch_all if p not in __all__])
27+
28+
_patch_sdk()
Lines changed: 118 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,70 @@
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:
1722
# pylint: disable=unused-import,ungrouped-imports
1823
from azure.core.credentials import TokenCredential
1924

20-
class _BaseClient:
25+
26+
class LoadTestAdministrationClient(
27+
LoadTestAdministrationClientOperationsMixin
28+
): # pylint: disable=client-accepts-api-version-keyword
29+
"""LoadTestAdministrationClient.
30+
31+
:param endpoint: Required.
32+
:type endpoint: str
33+
:param credential: Credential used to authenticate requests to the service. Required.
34+
:type credential: ~azure.core.credentials.TokenCredential
35+
:keyword api_version: The API version to use for this operation. Default value is
36+
"2024-05-01-preview". Note that overriding this default value may result in unsupported
37+
behavior.
38+
:paramtype api_version: str
39+
"""
40+
2141
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)
42+
_endpoint = "https://{endpoint}"
43+
self._config = LoadTestAdministrationClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
44+
_policies = kwargs.pop("policies", None)
45+
if _policies is None:
46+
_policies = [
47+
policies.RequestIdPolicy(**kwargs),
48+
self._config.headers_policy,
49+
self._config.user_agent_policy,
50+
self._config.proxy_policy,
51+
policies.ContentDecodePolicy(**kwargs),
52+
self._config.redirect_policy,
53+
self._config.retry_policy,
54+
self._config.authentication_policy,
55+
self._config.custom_hook_policy,
56+
self._config.logging_policy,
57+
policies.DistributedTracingPolicy(**kwargs),
58+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
59+
self._config.http_logging_policy,
60+
]
61+
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
2562

2663
self._serialize = Serializer()
2764
self._deserialize = Deserializer()
2865
self._serialize.client_side_validation = False
29-
super().__init__(self._client, self._config, self._serialize, self._deserialize)
3066

31-
def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
67+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
3268
"""Runs the network request through the client's chained policies.
3369
3470
>>> from azure.core.rest import HttpRequest
@@ -48,50 +84,94 @@ def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
4884

4985
request_copy = deepcopy(request)
5086
path_format_arguments = {
51-
"Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
87+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str"),
5288
}
5389

5490
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
55-
return self._client.send_request(request_copy, **kwargs)
91+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
5692

57-
def close(self):
58-
# type: () -> None
93+
def close(self) -> None:
5994
self._client.close()
6095

61-
def __exit__(self, *exc_details):
62-
# type: (Any) -> None
96+
def __enter__(self) -> Self:
97+
self._client.__enter__()
98+
return self
99+
100+
def __exit__(self, *exc_details: Any) -> None:
63101
self._client.__exit__(*exc_details)
64102

65103

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.
104+
class LoadTestRunClient(LoadTestRunClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
105+
"""LoadTestRunClient.
68106
69-
:param endpoint: URL to perform data plane API operations on the resource. Required.
107+
:param endpoint: Required.
70108
:type endpoint: str
71-
:param credential: Credential needed for the client to connect to Azure. Required.
109+
:param credential: Credential used to authenticate requests to the service. Required.
72110
: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.
111+
:keyword api_version: The API version to use for this operation. Default value is
112+
"2024-05-01-preview". Note that overriding this default value may result in unsupported
113+
behavior.
75114
:paramtype api_version: str
76115
"""
77116

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

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.
139+
self._serialize = Serializer()
140+
self._deserialize = Deserializer()
141+
self._serialize.client_side_validation = False
84142

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-
"""
143+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
144+
"""Runs the network request through the client's chained policies.
93145
94-
def __enter__(self) -> "LoadTestRunClient":
146+
>>> from azure.core.rest import HttpRequest
147+
>>> request = HttpRequest("GET", "https://www.example.org/")
148+
<HttpRequest [GET], url: 'https://www.example.org/'>
149+
>>> response = client.send_request(request)
150+
<HttpResponse: 200 OK>
151+
152+
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
153+
154+
:param request: The network request you want to make. Required.
155+
:type request: ~azure.core.rest.HttpRequest
156+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
157+
:return: The response of your network call. Does not do error handling on your response.
158+
:rtype: ~azure.core.rest.HttpResponse
159+
"""
160+
161+
request_copy = deepcopy(request)
162+
path_format_arguments = {
163+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str"),
164+
}
165+
166+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
167+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
168+
169+
def close(self) -> None:
170+
self._client.close()
171+
172+
def __enter__(self) -> Self:
95173
self._client.__enter__()
96174
return self
97175

176+
def __exit__(self, *exc_details: Any) -> None:
177+
self._client.__exit__(*exc_details)
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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+
# pylint: disable=unused-import,ungrouped-imports
17+
from azure.core.credentials import TokenCredential
18+
19+
20+
class LoadTestAdministrationClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
21+
"""Configuration for LoadTestAdministrationClient.
22+
23+
Note that all parameters used to create this instance are saved as instance
24+
attributes.
25+
26+
:param endpoint: Required.
27+
:type endpoint: str
28+
:param credential: Credential used to authenticate requests to the service. Required.
29+
:type credential: ~azure.core.credentials.TokenCredential
30+
:keyword api_version: The API version to use for this operation. Default value is
31+
"2024-05-01-preview". Note that overriding this default value may result in unsupported
32+
behavior.
33+
:paramtype api_version: str
34+
"""
35+
36+
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
37+
api_version: str = kwargs.pop("api_version", "2024-05-01-preview")
38+
39+
if endpoint is None:
40+
raise ValueError("Parameter 'endpoint' must not be None.")
41+
if credential is None:
42+
raise ValueError("Parameter 'credential' must not be None.")
43+
44+
self.endpoint = endpoint
45+
self.credential = credential
46+
self.api_version = api_version
47+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://cnt-prod.loadtesting.azure.com/.default"])
48+
kwargs.setdefault("sdk_moniker", "developer-loadtesting/{}".format(VERSION))
49+
self.polling_interval = kwargs.get("polling_interval", 30)
50+
self._configure(**kwargs)
51+
52+
def _configure(self, **kwargs: Any) -> None:
53+
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
54+
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
55+
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
56+
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
57+
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
58+
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
59+
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
60+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
61+
self.authentication_policy = kwargs.get("authentication_policy")
62+
if self.credential and not self.authentication_policy:
63+
self.authentication_policy = policies.BearerTokenCredentialPolicy(
64+
self.credential, *self.credential_scopes, **kwargs
65+
)
66+
67+
68+
class LoadTestRunClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
69+
"""Configuration for LoadTestRunClient.
70+
71+
Note that all parameters used to create this instance are saved as instance
72+
attributes.
73+
74+
:param endpoint: Required.
75+
:type endpoint: str
76+
:param credential: Credential used to authenticate requests to the service. Required.
77+
:type credential: ~azure.core.credentials.TokenCredential
78+
:keyword api_version: The API version to use for this operation. Default value is
79+
"2024-05-01-preview". Note that overriding this default value may result in unsupported
80+
behavior.
81+
:paramtype api_version: str
82+
"""
83+
84+
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
85+
api_version: str = kwargs.pop("api_version", "2024-05-01-preview")
86+
87+
if endpoint is None:
88+
raise ValueError("Parameter 'endpoint' must not be None.")
89+
if credential is None:
90+
raise ValueError("Parameter 'credential' must not be None.")
91+
92+
self.endpoint = endpoint
93+
self.credential = credential
94+
self.api_version = api_version
95+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://cnt-prod.loadtesting.azure.com/.default"])
96+
kwargs.setdefault("sdk_moniker", "developer-loadtesting/{}".format(VERSION))
97+
self.polling_interval = kwargs.get("polling_interval", 30)
98+
self._configure(**kwargs)
99+
100+
def _configure(self, **kwargs: Any) -> None:
101+
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
102+
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
103+
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
104+
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
105+
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
106+
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
107+
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
108+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
109+
self.authentication_policy = kwargs.get("authentication_policy")
110+
if self.credential and not self.authentication_policy:
111+
self.authentication_policy = policies.BearerTokenCredentialPolicy(
112+
self.credential, *self.credential_scopes, **kwargs
113+
)

sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_generated/__init__.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)