diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/_meta.json b/sdk/containerinstance/azure-mgmt-containerinstance/_meta.json index 4cba02a2cded..faba1dba76c8 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/_meta.json +++ b/sdk/containerinstance/azure-mgmt-containerinstance/_meta.json @@ -1,11 +1,11 @@ { "autorest": "3.7.2", "use": [ - "@autorest/python@5.12.0", + "@autorest/python@5.16.0", "@autorest/modelerfour@4.19.3" ], - "commit": "5dad3b83d0926768ede15ed41895d5f38defd512", + "commit": "0cba9ed11943a3e02e1d58d098fb2cc0a5244cda", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/containerinstance/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/containerinstance/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/containerinstance/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/__init__.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/__init__.py index ee4609bc2aba..61201f0d41f3 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/__init__.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['ContainerInstanceManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_configuration.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_configuration.py index 0f0b36953cde..a5c8154190b6 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_configuration.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class ContainerInstanceManagementClientConfiguration(Configuration): +class ContainerInstanceManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for ContainerInstanceManagementClient. Note that all parameters used to create this instance are saved as instance @@ -27,8 +27,12 @@ class ContainerInstanceManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +42,8 @@ def __init__( **kwargs: Any ) -> None: super(ContainerInstanceManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +51,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-10-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-containerinstance/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_container_instance_management_client.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_container_instance_management_client.py index b127cd6868b8..78668c9f1ab1 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_container_instance_management_client.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_container_instance_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import ContainerInstanceManagementClientConfiguration @@ -37,8 +38,11 @@ class ContainerInstanceManagementClient: :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -57,15 +61,23 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.container_groups = ContainerGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.location = LocationOperations(self._client, self._config, self._serialize, self._deserialize) - self.containers = ContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.container_groups = ContainerGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.location = LocationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.containers = ContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_metadata.json b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_metadata.json deleted file mode 100644 index 1700949c98f0..000000000000 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_metadata.json +++ /dev/null @@ -1,105 +0,0 @@ -{ - "chosen_version": "2021-10-01", - "total_api_version_list": ["2021-10-01"], - "client": { - "name": "ContainerInstanceManagementClient", - "filename": "_container_instance_management_client", - "description": "ContainerInstanceManagementClient.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerInstanceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerInstanceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "container_groups": "ContainerGroupsOperations", - "operations": "Operations", - "location": "LocationOperations", - "containers": "ContainersOperations" - } -} \ No newline at end of file diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_version.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_version.py index 6b357123854d..e5754a47ce68 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_version.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "9.2.0" +VERSION = "1.0.0b1" diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/__init__.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/__init__.py index 15e3f49794f2..5d45397e4b2f 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/__init__.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._container_instance_management_client import ContainerInstanceManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['ContainerInstanceManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/_configuration.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/_configuration.py index abc55271157b..920aaccdf9b2 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/_configuration.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class ContainerInstanceManagementClientConfiguration(Configuration): +class ContainerInstanceManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for ContainerInstanceManagementClient. Note that all parameters used to create this instance are saved as instance @@ -27,8 +27,12 @@ class ContainerInstanceManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +42,8 @@ def __init__( **kwargs: Any ) -> None: super(ContainerInstanceManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +51,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-10-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-containerinstance/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/_container_instance_management_client.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/_container_instance_management_client.py index 8018736f8395..a3b0ede201ee 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/_container_instance_management_client.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/_container_instance_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import ContainerInstanceManagementClientConfiguration @@ -38,8 +39,11 @@ class ContainerInstanceManagementClient: :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -58,10 +62,18 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.container_groups = ContainerGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.location = LocationOperations(self._client, self._config, self._serialize, self._deserialize) - self.containers = ContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.container_groups = ContainerGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.location = LocationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.containers = ContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/__init__.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/__init__.py index 65bb6fbdb75f..ab780c5f1066 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/__init__.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/__init__.py @@ -11,9 +11,14 @@ from ._location_operations import LocationOperations from ._containers_operations import ContainersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ContainerGroupsOperations', 'Operations', 'LocationOperations', 'ContainersOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_container_groups_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_container_groups_operations.py index b5a227ca2596..472c1844be56 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_container_groups_operations.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_container_groups_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, List, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -27,32 +27,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ContainerGroupsOperations: - """ContainerGroupsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerinstance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerinstance.aio.ContainerInstanceManagementClient`'s + :attr:`container_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ContainerGroupListResult"]: + ) -> AsyncIterable[_models.ContainerGroupListResult]: """Get a list of container groups in the specified subscription. Get a list of container groups in the specified subscription. This operation returns properties @@ -66,29 +64,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerinstance.models.ContainerGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerGroupListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContainerGroupListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -102,7 +111,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,14 +128,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/containerGroups'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/containerGroups"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ContainerGroupListResult"]: + ) -> AsyncIterable[_models.ContainerGroupListResult]: """Get a list of container groups in the specified subscription and resource group. Get a list of container groups in a specified subscription and resource group. This operation @@ -138,31 +151,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerinstance.models.ContainerGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerGroupListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContainerGroupListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -176,7 +200,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -189,7 +217,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups"} # type: ignore @distributed_trace_async async def get( @@ -197,7 +225,7 @@ async def get( resource_group_name: str, container_group_name: str, **kwargs: Any - ) -> "_models.ContainerGroup": + ) -> _models.ContainerGroup: """Get the properties of the specified container group. Gets the properties of the specified container group in the specified subscription and resource @@ -213,23 +241,35 @@ async def get( :rtype: ~azure.mgmt.containerinstance.models.ContainerGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContainerGroup] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -243,23 +283,27 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, container_group_name: str, - container_group: "_models.ContainerGroup", + container_group: _models.ContainerGroup, **kwargs: Any - ) -> "_models.ContainerGroup": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerGroup"] + ) -> _models.ContainerGroup: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContainerGroup] _json = self._serialize.body(container_group, 'ContainerGroup') @@ -267,14 +311,21 @@ async def _create_or_update_initial( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -292,7 +343,7 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}"} # type: ignore @distributed_trace_async @@ -300,9 +351,9 @@ async def begin_create_or_update( self, resource_group_name: str, container_group_name: str, - container_group: "_models.ContainerGroup", + container_group: _models.ContainerGroup, **kwargs: Any - ) -> AsyncLROPoller["_models.ContainerGroup"]: + ) -> AsyncLROPoller[_models.ContainerGroup]: """Create or update container groups. Create or update container groups with specified configurations. @@ -326,35 +377,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerinstance.models.ContainerGroup] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerGroup"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContainerGroup] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, container_group_name=container_group_name, container_group=container_group, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('ContainerGroup', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -363,19 +426,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}"} # type: ignore @distributed_trace_async async def update( self, resource_group_name: str, container_group_name: str, - resource: "_models.Resource", + resource: _models.Resource, **kwargs: Any - ) -> "_models.ContainerGroup": + ) -> _models.ContainerGroup: """Update container groups. Updates container group tags with specified values. @@ -391,13 +453,17 @@ async def update( :rtype: ~azure.mgmt.containerinstance.models.ContainerGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContainerGroup] _json = self._serialize.body(resource, 'Resource') @@ -405,14 +471,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -426,7 +499,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}"} # type: ignore async def _delete_initial( @@ -434,24 +507,36 @@ async def _delete_initial( resource_group_name: str, container_group_name: str, **kwargs: Any - ) -> Optional["_models.ContainerGroup"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ContainerGroup"]] + ) -> Optional[_models.ContainerGroup]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ContainerGroup]] request = build_delete_request_initial( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -467,7 +552,7 @@ async def _delete_initial( return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}"} # type: ignore @distributed_trace_async @@ -476,7 +561,7 @@ async def begin_delete( resource_group_name: str, container_group_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.ContainerGroup"]: + ) -> AsyncLROPoller[_models.ContainerGroup]: """Delete the specified container group. Delete the specified container group in the specified subscription and resource group. The @@ -499,32 +584,44 @@ async def begin_delete( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerinstance.models.ContainerGroup] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerGroup"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContainerGroup] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('ContainerGroup', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -533,34 +630,45 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}"} # type: ignore - async def _restart_initial( + async def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, container_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, template_url=self._restart_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -570,11 +678,11 @@ async def _restart_initial( if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/restart'} # type: ignore + _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/restart"} # type: ignore @distributed_trace_async - async def begin_restart( + async def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, container_group_name: str, @@ -601,18 +709,25 @@ async def begin_restart( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -622,8 +737,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -632,13 +753,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restart.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/restart'} # type: ignore + begin_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/restart"} # type: ignore @distributed_trace_async - async def stop( + async def stop( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, container_group_name: str, @@ -658,23 +778,35 @@ async def stop( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_stop_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, template_url=self.stop.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -684,32 +816,44 @@ async def stop( if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/stop"} # type: ignore - async def _start_initial( + async def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, container_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, template_url=self._start_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [202]: @@ -719,11 +863,11 @@ async def _start_initial( if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/start'} # type: ignore + _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/start"} # type: ignore @distributed_trace_async - async def begin_start( + async def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, container_group_name: str, @@ -750,18 +894,25 @@ async def begin_start( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -771,8 +922,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -781,10 +938,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/start'} # type: ignore + begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/start"} # type: ignore @distributed_trace_async async def get_outbound_network_dependencies_endpoints( @@ -807,23 +963,35 @@ async def get_outbound_network_dependencies_endpoints( :rtype: list[str] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List[str]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[str]] request = build_get_outbound_network_dependencies_endpoints_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, template_url=self.get_outbound_network_dependencies_endpoints.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -837,5 +1005,5 @@ async def get_outbound_network_dependencies_endpoints( return deserialized - get_outbound_network_dependencies_endpoints.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/outboundNetworkDependenciesEndpoints'} # type: ignore + get_outbound_network_dependencies_endpoints.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/outboundNetworkDependenciesEndpoints"} # type: ignore diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_containers_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_containers_operations.py index b2c891faa5ec..16710e205084 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_containers_operations.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ContainersOperations: - """ContainersOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerinstance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerinstance.aio.ContainerInstanceManagementClient`'s + :attr:`containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list_logs( @@ -53,7 +51,7 @@ async def list_logs( tail: Optional[int] = None, timestamps: Optional[bool] = None, **kwargs: Any - ) -> "_models.Logs": + ) -> _models.Logs: """Get the logs for a specified container instance. Get the logs for a specified container instance in a specified resource group and container @@ -66,21 +64,26 @@ async def list_logs( :param container_name: The name of the container instance. :type container_name: str :param tail: The number of lines to show from the tail of the container instance log. If not - provided, all available logs are shown up to 4mb. + provided, all available logs are shown up to 4mb. Default value is None. :type tail: int :param timestamps: If true, adds a timestamp at the beginning of every line of log output. If - not provided, defaults to false. + not provided, defaults to false. Default value is None. :type timestamps: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: Logs, or the result of cls(response) :rtype: ~azure.mgmt.containerinstance.models.Logs :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Logs"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Logs] request = build_list_logs_request( @@ -88,14 +91,21 @@ async def list_logs( resource_group_name=resource_group_name, container_group_name=container_group_name, container_name=container_name, + api_version=api_version, tail=tail, timestamps=timestamps, template_url=self.list_logs.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,7 +119,7 @@ async def list_logs( return deserialized - list_logs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/logs'} # type: ignore + list_logs.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/logs"} # type: ignore @distributed_trace_async @@ -118,9 +128,9 @@ async def execute_command( resource_group_name: str, container_group_name: str, container_name: str, - container_exec_request: "_models.ContainerExecRequest", + container_exec_request: _models.ContainerExecRequest, **kwargs: Any - ) -> "_models.ContainerExecResponse": + ) -> _models.ContainerExecResponse: """Executes a command in a specific container instance. Executes a command for a specific container instance in a specified resource group and @@ -139,13 +149,17 @@ async def execute_command( :rtype: ~azure.mgmt.containerinstance.models.ContainerExecResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerExecResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContainerExecResponse] _json = self._serialize.body(container_exec_request, 'ContainerExecRequest') @@ -154,14 +168,21 @@ async def execute_command( resource_group_name=resource_group_name, container_group_name=container_group_name, container_name=container_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.execute_command.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -175,7 +196,7 @@ async def execute_command( return deserialized - execute_command.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/exec'} # type: ignore + execute_command.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/exec"} # type: ignore @distributed_trace_async @@ -185,7 +206,7 @@ async def attach( container_group_name: str, container_name: str, **kwargs: Any - ) -> "_models.ContainerAttachResponse": + ) -> _models.ContainerAttachResponse: """Attach to the output of a specific container instance. Attach to the output stream of a specific container instance in a specified resource group and @@ -202,11 +223,16 @@ async def attach( :rtype: ~azure.mgmt.containerinstance.models.ContainerAttachResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerAttachResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContainerAttachResponse] request = build_attach_request( @@ -214,12 +240,19 @@ async def attach( resource_group_name=resource_group_name, container_group_name=container_group_name, container_name=container_name, + api_version=api_version, template_url=self.attach.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -233,5 +266,5 @@ async def attach( return deserialized - attach.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/attach'} # type: ignore + attach.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/attach"} # type: ignore diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_location_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_location_operations.py index 00dcf1673d3f..1c41064e1204 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_location_operations.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_location_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LocationOperations: - """LocationOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerinstance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerinstance.aio.ContainerInstanceManagementClient`'s + :attr:`location` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_usage( self, location: str, **kwargs: Any - ) -> AsyncIterable["_models.UsageListResult"]: + ) -> AsyncIterable[_models.UsageListResult]: """Get the usage for a subscription. :param location: The identifier for the physical azure location. @@ -62,31 +59,42 @@ def list_usage( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerinstance.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_usage_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_usage.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_usage_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -100,7 +108,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -113,14 +125,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_usage.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/usages'} # type: ignore + list_usage.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/usages"} # type: ignore @distributed_trace def list_cached_images( self, location: str, **kwargs: Any - ) -> AsyncIterable["_models.CachedImagesListResult"]: + ) -> AsyncIterable[_models.CachedImagesListResult]: """Get the list of cached images. Get the list of cached images on specific OS type for a subscription in a region. @@ -134,31 +146,42 @@ def list_cached_images( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerinstance.models.CachedImagesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CachedImagesListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CachedImagesListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_cached_images_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_cached_images.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_cached_images_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -172,7 +195,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -185,14 +212,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_cached_images.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/cachedImages'} # type: ignore + list_cached_images.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/cachedImages"} # type: ignore @distributed_trace def list_capabilities( self, location: str, **kwargs: Any - ) -> AsyncIterable["_models.CapabilitiesListResult"]: + ) -> AsyncIterable[_models.CapabilitiesListResult]: """Get the list of capabilities of the location. Get the list of CPU/memory/GPU capabilities of a region. @@ -206,31 +233,42 @@ def list_capabilities( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerinstance.models.CapabilitiesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapabilitiesListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapabilitiesListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_capabilities_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_capabilities.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_capabilities_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -244,7 +282,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -257,4 +299,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_capabilities.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/capabilities'} # type: ignore + list_capabilities.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/capabilities"} # type: ignore diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_operations.py index 56c26b2924ba..7d867bb1dd0c 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_operations.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerinstance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerinstance.aio.ContainerInstanceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """List the operations for Azure Container Instance service. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,27 +56,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerinstance.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +101,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,4 +118,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.ContainerInstance/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.ContainerInstance/operations"} # type: ignore diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_patch.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/__init__.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/__init__.py index e8bda58e56f0..938761e723fe 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/__init__.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/__init__.py @@ -73,7 +73,9 @@ ResourceIdentityType, Scheme, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'AzureFileVolume', 'CachedImages', @@ -139,3 +141,5 @@ 'ResourceIdentityType', 'Scheme', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/_container_instance_management_client_enums.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/_container_instance_management_client_enums.py index d41d17c8137b..89605e1a890f 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/_container_instance_management_client_enums.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/_container_instance_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AutoGeneratedDomainNameLabelScope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AutoGeneratedDomainNameLabelScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The value representing the security enum. """ @@ -21,21 +20,21 @@ class AutoGeneratedDomainNameLabelScope(with_metaclass(CaseInsensitiveEnumMeta, RESOURCE_GROUP_REUSE = "ResourceGroupReuse" NOREUSE = "Noreuse" -class ContainerGroupIpAddressType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ContainerGroupIpAddressType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies if the IP is exposed to the public internet or private VNET. """ PUBLIC = "Public" PRIVATE = "Private" -class ContainerGroupNetworkProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ContainerGroupNetworkProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The protocol associated with the port. """ TCP = "TCP" UDP = "UDP" -class ContainerGroupRestartPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ContainerGroupRestartPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Restart policy for all containers within the container group. @@ -48,28 +47,28 @@ class ContainerGroupRestartPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, E ON_FAILURE = "OnFailure" NEVER = "Never" -class ContainerGroupSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ContainerGroupSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The container group SKU. """ STANDARD = "Standard" DEDICATED = "Dedicated" -class ContainerInstanceOperationsOrigin(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ContainerInstanceOperationsOrigin(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The intended executor of the operation. """ USER = "User" SYSTEM = "System" -class ContainerNetworkProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ContainerNetworkProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The protocol associated with the port. """ TCP = "TCP" UDP = "UDP" -class GpuSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GpuSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU of the GPU resource. """ @@ -77,21 +76,21 @@ class GpuSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): P100 = "P100" V100 = "V100" -class LogAnalyticsLogType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LogAnalyticsLogType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The log type to be used. """ CONTAINER_INSIGHTS = "ContainerInsights" CONTAINER_INSTANCE_LOGS = "ContainerInstanceLogs" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operating system type required by the containers in the container group. """ WINDOWS = "Windows" LINUX = "Linux" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the container group. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the container group. @@ -102,7 +101,7 @@ class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class Scheme(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Scheme(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scheme. """ diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/_models_py3.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/_models_py3.py index ab7f49cff2af..6d46b2c27a54 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/_models_py3.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/_models_py3.py @@ -6,11 +6,13 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union import msrest.serialization -from ._container_instance_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AzureFileVolume(msrest.serialization.Model): @@ -127,7 +129,7 @@ class CachedImagesListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["CachedImages"]] = None, + value: Optional[List["_models.CachedImages"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -248,7 +250,7 @@ class CapabilitiesListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Capabilities"]] = None, + value: Optional[List["_models.Capabilities"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -292,7 +294,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -401,13 +403,13 @@ def __init__( *, name: str, image: str, - resources: "ResourceRequirements", + resources: "_models.ResourceRequirements", command: Optional[List[str]] = None, - ports: Optional[List["ContainerPort"]] = None, - environment_variables: Optional[List["EnvironmentVariable"]] = None, - volume_mounts: Optional[List["VolumeMount"]] = None, - liveness_probe: Optional["ContainerProbe"] = None, - readiness_probe: Optional["ContainerProbe"] = None, + ports: Optional[List["_models.ContainerPort"]] = None, + environment_variables: Optional[List["_models.EnvironmentVariable"]] = None, + volume_mounts: Optional[List["_models.VolumeMount"]] = None, + liveness_probe: Optional["_models.ContainerProbe"] = None, + readiness_probe: Optional["_models.ContainerProbe"] = None, **kwargs ): """ @@ -521,7 +523,7 @@ def __init__( self, *, command: Optional[str] = None, - terminal_size: Optional["ContainerExecRequestTerminalSize"] = None, + terminal_size: Optional["_models.ContainerExecRequestTerminalSize"] = None, **kwargs ): """ @@ -693,13 +695,13 @@ class ContainerGroup(Resource): * ``Always`` Always restart * ``OnFailure`` Restart on failure - * ``Never`` Never restart. Possible values include: "Always", "OnFailure", "Never". + * ``Never`` Never restart. Known values are: "Always", "OnFailure", "Never". :vartype restart_policy: str or ~azure.mgmt.containerinstance.models.ContainerGroupRestartPolicy :ivar ip_address: The IP address type of the container group. :vartype ip_address: ~azure.mgmt.containerinstance.models.IpAddress :ivar os_type: Required. The operating system type required by the containers in the container - group. Possible values include: "Windows", "Linux". + group. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.containerinstance.models.OperatingSystemTypes :ivar volumes: The list of volumes that can be mounted by containers in this container group. :vartype volumes: list[~azure.mgmt.containerinstance.models.Volume] @@ -712,7 +714,7 @@ class ContainerGroup(Resource): :vartype subnet_ids: list[~azure.mgmt.containerinstance.models.ContainerGroupSubnetId] :ivar dns_config: The DNS config information for a container group. :vartype dns_config: ~azure.mgmt.containerinstance.models.DnsConfiguration - :ivar sku: The SKU for a container group. Possible values include: "Standard", "Dedicated". + :ivar sku: The SKU for a container group. Known values are: "Standard", "Dedicated". :vartype sku: str or ~azure.mgmt.containerinstance.models.ContainerGroupSku :ivar encryption_properties: The encryption properties for a container group. :vartype encryption_properties: ~azure.mgmt.containerinstance.models.EncryptionProperties @@ -757,22 +759,22 @@ class ContainerGroup(Resource): def __init__( self, *, - containers: List["Container"], - os_type: Union[str, "OperatingSystemTypes"], + containers: List["_models.Container"], + os_type: Union[str, "_models.OperatingSystemTypes"], location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, zones: Optional[List[str]] = None, - identity: Optional["ContainerGroupIdentity"] = None, - image_registry_credentials: Optional[List["ImageRegistryCredential"]] = None, - restart_policy: Optional[Union[str, "ContainerGroupRestartPolicy"]] = None, - ip_address: Optional["IpAddress"] = None, - volumes: Optional[List["Volume"]] = None, - diagnostics: Optional["ContainerGroupDiagnostics"] = None, - subnet_ids: Optional[List["ContainerGroupSubnetId"]] = None, - dns_config: Optional["DnsConfiguration"] = None, - sku: Optional[Union[str, "ContainerGroupSku"]] = None, - encryption_properties: Optional["EncryptionProperties"] = None, - init_containers: Optional[List["InitContainerDefinition"]] = None, + identity: Optional["_models.ContainerGroupIdentity"] = None, + image_registry_credentials: Optional[List["_models.ImageRegistryCredential"]] = None, + restart_policy: Optional[Union[str, "_models.ContainerGroupRestartPolicy"]] = None, + ip_address: Optional["_models.IpAddress"] = None, + volumes: Optional[List["_models.Volume"]] = None, + diagnostics: Optional["_models.ContainerGroupDiagnostics"] = None, + subnet_ids: Optional[List["_models.ContainerGroupSubnetId"]] = None, + dns_config: Optional["_models.DnsConfiguration"] = None, + sku: Optional[Union[str, "_models.ContainerGroupSku"]] = None, + encryption_properties: Optional["_models.EncryptionProperties"] = None, + init_containers: Optional[List["_models.InitContainerDefinition"]] = None, **kwargs ): """ @@ -795,13 +797,13 @@ def __init__( * ``Always`` Always restart * ``OnFailure`` Restart on failure - * ``Never`` Never restart. Possible values include: "Always", "OnFailure", "Never". + * ``Never`` Never restart. Known values are: "Always", "OnFailure", "Never". :paramtype restart_policy: str or ~azure.mgmt.containerinstance.models.ContainerGroupRestartPolicy :keyword ip_address: The IP address type of the container group. :paramtype ip_address: ~azure.mgmt.containerinstance.models.IpAddress :keyword os_type: Required. The operating system type required by the containers in the - container group. Possible values include: "Windows", "Linux". + container group. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.containerinstance.models.OperatingSystemTypes :keyword volumes: The list of volumes that can be mounted by containers in this container group. @@ -812,7 +814,7 @@ def __init__( :paramtype subnet_ids: list[~azure.mgmt.containerinstance.models.ContainerGroupSubnetId] :keyword dns_config: The DNS config information for a container group. :paramtype dns_config: ~azure.mgmt.containerinstance.models.DnsConfiguration - :keyword sku: The SKU for a container group. Possible values include: "Standard", "Dedicated". + :keyword sku: The SKU for a container group. Known values are: "Standard", "Dedicated". :paramtype sku: str or ~azure.mgmt.containerinstance.models.ContainerGroupSku :keyword encryption_properties: The encryption properties for a container group. :paramtype encryption_properties: ~azure.mgmt.containerinstance.models.EncryptionProperties @@ -851,7 +853,7 @@ class ContainerGroupDiagnostics(msrest.serialization.Model): def __init__( self, *, - log_analytics: Optional["LogAnalytics"] = None, + log_analytics: Optional["_models.LogAnalytics"] = None, **kwargs ): """ @@ -875,8 +877,8 @@ class ContainerGroupIdentity(msrest.serialization.Model): :vartype tenant_id: str :ivar type: The type of identity used for the container group. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the container group. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the container group. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.containerinstance.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the container group. The user identity dictionary key references will be ARM resource ids in the form: @@ -900,15 +902,15 @@ class ContainerGroupIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "Components10Wh5UdSchemasContainergroupidentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.Components10Wh5UdSchemasContainergroupidentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, **kwargs ): """ :keyword type: The type of identity used for the container group. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the container group. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the container group. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.containerinstance.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the container group. The user identity dictionary key references will be ARM resource ids in the form: @@ -940,7 +942,7 @@ class ContainerGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ContainerGroup"]] = None, + value: Optional[List["_models.ContainerGroup"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -1034,7 +1036,7 @@ class ContainerHttpGet(msrest.serialization.Model): :vartype path: str :ivar port: Required. The port number to probe. :vartype port: int - :ivar scheme: The scheme. Possible values include: "http", "https". + :ivar scheme: The scheme. Known values are: "http", "https". :vartype scheme: str or ~azure.mgmt.containerinstance.models.Scheme :ivar http_headers: The HTTP headers. :vartype http_headers: list[~azure.mgmt.containerinstance.models.HttpHeader] @@ -1056,8 +1058,8 @@ def __init__( *, port: int, path: Optional[str] = None, - scheme: Optional[Union[str, "Scheme"]] = None, - http_headers: Optional[List["HttpHeader"]] = None, + scheme: Optional[Union[str, "_models.Scheme"]] = None, + http_headers: Optional[List["_models.HttpHeader"]] = None, **kwargs ): """ @@ -1065,7 +1067,7 @@ def __init__( :paramtype path: str :keyword port: Required. The port number to probe. :paramtype port: int - :keyword scheme: The scheme. Possible values include: "http", "https". + :keyword scheme: The scheme. Known values are: "http", "https". :paramtype scheme: str or ~azure.mgmt.containerinstance.models.Scheme :keyword http_headers: The HTTP headers. :paramtype http_headers: list[~azure.mgmt.containerinstance.models.HttpHeader] @@ -1082,7 +1084,7 @@ class ContainerPort(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar protocol: The protocol associated with the port. Possible values include: "TCP", "UDP". + :ivar protocol: The protocol associated with the port. Known values are: "TCP", "UDP". :vartype protocol: str or ~azure.mgmt.containerinstance.models.ContainerNetworkProtocol :ivar port: Required. The port number exposed within the container group. :vartype port: int @@ -1101,12 +1103,11 @@ def __init__( self, *, port: int, - protocol: Optional[Union[str, "ContainerNetworkProtocol"]] = None, + protocol: Optional[Union[str, "_models.ContainerNetworkProtocol"]] = None, **kwargs ): """ - :keyword protocol: The protocol associated with the port. Possible values include: "TCP", - "UDP". + :keyword protocol: The protocol associated with the port. Known values are: "TCP", "UDP". :paramtype protocol: str or ~azure.mgmt.containerinstance.models.ContainerNetworkProtocol :keyword port: Required. The port number exposed within the container group. :paramtype port: int @@ -1148,8 +1149,8 @@ class ContainerProbe(msrest.serialization.Model): def __init__( self, *, - exec_property: Optional["ContainerExec"] = None, - http_get: Optional["ContainerHttpGet"] = None, + exec_property: Optional["_models.ContainerExec"] = None, + http_get: Optional["_models.ContainerHttpGet"] = None, initial_delay_seconds: Optional[int] = None, period_seconds: Optional[int] = None, failure_threshold: Optional[int] = None, @@ -1518,8 +1519,7 @@ class GpuResource(msrest.serialization.Model): :ivar count: Required. The count of the GPU resource. :vartype count: int - :ivar sku: Required. The SKU of the GPU resource. Possible values include: "K80", "P100", - "V100". + :ivar sku: Required. The SKU of the GPU resource. Known values are: "K80", "P100", "V100". :vartype sku: str or ~azure.mgmt.containerinstance.models.GpuSku """ @@ -1537,14 +1537,13 @@ def __init__( self, *, count: int, - sku: Union[str, "GpuSku"], + sku: Union[str, "_models.GpuSku"], **kwargs ): """ :keyword count: Required. The count of the GPU resource. :paramtype count: int - :keyword sku: Required. The SKU of the GPU resource. Possible values include: "K80", "P100", - "V100". + :keyword sku: Required. The SKU of the GPU resource. Known values are: "K80", "P100", "V100". :paramtype sku: str or ~azure.mgmt.containerinstance.models.GpuSku """ super(GpuResource, self).__init__(**kwargs) @@ -1592,7 +1591,7 @@ class ImageRegistryCredential(msrest.serialization.Model): :ivar server: Required. The Docker image registry server without a protocol such as "http" and "https". :vartype server: str - :ivar username: Required. The username for the private registry. + :ivar username: The username for the private registry. :vartype username: str :ivar password: The password for the private registry. :vartype password: str @@ -1604,7 +1603,6 @@ class ImageRegistryCredential(msrest.serialization.Model): _validation = { 'server': {'required': True}, - 'username': {'required': True}, } _attribute_map = { @@ -1619,7 +1617,7 @@ def __init__( self, *, server: str, - username: str, + username: Optional[str] = None, password: Optional[str] = None, identity: Optional[str] = None, identity_url: Optional[str] = None, @@ -1629,7 +1627,7 @@ def __init__( :keyword server: Required. The Docker image registry server without a protocol such as "http" and "https". :paramtype server: str - :keyword username: Required. The username for the private registry. + :keyword username: The username for the private registry. :paramtype username: str :keyword password: The password for the private registry. :paramtype password: str @@ -1688,8 +1686,8 @@ def __init__( name: str, image: Optional[str] = None, command: Optional[List[str]] = None, - environment_variables: Optional[List["EnvironmentVariable"]] = None, - volume_mounts: Optional[List["VolumeMount"]] = None, + environment_variables: Optional[List["_models.EnvironmentVariable"]] = None, + volume_mounts: Optional[List["_models.VolumeMount"]] = None, **kwargs ): """ @@ -1766,14 +1764,14 @@ class IpAddress(msrest.serialization.Model): :ivar ports: Required. The list of ports exposed on the container group. :vartype ports: list[~azure.mgmt.containerinstance.models.Port] :ivar type: Required. Specifies if the IP is exposed to the public internet or private VNET. - Possible values include: "Public", "Private". + Known values are: "Public", "Private". :vartype type: str or ~azure.mgmt.containerinstance.models.ContainerGroupIpAddressType :ivar ip: The IP exposed to the public internet. :vartype ip: str :ivar dns_name_label: The Dns name label for the IP. :vartype dns_name_label: str - :ivar dns_name_label_reuse_policy: The value representing the security enum. Possible values - include: "Unsecure", "TenantReuse", "SubscriptionReuse", "ResourceGroupReuse", "Noreuse". + :ivar dns_name_label_reuse_policy: The value representing the security enum. Known values are: + "Unsecure", "TenantReuse", "SubscriptionReuse", "ResourceGroupReuse", "Noreuse". :vartype dns_name_label_reuse_policy: str or ~azure.mgmt.containerinstance.models.AutoGeneratedDomainNameLabelScope :ivar fqdn: The FQDN for the IP. @@ -1798,25 +1796,25 @@ class IpAddress(msrest.serialization.Model): def __init__( self, *, - ports: List["Port"], - type: Union[str, "ContainerGroupIpAddressType"], + ports: List["_models.Port"], + type: Union[str, "_models.ContainerGroupIpAddressType"], ip: Optional[str] = None, dns_name_label: Optional[str] = None, - dns_name_label_reuse_policy: Optional[Union[str, "AutoGeneratedDomainNameLabelScope"]] = None, + dns_name_label_reuse_policy: Optional[Union[str, "_models.AutoGeneratedDomainNameLabelScope"]] = None, **kwargs ): """ :keyword ports: Required. The list of ports exposed on the container group. :paramtype ports: list[~azure.mgmt.containerinstance.models.Port] :keyword type: Required. Specifies if the IP is exposed to the public internet or private VNET. - Possible values include: "Public", "Private". + Known values are: "Public", "Private". :paramtype type: str or ~azure.mgmt.containerinstance.models.ContainerGroupIpAddressType :keyword ip: The IP exposed to the public internet. :paramtype ip: str :keyword dns_name_label: The Dns name label for the IP. :paramtype dns_name_label: str - :keyword dns_name_label_reuse_policy: The value representing the security enum. Possible values - include: "Unsecure", "TenantReuse", "SubscriptionReuse", "ResourceGroupReuse", "Noreuse". + :keyword dns_name_label_reuse_policy: The value representing the security enum. Known values + are: "Unsecure", "TenantReuse", "SubscriptionReuse", "ResourceGroupReuse", "Noreuse". :paramtype dns_name_label_reuse_policy: str or ~azure.mgmt.containerinstance.models.AutoGeneratedDomainNameLabelScope """ @@ -1838,7 +1836,7 @@ class LogAnalytics(msrest.serialization.Model): :vartype workspace_id: str :ivar workspace_key: Required. The workspace key for log analytics. :vartype workspace_key: str - :ivar log_type: The log type to be used. Possible values include: "ContainerInsights", + :ivar log_type: The log type to be used. Known values are: "ContainerInsights", "ContainerInstanceLogs". :vartype log_type: str or ~azure.mgmt.containerinstance.models.LogAnalyticsLogType :ivar metadata: Metadata for log analytics. @@ -1865,7 +1863,7 @@ def __init__( *, workspace_id: str, workspace_key: str, - log_type: Optional[Union[str, "LogAnalyticsLogType"]] = None, + log_type: Optional[Union[str, "_models.LogAnalyticsLogType"]] = None, metadata: Optional[Dict[str, str]] = None, workspace_resource_id: Optional[str] = None, **kwargs @@ -1875,7 +1873,7 @@ def __init__( :paramtype workspace_id: str :keyword workspace_key: Required. The workspace key for log analytics. :paramtype workspace_key: str - :keyword log_type: The log type to be used. Possible values include: "ContainerInsights", + :keyword log_type: The log type to be used. Known values are: "ContainerInsights", "ContainerInstanceLogs". :paramtype log_type: str or ~azure.mgmt.containerinstance.models.LogAnalyticsLogType :keyword metadata: Metadata for log analytics. @@ -1927,8 +1925,7 @@ class Operation(msrest.serialization.Model): :vartype display: ~azure.mgmt.containerinstance.models.OperationDisplay :ivar properties: The additional properties. :vartype properties: any - :ivar origin: The intended executor of the operation. Possible values include: "User", - "System". + :ivar origin: The intended executor of the operation. Known values are: "User", "System". :vartype origin: str or ~azure.mgmt.containerinstance.models.ContainerInstanceOperationsOrigin """ @@ -1948,9 +1945,9 @@ def __init__( self, *, name: str, - display: "OperationDisplay", + display: "_models.OperationDisplay", properties: Optional[Any] = None, - origin: Optional[Union[str, "ContainerInstanceOperationsOrigin"]] = None, + origin: Optional[Union[str, "_models.ContainerInstanceOperationsOrigin"]] = None, **kwargs ): """ @@ -1960,8 +1957,7 @@ def __init__( :paramtype display: ~azure.mgmt.containerinstance.models.OperationDisplay :keyword properties: The additional properties. :paramtype properties: any - :keyword origin: The intended executor of the operation. Possible values include: "User", - "System". + :keyword origin: The intended executor of the operation. Known values are: "User", "System". :paramtype origin: str or ~azure.mgmt.containerinstance.models.ContainerInstanceOperationsOrigin """ @@ -2035,7 +2031,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -2055,7 +2051,7 @@ class Port(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar protocol: The protocol associated with the port. Possible values include: "TCP", "UDP". + :ivar protocol: The protocol associated with the port. Known values are: "TCP", "UDP". :vartype protocol: str or ~azure.mgmt.containerinstance.models.ContainerGroupNetworkProtocol :ivar port: Required. The port number. :vartype port: int @@ -2074,12 +2070,11 @@ def __init__( self, *, port: int, - protocol: Optional[Union[str, "ContainerGroupNetworkProtocol"]] = None, + protocol: Optional[Union[str, "_models.ContainerGroupNetworkProtocol"]] = None, **kwargs ): """ - :keyword protocol: The protocol associated with the port. Possible values include: "TCP", - "UDP". + :keyword protocol: The protocol associated with the port. Known values are: "TCP", "UDP". :paramtype protocol: str or ~azure.mgmt.containerinstance.models.ContainerGroupNetworkProtocol :keyword port: Required. The port number. :paramtype port: int @@ -2111,7 +2106,7 @@ def __init__( *, memory_in_gb: Optional[float] = None, cpu: Optional[float] = None, - gpu: Optional["GpuResource"] = None, + gpu: Optional["_models.GpuResource"] = None, **kwargs ): """ @@ -2157,7 +2152,7 @@ def __init__( *, memory_in_gb: float, cpu: float, - gpu: Optional["GpuResource"] = None, + gpu: Optional["_models.GpuResource"] = None, **kwargs ): """ @@ -2197,8 +2192,8 @@ class ResourceRequirements(msrest.serialization.Model): def __init__( self, *, - requests: "ResourceRequests", - limits: Optional["ResourceLimits"] = None, + requests: "_models.ResourceRequests", + limits: Optional["_models.ResourceLimits"] = None, **kwargs ): """ @@ -2346,10 +2341,10 @@ def __init__( self, *, name: str, - azure_file: Optional["AzureFileVolume"] = None, + azure_file: Optional["_models.AzureFileVolume"] = None, empty_dir: Optional[Any] = None, secret: Optional[Dict[str, str]] = None, - git_repo: Optional["GitRepoVolume"] = None, + git_repo: Optional["_models.GitRepoVolume"] = None, **kwargs ): """ diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/_patch.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/__init__.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/__init__.py index 65bb6fbdb75f..ab780c5f1066 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/__init__.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/__init__.py @@ -11,9 +11,14 @@ from ._location_operations import LocationOperations from ._containers_operations import ContainersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ContainerGroupsOperations', 'Operations', 'LocationOperations', 'ContainersOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_container_groups_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_container_groups_operations.py index f49b874b283f..9537ec4242dd 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_container_groups_operations.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_container_groups_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, List, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,29 +33,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/containerGroups') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/containerGroups") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -65,30 +67,32 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -99,31 +103,33 @@ def build_get_request( container_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "containerGroupName": _SERIALIZER.url("container_group_name", container_group_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -133,39 +139,40 @@ def build_create_or_update_request_initial( resource_group_name: str, container_group_name: str, *, - json: JSONType = None, + json: Optional[_models.ContainerGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-10-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "containerGroupName": _SERIALIZER.url("container_group_name", container_group_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -177,39 +184,40 @@ def build_update_request( resource_group_name: str, container_group_name: str, *, - json: JSONType = None, + json: Optional[_models.Resource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-10-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "containerGroupName": _SERIALIZER.url("container_group_name", container_group_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -222,31 +230,33 @@ def build_delete_request_initial( container_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "containerGroupName": _SERIALIZER.url("container_group_name", container_group_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -257,31 +267,33 @@ def build_restart_request_initial( container_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/restart') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/restart") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "containerGroupName": _SERIALIZER.url("container_group_name", container_group_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -292,31 +304,33 @@ def build_stop_request( container_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/stop') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/stop") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "containerGroupName": _SERIALIZER.url("container_group_name", container_group_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -327,31 +341,33 @@ def build_start_request_initial( container_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/start') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/start") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "containerGroupName": _SERIALIZER.url("container_group_name", container_group_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -362,61 +378,61 @@ def build_get_outbound_network_dependencies_endpoints_request( container_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/outboundNetworkDependenciesEndpoints') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/outboundNetworkDependenciesEndpoints") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "containerGroupName": _SERIALIZER.url("container_group_name", container_group_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ContainerGroupsOperations(object): - """ContainerGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ContainerGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerinstance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerinstance.ContainerInstanceManagementClient`'s + :attr:`container_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.ContainerGroupListResult"]: + ) -> Iterable[_models.ContainerGroupListResult]: """Get a list of container groups in the specified subscription. Get a list of container groups in the specified subscription. This operation returns properties @@ -430,29 +446,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.containerinstance.models.ContainerGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerGroupListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContainerGroupListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -466,7 +493,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -479,14 +510,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/containerGroups'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/containerGroups"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ContainerGroupListResult"]: + ) -> Iterable[_models.ContainerGroupListResult]: """Get a list of container groups in the specified subscription and resource group. Get a list of container groups in a specified subscription and resource group. This operation @@ -502,31 +533,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.containerinstance.models.ContainerGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerGroupListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContainerGroupListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -540,7 +582,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -553,7 +599,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups"} # type: ignore @distributed_trace def get( @@ -561,7 +607,7 @@ def get( resource_group_name: str, container_group_name: str, **kwargs: Any - ) -> "_models.ContainerGroup": + ) -> _models.ContainerGroup: """Get the properties of the specified container group. Gets the properties of the specified container group in the specified subscription and resource @@ -577,23 +623,35 @@ def get( :rtype: ~azure.mgmt.containerinstance.models.ContainerGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContainerGroup] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -607,23 +665,27 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, container_group_name: str, - container_group: "_models.ContainerGroup", + container_group: _models.ContainerGroup, **kwargs: Any - ) -> "_models.ContainerGroup": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerGroup"] + ) -> _models.ContainerGroup: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContainerGroup] _json = self._serialize.body(container_group, 'ContainerGroup') @@ -631,14 +693,21 @@ def _create_or_update_initial( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -656,7 +725,7 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}"} # type: ignore @distributed_trace @@ -664,9 +733,9 @@ def begin_create_or_update( self, resource_group_name: str, container_group_name: str, - container_group: "_models.ContainerGroup", + container_group: _models.ContainerGroup, **kwargs: Any - ) -> LROPoller["_models.ContainerGroup"]: + ) -> LROPoller[_models.ContainerGroup]: """Create or update container groups. Create or update container groups with specified configurations. @@ -690,35 +759,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerinstance.models.ContainerGroup] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerGroup"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContainerGroup] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, container_group_name=container_group_name, container_group=container_group, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('ContainerGroup', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -727,19 +808,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}"} # type: ignore @distributed_trace def update( self, resource_group_name: str, container_group_name: str, - resource: "_models.Resource", + resource: _models.Resource, **kwargs: Any - ) -> "_models.ContainerGroup": + ) -> _models.ContainerGroup: """Update container groups. Updates container group tags with specified values. @@ -755,13 +835,17 @@ def update( :rtype: ~azure.mgmt.containerinstance.models.ContainerGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContainerGroup] _json = self._serialize.body(resource, 'Resource') @@ -769,14 +853,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -790,7 +881,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}"} # type: ignore def _delete_initial( @@ -798,24 +889,36 @@ def _delete_initial( resource_group_name: str, container_group_name: str, **kwargs: Any - ) -> Optional["_models.ContainerGroup"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ContainerGroup"]] + ) -> Optional[_models.ContainerGroup]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ContainerGroup]] request = build_delete_request_initial( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -831,7 +934,7 @@ def _delete_initial( return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}"} # type: ignore @distributed_trace @@ -840,7 +943,7 @@ def begin_delete( resource_group_name: str, container_group_name: str, **kwargs: Any - ) -> LROPoller["_models.ContainerGroup"]: + ) -> LROPoller[_models.ContainerGroup]: """Delete the specified container group. Delete the specified container group in the specified subscription and resource group. The @@ -863,32 +966,44 @@ def begin_delete( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerinstance.models.ContainerGroup] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerGroup"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContainerGroup] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('ContainerGroup', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -897,34 +1012,45 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}"} # type: ignore - def _restart_initial( + def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, container_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, template_url=self._restart_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -934,11 +1060,11 @@ def _restart_initial( if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/restart'} # type: ignore + _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/restart"} # type: ignore @distributed_trace - def begin_restart( + def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, container_group_name: str, @@ -965,18 +1091,25 @@ def begin_restart( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -986,8 +1119,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -996,13 +1135,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restart.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/restart'} # type: ignore + begin_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/restart"} # type: ignore @distributed_trace - def stop( + def stop( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, container_group_name: str, @@ -1022,23 +1160,35 @@ def stop( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_stop_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, template_url=self.stop.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -1048,32 +1198,44 @@ def stop( if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/stop"} # type: ignore - def _start_initial( + def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, container_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, template_url=self._start_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [202]: @@ -1083,11 +1245,11 @@ def _start_initial( if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/start'} # type: ignore + _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/start"} # type: ignore @distributed_trace - def begin_start( + def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, container_group_name: str, @@ -1114,18 +1276,25 @@ def begin_start( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1135,8 +1304,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1145,10 +1320,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/start'} # type: ignore + begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/start"} # type: ignore @distributed_trace def get_outbound_network_dependencies_endpoints( @@ -1171,23 +1345,35 @@ def get_outbound_network_dependencies_endpoints( :rtype: list[str] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List[str]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[str]] request = build_get_outbound_network_dependencies_endpoints_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_group_name=container_group_name, + api_version=api_version, template_url=self.get_outbound_network_dependencies_endpoints.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1201,5 +1387,5 @@ def get_outbound_network_dependencies_endpoints( return deserialized - get_outbound_network_dependencies_endpoints.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/outboundNetworkDependenciesEndpoints'} # type: ignore + get_outbound_network_dependencies_endpoints.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/outboundNetworkDependenciesEndpoints"} # type: ignore diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_containers_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_containers_operations.py index e8d82a4fe7ab..0b2f22e627bb 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_containers_operations.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -36,10 +36,14 @@ def build_list_logs_request( timestamps: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/logs') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/logs") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), @@ -47,25 +51,23 @@ def build_list_logs_request( "containerName": _SERIALIZER.url("container_name", container_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if tail is not None: - query_parameters['tail'] = _SERIALIZER.query("tail", tail, 'int') + _params['tail'] = _SERIALIZER.query("tail", tail, 'int') if timestamps is not None: - query_parameters['timestamps'] = _SERIALIZER.query("timestamps", timestamps, 'bool') + _params['timestamps'] = _SERIALIZER.query("timestamps", timestamps, 'bool') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -76,16 +78,19 @@ def build_execute_command_request( container_group_name: str, container_name: str, *, - json: JSONType = None, + json: Optional[_models.ContainerExecRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-10-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/exec') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/exec") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), @@ -93,23 +98,21 @@ def build_execute_command_request( "containerName": _SERIALIZER.url("container_name", container_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,10 +126,14 @@ def build_attach_request( container_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/attach') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/attach") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), @@ -134,45 +141,41 @@ def build_attach_request( "containerName": _SERIALIZER.url("container_name", container_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ContainersOperations(object): - """ContainersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerinstance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerinstance.ContainerInstanceManagementClient`'s + :attr:`containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_logs( @@ -183,7 +186,7 @@ def list_logs( tail: Optional[int] = None, timestamps: Optional[bool] = None, **kwargs: Any - ) -> "_models.Logs": + ) -> _models.Logs: """Get the logs for a specified container instance. Get the logs for a specified container instance in a specified resource group and container @@ -196,21 +199,26 @@ def list_logs( :param container_name: The name of the container instance. :type container_name: str :param tail: The number of lines to show from the tail of the container instance log. If not - provided, all available logs are shown up to 4mb. + provided, all available logs are shown up to 4mb. Default value is None. :type tail: int :param timestamps: If true, adds a timestamp at the beginning of every line of log output. If - not provided, defaults to false. + not provided, defaults to false. Default value is None. :type timestamps: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: Logs, or the result of cls(response) :rtype: ~azure.mgmt.containerinstance.models.Logs :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Logs"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Logs] request = build_list_logs_request( @@ -218,14 +226,21 @@ def list_logs( resource_group_name=resource_group_name, container_group_name=container_group_name, container_name=container_name, + api_version=api_version, tail=tail, timestamps=timestamps, template_url=self.list_logs.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,7 +254,7 @@ def list_logs( return deserialized - list_logs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/logs'} # type: ignore + list_logs.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/logs"} # type: ignore @distributed_trace @@ -248,9 +263,9 @@ def execute_command( resource_group_name: str, container_group_name: str, container_name: str, - container_exec_request: "_models.ContainerExecRequest", + container_exec_request: _models.ContainerExecRequest, **kwargs: Any - ) -> "_models.ContainerExecResponse": + ) -> _models.ContainerExecResponse: """Executes a command in a specific container instance. Executes a command for a specific container instance in a specified resource group and @@ -269,13 +284,17 @@ def execute_command( :rtype: ~azure.mgmt.containerinstance.models.ContainerExecResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerExecResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContainerExecResponse] _json = self._serialize.body(container_exec_request, 'ContainerExecRequest') @@ -284,14 +303,21 @@ def execute_command( resource_group_name=resource_group_name, container_group_name=container_group_name, container_name=container_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.execute_command.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -305,7 +331,7 @@ def execute_command( return deserialized - execute_command.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/exec'} # type: ignore + execute_command.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/exec"} # type: ignore @distributed_trace @@ -315,7 +341,7 @@ def attach( container_group_name: str, container_name: str, **kwargs: Any - ) -> "_models.ContainerAttachResponse": + ) -> _models.ContainerAttachResponse: """Attach to the output of a specific container instance. Attach to the output stream of a specific container instance in a specified resource group and @@ -332,11 +358,16 @@ def attach( :rtype: ~azure.mgmt.containerinstance.models.ContainerAttachResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerAttachResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContainerAttachResponse] request = build_attach_request( @@ -344,12 +375,19 @@ def attach( resource_group_name=resource_group_name, container_group_name=container_group_name, container_name=container_name, + api_version=api_version, template_url=self.attach.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -363,5 +401,5 @@ def attach( return deserialized - attach.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/attach'} # type: ignore + attach.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/attach"} # type: ignore diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_location_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_location_operations.py index 0da0918bb360..035a265fe9a7 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_location_operations.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_location_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,30 +32,32 @@ def build_list_usage_request( location: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "location": _SERIALIZER.url("location", location, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -64,30 +67,32 @@ def build_list_cached_images_request( location: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/cachedImages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/cachedImages") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "location": _SERIALIZER.url("location", location, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -97,61 +102,61 @@ def build_list_capabilities_request( location: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/capabilities') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/capabilities") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "location": _SERIALIZER.url("location", location, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class LocationOperations(object): - """LocationOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LocationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerinstance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerinstance.ContainerInstanceManagementClient`'s + :attr:`location` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_usage( self, location: str, **kwargs: Any - ) -> Iterable["_models.UsageListResult"]: + ) -> Iterable[_models.UsageListResult]: """Get the usage for a subscription. :param location: The identifier for the physical azure location. @@ -161,31 +166,42 @@ def list_usage( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerinstance.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_usage_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_usage.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_usage_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -199,7 +215,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -212,14 +232,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_usage.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/usages'} # type: ignore + list_usage.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/usages"} # type: ignore @distributed_trace def list_cached_images( self, location: str, **kwargs: Any - ) -> Iterable["_models.CachedImagesListResult"]: + ) -> Iterable[_models.CachedImagesListResult]: """Get the list of cached images. Get the list of cached images on specific OS type for a subscription in a region. @@ -233,31 +253,42 @@ def list_cached_images( ~azure.core.paging.ItemPaged[~azure.mgmt.containerinstance.models.CachedImagesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CachedImagesListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CachedImagesListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_cached_images_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_cached_images.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_cached_images_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -271,7 +302,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -284,14 +319,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_cached_images.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/cachedImages'} # type: ignore + list_cached_images.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/cachedImages"} # type: ignore @distributed_trace def list_capabilities( self, location: str, **kwargs: Any - ) -> Iterable["_models.CapabilitiesListResult"]: + ) -> Iterable[_models.CapabilitiesListResult]: """Get the list of capabilities of the location. Get the list of CPU/memory/GPU capabilities of a region. @@ -305,31 +340,42 @@ def list_capabilities( ~azure.core.paging.ItemPaged[~azure.mgmt.containerinstance.models.CapabilitiesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapabilitiesListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapabilitiesListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_capabilities_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_capabilities.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_capabilities_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -343,7 +389,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -356,4 +406,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_capabilities.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/capabilities'} # type: ignore + list_capabilities.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/capabilities"} # type: ignore diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_operations.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_operations.py index 77293a8b6622..44280f2ad23c 100644 --- a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_operations.py +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,54 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.ContainerInstance/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.ContainerInstance/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.containerinstance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.containerinstance.ContainerInstanceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> Iterable[_models.OperationListResult]: """List the operations for Azure Container Instance service. :keyword callable cls: A custom type or function that will be passed the direct response @@ -84,27 +85,38 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerinstance.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -118,7 +130,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -131,4 +147,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.ContainerInstance/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.ContainerInstance/operations"} # type: ignore diff --git a/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_patch.py b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/containerinstance/azure-mgmt-containerinstance/azure/mgmt/containerinstance/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """