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