diff --git a/sdk/compute/azure-mgmt-imagebuilder/MANIFEST.in b/sdk/compute/azure-mgmt-imagebuilder/MANIFEST.in index a3cb07df8765..3a9b6517412b 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/MANIFEST.in +++ b/sdk/compute/azure-mgmt-imagebuilder/MANIFEST.in @@ -1,3 +1,4 @@ +include _meta.json recursive-include tests *.py *.yaml include *.md include azure/__init__.py diff --git a/sdk/compute/azure-mgmt-imagebuilder/_meta.json b/sdk/compute/azure-mgmt-imagebuilder/_meta.json new file mode 100644 index 000000000000..fca1485746ea --- /dev/null +++ b/sdk/compute/azure-mgmt-imagebuilder/_meta.json @@ -0,0 +1,8 @@ +{ + "autorest": "3.3.0", + "use": "@autorest/python@5.6.6", + "commit": "ca33ae74628960dafd970572655da4242ca997fd", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/imagebuilder/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.6.6 --version=3.3.0", + "readme": "specification/imagebuilder/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/__init__.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/__init__.py index b3ddd5dc4cc6..6bc8a7ccb752 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/__init__.py +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/__init__.py @@ -1,19 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import ImageBuilderClientConfiguration from ._image_builder_client import ImageBuilderClient -__all__ = ['ImageBuilderClient', 'ImageBuilderClientConfiguration'] - -from .version import VERSION +from ._version import VERSION __version__ = VERSION +__all__ = ['ImageBuilderClient'] +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_configuration.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_configuration.py index 99d2333d31c5..3ba4fc80b827 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_configuration.py +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_configuration.py @@ -1,50 +1,71 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + + +class ImageBuilderClientConfiguration(Configuration): + """Configuration for ImageBuilderClient. -class ImageBuilderClientConfiguration(AzureConfiguration): - """Configuration for ImageBuilderClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param subscription_id: Subscription credentials which uniquely identify - Microsoft Azure subscription. The subscription Id forms part of the URI - for every service call. + :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. :type subscription_id: str - :param str base_url: Service URL """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - if not base_url: - base_url = 'https://management.azure.com' - - super(ImageBuilderClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True + super(ImageBuilderClientConfiguration, self).__init__(**kwargs) - self.add_user_agent('azure-mgmt-imagebuilder/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2020-02-14" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-imagebuilder/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_image_builder_client.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_image_builder_client.py index 6bd34c3eaa9f..a45433632f79 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_image_builder_client.py +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_image_builder_client.py @@ -1,16 +1,22 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + from azure.core.pipeline.transport import HttpRequest, HttpResponse from ._configuration import ImageBuilderClientConfiguration from .operations import VirtualMachineImageTemplatesOperations @@ -18,39 +24,71 @@ from . import models -class ImageBuilderClient(SDKClient): - """Azure Virtual Machine Image Builder Client +class ImageBuilderClient(object): + """Azure Virtual Machine Image Builder Client. - :ivar config: Configuration for client. - :vartype config: ImageBuilderClientConfiguration - - :ivar virtual_machine_image_templates: VirtualMachineImageTemplates operations + :ivar virtual_machine_image_templates: VirtualMachineImageTemplatesOperations operations :vartype virtual_machine_image_templates: azure.mgmt.imagebuilder.operations.VirtualMachineImageTemplatesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.imagebuilder.operations.Operations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param subscription_id: Subscription credentials which uniquely identify - Microsoft Azure subscription. The subscription Id forms part of the URI - for every service call. + :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. :type subscription_id: str :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = ImageBuilderClientConfiguration(credentials, subscription_id, base_url) - super(ImageBuilderClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = ImageBuilderClientConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self.api_version = '2020-02-14' self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) self.virtual_machine_image_templates = VirtualMachineImageTemplatesOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.operations = Operations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, http_request, **kwargs): + # type: (HttpRequest, Any) -> HttpResponse + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.HttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ImageBuilderClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_metadata.json b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_metadata.json new file mode 100644 index 000000000000..18b810420bee --- /dev/null +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_metadata.json @@ -0,0 +1,104 @@ +{ + "chosen_version": "2020-02-14", + "total_api_version_list": ["2020-02-14"], + "client": { + "name": "ImageBuilderClient", + "filename": "_image_builder_client", + "description": "Azure Virtual Machine Image Builder Client.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": 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\": [\"ImageBuilderClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ImageBuilderClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + }, + "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=None, # type: Optional[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: Optional[str] = None,", + "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_default_policy_type": "BearerTokenCredentialPolicy", + "credential_default_policy_type_has_async_version": true, + "credential_key_header_name": null, + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"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\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "virtual_machine_image_templates": "VirtualMachineImageTemplatesOperations", + "operations": "Operations" + } +} \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/version.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_version.py similarity index 84% rename from sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/version.py rename to sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_version.py index 85da2c00c1a6..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/version.py +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_version.py @@ -1,13 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "0.4.0" - +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/__init__.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/__init__.py new file mode 100644 index 000000000000..334f853a6ca6 --- /dev/null +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._image_builder_client import ImageBuilderClient +__all__ = ['ImageBuilderClient'] diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/_configuration.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/_configuration.py new file mode 100644 index 000000000000..5556b447d5fb --- /dev/null +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/_configuration.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ImageBuilderClientConfiguration(Configuration): + """Configuration for ImageBuilderClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(ImageBuilderClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2020-02-14" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-imagebuilder/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/_image_builder_client.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/_image_builder_client.py new file mode 100644 index 000000000000..21412e5c7aeb --- /dev/null +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/_image_builder_client.py @@ -0,0 +1,87 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional, TYPE_CHECKING + +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import ImageBuilderClientConfiguration +from .operations import VirtualMachineImageTemplatesOperations +from .operations import Operations +from .. import models + + +class ImageBuilderClient(object): + """Azure Virtual Machine Image Builder Client. + + :ivar virtual_machine_image_templates: VirtualMachineImageTemplatesOperations operations + :vartype virtual_machine_image_templates: azure.mgmt.imagebuilder.aio.operations.VirtualMachineImageTemplatesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.imagebuilder.aio.operations.Operations + :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. + :type subscription_id: str + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = ImageBuilderClientConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.virtual_machine_image_templates = VirtualMachineImageTemplatesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + + async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ImageBuilderClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/operations/__init__.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/operations/__init__.py new file mode 100644 index 000000000000..f2e05de690ae --- /dev/null +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/operations/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._virtual_machine_image_templates_operations import VirtualMachineImageTemplatesOperations +from ._operations import Operations + +__all__ = [ + 'VirtualMachineImageTemplatesOperations', + 'Operations', +] diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/operations/_operations.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/operations/_operations.py new file mode 100644 index 000000000000..ae27c93942b2 --- /dev/null +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/operations/_operations.py @@ -0,0 +1,105 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.imagebuilder.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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["_models.OperationListResult"]: + """Lists available operations for the Microsoft.VirtualMachineImages provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.imagebuilder.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.VirtualMachineImages/operations'} # type: ignore diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/operations/_virtual_machine_image_templates_operations.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/operations/_virtual_machine_image_templates_operations.py new file mode 100644 index 000000000000..1a9cf34cbf08 --- /dev/null +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/operations/_virtual_machine_image_templates_operations.py @@ -0,0 +1,962 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class VirtualMachineImageTemplatesOperations: + """VirtualMachineImageTemplatesOperations 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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.imagebuilder.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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["_models.ImageTemplateListResult"]: + """Gets information about the VM image templates associated with the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ImageTemplateListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.imagebuilder.models.ImageTemplateListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageTemplateListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ImageTemplateListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.VirtualMachineImages/imageTemplates'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> AsyncIterable["_models.ImageTemplateListResult"]: + """Gets information about the VM image templates associated with the specified resource group. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ImageTemplateListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.imagebuilder.models.ImageTemplateListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageTemplateListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ImageTemplateListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + image_template_name: str, + parameters: "_models.ImageTemplate", + **kwargs + ) -> "_models.ImageTemplate": + cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageTemplate"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ImageTemplate') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ImageTemplate', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ImageTemplate', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + + async def begin_create_or_update( + self, + resource_group_name: str, + image_template_name: str, + parameters: "_models.ImageTemplate", + **kwargs + ) -> AsyncLROPoller["_models.ImageTemplate"]: + """Create or update a virtual machine image template. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param image_template_name: The name of the image Template. + :type image_template_name: str + :param parameters: Parameters supplied to the CreateImageTemplate operation. + :type parameters: ~azure.mgmt.imagebuilder.models.ImageTemplate + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ImageTemplate or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.imagebuilder.models.ImageTemplate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageTemplate"] + 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( + resource_group_name=resource_group_name, + image_template_name=image_template_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ImageTemplate', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + image_template_name: str, + parameters: "_models.ImageTemplateUpdateParameters", + **kwargs + ) -> Optional["_models.ImageTemplate"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ImageTemplate"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ImageTemplateUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ImageTemplate', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + + async def begin_update( + self, + resource_group_name: str, + image_template_name: str, + parameters: "_models.ImageTemplateUpdateParameters", + **kwargs + ) -> AsyncLROPoller["_models.ImageTemplate"]: + """Update the tags for this Virtual Machine Image Template. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param image_template_name: The name of the image Template. + :type image_template_name: str + :param parameters: Additional parameters for Image Template update. + :type parameters: ~azure.mgmt.imagebuilder.models.ImageTemplateUpdateParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ImageTemplate or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.imagebuilder.models.ImageTemplate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageTemplate"] + 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._update_initial( + resource_group_name=resource_group_name, + image_template_name=image_template_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ImageTemplate', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + image_template_name: str, + **kwargs + ) -> "_models.ImageTemplate": + """Get information about a virtual machine image template. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param image_template_name: The name of the image Template. + :type image_template_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImageTemplate, or the result of cls(response) + :rtype: ~azure.mgmt.imagebuilder.models.ImageTemplate + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageTemplate"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ImageTemplate', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + image_template_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + + async def begin_delete( + self, + resource_group_name: str, + image_template_name: str, + **kwargs + ) -> AsyncLROPoller[None]: + """Delete a virtual machine image template. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param image_template_name: The name of the image Template. + :type image_template_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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( + resource_group_name=resource_group_name, + image_template_name=image_template_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + + async def _run_initial( + self, + resource_group_name: str, + image_template_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + accept = "application/json" + + # Construct URL + url = self._run_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _run_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/run'} # type: ignore + + async def begin_run( + self, + resource_group_name: str, + image_template_name: str, + **kwargs + ) -> AsyncLROPoller[None]: + """Create artifacts from a existing image template. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param image_template_name: The name of the image Template. + :type image_template_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._run_initial( + resource_group_name=resource_group_name, + image_template_name=image_template_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_run.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/run'} # type: ignore + + async def _cancel_initial( + self, + resource_group_name: str, + image_template_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + accept = "application/json" + + # Construct URL + url = self._cancel_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _cancel_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/cancel'} # type: ignore + + async def begin_cancel( + self, + resource_group_name: str, + image_template_name: str, + **kwargs + ) -> AsyncLROPoller[None]: + """Cancel the long running image build based on the image template. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param image_template_name: The name of the image Template. + :type image_template_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._cancel_initial( + resource_group_name=resource_group_name, + image_template_name=image_template_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/cancel'} # type: ignore + + def list_run_outputs( + self, + resource_group_name: str, + image_template_name: str, + **kwargs + ) -> AsyncIterable["_models.RunOutputCollection"]: + """List all run outputs for the specified Image Template resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param image_template_name: The name of the image Template. + :type image_template_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RunOutputCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.imagebuilder.models.RunOutputCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RunOutputCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_run_outputs.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('RunOutputCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_run_outputs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/runOutputs'} # type: ignore + + async def get_run_output( + self, + resource_group_name: str, + image_template_name: str, + run_output_name: str, + **kwargs + ) -> "_models.RunOutput": + """Get the specified run output for the specified image template resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param image_template_name: The name of the image Template. + :type image_template_name: str + :param run_output_name: The name of the run output. + :type run_output_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RunOutput, or the result of cls(response) + :rtype: ~azure.mgmt.imagebuilder.models.RunOutput + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RunOutput"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + accept = "application/json" + + # Construct URL + url = self.get_run_output.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + 'runOutputName': self._serialize.url("run_output_name", run_output_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RunOutput', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_run_output.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/runOutputs/{runOutputName}'} # type: ignore diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/__init__.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/__init__.py index e011581e72b0..f98fa0367af8 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/__init__.py +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/__init__.py @@ -1,24 +1,22 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: - from ._models_py3 import ApiError, ApiErrorException + from ._models_py3 import ApiError from ._models_py3 import ApiErrorBase + from ._models_py3 import ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties from ._models_py3 import ImageTemplate from ._models_py3 import ImageTemplateCustomizer from ._models_py3 import ImageTemplateDistributor from ._models_py3 import ImageTemplateFileCustomizer from ._models_py3 import ImageTemplateIdentity - from ._models_py3 import ImageTemplateIdentityUserAssignedIdentitiesValue from ._models_py3 import ImageTemplateLastRunStatus + from ._models_py3 import ImageTemplateListResult from ._models_py3 import ImageTemplateManagedImageDistributor from ._models_py3 import ImageTemplateManagedImageSource from ._models_py3 import ImageTemplatePlatformImageSource @@ -35,66 +33,70 @@ from ._models_py3 import InnerError from ._models_py3 import Operation from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult from ._models_py3 import PlatformImagePurchasePlan from ._models_py3 import ProvisioningError from ._models_py3 import Resource from ._models_py3 import RunOutput + from ._models_py3 import RunOutputCollection from ._models_py3 import SubResource from ._models_py3 import VirtualNetworkConfig except (SyntaxError, ImportError): - from ._models import ApiError, ApiErrorException - from ._models import ApiErrorBase - from ._models import ImageTemplate - from ._models import ImageTemplateCustomizer - from ._models import ImageTemplateDistributor - from ._models import ImageTemplateFileCustomizer - from ._models import ImageTemplateIdentity - from ._models import ImageTemplateIdentityUserAssignedIdentitiesValue - from ._models import ImageTemplateLastRunStatus - from ._models import ImageTemplateManagedImageDistributor - from ._models import ImageTemplateManagedImageSource - from ._models import ImageTemplatePlatformImageSource - from ._models import ImageTemplatePowerShellCustomizer - from ._models import ImageTemplateRestartCustomizer - from ._models import ImageTemplateSharedImageDistributor - from ._models import ImageTemplateSharedImageVersionSource - from ._models import ImageTemplateShellCustomizer - from ._models import ImageTemplateSource - from ._models import ImageTemplateUpdateParameters - from ._models import ImageTemplateVhdDistributor - from ._models import ImageTemplateVmProfile - from ._models import ImageTemplateWindowsUpdateCustomizer - from ._models import InnerError - from ._models import Operation - from ._models import OperationDisplay - from ._models import PlatformImagePurchasePlan - from ._models import ProvisioningError - from ._models import Resource - from ._models import RunOutput - from ._models import SubResource - from ._models import VirtualNetworkConfig -from ._paged_models import ImageTemplatePaged -from ._paged_models import OperationPaged -from ._paged_models import RunOutputPaged + from ._models import ApiError # type: ignore + from ._models import ApiErrorBase # type: ignore + from ._models import ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties # type: ignore + from ._models import ImageTemplate # type: ignore + from ._models import ImageTemplateCustomizer # type: ignore + from ._models import ImageTemplateDistributor # type: ignore + from ._models import ImageTemplateFileCustomizer # type: ignore + from ._models import ImageTemplateIdentity # type: ignore + from ._models import ImageTemplateLastRunStatus # type: ignore + from ._models import ImageTemplateListResult # type: ignore + from ._models import ImageTemplateManagedImageDistributor # type: ignore + from ._models import ImageTemplateManagedImageSource # type: ignore + from ._models import ImageTemplatePlatformImageSource # type: ignore + from ._models import ImageTemplatePowerShellCustomizer # type: ignore + from ._models import ImageTemplateRestartCustomizer # type: ignore + from ._models import ImageTemplateSharedImageDistributor # type: ignore + from ._models import ImageTemplateSharedImageVersionSource # type: ignore + from ._models import ImageTemplateShellCustomizer # type: ignore + from ._models import ImageTemplateSource # type: ignore + from ._models import ImageTemplateUpdateParameters # type: ignore + from ._models import ImageTemplateVhdDistributor # type: ignore + from ._models import ImageTemplateVmProfile # type: ignore + from ._models import ImageTemplateWindowsUpdateCustomizer # type: ignore + from ._models import InnerError # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import PlatformImagePurchasePlan # type: ignore + from ._models import ProvisioningError # type: ignore + from ._models import Resource # type: ignore + from ._models import RunOutput # type: ignore + from ._models import RunOutputCollection # type: ignore + from ._models import SubResource # type: ignore + from ._models import VirtualNetworkConfig # type: ignore + from ._image_builder_client_enums import ( - ProvisioningState, ProvisioningErrorCode, + ProvisioningState, + ResourceIdentityType, RunState, RunSubState, - ResourceIdentityType, SharedImageStorageAccountType, ) __all__ = [ - 'ApiError', 'ApiErrorException', + 'ApiError', 'ApiErrorBase', + 'ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties', 'ImageTemplate', 'ImageTemplateCustomizer', 'ImageTemplateDistributor', 'ImageTemplateFileCustomizer', 'ImageTemplateIdentity', - 'ImageTemplateIdentityUserAssignedIdentitiesValue', 'ImageTemplateLastRunStatus', + 'ImageTemplateListResult', 'ImageTemplateManagedImageDistributor', 'ImageTemplateManagedImageSource', 'ImageTemplatePlatformImageSource', @@ -111,19 +113,18 @@ 'InnerError', 'Operation', 'OperationDisplay', + 'OperationListResult', 'PlatformImagePurchasePlan', 'ProvisioningError', 'Resource', 'RunOutput', + 'RunOutputCollection', 'SubResource', 'VirtualNetworkConfig', - 'ImageTemplatePaged', - 'RunOutputPaged', - 'OperationPaged', - 'ProvisioningState', 'ProvisioningErrorCode', + 'ProvisioningState', + 'ResourceIdentityType', 'RunState', 'RunSubState', - 'ResourceIdentityType', 'SharedImageStorageAccountType', ] diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_image_builder_client_enums.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_image_builder_client_enums.py index bfdc57a957c6..d279f7cce478 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_image_builder_client_enums.py +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_image_builder_client_enums.py @@ -1,66 +1,89 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum - - -class ProvisioningState(str, Enum): - - creating = "Creating" - updating = "Updating" - succeeded = "Succeeded" - failed = "Failed" - deleting = "Deleting" - - -class ProvisioningErrorCode(str, Enum): - - bad_source_type = "BadSourceType" - bad_pir_source = "BadPIRSource" - bad_managed_image_source = "BadManagedImageSource" - bad_shared_image_version_source = "BadSharedImageVersionSource" - bad_customizer_type = "BadCustomizerType" - unsupported_customizer_type = "UnsupportedCustomizerType" - no_customizer_script = "NoCustomizerScript" - bad_distribute_type = "BadDistributeType" - bad_shared_image_distribute = "BadSharedImageDistribute" - server_error = "ServerError" - other = "Other" - - -class RunState(str, Enum): - - running = "Running" - canceling = "Canceling" - succeeded = "Succeeded" - partially_succeeded = "PartiallySucceeded" - failed = "Failed" - canceled = "Canceled" - - -class RunSubState(str, Enum): - - queued = "Queued" - building = "Building" - customizing = "Customizing" - distributing = "Distributing" - - -class ResourceIdentityType(str, Enum): - - user_assigned = "UserAssigned" - none = "None" - - -class SharedImageStorageAccountType(str, Enum): - - standard_lrs = "Standard_LRS" - standard_zrs = "Standard_ZRS" +from enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class ProvisioningErrorCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Error code of the provisioning failure + """ + + BAD_SOURCE_TYPE = "BadSourceType" + BAD_PIR_SOURCE = "BadPIRSource" + BAD_MANAGED_IMAGE_SOURCE = "BadManagedImageSource" + BAD_SHARED_IMAGE_VERSION_SOURCE = "BadSharedImageVersionSource" + BAD_CUSTOMIZER_TYPE = "BadCustomizerType" + UNSUPPORTED_CUSTOMIZER_TYPE = "UnsupportedCustomizerType" + NO_CUSTOMIZER_SCRIPT = "NoCustomizerScript" + BAD_DISTRIBUTE_TYPE = "BadDistributeType" + BAD_SHARED_IMAGE_DISTRIBUTE = "BadSharedImageDistribute" + SERVER_ERROR = "ServerError" + OTHER = "Other" + +class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Provisioning state of the resource + """ + + CREATING = "Creating" + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + +class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity used for the image template. The type 'None' will remove any identities + from the image template. + """ + + USER_ASSIGNED = "UserAssigned" + NONE = "None" + +class RunState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """State of the last run + """ + + RUNNING = "Running" + CANCELING = "Canceling" + SUCCEEDED = "Succeeded" + PARTIALLY_SUCCEEDED = "PartiallySucceeded" + FAILED = "Failed" + CANCELED = "Canceled" + +class RunSubState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Sub-state of the last run + """ + + QUEUED = "Queued" + BUILDING = "Building" + CUSTOMIZING = "Customizing" + DISTRIBUTING = "Distributing" + +class SharedImageStorageAccountType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Storage account type to be used to store the shared image. Omit to use the default + (Standard_LRS). + """ + + STANDARD_LRS = "Standard_LRS" + STANDARD_ZRS = "Standard_ZRS" diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_models.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_models.py index 870168107568..1be9c426eba6 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_models.py +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_models.py @@ -1,24 +1,21 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class ApiError(Model): +class ApiError(msrest.serialization.Model): """Api error. - :param details: The Api error details + :param details: The Api error details. :type details: list[~azure.mgmt.imagebuilder.models.ApiErrorBase] - :param inner_error: The Api inner error + :param inner_error: The Api inner error. :type inner_error: ~azure.mgmt.imagebuilder.models.InnerError :param code: The error code. :type code: str @@ -36,7 +33,10 @@ class ApiError(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiError, self).__init__(**kwargs) self.details = kwargs.get('details', None) self.inner_error = kwargs.get('inner_error', None) @@ -45,19 +45,7 @@ def __init__(self, **kwargs): self.message = kwargs.get('message', None) -class ApiErrorException(HttpOperationError): - """Server responsed with exception of type: 'ApiError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(ApiErrorException, self).__init__(deserialize, response, 'ApiError', *args) - - -class ApiErrorBase(Model): +class ApiErrorBase(msrest.serialization.Model): """Api error base. :param code: The error code. @@ -74,38 +62,62 @@ class ApiErrorBase(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiErrorBase, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.target = kwargs.get('target', None) self.message = kwargs.get('message', None) -class CloudError(Model): - """CloudError. +class ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): + """ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str """ + _validation = { + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, + } + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, } + def __init__( + self, + **kwargs + ): + super(ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None + -class Resource(Model): +class Resource(msrest.serialization.Model): """The Resource model definition. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Resource Id + :ivar id: Resource Id. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Required. Resource location + :param location: Required. Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -124,64 +136,56 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None self.type = None - self.location = kwargs.get('location', None) + self.location = kwargs['location'] self.tags = kwargs.get('tags', None) class ImageTemplate(Resource): - """Image template is an ARM resource managed by Microsoft.VirtualMachineImages - provider. + """Image template is an ARM resource managed by Microsoft.VirtualMachineImages provider. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Resource Id + :ivar id: Resource Id. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Required. Resource location + :param location: Required. Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] - :param source: Required. Specifies the properties used to describe the - source image. + :param identity: Required. The identity of the image template, if configured. + :type identity: ~azure.mgmt.imagebuilder.models.ImageTemplateIdentity + :param source: Specifies the properties used to describe the source image. :type source: ~azure.mgmt.imagebuilder.models.ImageTemplateSource - :param customize: Specifies the properties used to describe the - customization steps of the image, like Image source etc - :type customize: - list[~azure.mgmt.imagebuilder.models.ImageTemplateCustomizer] - :param distribute: Required. The distribution targets where the image - output needs to go to. - :type distribute: - list[~azure.mgmt.imagebuilder.models.ImageTemplateDistributor] - :ivar provisioning_state: Provisioning state of the resource. Possible - values include: 'Creating', 'Updating', 'Succeeded', 'Failed', 'Deleting' - :vartype provisioning_state: str or - ~azure.mgmt.imagebuilder.models.ProvisioningState - :ivar provisioning_error: Provisioning error, if any - :vartype provisioning_error: - ~azure.mgmt.imagebuilder.models.ProvisioningError - :ivar last_run_status: State of 'run' that is currently executing or was - last executed. - :vartype last_run_status: - ~azure.mgmt.imagebuilder.models.ImageTemplateLastRunStatus - :param build_timeout_in_minutes: Maximum duration to wait while building - the image template. Omit or specify 0 to use the default (4 hours). + :param customize: Specifies the properties used to describe the customization steps of the + image, like Image source etc. + :type customize: list[~azure.mgmt.imagebuilder.models.ImageTemplateCustomizer] + :param distribute: The distribution targets where the image output needs to go to. + :type distribute: list[~azure.mgmt.imagebuilder.models.ImageTemplateDistributor] + :ivar provisioning_state: Provisioning state of the resource. Possible values include: + "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :vartype provisioning_state: str or ~azure.mgmt.imagebuilder.models.ProvisioningState + :ivar provisioning_error: Provisioning error, if any. + :vartype provisioning_error: ~azure.mgmt.imagebuilder.models.ProvisioningError + :ivar last_run_status: State of 'run' that is currently executing or was last executed. + :vartype last_run_status: ~azure.mgmt.imagebuilder.models.ImageTemplateLastRunStatus + :param build_timeout_in_minutes: Maximum duration to wait while building the image template. + Omit or specify 0 to use the default (4 hours). :type build_timeout_in_minutes: int - :param vm_profile: Describes how virtual machine is set up to build images + :param vm_profile: Describes how virtual machine is set up to build images. :type vm_profile: ~azure.mgmt.imagebuilder.models.ImageTemplateVmProfile - :param identity: Required. The identity of the image template, if - configured. - :type identity: ~azure.mgmt.imagebuilder.models.ImageTemplateIdentity """ _validation = { @@ -189,13 +193,11 @@ class ImageTemplate(Resource): 'name': {'readonly': True}, 'type': {'readonly': True}, 'location': {'required': True}, - 'source': {'required': True}, - 'distribute': {'required': True}, + 'identity': {'required': True}, 'provisioning_state': {'readonly': True}, 'provisioning_error': {'readonly': True}, 'last_run_status': {'readonly': True}, 'build_timeout_in_minutes': {'maximum': 960, 'minimum': 0}, - 'identity': {'required': True}, } _attribute_map = { @@ -204,45 +206,46 @@ class ImageTemplate(Resource): 'type': {'key': 'type', 'type': 'str'}, 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, + 'identity': {'key': 'identity', 'type': 'ImageTemplateIdentity'}, 'source': {'key': 'properties.source', 'type': 'ImageTemplateSource'}, 'customize': {'key': 'properties.customize', 'type': '[ImageTemplateCustomizer]'}, 'distribute': {'key': 'properties.distribute', 'type': '[ImageTemplateDistributor]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'ProvisioningState'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, 'provisioning_error': {'key': 'properties.provisioningError', 'type': 'ProvisioningError'}, 'last_run_status': {'key': 'properties.lastRunStatus', 'type': 'ImageTemplateLastRunStatus'}, 'build_timeout_in_minutes': {'key': 'properties.buildTimeoutInMinutes', 'type': 'int'}, 'vm_profile': {'key': 'properties.vmProfile', 'type': 'ImageTemplateVmProfile'}, - 'identity': {'key': 'identity', 'type': 'ImageTemplateIdentity'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ImageTemplate, self).__init__(**kwargs) + self.identity = kwargs['identity'] self.source = kwargs.get('source', None) self.customize = kwargs.get('customize', None) self.distribute = kwargs.get('distribute', None) self.provisioning_state = None self.provisioning_error = None self.last_run_status = None - self.build_timeout_in_minutes = kwargs.get('build_timeout_in_minutes', None) + self.build_timeout_in_minutes = kwargs.get('build_timeout_in_minutes', 0) self.vm_profile = kwargs.get('vm_profile', None) - self.identity = kwargs.get('identity', None) -class ImageTemplateCustomizer(Model): +class ImageTemplateCustomizer(msrest.serialization.Model): """Describes a unit of image customization. You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ImageTemplateShellCustomizer, - ImageTemplateRestartCustomizer, ImageTemplateWindowsUpdateCustomizer, - ImageTemplatePowerShellCustomizer, ImageTemplateFileCustomizer + sub-classes are: ImageTemplateFileCustomizer, ImageTemplatePowerShellCustomizer, ImageTemplateShellCustomizer, ImageTemplateRestartCustomizer, ImageTemplateWindowsUpdateCustomizer. All required parameters must be populated in order to send to Azure. - :param name: Friendly Name to provide context on what this customization - step does - :type name: str - :param type: Required. Constant filled by server. + :param type: Required. The type of customization tool you want to use on the Image. For + example, "Shell" can be shell customizer.Constant filled by server. :type type: str + :param name: Friendly Name to provide context on what this customization step does. + :type name: str """ _validation = { @@ -250,81 +253,82 @@ class ImageTemplateCustomizer(Model): } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, } _subtype_map = { - 'type': {'Shell': 'ImageTemplateShellCustomizer', 'WindowsRestart': 'ImageTemplateRestartCustomizer', 'WindowsUpdate': 'ImageTemplateWindowsUpdateCustomizer', 'PowerShell': 'ImageTemplatePowerShellCustomizer', 'File': 'ImageTemplateFileCustomizer'} + 'type': {'File': 'ImageTemplateFileCustomizer', 'PowerShell': 'ImageTemplatePowerShellCustomizer', 'Shell': 'ImageTemplateShellCustomizer', 'WindowsRestart': 'ImageTemplateRestartCustomizer', 'WindowsUpdate': 'ImageTemplateWindowsUpdateCustomizer'} } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ImageTemplateCustomizer, self).__init__(**kwargs) + self.type = None # type: Optional[str] self.name = kwargs.get('name', None) - self.type = None -class ImageTemplateDistributor(Model): +class ImageTemplateDistributor(msrest.serialization.Model): """Generic distribution object. You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ImageTemplateManagedImageDistributor, - ImageTemplateSharedImageDistributor, ImageTemplateVhdDistributor + sub-classes are: ImageTemplateManagedImageDistributor, ImageTemplateSharedImageDistributor, ImageTemplateVhdDistributor. All required parameters must be populated in order to send to Azure. - :param run_output_name: Required. The name to be used for the associated - RunOutput. + :param type: Required. Type of distribution.Constant filled by server. + :type type: str + :param run_output_name: Required. The name to be used for the associated RunOutput. :type run_output_name: str - :param artifact_tags: Tags that will be applied to the artifact once it - has been created/updated by the distributor. + :param artifact_tags: Tags that will be applied to the artifact once it has been + created/updated by the distributor. :type artifact_tags: dict[str, str] - :param type: Required. Constant filled by server. - :type type: str """ _validation = { - 'run_output_name': {'required': True, 'pattern': r'^[A-Za-z0-9-_.]{1,64}$'}, 'type': {'required': True}, + 'run_output_name': {'required': True, 'pattern': r'^[A-Za-z0-9-_.]{1,64}$'}, } _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, 'run_output_name': {'key': 'runOutputName', 'type': 'str'}, 'artifact_tags': {'key': 'artifactTags', 'type': '{str}'}, - 'type': {'key': 'type', 'type': 'str'}, } _subtype_map = { 'type': {'ManagedImage': 'ImageTemplateManagedImageDistributor', 'SharedImage': 'ImageTemplateSharedImageDistributor', 'VHD': 'ImageTemplateVhdDistributor'} } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ImageTemplateDistributor, self).__init__(**kwargs) - self.run_output_name = kwargs.get('run_output_name', None) + self.type = None # type: Optional[str] + self.run_output_name = kwargs['run_output_name'] self.artifact_tags = kwargs.get('artifact_tags', None) - self.type = None class ImageTemplateFileCustomizer(ImageTemplateCustomizer): - """Uploads files to VMs (Linux, Windows). Corresponds to Packer file - provisioner. + """Uploads files to VMs (Linux, Windows). Corresponds to Packer file provisioner. All required parameters must be populated in order to send to Azure. - :param name: Friendly Name to provide context on what this customization - step does - :type name: str - :param type: Required. Constant filled by server. + :param type: Required. The type of customization tool you want to use on the Image. For + example, "Shell" can be shell customizer.Constant filled by server. :type type: str - :param source_uri: The URI of the file to be uploaded for customizing the - VM. It can be a github link, SAS URI for Azure Storage, etc + :param name: Friendly Name to provide context on what this customization step does. + :type name: str + :param source_uri: The URI of the file to be uploaded for customizing the VM. It can be a + github link, SAS URI for Azure Storage, etc. :type source_uri: str - :param sha256_checksum: SHA256 checksum of the file provided in the - sourceUri field above + :param sha256_checksum: SHA256 checksum of the file provided in the sourceUri field above. :type sha256_checksum: str - :param destination: The absolute path to a file (with nested directory - structures already created) where the file (from sourceUri) will be - uploaded to in the VM + :param destination: The absolute path to a file (with nested directory structures already + created) where the file (from sourceUri) will be uploaded to in the VM. :type destination: str """ @@ -333,101 +337,80 @@ class ImageTemplateFileCustomizer(ImageTemplateCustomizer): } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'source_uri': {'key': 'sourceUri', 'type': 'str'}, 'sha256_checksum': {'key': 'sha256Checksum', 'type': 'str'}, 'destination': {'key': 'destination', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ImageTemplateFileCustomizer, self).__init__(**kwargs) + self.type = 'File' # type: str self.source_uri = kwargs.get('source_uri', None) - self.sha256_checksum = kwargs.get('sha256_checksum', None) + self.sha256_checksum = kwargs.get('sha256_checksum', "") self.destination = kwargs.get('destination', None) - self.type = 'File' -class ImageTemplateIdentity(Model): +class ImageTemplateIdentity(msrest.serialization.Model): """Identity for the image template. - :param type: The type of identity used for the image template. Possible - values include: 'UserAssigned' + :param type: The type of identity used for the image template. The type 'None' will remove any + identities from the image template. Possible values include: "UserAssigned", "None". :type type: str or ~azure.mgmt.imagebuilder.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated - with the image template. The user identity dictionary key references will - be ARM resource ids in the form: + :param user_assigned_identities: The list of user identities associated with the image + template. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. :type user_assigned_identities: dict[str, - ~azure.mgmt.imagebuilder.models.ImageTemplateIdentityUserAssignedIdentitiesValue] + ~azure.mgmt.imagebuilder.models.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties] """ _attribute_map = { - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ImageTemplateIdentityUserAssignedIdentitiesValue}'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ImageTemplateIdentity, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.user_assigned_identities = kwargs.get('user_assigned_identities', None) -class ImageTemplateIdentityUserAssignedIdentitiesValue(Model): - """ImageTemplateIdentityUserAssignedIdentitiesValue. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar principal_id: The principal id of user assigned identity. - :vartype principal_id: str - :ivar client_id: The client id of user assigned identity. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(ImageTemplateIdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class ImageTemplateLastRunStatus(Model): +class ImageTemplateLastRunStatus(msrest.serialization.Model): """Describes the latest status of running an image template. - :param start_time: Start time of the last run (UTC) - :type start_time: datetime - :param end_time: End time of the last run (UTC) - :type end_time: datetime - :param run_state: State of the last run. Possible values include: - 'Running', 'Canceling', 'Succeeded', 'PartiallySucceeded', 'Failed', - 'Canceled' + :param start_time: Start time of the last run (UTC). + :type start_time: ~datetime.datetime + :param end_time: End time of the last run (UTC). + :type end_time: ~datetime.datetime + :param run_state: State of the last run. Possible values include: "Running", "Canceling", + "Succeeded", "PartiallySucceeded", "Failed", "Canceled". :type run_state: str or ~azure.mgmt.imagebuilder.models.RunState - :param run_sub_state: Sub-state of the last run. Possible values include: - 'Queued', 'Building', 'Customizing', 'Distributing' + :param run_sub_state: Sub-state of the last run. Possible values include: "Queued", "Building", + "Customizing", "Distributing". :type run_sub_state: str or ~azure.mgmt.imagebuilder.models.RunSubState - :param message: Verbose information about the last run state + :param message: Verbose information about the last run state. :type message: str """ _attribute_map = { 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'run_state': {'key': 'runState', 'type': 'RunState'}, - 'run_sub_state': {'key': 'runSubState', 'type': 'RunSubState'}, + 'run_state': {'key': 'runState', 'type': 'str'}, + 'run_sub_state': {'key': 'runSubState', 'type': 'str'}, 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ImageTemplateLastRunStatus, self).__init__(**kwargs) self.start_time = kwargs.get('start_time', None) self.end_time = kwargs.get('end_time', None) @@ -436,59 +419,82 @@ def __init__(self, **kwargs): self.message = kwargs.get('message', None) +class ImageTemplateListResult(msrest.serialization.Model): + """The result of List image templates operation. + + :param value: An array of image templates. + :type value: list[~azure.mgmt.imagebuilder.models.ImageTemplate] + :param next_link: The continuation token. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ImageTemplate]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ImageTemplateListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + class ImageTemplateManagedImageDistributor(ImageTemplateDistributor): """Distribute as a Managed Disk Image. All required parameters must be populated in order to send to Azure. - :param run_output_name: Required. The name to be used for the associated - RunOutput. + :param type: Required. Type of distribution.Constant filled by server. + :type type: str + :param run_output_name: Required. The name to be used for the associated RunOutput. :type run_output_name: str - :param artifact_tags: Tags that will be applied to the artifact once it - has been created/updated by the distributor. + :param artifact_tags: Tags that will be applied to the artifact once it has been + created/updated by the distributor. :type artifact_tags: dict[str, str] - :param type: Required. Constant filled by server. - :type type: str - :param image_id: Required. Resource Id of the Managed Disk Image + :param image_id: Required. Resource Id of the Managed Disk Image. :type image_id: str - :param location: Required. Azure location for the image, should match if - image already exists + :param location: Required. Azure location for the image, should match if image already exists. :type location: str """ _validation = { - 'run_output_name': {'required': True, 'pattern': r'^[A-Za-z0-9-_.]{1,64}$'}, 'type': {'required': True}, + 'run_output_name': {'required': True, 'pattern': r'^[A-Za-z0-9-_.]{1,64}$'}, 'image_id': {'required': True}, 'location': {'required': True}, } _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, 'run_output_name': {'key': 'runOutputName', 'type': 'str'}, 'artifact_tags': {'key': 'artifactTags', 'type': '{str}'}, - 'type': {'key': 'type', 'type': 'str'}, 'image_id': {'key': 'imageId', 'type': 'str'}, 'location': {'key': 'location', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ImageTemplateManagedImageDistributor, self).__init__(**kwargs) - self.image_id = kwargs.get('image_id', None) - self.location = kwargs.get('location', None) - self.type = 'ManagedImage' + self.type = 'ManagedImage' # type: str + self.image_id = kwargs['image_id'] + self.location = kwargs['location'] -class ImageTemplateSource(Model): - """Describes a virtual machine image source for building, customizing and - distributing. +class ImageTemplateSource(msrest.serialization.Model): + """Describes a virtual machine image source for building, customizing and distributing. You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ImageTemplatePlatformImageSource, - ImageTemplateManagedImageSource, ImageTemplateSharedImageVersionSource + sub-classes are: ImageTemplateManagedImageSource, ImageTemplatePlatformImageSource, ImageTemplateSharedImageVersionSource. All required parameters must be populated in order to send to Azure. - :param type: Required. Constant filled by server. + :param type: Required. Specifies the type of source image you want to start with.Constant + filled by server. :type type: str """ @@ -501,12 +507,15 @@ class ImageTemplateSource(Model): } _subtype_map = { - 'type': {'PlatformImage': 'ImageTemplatePlatformImageSource', 'ManagedImage': 'ImageTemplateManagedImageSource', 'SharedImageVersion': 'ImageTemplateSharedImageVersionSource'} + 'type': {'ManagedImage': 'ImageTemplateManagedImageSource', 'PlatformImage': 'ImageTemplatePlatformImageSource', 'SharedImageVersion': 'ImageTemplateSharedImageVersionSource'} } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ImageTemplateSource, self).__init__(**kwargs) - self.type = None + self.type = None # type: Optional[str] class ImageTemplateManagedImageSource(ImageTemplateSource): @@ -514,10 +523,10 @@ class ImageTemplateManagedImageSource(ImageTemplateSource): All required parameters must be populated in order to send to Azure. - :param type: Required. Constant filled by server. + :param type: Required. Specifies the type of source image you want to start with.Constant + filled by server. :type type: str - :param image_id: Required. ARM resource id of the managed image in - customer subscription + :param image_id: Required. ARM resource id of the managed image in customer subscription. :type image_id: str """ @@ -531,34 +540,39 @@ class ImageTemplateManagedImageSource(ImageTemplateSource): 'image_id': {'key': 'imageId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ImageTemplateManagedImageSource, self).__init__(**kwargs) - self.image_id = kwargs.get('image_id', None) - self.type = 'ManagedImage' + self.type = 'ManagedImage' # type: str + self.image_id = kwargs['image_id'] class ImageTemplatePlatformImageSource(ImageTemplateSource): - """Describes an image source from [Azure Gallery - Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). + """Describes an image source from `Azure Gallery Images `_. All required parameters must be populated in order to send to Azure. - :param type: Required. Constant filled by server. + :param type: Required. Specifies the type of source image you want to start with.Constant + filled by server. :type type: str - :param publisher: Image Publisher in [Azure Gallery - Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). + :param publisher: Image Publisher in `Azure Gallery Images + `_. :type publisher: str - :param offer: Image offer from the [Azure Gallery - Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). + :param offer: Image offer from the `Azure Gallery Images + `_. :type offer: str - :param sku: Image sku from the [Azure Gallery - Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). + :param sku: Image sku from the `Azure Gallery Images + `_. :type sku: str - :param version: Image version from the [Azure Gallery - Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). + :param version: Image version from the `Azure Gallery Images + `_. If 'latest' is + specified here, the version is evaluated when the image build takes place, not when the + template is submitted. Specifying 'latest' could cause ROUNDTRIP_INCONSISTENT_PROPERTY issue + which will be fixed. :type version: str - :param plan_info: Optional configuration of purchase plan for platform - image. + :param plan_info: Optional configuration of purchase plan for platform image. :type plan_info: ~azure.mgmt.imagebuilder.models.PlatformImagePurchasePlan """ @@ -575,41 +589,43 @@ class ImageTemplatePlatformImageSource(ImageTemplateSource): 'plan_info': {'key': 'planInfo', 'type': 'PlatformImagePurchasePlan'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ImageTemplatePlatformImageSource, self).__init__(**kwargs) + self.type = 'PlatformImage' # type: str self.publisher = kwargs.get('publisher', None) self.offer = kwargs.get('offer', None) self.sku = kwargs.get('sku', None) self.version = kwargs.get('version', None) self.plan_info = kwargs.get('plan_info', None) - self.type = 'PlatformImage' class ImageTemplatePowerShellCustomizer(ImageTemplateCustomizer): - """Runs the specified PowerShell on the VM (Windows). Corresponds to Packer - powershell provisioner. Exactly one of 'scriptUri' or 'inline' can be - specified. + """Runs the specified PowerShell on the VM (Windows). Corresponds to Packer powershell provisioner. Exactly one of 'scriptUri' or 'inline' can be specified. All required parameters must be populated in order to send to Azure. - :param name: Friendly Name to provide context on what this customization - step does - :type name: str - :param type: Required. Constant filled by server. + :param type: Required. The type of customization tool you want to use on the Image. For + example, "Shell" can be shell customizer.Constant filled by server. :type type: str - :param script_uri: URI of the PowerShell script to be run for customizing. - It can be a github link, SAS URI for Azure Storage, etc + :param name: Friendly Name to provide context on what this customization step does. + :type name: str + :param script_uri: URI of the PowerShell script to be run for customizing. It can be a github + link, SAS URI for Azure Storage, etc. :type script_uri: str - :param sha256_checksum: SHA256 checksum of the power shell script provided - in the scriptUri field above + :param sha256_checksum: SHA256 checksum of the power shell script provided in the scriptUri + field above. :type sha256_checksum: str - :param inline: Array of PowerShell commands to execute + :param inline: Array of PowerShell commands to execute. :type inline: list[str] - :param run_elevated: If specified, the PowerShell script will be run with - elevated privileges + :param run_elevated: If specified, the PowerShell script will be run with elevated privileges. :type run_elevated: bool - :param valid_exit_codes: Valid exit codes for the PowerShell script. - [Default: 0] + :param run_as_system: If specified, the PowerShell script will be run with elevated privileges + using the Local System user. Can only be true when the runElevated field above is set to true. + :type run_as_system: bool + :param valid_exit_codes: Valid exit codes for the PowerShell script. [Default: 0]. :type valid_exit_codes: list[int] """ @@ -618,44 +634,47 @@ class ImageTemplatePowerShellCustomizer(ImageTemplateCustomizer): } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'script_uri': {'key': 'scriptUri', 'type': 'str'}, 'sha256_checksum': {'key': 'sha256Checksum', 'type': 'str'}, 'inline': {'key': 'inline', 'type': '[str]'}, 'run_elevated': {'key': 'runElevated', 'type': 'bool'}, + 'run_as_system': {'key': 'runAsSystem', 'type': 'bool'}, 'valid_exit_codes': {'key': 'validExitCodes', 'type': '[int]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ImageTemplatePowerShellCustomizer, self).__init__(**kwargs) + self.type = 'PowerShell' # type: str self.script_uri = kwargs.get('script_uri', None) - self.sha256_checksum = kwargs.get('sha256_checksum', None) + self.sha256_checksum = kwargs.get('sha256_checksum', "") self.inline = kwargs.get('inline', None) - self.run_elevated = kwargs.get('run_elevated', None) + self.run_elevated = kwargs.get('run_elevated', False) + self.run_as_system = kwargs.get('run_as_system', False) self.valid_exit_codes = kwargs.get('valid_exit_codes', None) - self.type = 'PowerShell' class ImageTemplateRestartCustomizer(ImageTemplateCustomizer): - """Reboots a VM and waits for it to come back online (Windows). Corresponds to - Packer windows-restart provisioner. + """Reboots a VM and waits for it to come back online (Windows). Corresponds to Packer windows-restart provisioner. All required parameters must be populated in order to send to Azure. - :param name: Friendly Name to provide context on what this customization - step does - :type name: str - :param type: Required. Constant filled by server. + :param type: Required. The type of customization tool you want to use on the Image. For + example, "Shell" can be shell customizer.Constant filled by server. :type type: str - :param restart_command: Command to execute the restart [Default: 'shutdown - /r /f /t 0 /c "packer restart"'] + :param name: Friendly Name to provide context on what this customization step does. + :type name: str + :param restart_command: Command to execute the restart [Default: 'shutdown /r /f /t 0 /c + "packer restart"']. :type restart_command: str - :param restart_check_command: Command to check if restart succeeded - [Default: ''] + :param restart_check_command: Command to check if restart succeeded [Default: '']. :type restart_check_command: str - :param restart_timeout: Restart timeout specified as a string of magnitude - and unit, e.g. '5m' (5 minutes) or '2h' (2 hours) [Default: '5m'] + :param restart_timeout: Restart timeout specified as a string of magnitude and unit, e.g. '5m' + (5 minutes) or '2h' (2 hours) [Default: '5m']. :type restart_timeout: str """ @@ -664,19 +683,22 @@ class ImageTemplateRestartCustomizer(ImageTemplateCustomizer): } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'restart_command': {'key': 'restartCommand', 'type': 'str'}, 'restart_check_command': {'key': 'restartCheckCommand', 'type': 'str'}, 'restart_timeout': {'key': 'restartTimeout', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ImageTemplateRestartCustomizer, self).__init__(**kwargs) + self.type = 'WindowsRestart' # type: str self.restart_command = kwargs.get('restart_command', None) self.restart_check_command = kwargs.get('restart_check_command', None) self.restart_timeout = kwargs.get('restart_timeout', None) - self.type = 'WindowsRestart' class ImageTemplateSharedImageDistributor(ImageTemplateDistributor): @@ -684,66 +706,65 @@ class ImageTemplateSharedImageDistributor(ImageTemplateDistributor): All required parameters must be populated in order to send to Azure. - :param run_output_name: Required. The name to be used for the associated - RunOutput. + :param type: Required. Type of distribution.Constant filled by server. + :type type: str + :param run_output_name: Required. The name to be used for the associated RunOutput. :type run_output_name: str - :param artifact_tags: Tags that will be applied to the artifact once it - has been created/updated by the distributor. + :param artifact_tags: Tags that will be applied to the artifact once it has been + created/updated by the distributor. :type artifact_tags: dict[str, str] - :param type: Required. Constant filled by server. - :type type: str - :param gallery_image_id: Required. Resource Id of the Shared Image Gallery - image + :param gallery_image_id: Required. Resource Id of the Shared Image Gallery image. :type gallery_image_id: str - :param replication_regions: Required. A list of regions that the image - will be replicated to + :param replication_regions: Required. A list of regions that the image will be replicated to. :type replication_regions: list[str] - :param exclude_from_latest: Flag that indicates whether created image - version should be excluded from latest. Omit to use the default (false). + :param exclude_from_latest: Flag that indicates whether created image version should be + excluded from latest. Omit to use the default (false). :type exclude_from_latest: bool - :param storage_account_type: Storage account type to be used to store the - shared image. Omit to use the default (Standard_LRS). Possible values - include: 'Standard_LRS', 'Standard_ZRS' + :param storage_account_type: Storage account type to be used to store the shared image. Omit to + use the default (Standard_LRS). Possible values include: "Standard_LRS", "Standard_ZRS". :type storage_account_type: str or ~azure.mgmt.imagebuilder.models.SharedImageStorageAccountType """ _validation = { - 'run_output_name': {'required': True, 'pattern': r'^[A-Za-z0-9-_.]{1,64}$'}, 'type': {'required': True}, + 'run_output_name': {'required': True, 'pattern': r'^[A-Za-z0-9-_.]{1,64}$'}, 'gallery_image_id': {'required': True}, 'replication_regions': {'required': True}, } _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, 'run_output_name': {'key': 'runOutputName', 'type': 'str'}, 'artifact_tags': {'key': 'artifactTags', 'type': '{str}'}, - 'type': {'key': 'type', 'type': 'str'}, 'gallery_image_id': {'key': 'galleryImageId', 'type': 'str'}, 'replication_regions': {'key': 'replicationRegions', 'type': '[str]'}, 'exclude_from_latest': {'key': 'excludeFromLatest', 'type': 'bool'}, 'storage_account_type': {'key': 'storageAccountType', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ImageTemplateSharedImageDistributor, self).__init__(**kwargs) - self.gallery_image_id = kwargs.get('gallery_image_id', None) - self.replication_regions = kwargs.get('replication_regions', None) - self.exclude_from_latest = kwargs.get('exclude_from_latest', None) + self.type = 'SharedImage' # type: str + self.gallery_image_id = kwargs['gallery_image_id'] + self.replication_regions = kwargs['replication_regions'] + self.exclude_from_latest = kwargs.get('exclude_from_latest', False) self.storage_account_type = kwargs.get('storage_account_type', None) - self.type = 'SharedImage' class ImageTemplateSharedImageVersionSource(ImageTemplateSource): - """Describes an image source that is an image version in a shared image - gallery. + """Describes an image source that is an image version in a shared image gallery. All required parameters must be populated in order to send to Azure. - :param type: Required. Constant filled by server. + :param type: Required. Specifies the type of source image you want to start with.Constant + filled by server. :type type: str - :param image_version_id: Required. ARM resource id of the image version in - the shared image gallery + :param image_version_id: Required. ARM resource id of the image version in the shared image + gallery. :type image_version_id: str """ @@ -757,31 +778,31 @@ class ImageTemplateSharedImageVersionSource(ImageTemplateSource): 'image_version_id': {'key': 'imageVersionId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ImageTemplateSharedImageVersionSource, self).__init__(**kwargs) - self.image_version_id = kwargs.get('image_version_id', None) - self.type = 'SharedImageVersion' + self.type = 'SharedImageVersion' # type: str + self.image_version_id = kwargs['image_version_id'] class ImageTemplateShellCustomizer(ImageTemplateCustomizer): - """Runs a shell script during the customization phase (Linux). Corresponds to - Packer shell provisioner. Exactly one of 'scriptUri' or 'inline' can be - specified. + """Runs a shell script during the customization phase (Linux). Corresponds to Packer shell provisioner. Exactly one of 'scriptUri' or 'inline' can be specified. All required parameters must be populated in order to send to Azure. - :param name: Friendly Name to provide context on what this customization - step does - :type name: str - :param type: Required. Constant filled by server. + :param type: Required. The type of customization tool you want to use on the Image. For + example, "Shell" can be shell customizer.Constant filled by server. :type type: str - :param script_uri: URI of the shell script to be run for customizing. It - can be a github link, SAS URI for Azure Storage, etc + :param name: Friendly Name to provide context on what this customization step does. + :type name: str + :param script_uri: URI of the shell script to be run for customizing. It can be a github link, + SAS URI for Azure Storage, etc. :type script_uri: str - :param sha256_checksum: SHA256 checksum of the shell script provided in - the scriptUri field + :param sha256_checksum: SHA256 checksum of the shell script provided in the scriptUri field. :type sha256_checksum: str - :param inline: Array of shell commands to execute + :param inline: Array of shell commands to execute. :type inline: list[str] """ @@ -790,27 +811,30 @@ class ImageTemplateShellCustomizer(ImageTemplateCustomizer): } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'script_uri': {'key': 'scriptUri', 'type': 'str'}, 'sha256_checksum': {'key': 'sha256Checksum', 'type': 'str'}, 'inline': {'key': 'inline', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ImageTemplateShellCustomizer, self).__init__(**kwargs) + self.type = 'Shell' # type: str self.script_uri = kwargs.get('script_uri', None) - self.sha256_checksum = kwargs.get('sha256_checksum', None) + self.sha256_checksum = kwargs.get('sha256_checksum', "") self.inline = kwargs.get('inline', None) - self.type = 'Shell' -class ImageTemplateUpdateParameters(Model): +class ImageTemplateUpdateParameters(msrest.serialization.Model): """Parameters for updating an image template. :param identity: The identity of the image template, if configured. :type identity: ~azure.mgmt.imagebuilder.models.ImageTemplateIdentity - :param tags: The user-specified tags associated with the image template. + :param tags: A set of tags. The user-specified tags associated with the image template. :type tags: dict[str, str] """ @@ -819,7 +843,10 @@ class ImageTemplateUpdateParameters(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ImageTemplateUpdateParameters, self).__init__(**kwargs) self.identity = kwargs.get('identity', None) self.tags = kwargs.get('tags', None) @@ -830,45 +857,45 @@ class ImageTemplateVhdDistributor(ImageTemplateDistributor): All required parameters must be populated in order to send to Azure. - :param run_output_name: Required. The name to be used for the associated - RunOutput. + :param type: Required. Type of distribution.Constant filled by server. + :type type: str + :param run_output_name: Required. The name to be used for the associated RunOutput. :type run_output_name: str - :param artifact_tags: Tags that will be applied to the artifact once it - has been created/updated by the distributor. + :param artifact_tags: Tags that will be applied to the artifact once it has been + created/updated by the distributor. :type artifact_tags: dict[str, str] - :param type: Required. Constant filled by server. - :type type: str """ _validation = { - 'run_output_name': {'required': True, 'pattern': r'^[A-Za-z0-9-_.]{1,64}$'}, 'type': {'required': True}, + 'run_output_name': {'required': True, 'pattern': r'^[A-Za-z0-9-_.]{1,64}$'}, } _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, 'run_output_name': {'key': 'runOutputName', 'type': 'str'}, 'artifact_tags': {'key': 'artifactTags', 'type': '{str}'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ImageTemplateVhdDistributor, self).__init__(**kwargs) - self.type = 'VHD' + self.type = 'VHD' # type: str -class ImageTemplateVmProfile(Model): +class ImageTemplateVmProfile(msrest.serialization.Model): """Describes the virtual machine used to build, customize and capture images. - :param vm_size: Size of the virtual machine used to build, customize and - capture images. Omit or specify empty string to use the default - (Standard_D1_v2). + :param vm_size: Size of the virtual machine used to build, customize and capture images. Omit + or specify empty string to use the default (Standard_D1_v2). :type vm_size: str - :param os_disk_size_gb: Size of the OS disk in GB. Omit or specify 0 to - use Azure's default OS disk size. + :param os_disk_size_gb: Size of the OS disk in GB. Omit or specify 0 to use Azure's default OS + disk size. :type os_disk_size_gb: int - :param vnet_config: Optional configuration of the virtual network to use - to deploy the build virtual machine in. Omit if no specific virtual - network needs to be used. + :param vnet_config: Optional configuration of the virtual network to use to deploy the build + virtual machine in. Omit if no specific virtual network needs to be used. :type vnet_config: ~azure.mgmt.imagebuilder.models.VirtualNetworkConfig """ @@ -882,34 +909,35 @@ class ImageTemplateVmProfile(Model): 'vnet_config': {'key': 'vnetConfig', 'type': 'VirtualNetworkConfig'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ImageTemplateVmProfile, self).__init__(**kwargs) - self.vm_size = kwargs.get('vm_size', None) - self.os_disk_size_gb = kwargs.get('os_disk_size_gb', None) + self.vm_size = kwargs.get('vm_size', "") + self.os_disk_size_gb = kwargs.get('os_disk_size_gb', 0) self.vnet_config = kwargs.get('vnet_config', None) class ImageTemplateWindowsUpdateCustomizer(ImageTemplateCustomizer): - """Installs Windows Updates. Corresponds to Packer Windows Update Provisioner - (https://github.com/rgl/packer-provisioner-windows-update). + """Installs Windows Updates. Corresponds to Packer Windows Update Provisioner (https://github.com/rgl/packer-provisioner-windows-update). All required parameters must be populated in order to send to Azure. - :param name: Friendly Name to provide context on what this customization - step does - :type name: str - :param type: Required. Constant filled by server. + :param type: Required. The type of customization tool you want to use on the Image. For + example, "Shell" can be shell customizer.Constant filled by server. :type type: str - :param search_criteria: Criteria to search updates. Omit or specify empty - string to use the default (search all). Refer to above link for examples - and detailed description of this field. + :param name: Friendly Name to provide context on what this customization step does. + :type name: str + :param search_criteria: Criteria to search updates. Omit or specify empty string to use the + default (search all). Refer to above link for examples and detailed description of this field. :type search_criteria: str - :param filters: Array of filters to select updates to apply. Omit or - specify empty array to use the default (no filter). Refer to above link - for examples and detailed description of this field. + :param filters: Array of filters to select updates to apply. Omit or specify empty array to use + the default (no filter). Refer to above link for examples and detailed description of this + field. :type filters: list[str] - :param update_limit: Maximum number of updates to apply at a time. Omit or - specify 0 to use the default (1000) + :param update_limit: Maximum number of updates to apply at a time. Omit or specify 0 to use the + default (1000). :type update_limit: int """ @@ -919,22 +947,25 @@ class ImageTemplateWindowsUpdateCustomizer(ImageTemplateCustomizer): } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'search_criteria': {'key': 'searchCriteria', 'type': 'str'}, 'filters': {'key': 'filters', 'type': '[str]'}, 'update_limit': {'key': 'updateLimit', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ImageTemplateWindowsUpdateCustomizer, self).__init__(**kwargs) + self.type = 'WindowsUpdate' # type: str self.search_criteria = kwargs.get('search_criteria', None) self.filters = kwargs.get('filters', None) self.update_limit = kwargs.get('update_limit', None) - self.type = 'WindowsUpdate' -class InnerError(Model): +class InnerError(msrest.serialization.Model): """Inner error details. :param exception_type: The exception type. @@ -948,26 +979,27 @@ class InnerError(Model): 'error_detail': {'key': 'errorDetail', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(InnerError, self).__init__(**kwargs) self.exception_type = kwargs.get('exception_type', None) self.error_detail = kwargs.get('error_detail', None) -class Operation(Model): +class Operation(msrest.serialization.Model): """A REST API operation. - :param name: The operation name. This is of the format - {provider}/{resource}/{operation} + :param name: This is of the format {provider}/{resource}/{operation}. :type name: str :param display: The object that describes the operation. :type display: ~azure.mgmt.imagebuilder.models.OperationDisplay :param origin: The intended executor of the operation. :type origin: str - :param properties: Properties of the operation. - :type properties: object - :param is_data_action: The flag that indicates whether the operation - applies to data plane. + :param properties: Any object. + :type properties: str + :param is_data_action: The flag that indicates whether the operation applies to data plane. :type is_data_action: bool """ @@ -975,11 +1007,14 @@ class Operation(Model): 'name': {'key': 'name', 'type': 'str'}, 'display': {'key': 'display', 'type': 'OperationDisplay'}, 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'object'}, + 'properties': {'key': 'properties', 'type': 'str'}, 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -988,13 +1023,12 @@ def __init__(self, **kwargs): self.is_data_action = kwargs.get('is_data_action', None) -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that describes the operation. :param provider: Friendly name of the resource provider. :type provider: str - :param operation: The operation type. For example: read, write, delete, or - listKeys/action + :param operation: For example: read, write, delete, or listKeys/action. :type operation: str :param resource: The resource type on which the operation is performed. :type resource: str @@ -1009,7 +1043,10 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.operation = kwargs.get('operation', None) @@ -1017,7 +1054,30 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class PlatformImagePurchasePlan(Model): +class OperationListResult(msrest.serialization.Model): + """Result of the request to list REST API operations. It contains a list of operations and a URL nextLink to get the next set of results. + + :param value: The list of operations supported by the resource provider. + :type value: list[~azure.mgmt.imagebuilder.models.Operation] + :param next_link: The URL to get the next set of operation list results if there are any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PlatformImagePurchasePlan(msrest.serialization.Model): """Purchase plan configuration for platform image. All required parameters must be populated in order to send to Azure. @@ -1042,24 +1102,25 @@ class PlatformImagePurchasePlan(Model): 'plan_publisher': {'key': 'planPublisher', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PlatformImagePurchasePlan, self).__init__(**kwargs) - self.plan_name = kwargs.get('plan_name', None) - self.plan_product = kwargs.get('plan_product', None) - self.plan_publisher = kwargs.get('plan_publisher', None) + self.plan_name = kwargs['plan_name'] + self.plan_product = kwargs['plan_product'] + self.plan_publisher = kwargs['plan_publisher'] -class ProvisioningError(Model): +class ProvisioningError(msrest.serialization.Model): """Describes the error happened when create or update an image template. - :param provisioning_error_code: Error code of the provisioning failure. - Possible values include: 'BadSourceType', 'BadPIRSource', - 'BadManagedImageSource', 'BadSharedImageVersionSource', - 'BadCustomizerType', 'UnsupportedCustomizerType', 'NoCustomizerScript', - 'BadDistributeType', 'BadSharedImageDistribute', 'ServerError', 'Other' - :type provisioning_error_code: str or - ~azure.mgmt.imagebuilder.models.ProvisioningErrorCode - :param message: Verbose error message about the provisioning failure + :param provisioning_error_code: Error code of the provisioning failure. Possible values + include: "BadSourceType", "BadPIRSource", "BadManagedImageSource", + "BadSharedImageVersionSource", "BadCustomizerType", "UnsupportedCustomizerType", + "NoCustomizerScript", "BadDistributeType", "BadSharedImageDistribute", "ServerError", "Other". + :type provisioning_error_code: str or ~azure.mgmt.imagebuilder.models.ProvisioningErrorCode + :param message: Verbose error message about the provisioning failure. :type message: str """ @@ -1068,25 +1129,27 @@ class ProvisioningError(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ProvisioningError, self).__init__(**kwargs) self.provisioning_error_code = kwargs.get('provisioning_error_code', None) self.message = kwargs.get('message', None) -class SubResource(Model): +class SubResource(msrest.serialization.Model): """The Sub Resource model definition. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Resource Id + :ivar id: Resource Id. :vartype id: str - :param name: Required. Resource name + :param name: Required. Resource name. :type name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str """ @@ -1102,35 +1165,36 @@ class SubResource(Model): 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = None - self.name = kwargs.get('name', None) + self.name = kwargs['name'] self.type = None class RunOutput(SubResource): """Represents an output that was created by running an image template. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Resource Id + :ivar id: Resource Id. :vartype id: str - :param name: Required. Resource name + :param name: Required. Resource name. :type name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str :param artifact_id: The resource id of the artifact. :type artifact_id: str :param artifact_uri: The location URI of the artifact. :type artifact_uri: str - :ivar provisioning_state: Provisioning state of the resource. Possible - values include: 'Creating', 'Updating', 'Succeeded', 'Failed', 'Deleting' - :vartype provisioning_state: str or - ~azure.mgmt.imagebuilder.models.ProvisioningState + :ivar provisioning_state: Provisioning state of the resource. Possible values include: + "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :vartype provisioning_state: str or ~azure.mgmt.imagebuilder.models.ProvisioningState """ _validation = { @@ -1146,17 +1210,43 @@ class RunOutput(SubResource): 'type': {'key': 'type', 'type': 'str'}, 'artifact_id': {'key': 'properties.artifactId', 'type': 'str'}, 'artifact_uri': {'key': 'properties.artifactUri', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'ProvisioningState'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(RunOutput, self).__init__(**kwargs) self.artifact_id = kwargs.get('artifact_id', None) self.artifact_uri = kwargs.get('artifact_uri', None) self.provisioning_state = None -class VirtualNetworkConfig(Model): +class RunOutputCollection(msrest.serialization.Model): + """The result of List run outputs operation. + + :param value: An array of run outputs. + :type value: list[~azure.mgmt.imagebuilder.models.RunOutput] + :param next_link: The continuation token. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[RunOutput]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(RunOutputCollection, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class VirtualNetworkConfig(msrest.serialization.Model): """Virtual Network configuration. :param subnet_id: Resource id of a pre-existing subnet. @@ -1167,6 +1257,9 @@ class VirtualNetworkConfig(Model): 'subnet_id': {'key': 'subnetId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(VirtualNetworkConfig, self).__init__(**kwargs) self.subnet_id = kwargs.get('subnet_id', None) diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_models_py3.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_models_py3.py index 5f6aded8d16c..f94175d46a57 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_models_py3.py @@ -1,24 +1,26 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +import datetime +from typing import Dict, List, Optional, Union +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class ApiError(Model): +from ._image_builder_client_enums import * + + +class ApiError(msrest.serialization.Model): """Api error. - :param details: The Api error details + :param details: The Api error details. :type details: list[~azure.mgmt.imagebuilder.models.ApiErrorBase] - :param inner_error: The Api inner error + :param inner_error: The Api inner error. :type inner_error: ~azure.mgmt.imagebuilder.models.InnerError :param code: The error code. :type code: str @@ -36,7 +38,16 @@ class ApiError(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, *, details=None, inner_error=None, code: str=None, target: str=None, message: str=None, **kwargs) -> None: + def __init__( + self, + *, + details: Optional[List["ApiErrorBase"]] = None, + inner_error: Optional["InnerError"] = None, + code: Optional[str] = None, + target: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): super(ApiError, self).__init__(**kwargs) self.details = details self.inner_error = inner_error @@ -45,19 +56,7 @@ def __init__(self, *, details=None, inner_error=None, code: str=None, target: st self.message = message -class ApiErrorException(HttpOperationError): - """Server responsed with exception of type: 'ApiError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(ApiErrorException, self).__init__(deserialize, response, 'ApiError', *args) - - -class ApiErrorBase(Model): +class ApiErrorBase(msrest.serialization.Model): """Api error base. :param code: The error code. @@ -74,38 +73,66 @@ class ApiErrorBase(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, *, code: str=None, target: str=None, message: str=None, **kwargs) -> None: + def __init__( + self, + *, + code: Optional[str] = None, + target: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): super(ApiErrorBase, self).__init__(**kwargs) self.code = code self.target = target self.message = message -class CloudError(Model): - """CloudError. +class ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): + """ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str """ + _validation = { + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, + } + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, } + def __init__( + self, + **kwargs + ): + super(ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None -class Resource(Model): + +class Resource(msrest.serialization.Model): """The Resource model definition. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Resource Id + :ivar id: Resource Id. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Required. Resource location + :param location: Required. Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -124,7 +151,13 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -134,54 +167,43 @@ def __init__(self, *, location: str, tags=None, **kwargs) -> None: class ImageTemplate(Resource): - """Image template is an ARM resource managed by Microsoft.VirtualMachineImages - provider. + """Image template is an ARM resource managed by Microsoft.VirtualMachineImages provider. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Resource Id + :ivar id: Resource Id. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Required. Resource location + :param location: Required. Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] - :param source: Required. Specifies the properties used to describe the - source image. + :param identity: Required. The identity of the image template, if configured. + :type identity: ~azure.mgmt.imagebuilder.models.ImageTemplateIdentity + :param source: Specifies the properties used to describe the source image. :type source: ~azure.mgmt.imagebuilder.models.ImageTemplateSource - :param customize: Specifies the properties used to describe the - customization steps of the image, like Image source etc - :type customize: - list[~azure.mgmt.imagebuilder.models.ImageTemplateCustomizer] - :param distribute: Required. The distribution targets where the image - output needs to go to. - :type distribute: - list[~azure.mgmt.imagebuilder.models.ImageTemplateDistributor] - :ivar provisioning_state: Provisioning state of the resource. Possible - values include: 'Creating', 'Updating', 'Succeeded', 'Failed', 'Deleting' - :vartype provisioning_state: str or - ~azure.mgmt.imagebuilder.models.ProvisioningState - :ivar provisioning_error: Provisioning error, if any - :vartype provisioning_error: - ~azure.mgmt.imagebuilder.models.ProvisioningError - :ivar last_run_status: State of 'run' that is currently executing or was - last executed. - :vartype last_run_status: - ~azure.mgmt.imagebuilder.models.ImageTemplateLastRunStatus - :param build_timeout_in_minutes: Maximum duration to wait while building - the image template. Omit or specify 0 to use the default (4 hours). + :param customize: Specifies the properties used to describe the customization steps of the + image, like Image source etc. + :type customize: list[~azure.mgmt.imagebuilder.models.ImageTemplateCustomizer] + :param distribute: The distribution targets where the image output needs to go to. + :type distribute: list[~azure.mgmt.imagebuilder.models.ImageTemplateDistributor] + :ivar provisioning_state: Provisioning state of the resource. Possible values include: + "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :vartype provisioning_state: str or ~azure.mgmt.imagebuilder.models.ProvisioningState + :ivar provisioning_error: Provisioning error, if any. + :vartype provisioning_error: ~azure.mgmt.imagebuilder.models.ProvisioningError + :ivar last_run_status: State of 'run' that is currently executing or was last executed. + :vartype last_run_status: ~azure.mgmt.imagebuilder.models.ImageTemplateLastRunStatus + :param build_timeout_in_minutes: Maximum duration to wait while building the image template. + Omit or specify 0 to use the default (4 hours). :type build_timeout_in_minutes: int - :param vm_profile: Describes how virtual machine is set up to build images + :param vm_profile: Describes how virtual machine is set up to build images. :type vm_profile: ~azure.mgmt.imagebuilder.models.ImageTemplateVmProfile - :param identity: Required. The identity of the image template, if - configured. - :type identity: ~azure.mgmt.imagebuilder.models.ImageTemplateIdentity """ _validation = { @@ -189,13 +211,11 @@ class ImageTemplate(Resource): 'name': {'readonly': True}, 'type': {'readonly': True}, 'location': {'required': True}, - 'source': {'required': True}, - 'distribute': {'required': True}, + 'identity': {'required': True}, 'provisioning_state': {'readonly': True}, 'provisioning_error': {'readonly': True}, 'last_run_status': {'readonly': True}, 'build_timeout_in_minutes': {'maximum': 960, 'minimum': 0}, - 'identity': {'required': True}, } _attribute_map = { @@ -204,19 +224,32 @@ class ImageTemplate(Resource): 'type': {'key': 'type', 'type': 'str'}, 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, + 'identity': {'key': 'identity', 'type': 'ImageTemplateIdentity'}, 'source': {'key': 'properties.source', 'type': 'ImageTemplateSource'}, 'customize': {'key': 'properties.customize', 'type': '[ImageTemplateCustomizer]'}, 'distribute': {'key': 'properties.distribute', 'type': '[ImageTemplateDistributor]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'ProvisioningState'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, 'provisioning_error': {'key': 'properties.provisioningError', 'type': 'ProvisioningError'}, 'last_run_status': {'key': 'properties.lastRunStatus', 'type': 'ImageTemplateLastRunStatus'}, 'build_timeout_in_minutes': {'key': 'properties.buildTimeoutInMinutes', 'type': 'int'}, 'vm_profile': {'key': 'properties.vmProfile', 'type': 'ImageTemplateVmProfile'}, - 'identity': {'key': 'identity', 'type': 'ImageTemplateIdentity'}, } - def __init__(self, *, location: str, source, distribute, identity, tags=None, customize=None, build_timeout_in_minutes: int=None, vm_profile=None, **kwargs) -> None: + def __init__( + self, + *, + location: str, + identity: "ImageTemplateIdentity", + tags: Optional[Dict[str, str]] = None, + source: Optional["ImageTemplateSource"] = None, + customize: Optional[List["ImageTemplateCustomizer"]] = None, + distribute: Optional[List["ImageTemplateDistributor"]] = None, + build_timeout_in_minutes: Optional[int] = 0, + vm_profile: Optional["ImageTemplateVmProfile"] = None, + **kwargs + ): super(ImageTemplate, self).__init__(location=location, tags=tags, **kwargs) + self.identity = identity self.source = source self.customize = customize self.distribute = distribute @@ -225,24 +258,21 @@ def __init__(self, *, location: str, source, distribute, identity, tags=None, cu self.last_run_status = None self.build_timeout_in_minutes = build_timeout_in_minutes self.vm_profile = vm_profile - self.identity = identity -class ImageTemplateCustomizer(Model): +class ImageTemplateCustomizer(msrest.serialization.Model): """Describes a unit of image customization. You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ImageTemplateShellCustomizer, - ImageTemplateRestartCustomizer, ImageTemplateWindowsUpdateCustomizer, - ImageTemplatePowerShellCustomizer, ImageTemplateFileCustomizer + sub-classes are: ImageTemplateFileCustomizer, ImageTemplatePowerShellCustomizer, ImageTemplateShellCustomizer, ImageTemplateRestartCustomizer, ImageTemplateWindowsUpdateCustomizer. All required parameters must be populated in order to send to Azure. - :param name: Friendly Name to provide context on what this customization - step does - :type name: str - :param type: Required. Constant filled by server. + :param type: Required. The type of customization tool you want to use on the Image. For + example, "Shell" can be shell customizer.Constant filled by server. :type type: str + :param name: Friendly Name to provide context on what this customization step does. + :type name: str """ _validation = { @@ -250,81 +280,87 @@ class ImageTemplateCustomizer(Model): } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, } _subtype_map = { - 'type': {'Shell': 'ImageTemplateShellCustomizer', 'WindowsRestart': 'ImageTemplateRestartCustomizer', 'WindowsUpdate': 'ImageTemplateWindowsUpdateCustomizer', 'PowerShell': 'ImageTemplatePowerShellCustomizer', 'File': 'ImageTemplateFileCustomizer'} + 'type': {'File': 'ImageTemplateFileCustomizer', 'PowerShell': 'ImageTemplatePowerShellCustomizer', 'Shell': 'ImageTemplateShellCustomizer', 'WindowsRestart': 'ImageTemplateRestartCustomizer', 'WindowsUpdate': 'ImageTemplateWindowsUpdateCustomizer'} } - def __init__(self, *, name: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + **kwargs + ): super(ImageTemplateCustomizer, self).__init__(**kwargs) + self.type = None # type: Optional[str] self.name = name - self.type = None -class ImageTemplateDistributor(Model): +class ImageTemplateDistributor(msrest.serialization.Model): """Generic distribution object. You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ImageTemplateManagedImageDistributor, - ImageTemplateSharedImageDistributor, ImageTemplateVhdDistributor + sub-classes are: ImageTemplateManagedImageDistributor, ImageTemplateSharedImageDistributor, ImageTemplateVhdDistributor. All required parameters must be populated in order to send to Azure. - :param run_output_name: Required. The name to be used for the associated - RunOutput. + :param type: Required. Type of distribution.Constant filled by server. + :type type: str + :param run_output_name: Required. The name to be used for the associated RunOutput. :type run_output_name: str - :param artifact_tags: Tags that will be applied to the artifact once it - has been created/updated by the distributor. + :param artifact_tags: Tags that will be applied to the artifact once it has been + created/updated by the distributor. :type artifact_tags: dict[str, str] - :param type: Required. Constant filled by server. - :type type: str """ _validation = { - 'run_output_name': {'required': True, 'pattern': r'^[A-Za-z0-9-_.]{1,64}$'}, 'type': {'required': True}, + 'run_output_name': {'required': True, 'pattern': r'^[A-Za-z0-9-_.]{1,64}$'}, } _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, 'run_output_name': {'key': 'runOutputName', 'type': 'str'}, 'artifact_tags': {'key': 'artifactTags', 'type': '{str}'}, - 'type': {'key': 'type', 'type': 'str'}, } _subtype_map = { 'type': {'ManagedImage': 'ImageTemplateManagedImageDistributor', 'SharedImage': 'ImageTemplateSharedImageDistributor', 'VHD': 'ImageTemplateVhdDistributor'} } - def __init__(self, *, run_output_name: str, artifact_tags=None, **kwargs) -> None: + def __init__( + self, + *, + run_output_name: str, + artifact_tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ImageTemplateDistributor, self).__init__(**kwargs) + self.type = None # type: Optional[str] self.run_output_name = run_output_name self.artifact_tags = artifact_tags - self.type = None class ImageTemplateFileCustomizer(ImageTemplateCustomizer): - """Uploads files to VMs (Linux, Windows). Corresponds to Packer file - provisioner. + """Uploads files to VMs (Linux, Windows). Corresponds to Packer file provisioner. All required parameters must be populated in order to send to Azure. - :param name: Friendly Name to provide context on what this customization - step does - :type name: str - :param type: Required. Constant filled by server. + :param type: Required. The type of customization tool you want to use on the Image. For + example, "Shell" can be shell customizer.Constant filled by server. :type type: str - :param source_uri: The URI of the file to be uploaded for customizing the - VM. It can be a github link, SAS URI for Azure Storage, etc + :param name: Friendly Name to provide context on what this customization step does. + :type name: str + :param source_uri: The URI of the file to be uploaded for customizing the VM. It can be a + github link, SAS URI for Azure Storage, etc. :type source_uri: str - :param sha256_checksum: SHA256 checksum of the file provided in the - sourceUri field above + :param sha256_checksum: SHA256 checksum of the file provided in the sourceUri field above. :type sha256_checksum: str - :param destination: The absolute path to a file (with nested directory - structures already created) where the file (from sourceUri) will be - uploaded to in the VM + :param destination: The absolute path to a file (with nested directory structures already + created) where the file (from sourceUri) will be uploaded to in the VM. :type destination: str """ @@ -333,101 +369,94 @@ class ImageTemplateFileCustomizer(ImageTemplateCustomizer): } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'source_uri': {'key': 'sourceUri', 'type': 'str'}, 'sha256_checksum': {'key': 'sha256Checksum', 'type': 'str'}, 'destination': {'key': 'destination', 'type': 'str'}, } - def __init__(self, *, name: str=None, source_uri: str=None, sha256_checksum: str=None, destination: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + source_uri: Optional[str] = None, + sha256_checksum: Optional[str] = "", + destination: Optional[str] = None, + **kwargs + ): super(ImageTemplateFileCustomizer, self).__init__(name=name, **kwargs) + self.type = 'File' # type: str self.source_uri = source_uri self.sha256_checksum = sha256_checksum self.destination = destination - self.type = 'File' -class ImageTemplateIdentity(Model): +class ImageTemplateIdentity(msrest.serialization.Model): """Identity for the image template. - :param type: The type of identity used for the image template. Possible - values include: 'UserAssigned' + :param type: The type of identity used for the image template. The type 'None' will remove any + identities from the image template. Possible values include: "UserAssigned", "None". :type type: str or ~azure.mgmt.imagebuilder.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated - with the image template. The user identity dictionary key references will - be ARM resource ids in the form: + :param user_assigned_identities: The list of user identities associated with the image + template. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. :type user_assigned_identities: dict[str, - ~azure.mgmt.imagebuilder.models.ImageTemplateIdentityUserAssignedIdentitiesValue] + ~azure.mgmt.imagebuilder.models.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties] """ _attribute_map = { - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ImageTemplateIdentityUserAssignedIdentitiesValue}'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties}'}, } - def __init__(self, *, type=None, user_assigned_identities=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, + **kwargs + ): super(ImageTemplateIdentity, self).__init__(**kwargs) self.type = type self.user_assigned_identities = user_assigned_identities -class ImageTemplateIdentityUserAssignedIdentitiesValue(Model): - """ImageTemplateIdentityUserAssignedIdentitiesValue. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar principal_id: The principal id of user assigned identity. - :vartype principal_id: str - :ivar client_id: The client id of user assigned identity. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__(self, **kwargs) -> None: - super(ImageTemplateIdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class ImageTemplateLastRunStatus(Model): +class ImageTemplateLastRunStatus(msrest.serialization.Model): """Describes the latest status of running an image template. - :param start_time: Start time of the last run (UTC) - :type start_time: datetime - :param end_time: End time of the last run (UTC) - :type end_time: datetime - :param run_state: State of the last run. Possible values include: - 'Running', 'Canceling', 'Succeeded', 'PartiallySucceeded', 'Failed', - 'Canceled' + :param start_time: Start time of the last run (UTC). + :type start_time: ~datetime.datetime + :param end_time: End time of the last run (UTC). + :type end_time: ~datetime.datetime + :param run_state: State of the last run. Possible values include: "Running", "Canceling", + "Succeeded", "PartiallySucceeded", "Failed", "Canceled". :type run_state: str or ~azure.mgmt.imagebuilder.models.RunState - :param run_sub_state: Sub-state of the last run. Possible values include: - 'Queued', 'Building', 'Customizing', 'Distributing' + :param run_sub_state: Sub-state of the last run. Possible values include: "Queued", "Building", + "Customizing", "Distributing". :type run_sub_state: str or ~azure.mgmt.imagebuilder.models.RunSubState - :param message: Verbose information about the last run state + :param message: Verbose information about the last run state. :type message: str """ _attribute_map = { 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'run_state': {'key': 'runState', 'type': 'RunState'}, - 'run_sub_state': {'key': 'runSubState', 'type': 'RunSubState'}, + 'run_state': {'key': 'runState', 'type': 'str'}, + 'run_sub_state': {'key': 'runSubState', 'type': 'str'}, 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, *, start_time=None, end_time=None, run_state=None, run_sub_state=None, message: str=None, **kwargs) -> None: + def __init__( + self, + *, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + run_state: Optional[Union[str, "RunState"]] = None, + run_sub_state: Optional[Union[str, "RunSubState"]] = None, + message: Optional[str] = None, + **kwargs + ): super(ImageTemplateLastRunStatus, self).__init__(**kwargs) self.start_time = start_time self.end_time = end_time @@ -436,59 +465,90 @@ def __init__(self, *, start_time=None, end_time=None, run_state=None, run_sub_st self.message = message +class ImageTemplateListResult(msrest.serialization.Model): + """The result of List image templates operation. + + :param value: An array of image templates. + :type value: list[~azure.mgmt.imagebuilder.models.ImageTemplate] + :param next_link: The continuation token. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ImageTemplate]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ImageTemplate"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(ImageTemplateListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + class ImageTemplateManagedImageDistributor(ImageTemplateDistributor): """Distribute as a Managed Disk Image. All required parameters must be populated in order to send to Azure. - :param run_output_name: Required. The name to be used for the associated - RunOutput. + :param type: Required. Type of distribution.Constant filled by server. + :type type: str + :param run_output_name: Required. The name to be used for the associated RunOutput. :type run_output_name: str - :param artifact_tags: Tags that will be applied to the artifact once it - has been created/updated by the distributor. + :param artifact_tags: Tags that will be applied to the artifact once it has been + created/updated by the distributor. :type artifact_tags: dict[str, str] - :param type: Required. Constant filled by server. - :type type: str - :param image_id: Required. Resource Id of the Managed Disk Image + :param image_id: Required. Resource Id of the Managed Disk Image. :type image_id: str - :param location: Required. Azure location for the image, should match if - image already exists + :param location: Required. Azure location for the image, should match if image already exists. :type location: str """ _validation = { - 'run_output_name': {'required': True, 'pattern': r'^[A-Za-z0-9-_.]{1,64}$'}, 'type': {'required': True}, + 'run_output_name': {'required': True, 'pattern': r'^[A-Za-z0-9-_.]{1,64}$'}, 'image_id': {'required': True}, 'location': {'required': True}, } _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, 'run_output_name': {'key': 'runOutputName', 'type': 'str'}, 'artifact_tags': {'key': 'artifactTags', 'type': '{str}'}, - 'type': {'key': 'type', 'type': 'str'}, 'image_id': {'key': 'imageId', 'type': 'str'}, 'location': {'key': 'location', 'type': 'str'}, } - def __init__(self, *, run_output_name: str, image_id: str, location: str, artifact_tags=None, **kwargs) -> None: + def __init__( + self, + *, + run_output_name: str, + image_id: str, + location: str, + artifact_tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ImageTemplateManagedImageDistributor, self).__init__(run_output_name=run_output_name, artifact_tags=artifact_tags, **kwargs) + self.type = 'ManagedImage' # type: str self.image_id = image_id self.location = location - self.type = 'ManagedImage' -class ImageTemplateSource(Model): - """Describes a virtual machine image source for building, customizing and - distributing. +class ImageTemplateSource(msrest.serialization.Model): + """Describes a virtual machine image source for building, customizing and distributing. You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ImageTemplatePlatformImageSource, - ImageTemplateManagedImageSource, ImageTemplateSharedImageVersionSource + sub-classes are: ImageTemplateManagedImageSource, ImageTemplatePlatformImageSource, ImageTemplateSharedImageVersionSource. All required parameters must be populated in order to send to Azure. - :param type: Required. Constant filled by server. + :param type: Required. Specifies the type of source image you want to start with.Constant + filled by server. :type type: str """ @@ -501,12 +561,15 @@ class ImageTemplateSource(Model): } _subtype_map = { - 'type': {'PlatformImage': 'ImageTemplatePlatformImageSource', 'ManagedImage': 'ImageTemplateManagedImageSource', 'SharedImageVersion': 'ImageTemplateSharedImageVersionSource'} + 'type': {'ManagedImage': 'ImageTemplateManagedImageSource', 'PlatformImage': 'ImageTemplatePlatformImageSource', 'SharedImageVersion': 'ImageTemplateSharedImageVersionSource'} } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ImageTemplateSource, self).__init__(**kwargs) - self.type = None + self.type = None # type: Optional[str] class ImageTemplateManagedImageSource(ImageTemplateSource): @@ -514,10 +577,10 @@ class ImageTemplateManagedImageSource(ImageTemplateSource): All required parameters must be populated in order to send to Azure. - :param type: Required. Constant filled by server. + :param type: Required. Specifies the type of source image you want to start with.Constant + filled by server. :type type: str - :param image_id: Required. ARM resource id of the managed image in - customer subscription + :param image_id: Required. ARM resource id of the managed image in customer subscription. :type image_id: str """ @@ -531,34 +594,41 @@ class ImageTemplateManagedImageSource(ImageTemplateSource): 'image_id': {'key': 'imageId', 'type': 'str'}, } - def __init__(self, *, image_id: str, **kwargs) -> None: + def __init__( + self, + *, + image_id: str, + **kwargs + ): super(ImageTemplateManagedImageSource, self).__init__(**kwargs) + self.type = 'ManagedImage' # type: str self.image_id = image_id - self.type = 'ManagedImage' class ImageTemplatePlatformImageSource(ImageTemplateSource): - """Describes an image source from [Azure Gallery - Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). + """Describes an image source from `Azure Gallery Images `_. All required parameters must be populated in order to send to Azure. - :param type: Required. Constant filled by server. + :param type: Required. Specifies the type of source image you want to start with.Constant + filled by server. :type type: str - :param publisher: Image Publisher in [Azure Gallery - Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). + :param publisher: Image Publisher in `Azure Gallery Images + `_. :type publisher: str - :param offer: Image offer from the [Azure Gallery - Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). + :param offer: Image offer from the `Azure Gallery Images + `_. :type offer: str - :param sku: Image sku from the [Azure Gallery - Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). + :param sku: Image sku from the `Azure Gallery Images + `_. :type sku: str - :param version: Image version from the [Azure Gallery - Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). + :param version: Image version from the `Azure Gallery Images + `_. If 'latest' is + specified here, the version is evaluated when the image build takes place, not when the + template is submitted. Specifying 'latest' could cause ROUNDTRIP_INCONSISTENT_PROPERTY issue + which will be fixed. :type version: str - :param plan_info: Optional configuration of purchase plan for platform - image. + :param plan_info: Optional configuration of purchase plan for platform image. :type plan_info: ~azure.mgmt.imagebuilder.models.PlatformImagePurchasePlan """ @@ -575,41 +645,49 @@ class ImageTemplatePlatformImageSource(ImageTemplateSource): 'plan_info': {'key': 'planInfo', 'type': 'PlatformImagePurchasePlan'}, } - def __init__(self, *, publisher: str=None, offer: str=None, sku: str=None, version: str=None, plan_info=None, **kwargs) -> None: + def __init__( + self, + *, + publisher: Optional[str] = None, + offer: Optional[str] = None, + sku: Optional[str] = None, + version: Optional[str] = None, + plan_info: Optional["PlatformImagePurchasePlan"] = None, + **kwargs + ): super(ImageTemplatePlatformImageSource, self).__init__(**kwargs) + self.type = 'PlatformImage' # type: str self.publisher = publisher self.offer = offer self.sku = sku self.version = version self.plan_info = plan_info - self.type = 'PlatformImage' class ImageTemplatePowerShellCustomizer(ImageTemplateCustomizer): - """Runs the specified PowerShell on the VM (Windows). Corresponds to Packer - powershell provisioner. Exactly one of 'scriptUri' or 'inline' can be - specified. + """Runs the specified PowerShell on the VM (Windows). Corresponds to Packer powershell provisioner. Exactly one of 'scriptUri' or 'inline' can be specified. All required parameters must be populated in order to send to Azure. - :param name: Friendly Name to provide context on what this customization - step does - :type name: str - :param type: Required. Constant filled by server. + :param type: Required. The type of customization tool you want to use on the Image. For + example, "Shell" can be shell customizer.Constant filled by server. :type type: str - :param script_uri: URI of the PowerShell script to be run for customizing. - It can be a github link, SAS URI for Azure Storage, etc + :param name: Friendly Name to provide context on what this customization step does. + :type name: str + :param script_uri: URI of the PowerShell script to be run for customizing. It can be a github + link, SAS URI for Azure Storage, etc. :type script_uri: str - :param sha256_checksum: SHA256 checksum of the power shell script provided - in the scriptUri field above + :param sha256_checksum: SHA256 checksum of the power shell script provided in the scriptUri + field above. :type sha256_checksum: str - :param inline: Array of PowerShell commands to execute + :param inline: Array of PowerShell commands to execute. :type inline: list[str] - :param run_elevated: If specified, the PowerShell script will be run with - elevated privileges + :param run_elevated: If specified, the PowerShell script will be run with elevated privileges. :type run_elevated: bool - :param valid_exit_codes: Valid exit codes for the PowerShell script. - [Default: 0] + :param run_as_system: If specified, the PowerShell script will be run with elevated privileges + using the Local System user. Can only be true when the runElevated field above is set to true. + :type run_as_system: bool + :param valid_exit_codes: Valid exit codes for the PowerShell script. [Default: 0]. :type valid_exit_codes: list[int] """ @@ -618,44 +696,55 @@ class ImageTemplatePowerShellCustomizer(ImageTemplateCustomizer): } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'script_uri': {'key': 'scriptUri', 'type': 'str'}, 'sha256_checksum': {'key': 'sha256Checksum', 'type': 'str'}, 'inline': {'key': 'inline', 'type': '[str]'}, 'run_elevated': {'key': 'runElevated', 'type': 'bool'}, + 'run_as_system': {'key': 'runAsSystem', 'type': 'bool'}, 'valid_exit_codes': {'key': 'validExitCodes', 'type': '[int]'}, } - def __init__(self, *, name: str=None, script_uri: str=None, sha256_checksum: str=None, inline=None, run_elevated: bool=None, valid_exit_codes=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + script_uri: Optional[str] = None, + sha256_checksum: Optional[str] = "", + inline: Optional[List[str]] = None, + run_elevated: Optional[bool] = False, + run_as_system: Optional[bool] = False, + valid_exit_codes: Optional[List[int]] = None, + **kwargs + ): super(ImageTemplatePowerShellCustomizer, self).__init__(name=name, **kwargs) + self.type = 'PowerShell' # type: str self.script_uri = script_uri self.sha256_checksum = sha256_checksum self.inline = inline self.run_elevated = run_elevated + self.run_as_system = run_as_system self.valid_exit_codes = valid_exit_codes - self.type = 'PowerShell' class ImageTemplateRestartCustomizer(ImageTemplateCustomizer): - """Reboots a VM and waits for it to come back online (Windows). Corresponds to - Packer windows-restart provisioner. + """Reboots a VM and waits for it to come back online (Windows). Corresponds to Packer windows-restart provisioner. All required parameters must be populated in order to send to Azure. - :param name: Friendly Name to provide context on what this customization - step does - :type name: str - :param type: Required. Constant filled by server. + :param type: Required. The type of customization tool you want to use on the Image. For + example, "Shell" can be shell customizer.Constant filled by server. :type type: str - :param restart_command: Command to execute the restart [Default: 'shutdown - /r /f /t 0 /c "packer restart"'] + :param name: Friendly Name to provide context on what this customization step does. + :type name: str + :param restart_command: Command to execute the restart [Default: 'shutdown /r /f /t 0 /c + "packer restart"']. :type restart_command: str - :param restart_check_command: Command to check if restart succeeded - [Default: ''] + :param restart_check_command: Command to check if restart succeeded [Default: '']. :type restart_check_command: str - :param restart_timeout: Restart timeout specified as a string of magnitude - and unit, e.g. '5m' (5 minutes) or '2h' (2 hours) [Default: '5m'] + :param restart_timeout: Restart timeout specified as a string of magnitude and unit, e.g. '5m' + (5 minutes) or '2h' (2 hours) [Default: '5m']. :type restart_timeout: str """ @@ -664,19 +753,27 @@ class ImageTemplateRestartCustomizer(ImageTemplateCustomizer): } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'restart_command': {'key': 'restartCommand', 'type': 'str'}, 'restart_check_command': {'key': 'restartCheckCommand', 'type': 'str'}, 'restart_timeout': {'key': 'restartTimeout', 'type': 'str'}, } - def __init__(self, *, name: str=None, restart_command: str=None, restart_check_command: str=None, restart_timeout: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + restart_command: Optional[str] = None, + restart_check_command: Optional[str] = None, + restart_timeout: Optional[str] = None, + **kwargs + ): super(ImageTemplateRestartCustomizer, self).__init__(name=name, **kwargs) + self.type = 'WindowsRestart' # type: str self.restart_command = restart_command self.restart_check_command = restart_check_command self.restart_timeout = restart_timeout - self.type = 'WindowsRestart' class ImageTemplateSharedImageDistributor(ImageTemplateDistributor): @@ -684,66 +781,72 @@ class ImageTemplateSharedImageDistributor(ImageTemplateDistributor): All required parameters must be populated in order to send to Azure. - :param run_output_name: Required. The name to be used for the associated - RunOutput. + :param type: Required. Type of distribution.Constant filled by server. + :type type: str + :param run_output_name: Required. The name to be used for the associated RunOutput. :type run_output_name: str - :param artifact_tags: Tags that will be applied to the artifact once it - has been created/updated by the distributor. + :param artifact_tags: Tags that will be applied to the artifact once it has been + created/updated by the distributor. :type artifact_tags: dict[str, str] - :param type: Required. Constant filled by server. - :type type: str - :param gallery_image_id: Required. Resource Id of the Shared Image Gallery - image + :param gallery_image_id: Required. Resource Id of the Shared Image Gallery image. :type gallery_image_id: str - :param replication_regions: Required. A list of regions that the image - will be replicated to + :param replication_regions: Required. A list of regions that the image will be replicated to. :type replication_regions: list[str] - :param exclude_from_latest: Flag that indicates whether created image - version should be excluded from latest. Omit to use the default (false). + :param exclude_from_latest: Flag that indicates whether created image version should be + excluded from latest. Omit to use the default (false). :type exclude_from_latest: bool - :param storage_account_type: Storage account type to be used to store the - shared image. Omit to use the default (Standard_LRS). Possible values - include: 'Standard_LRS', 'Standard_ZRS' + :param storage_account_type: Storage account type to be used to store the shared image. Omit to + use the default (Standard_LRS). Possible values include: "Standard_LRS", "Standard_ZRS". :type storage_account_type: str or ~azure.mgmt.imagebuilder.models.SharedImageStorageAccountType """ _validation = { - 'run_output_name': {'required': True, 'pattern': r'^[A-Za-z0-9-_.]{1,64}$'}, 'type': {'required': True}, + 'run_output_name': {'required': True, 'pattern': r'^[A-Za-z0-9-_.]{1,64}$'}, 'gallery_image_id': {'required': True}, 'replication_regions': {'required': True}, } _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, 'run_output_name': {'key': 'runOutputName', 'type': 'str'}, 'artifact_tags': {'key': 'artifactTags', 'type': '{str}'}, - 'type': {'key': 'type', 'type': 'str'}, 'gallery_image_id': {'key': 'galleryImageId', 'type': 'str'}, 'replication_regions': {'key': 'replicationRegions', 'type': '[str]'}, 'exclude_from_latest': {'key': 'excludeFromLatest', 'type': 'bool'}, 'storage_account_type': {'key': 'storageAccountType', 'type': 'str'}, } - def __init__(self, *, run_output_name: str, gallery_image_id: str, replication_regions, artifact_tags=None, exclude_from_latest: bool=None, storage_account_type=None, **kwargs) -> None: + def __init__( + self, + *, + run_output_name: str, + gallery_image_id: str, + replication_regions: List[str], + artifact_tags: Optional[Dict[str, str]] = None, + exclude_from_latest: Optional[bool] = False, + storage_account_type: Optional[Union[str, "SharedImageStorageAccountType"]] = None, + **kwargs + ): super(ImageTemplateSharedImageDistributor, self).__init__(run_output_name=run_output_name, artifact_tags=artifact_tags, **kwargs) + self.type = 'SharedImage' # type: str self.gallery_image_id = gallery_image_id self.replication_regions = replication_regions self.exclude_from_latest = exclude_from_latest self.storage_account_type = storage_account_type - self.type = 'SharedImage' class ImageTemplateSharedImageVersionSource(ImageTemplateSource): - """Describes an image source that is an image version in a shared image - gallery. + """Describes an image source that is an image version in a shared image gallery. All required parameters must be populated in order to send to Azure. - :param type: Required. Constant filled by server. + :param type: Required. Specifies the type of source image you want to start with.Constant + filled by server. :type type: str - :param image_version_id: Required. ARM resource id of the image version in - the shared image gallery + :param image_version_id: Required. ARM resource id of the image version in the shared image + gallery. :type image_version_id: str """ @@ -757,31 +860,33 @@ class ImageTemplateSharedImageVersionSource(ImageTemplateSource): 'image_version_id': {'key': 'imageVersionId', 'type': 'str'}, } - def __init__(self, *, image_version_id: str, **kwargs) -> None: + def __init__( + self, + *, + image_version_id: str, + **kwargs + ): super(ImageTemplateSharedImageVersionSource, self).__init__(**kwargs) + self.type = 'SharedImageVersion' # type: str self.image_version_id = image_version_id - self.type = 'SharedImageVersion' class ImageTemplateShellCustomizer(ImageTemplateCustomizer): - """Runs a shell script during the customization phase (Linux). Corresponds to - Packer shell provisioner. Exactly one of 'scriptUri' or 'inline' can be - specified. + """Runs a shell script during the customization phase (Linux). Corresponds to Packer shell provisioner. Exactly one of 'scriptUri' or 'inline' can be specified. All required parameters must be populated in order to send to Azure. - :param name: Friendly Name to provide context on what this customization - step does - :type name: str - :param type: Required. Constant filled by server. + :param type: Required. The type of customization tool you want to use on the Image. For + example, "Shell" can be shell customizer.Constant filled by server. :type type: str - :param script_uri: URI of the shell script to be run for customizing. It - can be a github link, SAS URI for Azure Storage, etc + :param name: Friendly Name to provide context on what this customization step does. + :type name: str + :param script_uri: URI of the shell script to be run for customizing. It can be a github link, + SAS URI for Azure Storage, etc. :type script_uri: str - :param sha256_checksum: SHA256 checksum of the shell script provided in - the scriptUri field + :param sha256_checksum: SHA256 checksum of the shell script provided in the scriptUri field. :type sha256_checksum: str - :param inline: Array of shell commands to execute + :param inline: Array of shell commands to execute. :type inline: list[str] """ @@ -790,27 +895,35 @@ class ImageTemplateShellCustomizer(ImageTemplateCustomizer): } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'script_uri': {'key': 'scriptUri', 'type': 'str'}, 'sha256_checksum': {'key': 'sha256Checksum', 'type': 'str'}, 'inline': {'key': 'inline', 'type': '[str]'}, } - def __init__(self, *, name: str=None, script_uri: str=None, sha256_checksum: str=None, inline=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + script_uri: Optional[str] = None, + sha256_checksum: Optional[str] = "", + inline: Optional[List[str]] = None, + **kwargs + ): super(ImageTemplateShellCustomizer, self).__init__(name=name, **kwargs) + self.type = 'Shell' # type: str self.script_uri = script_uri self.sha256_checksum = sha256_checksum self.inline = inline - self.type = 'Shell' -class ImageTemplateUpdateParameters(Model): +class ImageTemplateUpdateParameters(msrest.serialization.Model): """Parameters for updating an image template. :param identity: The identity of the image template, if configured. :type identity: ~azure.mgmt.imagebuilder.models.ImageTemplateIdentity - :param tags: The user-specified tags associated with the image template. + :param tags: A set of tags. The user-specified tags associated with the image template. :type tags: dict[str, str] """ @@ -819,7 +932,13 @@ class ImageTemplateUpdateParameters(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, identity=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + identity: Optional["ImageTemplateIdentity"] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ImageTemplateUpdateParameters, self).__init__(**kwargs) self.identity = identity self.tags = tags @@ -830,45 +949,48 @@ class ImageTemplateVhdDistributor(ImageTemplateDistributor): All required parameters must be populated in order to send to Azure. - :param run_output_name: Required. The name to be used for the associated - RunOutput. + :param type: Required. Type of distribution.Constant filled by server. + :type type: str + :param run_output_name: Required. The name to be used for the associated RunOutput. :type run_output_name: str - :param artifact_tags: Tags that will be applied to the artifact once it - has been created/updated by the distributor. + :param artifact_tags: Tags that will be applied to the artifact once it has been + created/updated by the distributor. :type artifact_tags: dict[str, str] - :param type: Required. Constant filled by server. - :type type: str """ _validation = { - 'run_output_name': {'required': True, 'pattern': r'^[A-Za-z0-9-_.]{1,64}$'}, 'type': {'required': True}, + 'run_output_name': {'required': True, 'pattern': r'^[A-Za-z0-9-_.]{1,64}$'}, } _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, 'run_output_name': {'key': 'runOutputName', 'type': 'str'}, 'artifact_tags': {'key': 'artifactTags', 'type': '{str}'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, run_output_name: str, artifact_tags=None, **kwargs) -> None: + def __init__( + self, + *, + run_output_name: str, + artifact_tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ImageTemplateVhdDistributor, self).__init__(run_output_name=run_output_name, artifact_tags=artifact_tags, **kwargs) - self.type = 'VHD' + self.type = 'VHD' # type: str -class ImageTemplateVmProfile(Model): +class ImageTemplateVmProfile(msrest.serialization.Model): """Describes the virtual machine used to build, customize and capture images. - :param vm_size: Size of the virtual machine used to build, customize and - capture images. Omit or specify empty string to use the default - (Standard_D1_v2). + :param vm_size: Size of the virtual machine used to build, customize and capture images. Omit + or specify empty string to use the default (Standard_D1_v2). :type vm_size: str - :param os_disk_size_gb: Size of the OS disk in GB. Omit or specify 0 to - use Azure's default OS disk size. + :param os_disk_size_gb: Size of the OS disk in GB. Omit or specify 0 to use Azure's default OS + disk size. :type os_disk_size_gb: int - :param vnet_config: Optional configuration of the virtual network to use - to deploy the build virtual machine in. Omit if no specific virtual - network needs to be used. + :param vnet_config: Optional configuration of the virtual network to use to deploy the build + virtual machine in. Omit if no specific virtual network needs to be used. :type vnet_config: ~azure.mgmt.imagebuilder.models.VirtualNetworkConfig """ @@ -882,7 +1004,14 @@ class ImageTemplateVmProfile(Model): 'vnet_config': {'key': 'vnetConfig', 'type': 'VirtualNetworkConfig'}, } - def __init__(self, *, vm_size: str=None, os_disk_size_gb: int=None, vnet_config=None, **kwargs) -> None: + def __init__( + self, + *, + vm_size: Optional[str] = "", + os_disk_size_gb: Optional[int] = 0, + vnet_config: Optional["VirtualNetworkConfig"] = None, + **kwargs + ): super(ImageTemplateVmProfile, self).__init__(**kwargs) self.vm_size = vm_size self.os_disk_size_gb = os_disk_size_gb @@ -890,26 +1019,24 @@ def __init__(self, *, vm_size: str=None, os_disk_size_gb: int=None, vnet_config= class ImageTemplateWindowsUpdateCustomizer(ImageTemplateCustomizer): - """Installs Windows Updates. Corresponds to Packer Windows Update Provisioner - (https://github.com/rgl/packer-provisioner-windows-update). + """Installs Windows Updates. Corresponds to Packer Windows Update Provisioner (https://github.com/rgl/packer-provisioner-windows-update). All required parameters must be populated in order to send to Azure. - :param name: Friendly Name to provide context on what this customization - step does - :type name: str - :param type: Required. Constant filled by server. + :param type: Required. The type of customization tool you want to use on the Image. For + example, "Shell" can be shell customizer.Constant filled by server. :type type: str - :param search_criteria: Criteria to search updates. Omit or specify empty - string to use the default (search all). Refer to above link for examples - and detailed description of this field. + :param name: Friendly Name to provide context on what this customization step does. + :type name: str + :param search_criteria: Criteria to search updates. Omit or specify empty string to use the + default (search all). Refer to above link for examples and detailed description of this field. :type search_criteria: str - :param filters: Array of filters to select updates to apply. Omit or - specify empty array to use the default (no filter). Refer to above link - for examples and detailed description of this field. + :param filters: Array of filters to select updates to apply. Omit or specify empty array to use + the default (no filter). Refer to above link for examples and detailed description of this + field. :type filters: list[str] - :param update_limit: Maximum number of updates to apply at a time. Omit or - specify 0 to use the default (1000) + :param update_limit: Maximum number of updates to apply at a time. Omit or specify 0 to use the + default (1000). :type update_limit: int """ @@ -919,22 +1046,30 @@ class ImageTemplateWindowsUpdateCustomizer(ImageTemplateCustomizer): } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'search_criteria': {'key': 'searchCriteria', 'type': 'str'}, 'filters': {'key': 'filters', 'type': '[str]'}, 'update_limit': {'key': 'updateLimit', 'type': 'int'}, } - def __init__(self, *, name: str=None, search_criteria: str=None, filters=None, update_limit: int=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + search_criteria: Optional[str] = None, + filters: Optional[List[str]] = None, + update_limit: Optional[int] = None, + **kwargs + ): super(ImageTemplateWindowsUpdateCustomizer, self).__init__(name=name, **kwargs) + self.type = 'WindowsUpdate' # type: str self.search_criteria = search_criteria self.filters = filters self.update_limit = update_limit - self.type = 'WindowsUpdate' -class InnerError(Model): +class InnerError(msrest.serialization.Model): """Inner error details. :param exception_type: The exception type. @@ -948,26 +1083,30 @@ class InnerError(Model): 'error_detail': {'key': 'errorDetail', 'type': 'str'}, } - def __init__(self, *, exception_type: str=None, error_detail: str=None, **kwargs) -> None: + def __init__( + self, + *, + exception_type: Optional[str] = None, + error_detail: Optional[str] = None, + **kwargs + ): super(InnerError, self).__init__(**kwargs) self.exception_type = exception_type self.error_detail = error_detail -class Operation(Model): +class Operation(msrest.serialization.Model): """A REST API operation. - :param name: The operation name. This is of the format - {provider}/{resource}/{operation} + :param name: This is of the format {provider}/{resource}/{operation}. :type name: str :param display: The object that describes the operation. :type display: ~azure.mgmt.imagebuilder.models.OperationDisplay :param origin: The intended executor of the operation. :type origin: str - :param properties: Properties of the operation. - :type properties: object - :param is_data_action: The flag that indicates whether the operation - applies to data plane. + :param properties: Any object. + :type properties: str + :param is_data_action: The flag that indicates whether the operation applies to data plane. :type is_data_action: bool """ @@ -975,11 +1114,20 @@ class Operation(Model): 'name': {'key': 'name', 'type': 'str'}, 'display': {'key': 'display', 'type': 'OperationDisplay'}, 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'object'}, + 'properties': {'key': 'properties', 'type': 'str'}, 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, } - def __init__(self, *, name: str=None, display=None, origin: str=None, properties=None, is_data_action: bool=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + origin: Optional[str] = None, + properties: Optional[str] = None, + is_data_action: Optional[bool] = None, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -988,13 +1136,12 @@ def __init__(self, *, name: str=None, display=None, origin: str=None, properties self.is_data_action = is_data_action -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that describes the operation. :param provider: Friendly name of the resource provider. :type provider: str - :param operation: The operation type. For example: read, write, delete, or - listKeys/action + :param operation: For example: read, write, delete, or listKeys/action. :type operation: str :param resource: The resource type on which the operation is performed. :type resource: str @@ -1009,7 +1156,15 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, provider: str=None, operation: str=None, resource: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + provider: Optional[str] = None, + operation: Optional[str] = None, + resource: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.operation = operation @@ -1017,7 +1172,33 @@ def __init__(self, *, provider: str=None, operation: str=None, resource: str=Non self.description = description -class PlatformImagePurchasePlan(Model): +class OperationListResult(msrest.serialization.Model): + """Result of the request to list REST API operations. It contains a list of operations and a URL nextLink to get the next set of results. + + :param value: The list of operations supported by the resource provider. + :type value: list[~azure.mgmt.imagebuilder.models.Operation] + :param next_link: The URL to get the next set of operation list results if there are any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PlatformImagePurchasePlan(msrest.serialization.Model): """Purchase plan configuration for platform image. All required parameters must be populated in order to send to Azure. @@ -1042,24 +1223,29 @@ class PlatformImagePurchasePlan(Model): 'plan_publisher': {'key': 'planPublisher', 'type': 'str'}, } - def __init__(self, *, plan_name: str, plan_product: str, plan_publisher: str, **kwargs) -> None: + def __init__( + self, + *, + plan_name: str, + plan_product: str, + plan_publisher: str, + **kwargs + ): super(PlatformImagePurchasePlan, self).__init__(**kwargs) self.plan_name = plan_name self.plan_product = plan_product self.plan_publisher = plan_publisher -class ProvisioningError(Model): +class ProvisioningError(msrest.serialization.Model): """Describes the error happened when create or update an image template. - :param provisioning_error_code: Error code of the provisioning failure. - Possible values include: 'BadSourceType', 'BadPIRSource', - 'BadManagedImageSource', 'BadSharedImageVersionSource', - 'BadCustomizerType', 'UnsupportedCustomizerType', 'NoCustomizerScript', - 'BadDistributeType', 'BadSharedImageDistribute', 'ServerError', 'Other' - :type provisioning_error_code: str or - ~azure.mgmt.imagebuilder.models.ProvisioningErrorCode - :param message: Verbose error message about the provisioning failure + :param provisioning_error_code: Error code of the provisioning failure. Possible values + include: "BadSourceType", "BadPIRSource", "BadManagedImageSource", + "BadSharedImageVersionSource", "BadCustomizerType", "UnsupportedCustomizerType", + "NoCustomizerScript", "BadDistributeType", "BadSharedImageDistribute", "ServerError", "Other". + :type provisioning_error_code: str or ~azure.mgmt.imagebuilder.models.ProvisioningErrorCode + :param message: Verbose error message about the provisioning failure. :type message: str """ @@ -1068,25 +1254,30 @@ class ProvisioningError(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, *, provisioning_error_code=None, message: str=None, **kwargs) -> None: + def __init__( + self, + *, + provisioning_error_code: Optional[Union[str, "ProvisioningErrorCode"]] = None, + message: Optional[str] = None, + **kwargs + ): super(ProvisioningError, self).__init__(**kwargs) self.provisioning_error_code = provisioning_error_code self.message = message -class SubResource(Model): +class SubResource(msrest.serialization.Model): """The Sub Resource model definition. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Resource Id + :ivar id: Resource Id. :vartype id: str - :param name: Required. Resource name + :param name: Required. Resource name. :type name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str """ @@ -1102,7 +1293,12 @@ class SubResource(Model): 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, name: str, **kwargs) -> None: + def __init__( + self, + *, + name: str, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = None self.name = name @@ -1112,25 +1308,23 @@ def __init__(self, *, name: str, **kwargs) -> None: class RunOutput(SubResource): """Represents an output that was created by running an image template. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Resource Id + :ivar id: Resource Id. :vartype id: str - :param name: Required. Resource name + :param name: Required. Resource name. :type name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str :param artifact_id: The resource id of the artifact. :type artifact_id: str :param artifact_uri: The location URI of the artifact. :type artifact_uri: str - :ivar provisioning_state: Provisioning state of the resource. Possible - values include: 'Creating', 'Updating', 'Succeeded', 'Failed', 'Deleting' - :vartype provisioning_state: str or - ~azure.mgmt.imagebuilder.models.ProvisioningState + :ivar provisioning_state: Provisioning state of the resource. Possible values include: + "Creating", "Updating", "Succeeded", "Failed", "Deleting". + :vartype provisioning_state: str or ~azure.mgmt.imagebuilder.models.ProvisioningState """ _validation = { @@ -1146,17 +1340,50 @@ class RunOutput(SubResource): 'type': {'key': 'type', 'type': 'str'}, 'artifact_id': {'key': 'properties.artifactId', 'type': 'str'}, 'artifact_uri': {'key': 'properties.artifactUri', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'ProvisioningState'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, } - def __init__(self, *, name: str, artifact_id: str=None, artifact_uri: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: str, + artifact_id: Optional[str] = None, + artifact_uri: Optional[str] = None, + **kwargs + ): super(RunOutput, self).__init__(name=name, **kwargs) self.artifact_id = artifact_id self.artifact_uri = artifact_uri self.provisioning_state = None -class VirtualNetworkConfig(Model): +class RunOutputCollection(msrest.serialization.Model): + """The result of List run outputs operation. + + :param value: An array of run outputs. + :type value: list[~azure.mgmt.imagebuilder.models.RunOutput] + :param next_link: The continuation token. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[RunOutput]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["RunOutput"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(RunOutputCollection, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class VirtualNetworkConfig(msrest.serialization.Model): """Virtual Network configuration. :param subnet_id: Resource id of a pre-existing subnet. @@ -1167,6 +1394,11 @@ class VirtualNetworkConfig(Model): 'subnet_id': {'key': 'subnetId', 'type': 'str'}, } - def __init__(self, *, subnet_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + subnet_id: Optional[str] = None, + **kwargs + ): super(VirtualNetworkConfig, self).__init__(**kwargs) self.subnet_id = subnet_id diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_paged_models.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_paged_models.py deleted file mode 100644 index b5df98f1db25..000000000000 --- a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_paged_models.py +++ /dev/null @@ -1,53 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class ImageTemplatePaged(Paged): - """ - A paging container for iterating over a list of :class:`ImageTemplate ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ImageTemplate]'} - } - - def __init__(self, *args, **kwargs): - - super(ImageTemplatePaged, self).__init__(*args, **kwargs) -class RunOutputPaged(Paged): - """ - A paging container for iterating over a list of :class:`RunOutput ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[RunOutput]'} - } - - def __init__(self, *args, **kwargs): - - super(RunOutputPaged, self).__init__(*args, **kwargs) -class OperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Operation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Operation]'} - } - - def __init__(self, *args, **kwargs): - - super(OperationPaged, self).__init__(*args, **kwargs) diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/operations/__init__.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/operations/__init__.py index 6c4b698e8187..f2e05de690ae 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/operations/__init__.py +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._virtual_machine_image_templates_operations import VirtualMachineImageTemplatesOperations diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/operations/_operations.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/operations/_operations.py index e153a10b9548..fc2cab392ab0 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/operations/_operations.py +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/operations/_operations.py @@ -1,101 +1,110 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat -from .. import models +from .. import models as _models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class Operations(object): """Operations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + 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. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.imagebuilder.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. - :ivar api_version: Client Api Version. Constant value: "2020-02-14". """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2020-02-14" - - self.config = config + self._config = config def list( - self, custom_headers=None, raw=False, **operation_config): - """Lists available operations for the Microsoft.VirtualMachineImages - provider. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Operation - :rtype: - ~azure.mgmt.imagebuilder.models.OperationPaged[~azure.mgmt.imagebuilder.models.Operation] - :raises: - :class:`ApiErrorException` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.OperationListResult"] + """Lists available operations for the Microsoft.VirtualMachineImages provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.imagebuilder.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list.metadata['url'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ApiErrorException(self._deserialize, response) - - return response + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/providers/Microsoft.VirtualMachineImages/operations'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.VirtualMachineImages/operations'} # type: ignore diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/operations/_virtual_machine_image_templates_operations.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/operations/_virtual_machine_image_templates_operations.py index bd7ad792e602..f463a6662956 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/operations/_virtual_machine_image_templates_operations.py +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/operations/_virtual_machine_image_templates_operations.py @@ -1,811 +1,981 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling -from .. import models +from .. import models as _models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImageTemplatesOperations(object): """VirtualMachineImageTemplatesOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + 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. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.imagebuilder.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. - :ivar api_version: Client Api Version. Constant value: "2020-02-14". """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2020-02-14" - - self.config = config + self._config = config def list( - self, custom_headers=None, raw=False, **operation_config): - """Gets information about the VM image templates associated with the - subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ImageTemplate - :rtype: - ~azure.mgmt.imagebuilder.models.ImageTemplatePaged[~azure.mgmt.imagebuilder.models.ImageTemplate] - :raises: - :class:`ApiErrorException` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ImageTemplateListResult"] + """Gets information about the VM image templates associated with the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ImageTemplateListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.imagebuilder.models.ImageTemplateListResult] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageTemplateListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ImageTemplateListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ApiErrorException(self._deserialize, response) - - return response + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ImageTemplatePaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.VirtualMachineImages/imageTemplates'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.VirtualMachineImages/imageTemplates'} # type: ignore def list_by_resource_group( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): - """Gets information about the VM image templates associated with the - specified resource group. + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ImageTemplateListResult"] + """Gets information about the VM image templates associated with the specified resource group. :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ImageTemplate - :rtype: - ~azure.mgmt.imagebuilder.models.ImageTemplatePaged[~azure.mgmt.imagebuilder.models.ImageTemplate] - :raises: - :class:`ApiErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ImageTemplateListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.imagebuilder.models.ImageTemplateListResult] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageTemplateListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['url'] + url = self.list_by_resource_group.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ImageTemplateListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ApiErrorException(self._deserialize, response) + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ImageTemplatePaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates'} + return pipeline_response + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates'} # type: ignore def _create_or_update_initial( - self, parameters, resource_group_name, image_template_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + image_template_name, # type: str + parameters, # type: "_models.ImageTemplate" + **kwargs # type: Any + ): + # type: (...) -> "_models.ImageTemplate" + cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageTemplate"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self._create_or_update_initial.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$') + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ImageTemplate') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ImageTemplate') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ApiErrorException(self._deserialize, response) - - deserialized = None + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ImageTemplate', response) + deserialized = self._deserialize('ImageTemplate', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ImageTemplate', response) + deserialized = self._deserialize('ImageTemplate', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, parameters, resource_group_name, image_template_name, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + image_template_name, # type: str + parameters, # type: "_models.ImageTemplate" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.ImageTemplate"] """Create or update a virtual machine image template. - :param parameters: Parameters supplied to the CreateImageTemplate - operation - :type parameters: ~azure.mgmt.imagebuilder.models.ImageTemplate :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param image_template_name: The name of the image Template + :param image_template_name: The name of the image Template. :type image_template_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy - :return: An instance of LROPoller that returns ImageTemplate or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.imagebuilder.models.ImageTemplate] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.imagebuilder.models.ImageTemplate]] - :raises: - :class:`ApiErrorException` + :param parameters: Parameters supplied to the CreateImageTemplate operation. + :type parameters: ~azure.mgmt.imagebuilder.models.ImageTemplate + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either ImageTemplate or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.imagebuilder.models.ImageTemplate] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._create_or_update_initial( - parameters=parameters, - resource_group_name=resource_group_name, - image_template_name=image_template_name, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageTemplate"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) - - def get_long_running_output(response): - deserialized = self._deserialize('ImageTemplate', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + image_template_name=image_template_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ImageTemplate', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} - + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore def _update_initial( - self, resource_group_name, image_template_name, identity=None, tags=None, custom_headers=None, raw=False, **operation_config): - parameters = models.ImageTemplateUpdateParameters(identity=identity, tags=tags) + self, + resource_group_name, # type: str + image_template_name, # type: str + parameters, # type: "_models.ImageTemplateUpdateParameters" + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.ImageTemplate"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ImageTemplate"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.update.metadata['url'] + url = self._update_initial.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$') + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ImageTemplateUpdateParameters') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ImageTemplateUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202]: - raise models.ApiErrorException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ImageTemplate', response) + deserialized = self._deserialize('ImageTemplate', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update( - self, resource_group_name, image_template_name, identity=None, tags=None, custom_headers=None, raw=False, polling=True, **operation_config): + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + + def begin_update( + self, + resource_group_name, # type: str + image_template_name, # type: str + parameters, # type: "_models.ImageTemplateUpdateParameters" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.ImageTemplate"] """Update the tags for this Virtual Machine Image Template. :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param image_template_name: The name of the image Template + :param image_template_name: The name of the image Template. :type image_template_name: str - :param identity: The identity of the image template, if configured. - :type identity: ~azure.mgmt.imagebuilder.models.ImageTemplateIdentity - :param tags: The user-specified tags associated with the image - template. - :type tags: dict[str, str] - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy - :return: An instance of LROPoller that returns ImageTemplate or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.imagebuilder.models.ImageTemplate] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.imagebuilder.models.ImageTemplate]] - :raises: - :class:`ApiErrorException` + :param parameters: Additional parameters for Image Template update. + :type parameters: ~azure.mgmt.imagebuilder.models.ImageTemplateUpdateParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either ImageTemplate or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.imagebuilder.models.ImageTemplate] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._update_initial( - resource_group_name=resource_group_name, - image_template_name=image_template_name, - identity=identity, - tags=tags, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageTemplate"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) - - def get_long_running_output(response): - deserialized = self._deserialize('ImageTemplate', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + image_template_name=image_template_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ImageTemplate', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore def get( - self, resource_group_name, image_template_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + image_template_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.ImageTemplate" """Get information about a virtual machine image template. :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param image_template_name: The name of the image Template + :param image_template_name: The name of the image Template. :type image_template_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ImageTemplate or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.imagebuilder.models.ImageTemplate or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ApiErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImageTemplate, or the result of cls(response) + :rtype: ~azure.mgmt.imagebuilder.models.ImageTemplate + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageTemplate"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$') + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ApiErrorException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ImageTemplate', response) + deserialized = self._deserialize('ImageTemplate', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} - + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore def _delete_initial( - self, resource_group_name, image_template_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + image_template_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self._delete_initial.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$') + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - raise models.ApiErrorException(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, image_template_name, custom_headers=None, raw=False, polling=True, **operation_config): + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + image_template_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] """Delete a virtual machine image template. :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param image_template_name: The name of the image Template + :param image_template_name: The name of the image Template. :type image_template_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: - :class:`ApiErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - image_template_name=image_template_name, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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( + resource_group_name=resource_group_name, + image_template_name=image_template_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} - + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore def _run_initial( - self, resource_group_name, image_template_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + image_template_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + accept = "application/json" + # Construct URL - url = self.run.metadata['url'] + url = self._run_initial.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$') + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - raise models.ApiErrorException(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def run( - self, resource_group_name, image_template_name, custom_headers=None, raw=False, polling=True, **operation_config): + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _run_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/run'} # type: ignore + + def begin_run( + self, + resource_group_name, # type: str + image_template_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] """Create artifacts from a existing image template. :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param image_template_name: The name of the image Template + :param image_template_name: The name of the image Template. :type image_template_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: - :class:`ApiErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._run_initial( - resource_group_name=resource_group_name, - image_template_name=image_template_name, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._run_initial( + resource_group_name=resource_group_name, + image_template_name=image_template_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - run.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/run'} - + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_run.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/run'} # type: ignore def _cancel_initial( - self, resource_group_name, image_template_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + image_template_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + accept = "application/json" + # Construct URL - url = self.cancel.metadata['url'] + url = self._cancel_initial.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$') + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - raise models.ApiErrorException(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def cancel( - self, resource_group_name, image_template_name, custom_headers=None, raw=False, polling=True, **operation_config): + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _cancel_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/cancel'} # type: ignore + + def begin_cancel( + self, + resource_group_name, # type: str + image_template_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] """Cancel the long running image build based on the image template. :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param image_template_name: The name of the image Template + :param image_template_name: The name of the image Template. :type image_template_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: - :class:`ApiErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._cancel_initial( - resource_group_name=resource_group_name, - image_template_name=image_template_name, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._cancel_initial( + resource_group_name=resource_group_name, + image_template_name=image_template_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/cancel'} + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/cancel'} # type: ignore def list_run_outputs( - self, resource_group_name, image_template_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + image_template_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.RunOutputCollection"] """List all run outputs for the specified Image Template resource. :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param image_template_name: The name of the image Template + :param image_template_name: The name of the image Template. :type image_template_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of RunOutput - :rtype: - ~azure.mgmt.imagebuilder.models.RunOutputPaged[~azure.mgmt.imagebuilder.models.RunOutput] - :raises: - :class:`ApiErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RunOutputCollection or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.imagebuilder.models.RunOutputCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RunOutputCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_run_outputs.metadata['url'] + url = self.list_run_outputs.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$') + 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('RunOutputCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ApiErrorException(self._deserialize, response) - - return response + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.RunOutputPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_run_outputs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/runOutputs'} + return ItemPaged( + get_next, extract_data + ) + list_run_outputs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/runOutputs'} # type: ignore def get_run_output( - self, resource_group_name, image_template_name, run_output_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + image_template_name, # type: str + run_output_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.RunOutput" """Get the specified run output for the specified image template resource. :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param image_template_name: The name of the image Template + :param image_template_name: The name of the image Template. :type image_template_name: str - :param run_output_name: The name of the run output + :param run_output_name: The name of the run output. :type run_output_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: RunOutput or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.imagebuilder.models.RunOutput or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ApiErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RunOutput, or the result of cls(response) + :rtype: ~azure.mgmt.imagebuilder.models.RunOutput + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RunOutput"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-14" + accept = "application/json" + # Construct URL - url = self.get_run_output.metadata['url'] + url = self.get_run_output.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'imageTemplateName': self._serialize.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), - 'runOutputName': self._serialize.url("run_output_name", run_output_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$') + 'runOutputName': self._serialize.url("run_output_name", run_output_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ApiErrorException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ApiError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('RunOutput', response) + deserialized = self._deserialize('RunOutput', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_run_output.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/runOutputs/{runOutputName}'} + get_run_output.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/runOutputs/{runOutputName}'} # type: ignore diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/py.typed b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file