|
| 1 | +# coding=utf-8 |
| 2 | +# -------------------------------------------------------------------------- |
| 3 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 4 | +# Licensed under the MIT License. See License.txt in the project root for |
| 5 | +# license information. |
| 6 | +# |
| 7 | +# Code generated by Microsoft (R) AutoRest Code Generator. |
| 8 | +# Changes may cause incorrect behavior and will be lost if the code is |
| 9 | +# regenerated. |
| 10 | +# -------------------------------------------------------------------------- |
| 11 | + |
| 12 | +from typing import TYPE_CHECKING |
| 13 | + |
| 14 | +from azure.mgmt.core import ARMPipelineClient |
| 15 | +from azure.profiles import KnownProfiles, ProfileDefinition |
| 16 | +from azure.profiles.multiapiclient import MultiApiClientMixin |
| 17 | +from msrest import Deserializer, Serializer |
| 18 | + |
| 19 | +from ._configuration import ApplicationClientConfiguration |
| 20 | +from ._operations_mixin import ApplicationClientOperationsMixin |
| 21 | + |
| 22 | +if TYPE_CHECKING: |
| 23 | + # pylint: disable=unused-import,ungrouped-imports |
| 24 | + from typing import Any, Optional |
| 25 | + |
| 26 | + from azure.core.credentials import TokenCredential |
| 27 | + |
| 28 | +class _SDKClient(object): |
| 29 | + def __init__(self, *args, **kwargs): |
| 30 | + """This is a fake class to support current implemetation of MultiApiClientMixin." |
| 31 | + Will be removed in final version of multiapi azure-core based client |
| 32 | + """ |
| 33 | + pass |
| 34 | + |
| 35 | +class ApplicationClient(ApplicationClientOperationsMixin, MultiApiClientMixin, _SDKClient): |
| 36 | + """ARM applications. |
| 37 | +
|
| 38 | + This ready contains multiple API versions, to help you deal with all of the Azure clouds |
| 39 | + (Azure Stack, Azure Government, Azure China, etc.). |
| 40 | + By default, it uses the latest API version available on public Azure. |
| 41 | + For production, you should stick to a particular api-version and/or profile. |
| 42 | + The profile sets a mapping between an operation group and its API version. |
| 43 | + The api-version parameter sets the default API version if the operation |
| 44 | + group is not described in the profile. |
| 45 | +
|
| 46 | + :param credential: Credential needed for the client to connect to Azure. |
| 47 | + :type credential: ~azure.core.credentials.TokenCredential |
| 48 | + :param subscription_id: The ID of the target subscription. |
| 49 | + :type subscription_id: str |
| 50 | + :param api_version: API version to use if no profile is provided, or if missing in profile. |
| 51 | + :type api_version: str |
| 52 | + :param base_url: Service URL |
| 53 | + :type base_url: str |
| 54 | + :param profile: A profile definition, from KnownProfiles to dict. |
| 55 | + :type profile: azure.profiles.KnownProfiles |
| 56 | + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. |
| 57 | + """ |
| 58 | + |
| 59 | + DEFAULT_API_VERSION = '2021-07-01' |
| 60 | + _PROFILE_TAG = "azure.mgmt.managedapplication.ApplicationClient" |
| 61 | + LATEST_PROFILE = ProfileDefinition({ |
| 62 | + _PROFILE_TAG: { |
| 63 | + None: DEFAULT_API_VERSION, |
| 64 | + }}, |
| 65 | + _PROFILE_TAG + " latest" |
| 66 | + ) |
| 67 | + |
| 68 | + def __init__( |
| 69 | + self, |
| 70 | + credential, # type: "TokenCredential" |
| 71 | + subscription_id, # type: str |
| 72 | + api_version=None, # type: Optional[str] |
| 73 | + base_url="https://management.azure.com", # type: str |
| 74 | + profile=KnownProfiles.default, # type: KnownProfiles |
| 75 | + **kwargs # type: Any |
| 76 | + ): |
| 77 | + self._config = ApplicationClientConfiguration(credential, subscription_id, **kwargs) |
| 78 | + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) |
| 79 | + super(ApplicationClient, self).__init__( |
| 80 | + api_version=api_version, |
| 81 | + profile=profile |
| 82 | + ) |
| 83 | + |
| 84 | + @classmethod |
| 85 | + def _models_dict(cls, api_version): |
| 86 | + return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} |
| 87 | + |
| 88 | + @classmethod |
| 89 | + def models(cls, api_version=DEFAULT_API_VERSION): |
| 90 | + """Module depends on the API version: |
| 91 | +
|
| 92 | + * 2021-07-01: :mod:`v2021_07_01.models<azure.mgmt.managedapplication.v2021_07_01.models>` |
| 93 | + """ |
| 94 | + if api_version == '2021-07-01': |
| 95 | + from .v2021_07_01 import models |
| 96 | + return models |
| 97 | + raise ValueError("API version {} is not available".format(api_version)) |
| 98 | + |
| 99 | + @property |
| 100 | + def application_definitions(self): |
| 101 | + """Instance depends on the API version: |
| 102 | +
|
| 103 | + * 2021-07-01: :class:`ApplicationDefinitionsOperations<azure.mgmt.managedapplication.v2021_07_01.operations.ApplicationDefinitionsOperations>` |
| 104 | + """ |
| 105 | + api_version = self._get_api_version('application_definitions') |
| 106 | + if api_version == '2021-07-01': |
| 107 | + from .v2021_07_01.operations import ApplicationDefinitionsOperations as OperationClass |
| 108 | + else: |
| 109 | + raise ValueError("API version {} does not have operation group 'application_definitions'".format(api_version)) |
| 110 | + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
| 111 | + |
| 112 | + @property |
| 113 | + def applications(self): |
| 114 | + """Instance depends on the API version: |
| 115 | +
|
| 116 | + * 2021-07-01: :class:`ApplicationsOperations<azure.mgmt.managedapplication.v2021_07_01.operations.ApplicationsOperations>` |
| 117 | + """ |
| 118 | + api_version = self._get_api_version('applications') |
| 119 | + if api_version == '2021-07-01': |
| 120 | + from .v2021_07_01.operations import ApplicationsOperations as OperationClass |
| 121 | + else: |
| 122 | + raise ValueError("API version {} does not have operation group 'applications'".format(api_version)) |
| 123 | + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
| 124 | + |
| 125 | + @property |
| 126 | + def jit_requests(self): |
| 127 | + """Instance depends on the API version: |
| 128 | +
|
| 129 | + * 2021-07-01: :class:`JitRequestsOperations<azure.mgmt.managedapplication.v2021_07_01.operations.JitRequestsOperations>` |
| 130 | + """ |
| 131 | + api_version = self._get_api_version('jit_requests') |
| 132 | + if api_version == '2021-07-01': |
| 133 | + from .v2021_07_01.operations import JitRequestsOperations as OperationClass |
| 134 | + else: |
| 135 | + raise ValueError("API version {} does not have operation group 'jit_requests'".format(api_version)) |
| 136 | + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) |
| 137 | + |
| 138 | + def close(self): |
| 139 | + self._client.close() |
| 140 | + def __enter__(self): |
| 141 | + self._client.__enter__() |
| 142 | + return self |
| 143 | + def __exit__(self, *exc_details): |
| 144 | + self._client.__exit__(*exc_details) |
0 commit comments