|
1 | 1 | # coding=utf-8 |
2 | 2 | # -------------------------------------------------------------------------- |
3 | 3 | # Copyright (c) Microsoft Corporation. All rights reserved. |
4 | | -# Licensed under the MIT License. See License.txt in the project root for license information. |
| 4 | +# Licensed under the MIT License. See License.txt in the project root for |
| 5 | +# license information. |
| 6 | +# |
5 | 7 | # Code generated by Microsoft (R) AutoRest Code Generator. |
6 | | -# Changes may cause incorrect behavior and will be lost if the code is regenerated. |
| 8 | +# Changes may cause incorrect behavior and will be lost if the code is |
| 9 | +# regenerated. |
7 | 10 | # -------------------------------------------------------------------------- |
8 | 11 |
|
9 | 12 | from typing import TYPE_CHECKING |
10 | 13 |
|
11 | 14 | from azure.mgmt.core import ARMPipelineClient |
| 15 | +from azure.profiles import KnownProfiles, ProfileDefinition |
| 16 | +from azure.profiles.multiapiclient import MultiApiClientMixin |
12 | 17 | from msrest import Deserializer, Serializer |
13 | 18 |
|
| 19 | +from ._configuration import EdgeOrderManagementClientConfiguration |
| 20 | +from ._operations_mixin import EdgeOrderManagementClientOperationsMixin |
| 21 | + |
14 | 22 | if TYPE_CHECKING: |
15 | 23 | # pylint: disable=unused-import,ungrouped-imports |
16 | 24 | from typing import Any, Optional |
17 | 25 |
|
18 | 26 | from azure.core.credentials import TokenCredential |
19 | 27 | from azure.core.pipeline.transport import HttpRequest, HttpResponse |
20 | 28 |
|
21 | | -from ._configuration import EdgeOrderManagementClientConfiguration |
22 | | -from .operations import EdgeOrderManagementClientOperationsMixin |
23 | | -from . import models |
| 29 | +class _SDKClient(object): |
| 30 | + def __init__(self, *args, **kwargs): |
| 31 | + """This is a fake class to support current implemetation of MultiApiClientMixin." |
| 32 | + Will be removed in final version of multiapi azure-core based client |
| 33 | + """ |
| 34 | + pass |
24 | 35 |
|
| 36 | +class EdgeOrderManagementClient(EdgeOrderManagementClientOperationsMixin, MultiApiClientMixin, _SDKClient): |
| 37 | + """The EdgeOrder Client. |
25 | 38 |
|
26 | | -class EdgeOrderManagementClient(EdgeOrderManagementClientOperationsMixin): |
27 | | - """Edge Order API's. |
| 39 | + This ready contains multiple API versions, to help you deal with all of the Azure clouds |
| 40 | + (Azure Stack, Azure Government, Azure China, etc.). |
| 41 | + By default, it uses the latest API version available on public Azure. |
| 42 | + For production, you should stick to a particular api-version and/or profile. |
| 43 | + The profile sets a mapping between an operation group and its API version. |
| 44 | + The api-version parameter sets the default API version if the operation |
| 45 | + group is not described in the profile. |
28 | 46 |
|
29 | 47 | :param credential: Credential needed for the client to connect to Azure. |
30 | 48 | :type credential: ~azure.core.credentials.TokenCredential |
31 | 49 | :param subscription_id: The ID of the target subscription. |
32 | 50 | :type subscription_id: str |
33 | | - :param str base_url: Service URL |
| 51 | + :param api_version: API version to use if no profile is provided, or if missing in profile. |
| 52 | + :type api_version: str |
| 53 | + :param base_url: Service URL |
| 54 | + :type base_url: str |
| 55 | + :param profile: A profile definition, from KnownProfiles to dict. |
| 56 | + :type profile: azure.profiles.KnownProfiles |
34 | 57 | :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. |
35 | 58 | """ |
36 | 59 |
|
| 60 | + DEFAULT_API_VERSION = '2021-12-01' |
| 61 | + _PROFILE_TAG = "azure.mgmt.edgeorder.EdgeOrderManagementClient" |
| 62 | + LATEST_PROFILE = ProfileDefinition({ |
| 63 | + _PROFILE_TAG: { |
| 64 | + None: DEFAULT_API_VERSION, |
| 65 | + }}, |
| 66 | + _PROFILE_TAG + " latest" |
| 67 | + ) |
| 68 | + |
37 | 69 | def __init__( |
38 | 70 | self, |
39 | 71 | credential, # type: "TokenCredential" |
40 | 72 | subscription_id, # type: str |
| 73 | + api_version=None, # type: Optional[str] |
41 | 74 | base_url=None, # type: Optional[str] |
| 75 | + profile=KnownProfiles.default, # type: KnownProfiles |
42 | 76 | **kwargs # type: Any |
43 | 77 | ): |
44 | | - # type: (...) -> None |
45 | 78 | if not base_url: |
46 | 79 | base_url = 'https://management.azure.com' |
47 | 80 | self._config = EdgeOrderManagementClientConfiguration(credential, subscription_id, **kwargs) |
48 | 81 | self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) |
| 82 | + super(EdgeOrderManagementClient, self).__init__( |
| 83 | + api_version=api_version, |
| 84 | + profile=profile |
| 85 | + ) |
49 | 86 |
|
50 | | - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} |
51 | | - self._serialize = Serializer(client_models) |
52 | | - self._serialize.client_side_validation = False |
53 | | - self._deserialize = Deserializer(client_models) |
54 | | - |
| 87 | + @classmethod |
| 88 | + def _models_dict(cls, api_version): |
| 89 | + return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} |
55 | 90 |
|
56 | | - def _send_request(self, http_request, **kwargs): |
57 | | - # type: (HttpRequest, Any) -> HttpResponse |
58 | | - """Runs the network request through the client's chained policies. |
| 91 | + @classmethod |
| 92 | + def models(cls, api_version=DEFAULT_API_VERSION): |
| 93 | + """Module depends on the API version: |
59 | 94 |
|
60 | | - :param http_request: The network request you want to make. Required. |
61 | | - :type http_request: ~azure.core.pipeline.transport.HttpRequest |
62 | | - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. |
63 | | - :return: The response of your network call. Does not do error handling on your response. |
64 | | - :rtype: ~azure.core.pipeline.transport.HttpResponse |
| 95 | + * 2020-12-01-preview: :mod:`v2020_12_01_preview.models<azure.mgmt.edgeorder.v2020_12_01_preview.models>` |
| 96 | + * 2021-12-01: :mod:`v2021_12_01.models<azure.mgmt.edgeorder.v2021_12_01.models>` |
65 | 97 | """ |
66 | | - path_format_arguments = { |
67 | | - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), |
68 | | - } |
69 | | - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) |
70 | | - stream = kwargs.pop("stream", True) |
71 | | - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) |
72 | | - return pipeline_response.http_response |
| 98 | + if api_version == '2020-12-01-preview': |
| 99 | + from .v2020_12_01_preview import models |
| 100 | + return models |
| 101 | + elif api_version == '2021-12-01': |
| 102 | + from .v2021_12_01 import models |
| 103 | + return models |
| 104 | + raise ValueError("API version {} is not available".format(api_version)) |
73 | 105 |
|
74 | 106 | def close(self): |
75 | | - # type: () -> None |
76 | 107 | self._client.close() |
77 | | - |
78 | 108 | def __enter__(self): |
79 | | - # type: () -> EdgeOrderManagementClient |
80 | 109 | self._client.__enter__() |
81 | 110 | return self |
82 | | - |
83 | 111 | def __exit__(self, *exc_details): |
84 | | - # type: (Any) -> None |
85 | 112 | self._client.__exit__(*exc_details) |
0 commit comments