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
12
13
from azure .core .pipeline import policies
13
14
from azure .core .rest import HttpRequest , HttpResponse
15
+ from azure .core .settings import settings
14
16
from azure .mgmt .core import ARMPipelineClient
15
17
from azure .mgmt .core .policies import ARMAutoResourceProviderRegistrationPolicy
18
+ from azure .mgmt .core .tools import get_arm_endpoints
16
19
17
20
from . import models as _models
18
21
from ._configuration import NotificationHubsManagementClientConfiguration
19
- from ._serialization import Deserializer , Serializer
22
+ from ._utils . serialization import Deserializer , Serializer
20
23
from .operations import (
21
24
NamespacesOperations ,
22
25
NotificationHubsOperations ,
25
28
)
26
29
27
30
if TYPE_CHECKING :
28
- # pylint: disable=unused-import,ungrouped-imports
29
31
from azure .core .credentials import TokenCredential
30
32
31
33
32
- class NotificationHubsManagementClient : # pylint: disable=client-accepts-api-version-keyword
34
+ class NotificationHubsManagementClient :
33
35
"""Microsoft Notification Hubs Resource Provider REST API.
34
36
35
- :ivar notification_hubs: NotificationHubsOperations operations
36
- :vartype notification_hubs: azure.mgmt.notificationhubs.operations.NotificationHubsOperations
37
- :ivar namespaces: NamespacesOperations operations
38
- :vartype namespaces: azure.mgmt.notificationhubs.operations.NamespacesOperations
39
37
:ivar operations: Operations operations
40
38
:vartype operations: azure.mgmt.notificationhubs.operations.Operations
39
+ :ivar namespaces: NamespacesOperations operations
40
+ :vartype namespaces: azure.mgmt.notificationhubs.operations.NamespacesOperations
41
+ :ivar notification_hubs: NotificationHubsOperations operations
42
+ :vartype notification_hubs: azure.mgmt.notificationhubs.operations.NotificationHubsOperations
41
43
:ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations
42
44
:vartype private_endpoint_connections:
43
45
azure.mgmt.notificationhubs.operations.PrivateEndpointConnectionsOperations
44
46
:param credential: Credential needed for the client to connect to Azure. Required.
45
47
:type credential: ~azure.core.credentials.TokenCredential
46
48
:param subscription_id: The ID of the target subscription. The value must be an UUID. Required.
47
49
:type subscription_id: str
48
- :param base_url: Service URL. Default value is "https://management.azure.com" .
50
+ :param base_url: Service URL. Default value is None .
49
51
:type base_url: str
50
52
:keyword api_version: Api Version. Default value is "2023-10-01-preview". Note that overriding
51
53
this default value may result in unsupported behavior.
@@ -55,15 +57,17 @@ class NotificationHubsManagementClient: # pylint: disable=client-accepts-api-ve
55
57
"""
56
58
57
59
def __init__ (
58
- self ,
59
- credential : "TokenCredential" ,
60
- subscription_id : str ,
61
- base_url : str = "https://management.azure.com" ,
62
- ** kwargs : Any
60
+ self , credential : "TokenCredential" , subscription_id : str , base_url : Optional [str ] = None , ** kwargs : Any
63
61
) -> None :
62
+ _cloud = kwargs .pop ("cloud_setting" , None ) or settings .current .azure_cloud # type: ignore
63
+ _endpoints = get_arm_endpoints (_cloud )
64
+ if not base_url :
65
+ base_url = _endpoints ["resource_manager" ]
66
+ credential_scopes = kwargs .pop ("credential_scopes" , _endpoints ["credential_scopes" ])
64
67
self ._config = NotificationHubsManagementClientConfiguration (
65
- credential = credential , subscription_id = subscription_id , ** kwargs
68
+ credential = credential , subscription_id = subscription_id , credential_scopes = credential_scopes , ** kwargs
66
69
)
70
+
67
71
_policies = kwargs .pop ("policies" , None )
68
72
if _policies is None :
69
73
_policies = [
@@ -82,17 +86,17 @@ def __init__(
82
86
policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
83
87
self ._config .http_logging_policy ,
84
88
]
85
- self ._client : ARMPipelineClient = ARMPipelineClient (base_url = base_url , policies = _policies , ** kwargs )
89
+ self ._client : ARMPipelineClient = ARMPipelineClient (base_url = cast ( str , base_url ) , policies = _policies , ** kwargs )
86
90
87
91
client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
88
92
self ._serialize = Serializer (client_models )
89
93
self ._deserialize = Deserializer (client_models )
90
94
self ._serialize .client_side_validation = False
95
+ self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
96
+ self .namespaces = NamespacesOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
91
97
self .notification_hubs = NotificationHubsOperations (
92
98
self ._client , self ._config , self ._serialize , self ._deserialize
93
99
)
94
- self .namespaces = NamespacesOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
95
- self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
96
100
self .private_endpoint_connections = PrivateEndpointConnectionsOperations (
97
101
self ._client , self ._config , self ._serialize , self ._deserialize
98
102
)
@@ -122,7 +126,7 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
122
126
def close (self ) -> None :
123
127
self ._client .close ()
124
128
125
- def __enter__ (self ) -> "NotificationHubsManagementClient" :
129
+ def __enter__ (self ) -> Self :
126
130
self ._client .__enter__ ()
127
131
return self
128
132
0 commit comments