6
6
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
7
# --------------------------------------------------------------------------
8
8
9
- from typing import TYPE_CHECKING
9
+ from copy import deepcopy
10
+ from typing import Any , Optional , TYPE_CHECKING
10
11
12
+ from azure .core .rest import HttpRequest , HttpResponse
11
13
from azure .mgmt .core import ARMPipelineClient
12
14
from msrest import Deserializer , Serializer
13
15
16
+ from . import models
17
+ from ._configuration import AzureQuantumManagementClientConfiguration
18
+ from .operations import OfferingsOperations , Operations , WorkspaceOperations , WorkspacesOperations
19
+
14
20
if TYPE_CHECKING :
15
21
# pylint: disable=unused-import,ungrouped-imports
16
- from typing import Any , Optional
17
-
18
22
from azure .core .credentials import TokenCredential
19
- from azure .core .pipeline .transport import HttpRequest , HttpResponse
20
-
21
- from ._configuration import AzureQuantumManagementClientConfiguration
22
- from .operations import WorkspacesOperations
23
- from .operations import OfferingsOperations
24
- from .operations import Operations
25
- from . import models
26
23
27
-
28
- class AzureQuantumManagementClient (object ):
24
+ class AzureQuantumManagementClient :
29
25
"""AzureQuantumManagementClient.
30
26
31
27
:ivar workspaces: WorkspacesOperations operations
@@ -34,56 +30,63 @@ class AzureQuantumManagementClient(object):
34
30
:vartype offerings: azure.mgmt.quantum.operations.OfferingsOperations
35
31
:ivar operations: Operations operations
36
32
:vartype operations: azure.mgmt.quantum.operations.Operations
33
+ :ivar workspace: WorkspaceOperations operations
34
+ :vartype workspace: azure.mgmt.quantum.operations.WorkspaceOperations
37
35
:param credential: Credential needed for the client to connect to Azure.
38
36
:type credential: ~azure.core.credentials.TokenCredential
39
37
:param subscription_id: The Azure subscription ID.
40
38
:type subscription_id: str
41
- :param str base_url: Service URL
42
- :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
39
+ :param base_url: Service URL. Default value is 'https://management.azure.com'.
40
+ :type base_url: str
41
+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no
42
+ Retry-After header is present.
43
43
"""
44
44
45
45
def __init__ (
46
46
self ,
47
- credential , # type: "TokenCredential"
48
- subscription_id , # type: str
49
- base_url = None , # type: Optional[str]
50
- ** kwargs # type: Any
51
- ):
52
- # type: (...) -> None
53
- if not base_url :
54
- base_url = 'https://management.azure.com'
55
- self ._config = AzureQuantumManagementClientConfiguration (credential , subscription_id , ** kwargs )
47
+ credential : "TokenCredential" ,
48
+ subscription_id : str ,
49
+ base_url : str = "https://management.azure.com" ,
50
+ ** kwargs : Any
51
+ ) -> None :
52
+ self ._config = AzureQuantumManagementClientConfiguration (credential = credential , subscription_id = subscription_id , ** kwargs )
56
53
self ._client = ARMPipelineClient (base_url = base_url , config = self ._config , ** kwargs )
57
54
58
55
client_models = {k : v for k , v in models .__dict__ .items () if isinstance (v , type )}
59
56
self ._serialize = Serializer (client_models )
60
- self ._serialize .client_side_validation = False
61
57
self ._deserialize = Deserializer (client_models )
58
+ self ._serialize .client_side_validation = False
59
+ self .workspaces = WorkspacesOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
60
+ self .offerings = OfferingsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
61
+ self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
62
+ self .workspace = WorkspaceOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
62
63
63
- self .workspaces = WorkspacesOperations (
64
- self ._client , self ._config , self ._serialize , self ._deserialize )
65
- self .offerings = OfferingsOperations (
66
- self ._client , self ._config , self ._serialize , self ._deserialize )
67
- self .operations = Operations (
68
- self ._client , self ._config , self ._serialize , self ._deserialize )
69
64
70
- def _send_request (self , http_request , ** kwargs ):
71
- # type: (HttpRequest, Any) -> HttpResponse
65
+ def _send_request (
66
+ self ,
67
+ request , # type: HttpRequest
68
+ ** kwargs : Any
69
+ ) -> HttpResponse :
72
70
"""Runs the network request through the client's chained policies.
73
71
74
- :param http_request: The network request you want to make. Required.
75
- :type http_request: ~azure.core.pipeline.transport.HttpRequest
76
- :keyword bool stream: Whether the response payload will be streamed. Defaults to True.
72
+ >>> from azure.core.rest import HttpRequest
73
+ >>> request = HttpRequest("GET", "https://www.example.org/")
74
+ <HttpRequest [GET], url: 'https://www.example.org/'>
75
+ >>> response = client._send_request(request)
76
+ <HttpResponse: 200 OK>
77
+
78
+ For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
79
+
80
+ :param request: The network request you want to make. Required.
81
+ :type request: ~azure.core.rest.HttpRequest
82
+ :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
77
83
:return: The response of your network call. Does not do error handling on your response.
78
- :rtype: ~azure.core.pipeline.transport .HttpResponse
84
+ :rtype: ~azure.core.rest .HttpResponse
79
85
"""
80
- path_format_arguments = {
81
- 'subscriptionId' : self ._serialize .url ("self._config.subscription_id" , self ._config .subscription_id , 'str' ),
82
- }
83
- http_request .url = self ._client .format_url (http_request .url , ** path_format_arguments )
84
- stream = kwargs .pop ("stream" , True )
85
- pipeline_response = self ._client ._pipeline .run (http_request , stream = stream , ** kwargs )
86
- return pipeline_response .http_response
86
+
87
+ request_copy = deepcopy (request )
88
+ request_copy .url = self ._client .format_url (request_copy .url )
89
+ return self ._client .send_request (request_copy , ** kwargs )
87
90
88
91
def close (self ):
89
92
# type: () -> None
0 commit comments