|
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 ManagedServicesClientConfiguration |
| 18 | +from .operations import MarketplaceRegistrationDefinitionsOperations, MarketplaceRegistrationDefinitionsWithoutScopeOperations, Operations, OperationsWithScopeOperations, RegistrationAssignmentsOperations, RegistrationDefinitionsOperations |
| 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 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 | | - |
29 | 23 |
|
30 | | -class ManagedServicesClient(object): |
31 | | - """Specification for ManagedServices. |
| 24 | +class ManagedServicesClient: |
| 25 | + """The specification for ManagedServices. |
32 | 26 |
|
33 | 27 | :ivar registration_definitions: RegistrationDefinitionsOperations operations |
34 | | - :vartype registration_definitions: azure.mgmt.managedservices.operations.RegistrationDefinitionsOperations |
| 28 | + :vartype registration_definitions: |
| 29 | + azure.mgmt.managedservices.operations.RegistrationDefinitionsOperations |
35 | 30 | :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 |
| 31 | + :vartype registration_assignments: |
| 32 | + azure.mgmt.managedservices.operations.RegistrationAssignmentsOperations |
| 33 | + :ivar marketplace_registration_definitions: MarketplaceRegistrationDefinitionsOperations |
| 34 | + operations |
| 35 | + :vartype marketplace_registration_definitions: |
| 36 | + azure.mgmt.managedservices.operations.MarketplaceRegistrationDefinitionsOperations |
| 37 | + :ivar marketplace_registration_definitions_without_scope: |
| 38 | + MarketplaceRegistrationDefinitionsWithoutScopeOperations operations |
| 39 | + :vartype marketplace_registration_definitions_without_scope: |
| 40 | + azure.mgmt.managedservices.operations.MarketplaceRegistrationDefinitionsWithoutScopeOperations |
41 | 41 | :ivar operations: Operations operations |
42 | 42 | :vartype operations: azure.mgmt.managedservices.operations.Operations |
| 43 | + :ivar operations_with_scope: OperationsWithScopeOperations operations |
| 44 | + :vartype operations_with_scope: |
| 45 | + azure.mgmt.managedservices.operations.OperationsWithScopeOperations |
43 | 46 | :param credential: Credential needed for the client to connect to Azure. |
44 | 47 | :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. |
| 48 | + :param base_url: Service URL. Default value is 'https://management.azure.com'. |
| 49 | + :type base_url: str |
| 50 | + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no |
| 51 | + Retry-After header is present. |
47 | 52 | """ |
48 | 53 |
|
49 | 54 | def __init__( |
50 | 55 | 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) |
| 56 | + credential: "TokenCredential", |
| 57 | + base_url: str = "https://management.azure.com", |
| 58 | + **kwargs: Any |
| 59 | + ) -> None: |
| 60 | + self._config = ManagedServicesClientConfiguration(credential=credential, **kwargs) |
59 | 61 | self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) |
60 | 62 |
|
61 | 63 | client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} |
62 | 64 | self._serialize = Serializer(client_models) |
63 | | - self._serialize.client_side_validation = False |
64 | 65 | self._deserialize = Deserializer(client_models) |
| 66 | + self._serialize.client_side_validation = False |
| 67 | + self.registration_definitions = RegistrationDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 68 | + self.registration_assignments = RegistrationAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 69 | + self.marketplace_registration_definitions = MarketplaceRegistrationDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 70 | + self.marketplace_registration_definitions_without_scope = MarketplaceRegistrationDefinitionsWithoutScopeOperations(self._client, self._config, self._serialize, self._deserialize) |
| 71 | + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) |
| 72 | + self.operations_with_scope = OperationsWithScopeOperations(self._client, self._config, self._serialize, self._deserialize) |
65 | 73 |
|
66 | | - self.registration_definitions = RegistrationDefinitionsOperations( |
67 | | - self._client, self._config, self._serialize, self._deserialize) |
68 | | - self.registration_assignments = RegistrationAssignmentsOperations( |
69 | | - self._client, self._config, self._serialize, self._deserialize) |
70 | | - 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 |
| 74 | + |
| 75 | + def _send_request( |
| 76 | + self, |
| 77 | + request, # type: HttpRequest |
| 78 | + **kwargs: Any |
| 79 | + ) -> HttpResponse: |
79 | 80 | """Runs the network request through the client's chained policies. |
80 | 81 |
|
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. |
| 82 | + >>> from azure.core.rest import HttpRequest |
| 83 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 84 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 85 | + >>> response = client._send_request(request) |
| 86 | + <HttpResponse: 200 OK> |
| 87 | +
|
| 88 | + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart |
| 89 | +
|
| 90 | + :param request: The network request you want to make. Required. |
| 91 | + :type request: ~azure.core.rest.HttpRequest |
| 92 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
84 | 93 | :return: The response of your network call. Does not do error handling on your response. |
85 | | - :rtype: ~azure.core.pipeline.transport.HttpResponse |
| 94 | + :rtype: ~azure.core.rest.HttpResponse |
86 | 95 | """ |
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 |
| 96 | + |
| 97 | + request_copy = deepcopy(request) |
| 98 | + request_copy.url = self._client.format_url(request_copy.url) |
| 99 | + return self._client.send_request(request_copy, **kwargs) |
91 | 100 |
|
92 | 101 | def close(self): |
93 | 102 | # type: () -> None |
|
0 commit comments