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 DashboardManagementClientConfiguration
17
- from ._serialization import Deserializer , Serializer
22
+ from ._utils . serialization import Deserializer , Serializer
18
23
from .operations import (
19
24
GrafanaOperations ,
25
+ IntegrationFabricsOperations ,
20
26
ManagedPrivateEndpointsOperations ,
21
27
Operations ,
22
28
PrivateEndpointConnectionsOperations ,
23
29
PrivateLinkResourcesOperations ,
24
30
)
25
31
26
32
if TYPE_CHECKING :
27
- # pylint: disable=unused-import,ungrouped-imports
28
33
from azure .core .credentials import TokenCredential
29
34
30
35
31
- class DashboardManagementClient : # pylint: disable=client-accepts-api-version-keyword
36
+ class DashboardManagementClient :
32
37
"""The Microsoft.Dashboard Rest API spec.
33
38
34
39
:ivar operations: Operations operations
35
40
:vartype operations: azure.mgmt.dashboard.operations.Operations
36
41
:ivar grafana: GrafanaOperations operations
37
42
:vartype grafana: azure.mgmt.dashboard.operations.GrafanaOperations
43
+ :ivar integration_fabrics: IntegrationFabricsOperations operations
44
+ :vartype integration_fabrics: azure.mgmt.dashboard.operations.IntegrationFabricsOperations
45
+ :ivar managed_private_endpoints: ManagedPrivateEndpointsOperations operations
46
+ :vartype managed_private_endpoints:
47
+ azure.mgmt.dashboard.operations.ManagedPrivateEndpointsOperations
38
48
:ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations
39
49
:vartype private_endpoint_connections:
40
50
azure.mgmt.dashboard.operations.PrivateEndpointConnectionsOperations
41
51
:ivar private_link_resources: PrivateLinkResourcesOperations operations
42
52
:vartype private_link_resources: azure.mgmt.dashboard.operations.PrivateLinkResourcesOperations
43
- :ivar managed_private_endpoints: ManagedPrivateEndpointsOperations operations
44
- :vartype managed_private_endpoints:
45
- azure.mgmt.dashboard.operations.ManagedPrivateEndpointsOperations
46
53
:param credential: Credential needed for the client to connect to Azure. Required.
47
54
:type credential: ~azure.core.credentials.TokenCredential
48
55
:param subscription_id: The ID of the target subscription. Required.
49
56
:type subscription_id: str
50
- :param base_url: Service URL. Default value is "https://management.azure.com" .
57
+ :param base_url: Service URL. Default value is None .
51
58
:type base_url: str
52
- :keyword api_version: Api Version. Default value is "2023-09 -01". Note that overriding this
59
+ :keyword api_version: Api Version. Default value is "2024-10 -01". Note that overriding this
53
60
default value may result in unsupported behavior.
54
61
:paramtype api_version: str
55
62
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
56
63
Retry-After header is present.
57
64
"""
58
65
59
66
def __init__ (
60
- self ,
61
- credential : "TokenCredential" ,
62
- subscription_id : str ,
63
- base_url : str = "https://management.azure.com" ,
64
- ** kwargs : Any
67
+ self , credential : "TokenCredential" , subscription_id : str , base_url : Optional [str ] = None , ** kwargs : Any
65
68
) -> None :
69
+ _cloud = kwargs .pop ("cloud_setting" , None ) or settings .current .azure_cloud # type: ignore
70
+ _endpoints = get_arm_endpoints (_cloud )
71
+ if not base_url :
72
+ base_url = _endpoints ["resource_manager" ]
73
+ credential_scopes = kwargs .pop ("credential_scopes" , _endpoints ["credential_scopes" ])
66
74
self ._config = DashboardManagementClientConfiguration (
67
- credential = credential , subscription_id = subscription_id , ** kwargs
75
+ credential = credential , subscription_id = subscription_id , credential_scopes = credential_scopes , ** kwargs
68
76
)
69
- self ._client : ARMPipelineClient = ARMPipelineClient (base_url = base_url , config = self ._config , ** kwargs )
77
+
78
+ _policies = kwargs .pop ("policies" , None )
79
+ if _policies is None :
80
+ _policies = [
81
+ policies .RequestIdPolicy (** kwargs ),
82
+ self ._config .headers_policy ,
83
+ self ._config .user_agent_policy ,
84
+ self ._config .proxy_policy ,
85
+ policies .ContentDecodePolicy (** kwargs ),
86
+ ARMAutoResourceProviderRegistrationPolicy (),
87
+ self ._config .redirect_policy ,
88
+ self ._config .retry_policy ,
89
+ self ._config .authentication_policy ,
90
+ self ._config .custom_hook_policy ,
91
+ self ._config .logging_policy ,
92
+ policies .DistributedTracingPolicy (** kwargs ),
93
+ policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
94
+ self ._config .http_logging_policy ,
95
+ ]
96
+ self ._client : ARMPipelineClient = ARMPipelineClient (base_url = cast (str , base_url ), policies = _policies , ** kwargs )
70
97
71
98
client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
72
99
self ._serialize = Serializer (client_models )
73
100
self ._deserialize = Deserializer (client_models )
74
101
self ._serialize .client_side_validation = False
75
102
self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
76
103
self .grafana = GrafanaOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
77
- self .private_endpoint_connections = PrivateEndpointConnectionsOperations (
104
+ self .integration_fabrics = IntegrationFabricsOperations (
78
105
self ._client , self ._config , self ._serialize , self ._deserialize
79
106
)
80
- self .private_link_resources = PrivateLinkResourcesOperations (
107
+ self .managed_private_endpoints = ManagedPrivateEndpointsOperations (
81
108
self ._client , self ._config , self ._serialize , self ._deserialize
82
109
)
83
- self .managed_private_endpoints = ManagedPrivateEndpointsOperations (
110
+ self .private_endpoint_connections = PrivateEndpointConnectionsOperations (
111
+ self ._client , self ._config , self ._serialize , self ._deserialize
112
+ )
113
+ self .private_link_resources = PrivateLinkResourcesOperations (
84
114
self ._client , self ._config , self ._serialize , self ._deserialize
85
115
)
86
116
87
- def _send_request (self , request : HttpRequest , ** kwargs : Any ) -> HttpResponse :
117
+ def _send_request (self , request : HttpRequest , * , stream : bool = False , * *kwargs : Any ) -> HttpResponse :
88
118
"""Runs the network request through the client's chained policies.
89
119
90
120
>>> from azure.core.rest import HttpRequest
@@ -104,12 +134,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
104
134
105
135
request_copy = deepcopy (request )
106
136
request_copy .url = self ._client .format_url (request_copy .url )
107
- return self ._client .send_request (request_copy , ** kwargs )
137
+ return self ._client .send_request (request_copy , stream = stream , ** kwargs ) # type: ignore
108
138
109
139
def close (self ) -> None :
110
140
self ._client .close ()
111
141
112
- def __enter__ (self ) -> "DashboardManagementClient" :
142
+ def __enter__ (self ) -> Self :
113
143
self ._client .__enter__ ()
114
144
return self
115
145
0 commit comments