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 :
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 )
0 commit comments