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 HardwareSecurityModulesMgmtClientConfiguration
20
- from ._serialization import Deserializer , Serializer
20
+ from ._configuration import HardwareSecurityModulesClientConfiguration
21
+ from ._utils .serialization import Deserializer , Serializer
21
22
from .operations import (
22
- CloudHsmClusterBackupStatusOperations ,
23
- CloudHsmClusterPrivateEndpointConnectionsOperations ,
24
- CloudHsmClusterPrivateLinkResourcesOperations ,
25
- CloudHsmClusterRestoreStatusOperations ,
26
23
CloudHsmClustersOperations ,
27
- DedicatedHsmOperations ,
24
+ DedicatedHsmsOperations ,
28
25
Operations ,
29
26
PrivateEndpointConnectionsOperations ,
30
27
)
31
28
32
29
if TYPE_CHECKING :
33
- # pylint: disable=unused-import,ungrouped-imports
34
30
from azure .core .credentials import TokenCredential
35
31
36
32
37
- class HardwareSecurityModulesMgmtClient : # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes
38
- """The Azure management API provides a RESTful set of web services that interact with Azure HSM
39
- RP .
33
+ class HardwareSecurityModulesClient :
34
+ """The Azure management API provides a RESTful set of web services that interact with Hardware
35
+ Security Modules .
40
36
37
+ :ivar operations: Operations operations
38
+ :vartype operations: azure.mgmt.hardwaresecuritymodules.operations.Operations
41
39
:ivar cloud_hsm_clusters: CloudHsmClustersOperations operations
42
40
:vartype cloud_hsm_clusters:
43
41
azure.mgmt.hardwaresecuritymodules.operations.CloudHsmClustersOperations
44
- :ivar cloud_hsm_cluster_private_link_resources: CloudHsmClusterPrivateLinkResourcesOperations
45
- operations
46
- :vartype cloud_hsm_cluster_private_link_resources:
47
- azure.mgmt.hardwaresecuritymodules.operations.CloudHsmClusterPrivateLinkResourcesOperations
48
- :ivar cloud_hsm_cluster_private_endpoint_connections:
49
- CloudHsmClusterPrivateEndpointConnectionsOperations operations
50
- :vartype cloud_hsm_cluster_private_endpoint_connections:
51
- azure.mgmt.hardwaresecuritymodules.operations.CloudHsmClusterPrivateEndpointConnectionsOperations
52
42
:ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations
53
43
:vartype private_endpoint_connections:
54
44
azure.mgmt.hardwaresecuritymodules.operations.PrivateEndpointConnectionsOperations
55
- :ivar cloud_hsm_cluster_backup_status: CloudHsmClusterBackupStatusOperations operations
56
- :vartype cloud_hsm_cluster_backup_status:
57
- azure.mgmt.hardwaresecuritymodules.operations.CloudHsmClusterBackupStatusOperations
58
- :ivar cloud_hsm_cluster_restore_status: CloudHsmClusterRestoreStatusOperations operations
59
- :vartype cloud_hsm_cluster_restore_status:
60
- azure.mgmt.hardwaresecuritymodules.operations.CloudHsmClusterRestoreStatusOperations
61
- :ivar dedicated_hsm: DedicatedHsmOperations operations
62
- :vartype dedicated_hsm: azure.mgmt.hardwaresecuritymodules.operations.DedicatedHsmOperations
63
- :ivar operations: Operations operations
64
- :vartype operations: azure.mgmt.hardwaresecuritymodules.operations.Operations
65
- :param credential: Credential needed for the client to connect to Azure. Required.
45
+ :ivar dedicated_hsms: DedicatedHsmsOperations operations
46
+ :vartype dedicated_hsms: azure.mgmt.hardwaresecuritymodules.operations.DedicatedHsmsOperations
47
+ :param credential: Credential used to authenticate requests to the service. Required.
66
48
:type credential: ~azure.core.credentials.TokenCredential
67
49
:param subscription_id: The ID of the target subscription. The value must be an UUID. Required.
68
50
:type subscription_id: str
69
- :param base_url: Service URL . Default value is "https://management.azure.com" .
51
+ :param base_url: Service host . Default value is None .
70
52
:type base_url: str
71
- :keyword api_version: Api Version. Default value is "2024-06-30-preview". Note that overriding
72
- this default value may result in unsupported behavior.
53
+ :keyword api_version: The API version to use for this operation. Default value is
54
+ "2024-06-30-preview". Note that overriding this default value may result in unsupported
55
+ behavior.
73
56
:paramtype api_version: str
74
57
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
75
58
Retry-After header is present.
76
59
"""
77
60
78
61
def __init__ (
79
- self ,
80
- credential : "TokenCredential" ,
81
- subscription_id : str ,
82
- base_url : str = "https://management.azure.com" ,
83
- ** kwargs : Any
62
+ self , credential : "TokenCredential" , subscription_id : str , base_url : Optional [str ] = None , ** kwargs : Any
84
63
) -> None :
85
- self ._config = HardwareSecurityModulesMgmtClientConfiguration (
86
- credential = credential , subscription_id = subscription_id , ** kwargs
64
+ _endpoint = "{endpoint}"
65
+ _cloud = kwargs .pop ("cloud_setting" , None ) or settings .current .azure_cloud # type: ignore
66
+ _endpoints = get_arm_endpoints (_cloud )
67
+ if not base_url :
68
+ base_url = _endpoints ["resource_manager" ]
69
+ credential_scopes = kwargs .pop ("credential_scopes" , _endpoints ["credential_scopes" ])
70
+ self ._config = HardwareSecurityModulesClientConfiguration (
71
+ credential = credential ,
72
+ subscription_id = subscription_id ,
73
+ base_url = cast (str , base_url ),
74
+ credential_scopes = credential_scopes ,
75
+ ** kwargs
87
76
)
77
+
88
78
_policies = kwargs .pop ("policies" , None )
89
79
if _policies is None :
90
80
_policies = [
@@ -103,40 +93,27 @@ def __init__(
103
93
policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
104
94
self ._config .http_logging_policy ,
105
95
]
106
- self ._client : ARMPipelineClient = ARMPipelineClient (base_url = base_url , policies = _policies , ** kwargs )
96
+ self ._client : ARMPipelineClient = ARMPipelineClient (base_url = cast ( str , _endpoint ) , policies = _policies , ** kwargs )
107
97
108
- client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
109
- self ._serialize = Serializer (client_models )
110
- self ._deserialize = Deserializer (client_models )
98
+ self ._serialize = Serializer ()
99
+ self ._deserialize = Deserializer ()
111
100
self ._serialize .client_side_validation = False
101
+ self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
112
102
self .cloud_hsm_clusters = CloudHsmClustersOperations (
113
103
self ._client , self ._config , self ._serialize , self ._deserialize
114
104
)
115
- self .cloud_hsm_cluster_private_link_resources = CloudHsmClusterPrivateLinkResourcesOperations (
116
- self ._client , self ._config , self ._serialize , self ._deserialize
117
- )
118
- self .cloud_hsm_cluster_private_endpoint_connections = CloudHsmClusterPrivateEndpointConnectionsOperations (
119
- self ._client , self ._config , self ._serialize , self ._deserialize
120
- )
121
105
self .private_endpoint_connections = PrivateEndpointConnectionsOperations (
122
106
self ._client , self ._config , self ._serialize , self ._deserialize
123
107
)
124
- self .cloud_hsm_cluster_backup_status = CloudHsmClusterBackupStatusOperations (
125
- self ._client , self ._config , self ._serialize , self ._deserialize
126
- )
127
- self .cloud_hsm_cluster_restore_status = CloudHsmClusterRestoreStatusOperations (
128
- self ._client , self ._config , self ._serialize , self ._deserialize
129
- )
130
- self .dedicated_hsm = DedicatedHsmOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
131
- self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
108
+ self .dedicated_hsms = DedicatedHsmsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
132
109
133
- def _send_request (self , request : HttpRequest , * , stream : bool = False , ** kwargs : Any ) -> HttpResponse :
110
+ def send_request (self , request : HttpRequest , * , stream : bool = False , ** kwargs : Any ) -> HttpResponse :
134
111
"""Runs the network request through the client's chained policies.
135
112
136
113
>>> from azure.core.rest import HttpRequest
137
114
>>> request = HttpRequest("GET", "https://www.example.org/")
138
115
<HttpRequest [GET], url: 'https://www.example.org/'>
139
- >>> response = client._send_request (request)
116
+ >>> response = client.send_request (request)
140
117
<HttpResponse: 200 OK>
141
118
142
119
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
@@ -149,7 +126,11 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
149
126
"""
150
127
151
128
request_copy = deepcopy (request )
152
- request_copy .url = self ._client .format_url (request_copy .url )
129
+ path_format_arguments = {
130
+ "endpoint" : self ._serialize .url ("self._config.base_url" , self ._config .base_url , "str" , skip_quote = True ),
131
+ }
132
+
133
+ request_copy .url = self ._client .format_url (request_copy .url , ** path_format_arguments )
153
134
return self ._client .send_request (request_copy , stream = stream , ** kwargs ) # type: ignore
154
135
155
136
def close (self ) -> None :
0 commit comments