2
2
# --------------------------------------------------------------------------
3
3
# Copyright (c) Microsoft Corporation. All rights reserved.
4
4
# Licensed under the MIT License. See License.txt in the project root for license information.
5
- # Code generated by Microsoft (R) AutoRest Code Generator.
5
+ # Code generated by Microsoft (R) Python Code Generator.
6
6
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
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
- from . import models as _models
19
- from ._configuration import ConnectedKubernetesClientConfiguration
20
- from ._serialization import Deserializer , Serializer
21
- from .operations import ConnectedClusterOperations , Operations
20
+ from ._configuration import KubernetesClientConfiguration
21
+ from ._utils .serialization import Deserializer , Serializer
22
+ from .operations import ConnectedClustersOperations , Operations
22
23
23
24
if TYPE_CHECKING :
24
25
from azure .core .credentials import TokenCredential
25
26
26
27
27
- class ConnectedKubernetesClient :
28
+ class KubernetesClient :
28
29
"""Azure Connected Cluster Resource Provider API for onboarding a Kubernetes Cluster to Azure Arc.
29
30
30
- :ivar connected_cluster: ConnectedClusterOperations operations
31
- :vartype connected_cluster: azure.mgmt.hybridkubernetes.operations.ConnectedClusterOperations
32
31
:ivar operations: Operations operations
33
32
:vartype operations: azure.mgmt.hybridkubernetes.operations.Operations
34
- :param credential: Credential needed for the client to connect to Azure. Required.
33
+ :ivar connected_clusters: ConnectedClustersOperations operations
34
+ :vartype connected_clusters: azure.mgmt.hybridkubernetes.operations.ConnectedClustersOperations
35
+ :param credential: Credential used to authenticate requests to the service. Required.
35
36
:type credential: ~azure.core.credentials.TokenCredential
36
- :param subscription_id: The ID of the target subscription. Required.
37
+ :param subscription_id: The ID of the target subscription. The value must be an UUID. Required.
37
38
:type subscription_id: str
38
- :param base_url: Service URL . Default value is "https://management.azure.com" .
39
+ :param base_url: Service host . Default value is None .
39
40
:type base_url: str
40
- :keyword api_version: Api Version. Default value is "2024-12-01-preview". Note that overriding
41
- this default value may result in unsupported behavior.
41
+ :keyword api_version: The API version to use for this operation. Default value is
42
+ "2024-12-01-preview". Note that overriding this default value may result in unsupported
43
+ behavior.
42
44
:paramtype api_version: str
43
45
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
44
46
Retry-After header is present.
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 :
54
- self ._config = ConnectedKubernetesClientConfiguration (
55
- credential = credential , subscription_id = subscription_id , ** kwargs
52
+ _endpoint = "{endpoint}"
53
+ _cloud = kwargs .pop ("cloud_setting" , None ) or settings .current .azure_cloud # type: ignore
54
+ _endpoints = get_arm_endpoints (_cloud )
55
+ if not base_url :
56
+ base_url = _endpoints ["resource_manager" ]
57
+ credential_scopes = kwargs .pop ("credential_scopes" , _endpoints ["credential_scopes" ])
58
+ self ._config = KubernetesClientConfiguration (
59
+ credential = credential ,
60
+ subscription_id = subscription_id ,
61
+ base_url = cast (str , base_url ),
62
+ credential_scopes = credential_scopes ,
63
+ ** kwargs
56
64
)
65
+
57
66
_policies = kwargs .pop ("policies" , None )
58
67
if _policies is None :
59
68
_policies = [
@@ -72,24 +81,23 @@ def __init__(
72
81
policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
73
82
self ._config .http_logging_policy ,
74
83
]
75
- self ._client : ARMPipelineClient = ARMPipelineClient (base_url = base_url , policies = _policies , ** kwargs )
84
+ self ._client : ARMPipelineClient = ARMPipelineClient (base_url = cast ( str , _endpoint ) , policies = _policies , ** kwargs )
76
85
77
- client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
78
- self ._serialize = Serializer (client_models )
79
- self ._deserialize = Deserializer (client_models )
86
+ self ._serialize = Serializer ()
87
+ self ._deserialize = Deserializer ()
80
88
self ._serialize .client_side_validation = False
81
- self .connected_cluster = ConnectedClusterOperations (
89
+ self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
90
+ self .connected_clusters = ConnectedClustersOperations (
82
91
self ._client , self ._config , self ._serialize , self ._deserialize
83
92
)
84
- self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
85
93
86
- def _send_request (self , request : HttpRequest , * , stream : bool = False , ** kwargs : Any ) -> HttpResponse :
94
+ def send_request (self , request : HttpRequest , * , stream : bool = False , ** kwargs : Any ) -> HttpResponse :
87
95
"""Runs the network request through the client's chained policies.
88
96
89
97
>>> from azure.core.rest import HttpRequest
90
98
>>> request = HttpRequest("GET", "https://www.example.org/")
91
99
<HttpRequest [GET], url: 'https://www.example.org/'>
92
- >>> response = client._send_request (request)
100
+ >>> response = client.send_request (request)
93
101
<HttpResponse: 200 OK>
94
102
95
103
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
@@ -102,7 +110,11 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
102
110
"""
103
111
104
112
request_copy = deepcopy (request )
105
- request_copy .url = self ._client .format_url (request_copy .url )
113
+ path_format_arguments = {
114
+ "endpoint" : self ._serialize .url ("self._config.base_url" , self ._config .base_url , "str" , skip_quote = True ),
115
+ }
116
+
117
+ request_copy .url = self ._client .format_url (request_copy .url , ** path_format_arguments )
106
118
return self ._client .send_request (request_copy , stream = stream , ** kwargs ) # type: ignore
107
119
108
120
def close (self ) -> None :
0 commit comments