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
11
from typing_extensions import Self
12
12
13
13
from azure .core .pipeline import policies
14
14
from azure .core .rest import HttpRequest , HttpResponse
15
+ from azure .core .settings import settings
15
16
from azure .mgmt .core import ARMPipelineClient
16
17
from azure .mgmt .core .policies import ARMAutoResourceProviderRegistrationPolicy
18
+ from azure .mgmt .core .tools import get_arm_endpoints
17
19
18
20
from . import models as _models
19
21
from ._configuration import ConnectedKubernetesClientConfiguration
20
- from ._serialization import Deserializer , Serializer
22
+ from ._utils . serialization import Deserializer , Serializer
21
23
from .operations import ConnectedClusterOperations , Operations
22
24
23
25
if TYPE_CHECKING :
27
29
class ConnectedKubernetesClient :
28
30
"""Azure Connected Cluster Resource Provider API for onboarding a Kubernetes Cluster to Azure Arc.
29
31
30
- :ivar connected_cluster: ConnectedClusterOperations operations
31
- :vartype connected_cluster: azure.mgmt.hybridkubernetes.operations.ConnectedClusterOperations
32
32
:ivar operations: Operations operations
33
33
:vartype operations: azure.mgmt.hybridkubernetes.operations.Operations
34
+ :ivar connected_cluster: ConnectedClusterOperations operations
35
+ :vartype connected_cluster: azure.mgmt.hybridkubernetes.operations.ConnectedClusterOperations
34
36
:param credential: Credential needed for the client to connect to Azure. Required.
35
37
:type credential: ~azure.core.credentials.TokenCredential
36
38
:param subscription_id: The ID of the target subscription. Required.
37
39
:type subscription_id: str
38
- :param base_url: Service URL. Default value is "https://management.azure.com" .
40
+ :param base_url: Service URL. Default value is None .
39
41
:type base_url: str
40
42
:keyword api_version: Api Version. Default value is "2024-12-01-preview". Note that overriding
41
43
this default value may result in unsupported behavior.
@@ -45,15 +47,17 @@ class ConnectedKubernetesClient:
45
47
"""
46
48
47
49
def __init__ (
48
- self ,
49
- credential : "TokenCredential" ,
50
- subscription_id : str ,
51
- base_url : str = "https://management.azure.com" ,
52
- ** kwargs : Any
50
+ self , credential : "TokenCredential" , subscription_id : str , base_url : Optional [str ] = None , ** kwargs : Any
53
51
) -> None :
52
+ _cloud = kwargs .pop ("cloud_setting" , None ) or settings .current .azure_cloud # type: ignore
53
+ _endpoints = get_arm_endpoints (_cloud )
54
+ if not base_url :
55
+ base_url = _endpoints ["resource_manager" ]
56
+ credential_scopes = kwargs .pop ("credential_scopes" , _endpoints ["credential_scopes" ])
54
57
self ._config = ConnectedKubernetesClientConfiguration (
55
- credential = credential , subscription_id = subscription_id , ** kwargs
58
+ credential = credential , subscription_id = subscription_id , credential_scopes = credential_scopes , ** kwargs
56
59
)
60
+
57
61
_policies = kwargs .pop ("policies" , None )
58
62
if _policies is None :
59
63
_policies = [
@@ -72,16 +76,16 @@ def __init__(
72
76
policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
73
77
self ._config .http_logging_policy ,
74
78
]
75
- self ._client : ARMPipelineClient = ARMPipelineClient (base_url = base_url , policies = _policies , ** kwargs )
79
+ self ._client : ARMPipelineClient = ARMPipelineClient (base_url = cast ( str , base_url ) , policies = _policies , ** kwargs )
76
80
77
81
client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
78
82
self ._serialize = Serializer (client_models )
79
83
self ._deserialize = Deserializer (client_models )
80
84
self ._serialize .client_side_validation = False
85
+ self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
81
86
self .connected_cluster = ConnectedClusterOperations (
82
87
self ._client , self ._config , self ._serialize , self ._deserialize
83
88
)
84
- self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
85
89
86
90
def _send_request (self , request : HttpRequest , * , stream : bool = False , ** kwargs : Any ) -> HttpResponse :
87
91
"""Runs the network request through the client's chained policies.
0 commit comments