7
7
# --------------------------------------------------------------------------
8
8
9
9
from copy import deepcopy
10
- from typing import Any , TYPE_CHECKING
10
+ from typing import Any , Optional , TYPE_CHECKING , cast
11
+ from typing_extensions import Self
11
12
13
+ from azure .core .pipeline import policies
12
14
from azure .core .rest import HttpRequest , HttpResponse
15
+ from azure .core .settings import settings
13
16
from azure .mgmt .core import ARMPipelineClient
17
+ from azure .mgmt .core .policies import ARMAutoResourceProviderRegistrationPolicy
18
+ from azure .mgmt .core .tools import get_arm_endpoints
14
19
15
20
from . import models as _models
16
21
from ._configuration import SqlVirtualMachineManagementClientConfiguration
17
- from ._serialization import Deserializer , Serializer
22
+ from ._utils . serialization import Deserializer , Serializer
18
23
from .operations import (
19
24
AvailabilityGroupListenersOperations ,
20
25
Operations ,
24
29
)
25
30
26
31
if TYPE_CHECKING :
27
- # pylint: disable=unused-import,ungrouped-imports
28
32
from azure .core .credentials import TokenCredential
29
33
30
34
31
- class SqlVirtualMachineManagementClient : # pylint: disable=client-accepts-api-version-keyword
35
+ class SqlVirtualMachineManagementClient :
32
36
"""The SQL virtual machine management API provides a RESTful set of web APIs that interact with
33
37
Azure Compute, Network & Storage services to manage your SQL Server virtual machine. The API
34
38
enables users to create, delete and retrieve a SQL virtual machine, SQL virtual machine group
35
39
or availability group listener.
36
40
37
- :ivar availability_group_listeners: AvailabilityGroupListenersOperations operations
38
- :vartype availability_group_listeners:
39
- azure.mgmt.sqlvirtualmachine.operations.AvailabilityGroupListenersOperations
40
41
:ivar operations: Operations operations
41
42
:vartype operations: azure.mgmt.sqlvirtualmachine.operations.Operations
42
43
:ivar sql_virtual_machine_groups: SqlVirtualMachineGroupsOperations operations
@@ -45,53 +46,76 @@ class SqlVirtualMachineManagementClient: # pylint: disable=client-accepts-api-v
45
46
:ivar sql_virtual_machines: SqlVirtualMachinesOperations operations
46
47
:vartype sql_virtual_machines:
47
48
azure.mgmt.sqlvirtualmachine.operations.SqlVirtualMachinesOperations
49
+ :ivar availability_group_listeners: AvailabilityGroupListenersOperations operations
50
+ :vartype availability_group_listeners:
51
+ azure.mgmt.sqlvirtualmachine.operations.AvailabilityGroupListenersOperations
48
52
:ivar sql_virtual_machine_troubleshoot: SqlVirtualMachineTroubleshootOperations operations
49
53
:vartype sql_virtual_machine_troubleshoot:
50
54
azure.mgmt.sqlvirtualmachine.operations.SqlVirtualMachineTroubleshootOperations
51
55
:param credential: Credential needed for the client to connect to Azure. Required.
52
56
:type credential: ~azure.core.credentials.TokenCredential
53
- :param subscription_id: Subscription ID that identifies an Azure subscription. Required.
57
+ :param subscription_id: The ID of the target subscription. Required.
54
58
:type subscription_id: str
55
- :param base_url: Service URL. Default value is "https://management.azure.com" .
59
+ :param base_url: Service URL. Default value is None .
56
60
:type base_url: str
57
- :keyword api_version: Api Version. Default value is "2022-08 -01-preview ". Note that overriding
58
- this default value may result in unsupported behavior.
61
+ :keyword api_version: Api Version. Default value is "2023-10 -01". Note that overriding this
62
+ default value may result in unsupported behavior.
59
63
:paramtype api_version: str
60
64
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
61
65
Retry-After header is present.
62
66
"""
63
67
64
68
def __init__ (
65
- self ,
66
- credential : "TokenCredential" ,
67
- subscription_id : str ,
68
- base_url : str = "https://management.azure.com" ,
69
- ** kwargs : Any
69
+ self , credential : "TokenCredential" , subscription_id : str , base_url : Optional [str ] = None , ** kwargs : Any
70
70
) -> None :
71
+ _cloud = kwargs .pop ("cloud_setting" , None ) or settings .current .azure_cloud # type: ignore
72
+ _endpoints = get_arm_endpoints (_cloud )
73
+ if not base_url :
74
+ base_url = _endpoints ["resource_manager" ]
75
+ credential_scopes = kwargs .pop ("credential_scopes" , _endpoints ["credential_scopes" ])
71
76
self ._config = SqlVirtualMachineManagementClientConfiguration (
72
- credential = credential , subscription_id = subscription_id , ** kwargs
77
+ credential = credential , subscription_id = subscription_id , credential_scopes = credential_scopes , ** kwargs
73
78
)
74
- self ._client : ARMPipelineClient = ARMPipelineClient (base_url = base_url , config = self ._config , ** kwargs )
79
+
80
+ _policies = kwargs .pop ("policies" , None )
81
+ if _policies is None :
82
+ _policies = [
83
+ policies .RequestIdPolicy (** kwargs ),
84
+ self ._config .headers_policy ,
85
+ self ._config .user_agent_policy ,
86
+ self ._config .proxy_policy ,
87
+ policies .ContentDecodePolicy (** kwargs ),
88
+ ARMAutoResourceProviderRegistrationPolicy (),
89
+ self ._config .redirect_policy ,
90
+ self ._config .retry_policy ,
91
+ self ._config .authentication_policy ,
92
+ self ._config .custom_hook_policy ,
93
+ self ._config .logging_policy ,
94
+ policies .DistributedTracingPolicy (** kwargs ),
95
+ policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
96
+ self ._config .http_logging_policy ,
97
+ ]
98
+ self ._client : ARMPipelineClient = ARMPipelineClient (base_url = cast (str , base_url ), policies = _policies , ** kwargs )
75
99
76
100
client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
77
101
self ._serialize = Serializer (client_models )
78
102
self ._deserialize = Deserializer (client_models )
79
103
self ._serialize .client_side_validation = False
80
- self .availability_group_listeners = AvailabilityGroupListenersOperations (
81
- self ._client , self ._config , self ._serialize , self ._deserialize
82
- )
83
104
self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
84
105
self .sql_virtual_machine_groups = SqlVirtualMachineGroupsOperations (
85
106
self ._client , self ._config , self ._serialize , self ._deserialize
86
107
)
87
108
self .sql_virtual_machines = SqlVirtualMachinesOperations (
88
109
self ._client , self ._config , self ._serialize , self ._deserialize
89
110
)
111
+ self .availability_group_listeners = AvailabilityGroupListenersOperations (
112
+ self ._client , self ._config , self ._serialize , self ._deserialize
113
+ )
90
114
self .sql_virtual_machine_troubleshoot = SqlVirtualMachineTroubleshootOperations (
91
115
self ._client , self ._config , self ._serialize , self ._deserialize
92
116
)
93
117
94
- def _send_request (self , request : HttpRequest , ** kwargs : Any ) -> HttpResponse :
118
+ def _send_request (self , request : HttpRequest , * , stream : bool = False , * *kwargs : Any ) -> HttpResponse :
95
119
"""Runs the network request through the client's chained policies.
96
120
97
121
>>> from azure.core.rest import HttpRequest
@@ -111,12 +135,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
111
135
112
136
request_copy = deepcopy (request )
113
137
request_copy .url = self ._client .format_url (request_copy .url )
114
- return self ._client .send_request (request_copy , ** kwargs )
138
+ return self ._client .send_request (request_copy , stream = stream , ** kwargs ) # type: ignore
115
139
116
140
def close (self ) -> None :
117
141
self ._client .close ()
118
142
119
- def __enter__ (self ) -> "SqlVirtualMachineManagementClient" :
143
+ def __enter__ (self ) -> Self :
120
144
self ._client .__enter__ ()
121
145
return self
122
146
0 commit comments