|
| 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 msrest.service_client import SDKClient |
| 13 | +from msrest import Serializer, Deserializer |
| 14 | +from msrestazure import AzureConfiguration |
| 15 | +from .version import VERSION |
| 16 | +from msrest.pipeline import ClientRawResponse |
| 17 | +from msrestazure.azure_exceptions import CloudError |
| 18 | +from msrest.polling import LROPoller, NoPolling |
| 19 | +from msrestazure.polling.arm_polling import ARMPolling |
| 20 | +import uuid |
| 21 | +from .operations.container_groups_operations import ContainerGroupsOperations |
| 22 | +from .operations.operations import Operations |
| 23 | +from .operations.container_group_usage_operations import ContainerGroupUsageOperations |
| 24 | +from .operations.container_operations import ContainerOperations |
| 25 | +from .operations.service_association_link_operations import ServiceAssociationLinkOperations |
| 26 | +from . import models |
| 27 | + |
| 28 | + |
| 29 | +class ContainerInstanceManagementClientConfiguration(AzureConfiguration): |
| 30 | + """Configuration for ContainerInstanceManagementClient |
| 31 | + Note that all parameters used to create this instance are saved as instance |
| 32 | + attributes. |
| 33 | +
|
| 34 | + :param credentials: Credentials needed for the client to connect to Azure. |
| 35 | + :type credentials: :mod:`A msrestazure Credentials |
| 36 | + object<msrestazure.azure_active_directory>` |
| 37 | + :param subscription_id: Subscription credentials which uniquely identify |
| 38 | + Microsoft Azure subscription. The subscription ID forms part of the URI |
| 39 | + for every service call. |
| 40 | + :type subscription_id: str |
| 41 | + :param str base_url: Service URL |
| 42 | + """ |
| 43 | + |
| 44 | + def __init__( |
| 45 | + self, credentials, subscription_id, base_url=None): |
| 46 | + |
| 47 | + if credentials is None: |
| 48 | + raise ValueError("Parameter 'credentials' must not be None.") |
| 49 | + if subscription_id is None: |
| 50 | + raise ValueError("Parameter 'subscription_id' must not be None.") |
| 51 | + if not base_url: |
| 52 | + base_url = 'https://management.azure.com' |
| 53 | + |
| 54 | + super(ContainerInstanceManagementClientConfiguration, self).__init__(base_url) |
| 55 | + |
| 56 | + self.add_user_agent('azure-mgmt-containerinstance/{}'.format(VERSION)) |
| 57 | + self.add_user_agent('Azure-SDK-For-Python') |
| 58 | + |
| 59 | + self.credentials = credentials |
| 60 | + self.subscription_id = subscription_id |
| 61 | + |
| 62 | + |
| 63 | +class ContainerInstanceManagementClient(SDKClient): |
| 64 | + """ContainerInstanceManagementClient |
| 65 | +
|
| 66 | + :ivar config: Configuration for client. |
| 67 | + :vartype config: ContainerInstanceManagementClientConfiguration |
| 68 | +
|
| 69 | + :ivar container_groups: ContainerGroups operations |
| 70 | + :vartype container_groups: azure.mgmt.containerinstance.operations.ContainerGroupsOperations |
| 71 | + :ivar operations: Operations operations |
| 72 | + :vartype operations: azure.mgmt.containerinstance.operations.Operations |
| 73 | + :ivar container_group_usage: ContainerGroupUsage operations |
| 74 | + :vartype container_group_usage: azure.mgmt.containerinstance.operations.ContainerGroupUsageOperations |
| 75 | + :ivar container: Container operations |
| 76 | + :vartype container: azure.mgmt.containerinstance.operations.ContainerOperations |
| 77 | + :ivar service_association_link: ServiceAssociationLink operations |
| 78 | + :vartype service_association_link: azure.mgmt.containerinstance.operations.ServiceAssociationLinkOperations |
| 79 | +
|
| 80 | + :param credentials: Credentials needed for the client to connect to Azure. |
| 81 | + :type credentials: :mod:`A msrestazure Credentials |
| 82 | + object<msrestazure.azure_active_directory>` |
| 83 | + :param subscription_id: Subscription credentials which uniquely identify |
| 84 | + Microsoft Azure subscription. The subscription ID forms part of the URI |
| 85 | + for every service call. |
| 86 | + :type subscription_id: str |
| 87 | + :param str base_url: Service URL |
| 88 | + """ |
| 89 | + |
| 90 | + def __init__( |
| 91 | + self, credentials, subscription_id, base_url=None): |
| 92 | + |
| 93 | + self.config = ContainerInstanceManagementClientConfiguration(credentials, subscription_id, base_url) |
| 94 | + super(ContainerInstanceManagementClient, self).__init__(self.config.credentials, self.config) |
| 95 | + |
| 96 | + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} |
| 97 | + self.api_version = '2018-10-01' |
| 98 | + self._serialize = Serializer(client_models) |
| 99 | + self._deserialize = Deserializer(client_models) |
| 100 | + |
| 101 | + self.container_groups = ContainerGroupsOperations( |
| 102 | + self._client, self.config, self._serialize, self._deserialize) |
| 103 | + self.operations = Operations( |
| 104 | + self._client, self.config, self._serialize, self._deserialize) |
| 105 | + self.container_group_usage = ContainerGroupUsageOperations( |
| 106 | + self._client, self.config, self._serialize, self._deserialize) |
| 107 | + self.container = ContainerOperations( |
| 108 | + self._client, self.config, self._serialize, self._deserialize) |
| 109 | + self.service_association_link = ServiceAssociationLinkOperations( |
| 110 | + self._client, self.config, self._serialize, self._deserialize) |
| 111 | + |
| 112 | + def list_cached_images( |
| 113 | + self, location, custom_headers=None, raw=False, **operation_config): |
| 114 | + """Get the list of cached images. |
| 115 | +
|
| 116 | + Get the list of cached images on specific OS type for a subscription in |
| 117 | + a region. |
| 118 | +
|
| 119 | + :param location: The identifier for the physical azure location. |
| 120 | + :type location: str |
| 121 | + :param dict custom_headers: headers that will be added to the request |
| 122 | + :param bool raw: returns the direct response alongside the |
| 123 | + deserialized response |
| 124 | + :param operation_config: :ref:`Operation configuration |
| 125 | + overrides<msrest:optionsforoperations>`. |
| 126 | + :return: CachedImagesListResult or ClientRawResponse if raw=true |
| 127 | + :rtype: ~azure.mgmt.containerinstance.models.CachedImagesListResult or |
| 128 | + ~msrest.pipeline.ClientRawResponse |
| 129 | + :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` |
| 130 | + """ |
| 131 | + # Construct URL |
| 132 | + url = self.list_cached_images.metadata['url'] |
| 133 | + path_format_arguments = { |
| 134 | + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), |
| 135 | + 'location': self._serialize.url("location", location, 'str') |
| 136 | + } |
| 137 | + url = self._client.format_url(url, **path_format_arguments) |
| 138 | + |
| 139 | + # Construct parameters |
| 140 | + query_parameters = {} |
| 141 | + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') |
| 142 | + |
| 143 | + # Construct headers |
| 144 | + header_parameters = {} |
| 145 | + header_parameters['Accept'] = 'application/json' |
| 146 | + if self.config.generate_client_request_id: |
| 147 | + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) |
| 148 | + if custom_headers: |
| 149 | + header_parameters.update(custom_headers) |
| 150 | + if self.config.accept_language is not None: |
| 151 | + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') |
| 152 | + |
| 153 | + # Construct and send request |
| 154 | + request = self._client.get(url, query_parameters, header_parameters) |
| 155 | + response = self._client.send(request, stream=False, **operation_config) |
| 156 | + |
| 157 | + if response.status_code not in [200]: |
| 158 | + exp = CloudError(response) |
| 159 | + exp.request_id = response.headers.get('x-ms-request-id') |
| 160 | + raise exp |
| 161 | + |
| 162 | + deserialized = None |
| 163 | + |
| 164 | + if response.status_code == 200: |
| 165 | + deserialized = self._deserialize('CachedImagesListResult', response) |
| 166 | + |
| 167 | + if raw: |
| 168 | + client_raw_response = ClientRawResponse(deserialized, response) |
| 169 | + return client_raw_response |
| 170 | + |
| 171 | + return deserialized |
| 172 | + list_cached_images.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/cachedImages'} |
| 173 | + |
| 174 | + def list_capabilities( |
| 175 | + self, location, custom_headers=None, raw=False, **operation_config): |
| 176 | + """Get the list of capabilities of the location. |
| 177 | +
|
| 178 | + Get the list of CPU/memory/GPU capabilities of a region. |
| 179 | +
|
| 180 | + :param location: The identifier for the physical azure location. |
| 181 | + :type location: str |
| 182 | + :param dict custom_headers: headers that will be added to the request |
| 183 | + :param bool raw: returns the direct response alongside the |
| 184 | + deserialized response |
| 185 | + :param operation_config: :ref:`Operation configuration |
| 186 | + overrides<msrest:optionsforoperations>`. |
| 187 | + :return: CapabilitiesListResult or ClientRawResponse if raw=true |
| 188 | + :rtype: ~azure.mgmt.containerinstance.models.CapabilitiesListResult or |
| 189 | + ~msrest.pipeline.ClientRawResponse |
| 190 | + :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` |
| 191 | + """ |
| 192 | + # Construct URL |
| 193 | + url = self.list_capabilities.metadata['url'] |
| 194 | + path_format_arguments = { |
| 195 | + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), |
| 196 | + 'location': self._serialize.url("location", location, 'str') |
| 197 | + } |
| 198 | + url = self._client.format_url(url, **path_format_arguments) |
| 199 | + |
| 200 | + # Construct parameters |
| 201 | + query_parameters = {} |
| 202 | + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') |
| 203 | + |
| 204 | + # Construct headers |
| 205 | + header_parameters = {} |
| 206 | + header_parameters['Accept'] = 'application/json' |
| 207 | + if self.config.generate_client_request_id: |
| 208 | + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) |
| 209 | + if custom_headers: |
| 210 | + header_parameters.update(custom_headers) |
| 211 | + if self.config.accept_language is not None: |
| 212 | + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') |
| 213 | + |
| 214 | + # Construct and send request |
| 215 | + request = self._client.get(url, query_parameters, header_parameters) |
| 216 | + response = self._client.send(request, stream=False, **operation_config) |
| 217 | + |
| 218 | + if response.status_code not in [200]: |
| 219 | + exp = CloudError(response) |
| 220 | + exp.request_id = response.headers.get('x-ms-request-id') |
| 221 | + raise exp |
| 222 | + |
| 223 | + deserialized = None |
| 224 | + |
| 225 | + if response.status_code == 200: |
| 226 | + deserialized = self._deserialize('CapabilitiesListResult', response) |
| 227 | + |
| 228 | + if raw: |
| 229 | + client_raw_response = ClientRawResponse(deserialized, response) |
| 230 | + return client_raw_response |
| 231 | + |
| 232 | + return deserialized |
| 233 | + list_capabilities.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/capabilities'} |
0 commit comments