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+
69from copy import deepcopy
710from typing import Any , TYPE_CHECKING
11+ from typing_extensions import Self
812
913from azure .core import PipelineClient
14+ from azure .core .pipeline import policies
1015from 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
1621if 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 )
0 commit comments