|
6 | 6 | # Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
7 | 7 | # --------------------------------------------------------------------------
|
8 | 8 |
|
9 |
| -from typing import TYPE_CHECKING |
| 9 | +from copy import deepcopy |
| 10 | +from typing import Any, Optional, TYPE_CHECKING |
10 | 11 |
|
| 12 | +from azure.core.rest import HttpRequest, HttpResponse |
11 | 13 | from azure.mgmt.core import ARMPipelineClient
|
12 | 14 | from msrest import Deserializer, Serializer
|
13 | 15 |
|
| 16 | +from . import models |
| 17 | +from ._configuration import ManagedServiceIdentityClientConfiguration |
| 18 | +from .operations import Operations, SystemAssignedIdentitiesOperations, UserAssignedIdentitiesOperations |
| 19 | + |
14 | 20 | if TYPE_CHECKING:
|
15 | 21 | # pylint: disable=unused-import,ungrouped-imports
|
16 |
| - from typing import Any, Optional |
17 |
| - |
18 | 22 | from azure.core.credentials import TokenCredential
|
19 |
| - from azure.core.pipeline.transport import HttpRequest, HttpResponse |
20 |
| - |
21 |
| -from ._configuration import ManagedServiceIdentityClientConfiguration |
22 |
| -from .operations import SystemAssignedIdentitiesOperations |
23 |
| -from .operations import Operations |
24 |
| -from .operations import UserAssignedIdentitiesOperations |
25 |
| -from . import models |
26 | 23 |
|
27 |
| - |
28 |
| -class ManagedServiceIdentityClient(object): |
| 24 | +class ManagedServiceIdentityClient: |
29 | 25 | """The Managed Service Identity Client.
|
30 | 26 |
|
31 | 27 | :ivar system_assigned_identities: SystemAssignedIdentitiesOperations operations
|
32 |
| - :vartype system_assigned_identities: managed_service_identity_client.operations.SystemAssignedIdentitiesOperations |
| 28 | + :vartype system_assigned_identities: |
| 29 | + azure.mgmt.msi.operations.SystemAssignedIdentitiesOperations |
33 | 30 | :ivar operations: Operations operations
|
34 |
| - :vartype operations: managed_service_identity_client.operations.Operations |
| 31 | + :vartype operations: azure.mgmt.msi.operations.Operations |
35 | 32 | :ivar user_assigned_identities: UserAssignedIdentitiesOperations operations
|
36 |
| - :vartype user_assigned_identities: managed_service_identity_client.operations.UserAssignedIdentitiesOperations |
| 33 | + :vartype user_assigned_identities: azure.mgmt.msi.operations.UserAssignedIdentitiesOperations |
37 | 34 | :param credential: Credential needed for the client to connect to Azure.
|
38 | 35 | :type credential: ~azure.core.credentials.TokenCredential
|
39 | 36 | :param subscription_id: The Id of the Subscription to which the identity belongs.
|
40 | 37 | :type subscription_id: str
|
41 |
| - :param str base_url: Service URL |
| 38 | + :param base_url: Service URL. Default value is 'https://management.azure.com'. |
| 39 | + :type base_url: str |
42 | 40 | """
|
43 | 41 |
|
44 | 42 | def __init__(
|
45 | 43 | self,
|
46 |
| - credential, # type: "TokenCredential" |
47 |
| - subscription_id, # type: str |
48 |
| - base_url=None, # type: Optional[str] |
49 |
| - **kwargs # type: Any |
50 |
| - ): |
51 |
| - # type: (...) -> None |
52 |
| - if not base_url: |
53 |
| - base_url = 'https://management.azure.com' |
54 |
| - self._config = ManagedServiceIdentityClientConfiguration(credential, subscription_id, **kwargs) |
| 44 | + credential: "TokenCredential", |
| 45 | + subscription_id: str, |
| 46 | + base_url: str = "https://management.azure.com", |
| 47 | + **kwargs: Any |
| 48 | + ) -> None: |
| 49 | + self._config = ManagedServiceIdentityClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) |
55 | 50 | self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
|
56 | 51 |
|
57 | 52 | client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
|
58 | 53 | self._serialize = Serializer(client_models)
|
59 |
| - self._serialize.client_side_validation = False |
60 | 54 | self._deserialize = Deserializer(client_models)
|
| 55 | + self._serialize.client_side_validation = False |
| 56 | + self.system_assigned_identities = SystemAssignedIdentitiesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 57 | + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) |
| 58 | + self.user_assigned_identities = UserAssignedIdentitiesOperations(self._client, self._config, self._serialize, self._deserialize) |
61 | 59 |
|
62 |
| - self.system_assigned_identities = SystemAssignedIdentitiesOperations( |
63 |
| - self._client, self._config, self._serialize, self._deserialize) |
64 |
| - self.operations = Operations( |
65 |
| - self._client, self._config, self._serialize, self._deserialize) |
66 |
| - self.user_assigned_identities = UserAssignedIdentitiesOperations( |
67 |
| - self._client, self._config, self._serialize, self._deserialize) |
68 | 60 |
|
69 |
| - def _send_request(self, http_request, **kwargs): |
70 |
| - # type: (HttpRequest, Any) -> HttpResponse |
| 61 | + def _send_request( |
| 62 | + self, |
| 63 | + request, # type: HttpRequest |
| 64 | + **kwargs: Any |
| 65 | + ) -> HttpResponse: |
71 | 66 | """Runs the network request through the client's chained policies.
|
72 | 67 |
|
73 |
| - :param http_request: The network request you want to make. Required. |
74 |
| - :type http_request: ~azure.core.pipeline.transport.HttpRequest |
75 |
| - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. |
| 68 | + >>> from azure.core.rest import HttpRequest |
| 69 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 70 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 71 | + >>> response = client._send_request(request) |
| 72 | + <HttpResponse: 200 OK> |
| 73 | +
|
| 74 | + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart |
| 75 | +
|
| 76 | + :param request: The network request you want to make. Required. |
| 77 | + :type request: ~azure.core.rest.HttpRequest |
| 78 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
76 | 79 | :return: The response of your network call. Does not do error handling on your response.
|
77 |
| - :rtype: ~azure.core.pipeline.transport.HttpResponse |
| 80 | + :rtype: ~azure.core.rest.HttpResponse |
78 | 81 | """
|
79 |
| - path_format_arguments = { |
80 |
| - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), |
81 |
| - } |
82 |
| - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) |
83 |
| - stream = kwargs.pop("stream", True) |
84 |
| - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) |
85 |
| - return pipeline_response.http_response |
| 82 | + |
| 83 | + request_copy = deepcopy(request) |
| 84 | + request_copy.url = self._client.format_url(request_copy.url) |
| 85 | + return self._client.send_request(request_copy, **kwargs) |
86 | 86 |
|
87 | 87 | def close(self):
|
88 | 88 | # type: () -> None
|
|
0 commit comments