|
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, TYPE_CHECKING |
10 | 11 |
|
| 12 | +from azure.core.rest import HttpRequest, HttpResponse |
11 | 13 | from azure.mgmt.core import ARMPipelineClient |
12 | | -from msrest import Deserializer, Serializer |
| 14 | + |
| 15 | +from . import models |
| 16 | +from ._configuration import ManagedServicesClientConfiguration |
| 17 | +from ._serialization import Deserializer, Serializer |
| 18 | +from .operations import ( |
| 19 | + MarketplaceRegistrationDefinitionsOperations, |
| 20 | + MarketplaceRegistrationDefinitionsWithoutScopeOperations, |
| 21 | + Operations, |
| 22 | + OperationsWithScopeOperations, |
| 23 | + RegistrationAssignmentsOperations, |
| 24 | + RegistrationDefinitionsOperations, |
| 25 | +) |
13 | 26 |
|
14 | 27 | if TYPE_CHECKING: |
15 | 28 | # pylint: disable=unused-import,ungrouped-imports |
16 | | - from typing import Any, Optional |
17 | | - |
18 | 29 | from azure.core.credentials import TokenCredential |
19 | | - from azure.core.pipeline.transport import HttpRequest, HttpResponse |
20 | | - |
21 | | -from ._configuration import ManagedServicesClientConfiguration |
22 | | -from .operations import RegistrationDefinitionsOperations |
23 | | -from .operations import RegistrationAssignmentsOperations |
24 | | -from .operations import MarketplaceRegistrationDefinitionsOperations |
25 | | -from .operations import MarketplaceRegistrationDefinitionsWithoutScopeOperations |
26 | | -from .operations import Operations |
27 | | -from . import models |
28 | 30 |
|
29 | 31 |
|
30 | | -class ManagedServicesClient(object): |
31 | | - """Specification for ManagedServices. |
| 32 | +class ManagedServicesClient: # pylint: disable=client-accepts-api-version-keyword |
| 33 | + """The specification for ManagedServices. |
32 | 34 |
|
33 | 35 | :ivar registration_definitions: RegistrationDefinitionsOperations operations |
34 | | - :vartype registration_definitions: azure.mgmt.managedservices.operations.RegistrationDefinitionsOperations |
| 36 | + :vartype registration_definitions: |
| 37 | + azure.mgmt.managedservices.operations.RegistrationDefinitionsOperations |
35 | 38 | :ivar registration_assignments: RegistrationAssignmentsOperations operations |
36 | | - :vartype registration_assignments: azure.mgmt.managedservices.operations.RegistrationAssignmentsOperations |
37 | | - :ivar marketplace_registration_definitions: MarketplaceRegistrationDefinitionsOperations operations |
38 | | - :vartype marketplace_registration_definitions: azure.mgmt.managedservices.operations.MarketplaceRegistrationDefinitionsOperations |
39 | | - :ivar marketplace_registration_definitions_without_scope: MarketplaceRegistrationDefinitionsWithoutScopeOperations operations |
40 | | - :vartype marketplace_registration_definitions_without_scope: azure.mgmt.managedservices.operations.MarketplaceRegistrationDefinitionsWithoutScopeOperations |
| 39 | + :vartype registration_assignments: |
| 40 | + azure.mgmt.managedservices.operations.RegistrationAssignmentsOperations |
| 41 | + :ivar marketplace_registration_definitions: MarketplaceRegistrationDefinitionsOperations |
| 42 | + operations |
| 43 | + :vartype marketplace_registration_definitions: |
| 44 | + azure.mgmt.managedservices.operations.MarketplaceRegistrationDefinitionsOperations |
| 45 | + :ivar marketplace_registration_definitions_without_scope: |
| 46 | + MarketplaceRegistrationDefinitionsWithoutScopeOperations operations |
| 47 | + :vartype marketplace_registration_definitions_without_scope: |
| 48 | + azure.mgmt.managedservices.operations.MarketplaceRegistrationDefinitionsWithoutScopeOperations |
41 | 49 | :ivar operations: Operations operations |
42 | 50 | :vartype operations: azure.mgmt.managedservices.operations.Operations |
43 | | - :param credential: Credential needed for the client to connect to Azure. |
| 51 | + :ivar operations_with_scope: OperationsWithScopeOperations operations |
| 52 | + :vartype operations_with_scope: |
| 53 | + azure.mgmt.managedservices.operations.OperationsWithScopeOperations |
| 54 | + :param credential: Credential needed for the client to connect to Azure. Required. |
44 | 55 | :type credential: ~azure.core.credentials.TokenCredential |
45 | | - :param str base_url: Service URL |
46 | | - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. |
| 56 | + :param base_url: Service URL. Default value is "https://management.azure.com". |
| 57 | + :type base_url: str |
| 58 | + :keyword api_version: Api Version. Default value is "2022-10-01". Note that overriding this |
| 59 | + default value may result in unsupported behavior. |
| 60 | + :paramtype api_version: str |
| 61 | + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no |
| 62 | + Retry-After header is present. |
47 | 63 | """ |
48 | 64 |
|
49 | 65 | def __init__( |
50 | | - self, |
51 | | - credential, # type: "TokenCredential" |
52 | | - base_url=None, # type: Optional[str] |
53 | | - **kwargs # type: Any |
54 | | - ): |
55 | | - # type: (...) -> None |
56 | | - if not base_url: |
57 | | - base_url = 'https://management.azure.com' |
58 | | - self._config = ManagedServicesClientConfiguration(credential, **kwargs) |
| 66 | + self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any |
| 67 | + ) -> None: |
| 68 | + self._config = ManagedServicesClientConfiguration(credential=credential, **kwargs) |
59 | 69 | self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) |
60 | 70 |
|
61 | 71 | client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} |
62 | 72 | self._serialize = Serializer(client_models) |
63 | | - self._serialize.client_side_validation = False |
64 | 73 | self._deserialize = Deserializer(client_models) |
65 | | - |
| 74 | + self._serialize.client_side_validation = False |
66 | 75 | self.registration_definitions = RegistrationDefinitionsOperations( |
67 | | - self._client, self._config, self._serialize, self._deserialize) |
| 76 | + self._client, self._config, self._serialize, self._deserialize |
| 77 | + ) |
68 | 78 | self.registration_assignments = RegistrationAssignmentsOperations( |
69 | | - self._client, self._config, self._serialize, self._deserialize) |
| 79 | + self._client, self._config, self._serialize, self._deserialize |
| 80 | + ) |
70 | 81 | self.marketplace_registration_definitions = MarketplaceRegistrationDefinitionsOperations( |
71 | | - self._client, self._config, self._serialize, self._deserialize) |
72 | | - self.marketplace_registration_definitions_without_scope = MarketplaceRegistrationDefinitionsWithoutScopeOperations( |
73 | | - self._client, self._config, self._serialize, self._deserialize) |
74 | | - self.operations = Operations( |
75 | | - self._client, self._config, self._serialize, self._deserialize) |
76 | | - |
77 | | - def _send_request(self, http_request, **kwargs): |
78 | | - # type: (HttpRequest, Any) -> HttpResponse |
| 82 | + self._client, self._config, self._serialize, self._deserialize |
| 83 | + ) |
| 84 | + self.marketplace_registration_definitions_without_scope = ( |
| 85 | + MarketplaceRegistrationDefinitionsWithoutScopeOperations( |
| 86 | + self._client, self._config, self._serialize, self._deserialize |
| 87 | + ) |
| 88 | + ) |
| 89 | + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) |
| 90 | + self.operations_with_scope = OperationsWithScopeOperations( |
| 91 | + self._client, self._config, self._serialize, self._deserialize |
| 92 | + ) |
| 93 | + |
| 94 | + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: |
79 | 95 | """Runs the network request through the client's chained policies. |
80 | 96 |
|
81 | | - :param http_request: The network request you want to make. Required. |
82 | | - :type http_request: ~azure.core.pipeline.transport.HttpRequest |
83 | | - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. |
| 97 | + >>> from azure.core.rest import HttpRequest |
| 98 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 99 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 100 | + >>> response = client._send_request(request) |
| 101 | + <HttpResponse: 200 OK> |
| 102 | +
|
| 103 | + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request |
| 104 | +
|
| 105 | + :param request: The network request you want to make. Required. |
| 106 | + :type request: ~azure.core.rest.HttpRequest |
| 107 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
84 | 108 | :return: The response of your network call. Does not do error handling on your response. |
85 | | - :rtype: ~azure.core.pipeline.transport.HttpResponse |
| 109 | + :rtype: ~azure.core.rest.HttpResponse |
86 | 110 | """ |
87 | | - http_request.url = self._client.format_url(http_request.url) |
88 | | - stream = kwargs.pop("stream", True) |
89 | | - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) |
90 | | - return pipeline_response.http_response |
| 111 | + |
| 112 | + request_copy = deepcopy(request) |
| 113 | + request_copy.url = self._client.format_url(request_copy.url) |
| 114 | + return self._client.send_request(request_copy, **kwargs) |
91 | 115 |
|
92 | 116 | def close(self): |
93 | 117 | # type: () -> None |
|
0 commit comments