88
99from copy import deepcopy
1010from typing import Any , TYPE_CHECKING
11+ from typing_extensions import Self
1112
13+ from azure .core .pipeline import policies
1214from azure .core .rest import HttpRequest , HttpResponse
1315from azure .mgmt .core import ARMPipelineClient
16+ from azure .mgmt .core .policies import ARMAutoResourceProviderRegistrationPolicy
1417
1518from . import models as _models
1619from ._configuration import AzureQuantumMgmtClientConfiguration
1720from ._serialization import Deserializer , Serializer
1821from .operations import OfferingsOperations , Operations , WorkspaceOperations , WorkspacesOperations
1922
2023if TYPE_CHECKING :
21- # pylint: disable=unused-import,ungrouped-imports
2224 from azure .core .credentials import TokenCredential
2325
2426
25- class AzureQuantumMgmtClient : # pylint: disable=client-accepts-api-version-keyword
27+ class AzureQuantumMgmtClient :
2628 """AzureQuantumMgmtClient.
2729
28- :ivar workspaces: WorkspacesOperations operations
29- :vartype workspaces: azure.mgmt.quantum.operations.WorkspacesOperations
30- :ivar offerings: OfferingsOperations operations
31- :vartype offerings: azure.mgmt.quantum.operations.OfferingsOperations
3230 :ivar operations: Operations operations
3331 :vartype operations: azure.mgmt.quantum.operations.Operations
3432 :ivar workspace: WorkspaceOperations operations
3533 :vartype workspace: azure.mgmt.quantum.operations.WorkspaceOperations
34+ :ivar offerings: OfferingsOperations operations
35+ :vartype offerings: azure.mgmt.quantum.operations.OfferingsOperations
36+ :ivar workspaces: WorkspacesOperations operations
37+ :vartype workspaces: azure.mgmt.quantum.operations.WorkspacesOperations
3638 :param credential: Credential needed for the client to connect to Azure. Required.
3739 :type credential: ~azure.core.credentials.TokenCredential
3840 :param subscription_id: The ID of the target subscription. The value must be an UUID. Required.
@@ -56,18 +58,36 @@ def __init__(
5658 self ._config = AzureQuantumMgmtClientConfiguration (
5759 credential = credential , subscription_id = subscription_id , ** kwargs
5860 )
59- self ._client : ARMPipelineClient = ARMPipelineClient (base_url = base_url , config = self ._config , ** kwargs )
61+ _policies = kwargs .pop ("policies" , None )
62+ if _policies is None :
63+ _policies = [
64+ policies .RequestIdPolicy (** kwargs ),
65+ self ._config .headers_policy ,
66+ self ._config .user_agent_policy ,
67+ self ._config .proxy_policy ,
68+ policies .ContentDecodePolicy (** kwargs ),
69+ ARMAutoResourceProviderRegistrationPolicy (),
70+ self ._config .redirect_policy ,
71+ self ._config .retry_policy ,
72+ self ._config .authentication_policy ,
73+ self ._config .custom_hook_policy ,
74+ self ._config .logging_policy ,
75+ policies .DistributedTracingPolicy (** kwargs ),
76+ policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
77+ self ._config .http_logging_policy ,
78+ ]
79+ self ._client : ARMPipelineClient = ARMPipelineClient (base_url = base_url , policies = _policies , ** kwargs )
6080
6181 client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
6282 self ._serialize = Serializer (client_models )
6383 self ._deserialize = Deserializer (client_models )
6484 self ._serialize .client_side_validation = False
65- self .workspaces = WorkspacesOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
66- self .offerings = OfferingsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
6785 self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
6886 self .workspace = WorkspaceOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
87+ self .offerings = OfferingsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
88+ self .workspaces = WorkspacesOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
6989
70- def _send_request (self , request : HttpRequest , ** kwargs : Any ) -> HttpResponse :
90+ def _send_request (self , request : HttpRequest , * , stream : bool = False , * *kwargs : Any ) -> HttpResponse :
7191 """Runs the network request through the client's chained policies.
7292
7393 >>> from azure.core.rest import HttpRequest
@@ -87,12 +107,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
87107
88108 request_copy = deepcopy (request )
89109 request_copy .url = self ._client .format_url (request_copy .url )
90- return self ._client .send_request (request_copy , ** kwargs )
110+ return self ._client .send_request (request_copy , stream = stream , ** kwargs ) # type: ignore
91111
92112 def close (self ) -> None :
93113 self ._client .close ()
94114
95- def __enter__ (self ) -> "AzureQuantumMgmtClient" :
115+ def __enter__ (self ) -> Self :
96116 self ._client .__enter__ ()
97117 return self
98118
0 commit comments