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
+ 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
- from . import models as _models
18
20
from ._configuration import AzureSphereMgmtClientConfiguration
19
- from ._serialization import Deserializer , Serializer
21
+ from ._utils . serialization import Deserializer , Serializer
20
22
from .operations import (
21
23
CatalogsOperations ,
22
24
CertificatesOperations ,
29
31
)
30
32
31
33
if TYPE_CHECKING :
32
- # pylint: disable=unused-import,ungrouped-imports
33
34
from azure .core .credentials import TokenCredential
34
35
35
36
36
- class AzureSphereMgmtClient : # pylint: disable=client-accepts-api-version-keyword, too-many-instance-attributes
37
+ class AzureSphereMgmtClient : # pylint: disable=too-many-instance-attributes
37
38
"""Azure Sphere resource management API.
38
39
39
40
:ivar operations: Operations operations
@@ -52,29 +53,36 @@ class AzureSphereMgmtClient: # pylint: disable=client-accepts-api-version-keywo
52
53
:vartype deployments: azure.mgmt.sphere.operations.DeploymentsOperations
53
54
:ivar devices: DevicesOperations operations
54
55
:vartype devices: azure.mgmt.sphere.operations.DevicesOperations
55
- :param credential: Credential needed for the client to connect to Azure . Required.
56
+ :param credential: Credential used to authenticate requests to the service . Required.
56
57
:type credential: ~azure.core.credentials.TokenCredential
57
- :param subscription_id: The ID of the target subscription. Required.
58
+ :param subscription_id: The ID of the target subscription. The value must be an UUID. Required.
58
59
:type subscription_id: str
59
- :param base_url: Service URL . Default value is "https://management.azure.com" .
60
+ :param base_url: Service host . Default value is None .
60
61
:type base_url: str
61
- :keyword api_version: Api Version . Default value is "2024-04-01". Note that overriding this
62
- default value may result in unsupported behavior.
62
+ :keyword api_version: The API version to use for this operation . Default value is "2024-04-01".
63
+ Note that overriding this default value may result in unsupported behavior.
63
64
:paramtype api_version: str
64
65
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
65
66
Retry-After header is present.
66
67
"""
67
68
68
69
def __init__ (
69
- self ,
70
- credential : "TokenCredential" ,
71
- subscription_id : str ,
72
- base_url : str = "https://management.azure.com" ,
73
- ** kwargs : Any
70
+ self , credential : "TokenCredential" , subscription_id : str , base_url : Optional [str ] = None , ** kwargs : Any
74
71
) -> None :
72
+ _endpoint = "{endpoint}"
73
+ _cloud = kwargs .pop ("cloud_setting" , None ) or settings .current .azure_cloud # type: ignore
74
+ _endpoints = get_arm_endpoints (_cloud )
75
+ if not base_url :
76
+ base_url = _endpoints ["resource_manager" ]
77
+ credential_scopes = kwargs .pop ("credential_scopes" , _endpoints ["credential_scopes" ])
75
78
self ._config = AzureSphereMgmtClientConfiguration (
76
- credential = credential , subscription_id = subscription_id , ** kwargs
79
+ credential = credential ,
80
+ subscription_id = subscription_id ,
81
+ base_url = cast (str , base_url ),
82
+ credential_scopes = credential_scopes ,
83
+ ** kwargs
77
84
)
85
+
78
86
_policies = kwargs .pop ("policies" , None )
79
87
if _policies is None :
80
88
_policies = [
@@ -93,11 +101,10 @@ def __init__(
93
101
policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
94
102
self ._config .http_logging_policy ,
95
103
]
96
- self ._client : ARMPipelineClient = ARMPipelineClient (base_url = base_url , policies = _policies , ** kwargs )
104
+ self ._client : ARMPipelineClient = ARMPipelineClient (base_url = cast ( str , _endpoint ) , policies = _policies , ** kwargs )
97
105
98
- client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
99
- self ._serialize = Serializer (client_models )
100
- self ._deserialize = Deserializer (client_models )
106
+ self ._serialize = Serializer ()
107
+ self ._deserialize = Deserializer ()
101
108
self ._serialize .client_side_validation = False
102
109
self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
103
110
self .catalogs = CatalogsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
@@ -108,13 +115,13 @@ def __init__(
108
115
self .deployments = DeploymentsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
109
116
self .devices = DevicesOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
110
117
111
- def _send_request (self , request : HttpRequest , * , stream : bool = False , ** kwargs : Any ) -> HttpResponse :
118
+ def send_request (self , request : HttpRequest , * , stream : bool = False , ** kwargs : Any ) -> HttpResponse :
112
119
"""Runs the network request through the client's chained policies.
113
120
114
121
>>> from azure.core.rest import HttpRequest
115
122
>>> request = HttpRequest("GET", "https://www.example.org/")
116
123
<HttpRequest [GET], url: 'https://www.example.org/'>
117
- >>> response = client._send_request (request)
124
+ >>> response = client.send_request (request)
118
125
<HttpResponse: 200 OK>
119
126
120
127
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
@@ -127,13 +134,17 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
127
134
"""
128
135
129
136
request_copy = deepcopy (request )
130
- request_copy .url = self ._client .format_url (request_copy .url )
137
+ path_format_arguments = {
138
+ "endpoint" : self ._serialize .url ("self._config.base_url" , self ._config .base_url , "str" , skip_quote = True ),
139
+ }
140
+
141
+ request_copy .url = self ._client .format_url (request_copy .url , ** path_format_arguments )
131
142
return self ._client .send_request (request_copy , stream = stream , ** kwargs ) # type: ignore
132
143
133
144
def close (self ) -> None :
134
145
self ._client .close ()
135
146
136
- def __enter__ (self ) -> "AzureSphereMgmtClient" :
147
+ def __enter__ (self ) -> Self :
137
148
self ._client .__enter__ ()
138
149
return self
139
150
0 commit comments