From 2d978e2ca567ac7631d06c61d444877ee89f3e71 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 16 May 2022 22:32:24 +0000 Subject: [PATCH] CodeGen from PR 18896 in Azure/azure-rest-api-specs Merge 8d60aa0b1ca9db97f495daa4144f5aeb09f4cfd5 into 63353171621815e17db46a3075a79c9af60a0831 --- .../azure-mgmt-imagebuilder/_meta.json | 10 +- .../azure/mgmt/imagebuilder/__init__.py | 9 +- .../azure/mgmt/imagebuilder/_configuration.py | 31 +- .../imagebuilder/_image_builder_client.py | 94 +- .../azure/mgmt/imagebuilder/_metadata.json | 25 +- .../azure/mgmt/imagebuilder/_patch.py | 31 + .../azure/mgmt/imagebuilder/_vendor.py | 27 + .../azure/mgmt/imagebuilder/_version.py | 2 +- .../azure/mgmt/imagebuilder/aio/__init__.py | 5 + .../mgmt/imagebuilder/aio/_configuration.py | 18 +- .../imagebuilder/aio/_image_builder_client.py | 82 +- .../azure/mgmt/imagebuilder/aio/_patch.py | 31 + .../aio/operations/_operations.py | 59 +- ...tual_machine_image_templates_operations.py | 665 +++++---- .../mgmt/imagebuilder/models/__init__.py | 115 +- .../models/_image_builder_client_enums.py | 38 +- .../azure/mgmt/imagebuilder/models/_models.py | 1317 ----------------- .../mgmt/imagebuilder/models/_models_py3.py | 1216 +++++++++++---- .../imagebuilder/operations/_operations.py | 98 +- ...tual_machine_image_templates_operations.py | 1178 ++++++++++----- 20 files changed, 2432 insertions(+), 2619 deletions(-) create mode 100644 sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_patch.py create mode 100644 sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_vendor.py create mode 100644 sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/_patch.py delete mode 100644 sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_models.py diff --git a/sdk/compute/azure-mgmt-imagebuilder/_meta.json b/sdk/compute/azure-mgmt-imagebuilder/_meta.json index c63bfe67740e1..ecbc5dfa8b1b6 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/_meta.json +++ b/sdk/compute/azure-mgmt-imagebuilder/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.13.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "c6fc51d3b5e900961dab94f7655ba63d2813da19", + "commit": "f7f0b129e1bffb6bd4400efd403d956cc1d625a5", "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.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "autorest_command": "autorest specification/imagebuilder/resource-manager/readme.md --multiapi --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "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 6bc8a7ccb752c..7563ac8f4c8a9 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/__init__.py +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ImageBuilderClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() 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 9a33f417df428..e00bd97169f7b 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_configuration.py +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, 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): +class ImageBuilderClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for ImageBuilderClient. Note that all parameters used to create this instance are saved as instance @@ -29,26 +27,31 @@ class ImageBuilderClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription Id forms part of the URI for every service call. + :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription Id forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-02-14". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ImageBuilderClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + 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 = "2021-10-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-imagebuilder/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +71,4 @@ def _configure( 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy(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 a45433632f793..e7031a37d2ad6 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 @@ -6,79 +6,87 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, 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 azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import ImageBuilderClientConfiguration -from .operations import VirtualMachineImageTemplatesOperations -from .operations import Operations from . import models +from ._configuration import ImageBuilderClientConfiguration +from .operations import Operations, VirtualMachineImageTemplatesOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class ImageBuilderClient(object): +class ImageBuilderClient: """Azure Virtual Machine Image Builder Client. :ivar virtual_machine_image_templates: VirtualMachineImageTemplatesOperations operations - :vartype virtual_machine_image_templates: azure.mgmt.imagebuilder.operations.VirtualMachineImageTemplatesOperations + :vartype virtual_machine_image_templates: + azure.mgmt.imagebuilder.operations.VirtualMachineImageTemplatesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.imagebuilder.operations.Operations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription Id forms part of the URI for every service call. + :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription Id forms part of the URI for every service call. :type subscription_id: str - :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. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-02-14". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( 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) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ImageBuilderClientConfiguration(credential=credential, subscription_id=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._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + 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) - 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) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: 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. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.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 + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_metadata.json b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_metadata.json index e826e2228ba78..57435eb7e085c 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_metadata.json +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_metadata.json @@ -1,17 +1,17 @@ { - "chosen_version": "2021-10-01", - "total_api_version_list": ["2021-10-01"], + "chosen_version": "2022-02-14", + "total_api_version_list": ["2022-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, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"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\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ImageBuilderClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ImageBuilderClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "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\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "virtual_machine_image_templates": "VirtualMachineImageTemplatesOperations", diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_patch.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_vendor.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# 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 azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_version.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_version.py index c47f66669f1bf..e5754a47ce68f 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_version.py +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.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 index 334f853a6ca6c..3df2f6117e6b7 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/__init__.py +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/__init__.py @@ -8,3 +8,8 @@ from ._image_builder_client import ImageBuilderClient __all__ = ['ImageBuilderClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() 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 index 7087c04000cd2..0701f7e44aecb 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/_configuration.py +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class ImageBuilderClientConfiguration(Configuration): +class ImageBuilderClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for ImageBuilderClient. Note that all parameters used to create this instance are saved as instance @@ -27,8 +27,12 @@ class ImageBuilderClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription Id forms part of the URI for every service call. + :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription Id forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-02-14". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +41,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ImageBuilderClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + 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 = "2021-10-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-imagebuilder/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +70,4 @@ def _configure( 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) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(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 index 21412e5c7aebd..47ba27df0fcef 100644 --- 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 @@ -6,75 +6,87 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, 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 azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import ImageBuilderClientConfiguration -from .operations import VirtualMachineImageTemplatesOperations -from .operations import Operations from .. import models +from ._configuration import ImageBuilderClientConfiguration +from .operations import Operations, VirtualMachineImageTemplatesOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class ImageBuilderClient(object): +class ImageBuilderClient: """Azure Virtual Machine Image Builder Client. :ivar virtual_machine_image_templates: VirtualMachineImageTemplatesOperations operations - :vartype virtual_machine_image_templates: azure.mgmt.imagebuilder.aio.operations.VirtualMachineImageTemplatesOperations + :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. + :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. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-02-14". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ImageBuilderClientConfiguration(credential, subscription_id, **kwargs) + self._config = ImageBuilderClientConfiguration(credential=credential, subscription_id=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._serialize.client_side_validation = False + 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) - 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: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[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. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.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 + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/_patch.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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 index fb17a539cd9b3..83522f79109c3 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # 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 typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,38 +53,40 @@ def list( :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] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.imagebuilder.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - 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 = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,7 +95,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -98,7 +108,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.VirtualMachineImages/operations'} # type: ignore + 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 index ca6687d6ab791..78eb13320a955 100644 --- 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,19 +6,22 @@ # 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 typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union 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.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._virtual_machine_image_templates_operations import build_cancel_request_initial, build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_get_run_output_request, build_list_by_resource_group_request, build_list_request, build_list_run_outputs_request, build_run_request_initial, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -50,43 +55,44 @@ def list( """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] + :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 """ + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + 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 = "2021-10-01" - 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) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ImageTemplateListResult', pipeline_response) + deserialized = self._deserialize("ImageTemplateListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -95,7 +101,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -104,11 +114,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.VirtualMachineImages/imageTemplates'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.VirtualMachineImages/imageTemplates"} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -119,44 +131,46 @@ def list_by_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] + :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 """ + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + 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 = "2021-10-01" - 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) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ImageTemplateListResult', pipeline_response) + deserialized = self._deserialize("ImageTemplateListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -165,7 +179,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -174,10 +192,11 @@ async def get_next(next_link=None): 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 + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates"} # type: ignore async def _create_or_update_initial( self, @@ -191,33 +210,29 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - 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) + + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ImageTemplate') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + image_template_name=image_template_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -234,8 +249,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}"} # type: ignore + + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -253,14 +271,19 @@ async def begin_create_or_update( :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: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in 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) + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageTemplate"] lro_delay = kwargs.pop( @@ -273,27 +296,22 @@ async def begin_create_or_update( resource_group_name=resource_group_name, image_template_name=image_template_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_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) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -303,9 +321,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + 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, @@ -319,33 +337,29 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - 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) + + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ImageTemplateUpdateParameters') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + image_template_name=image_template_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -360,8 +374,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}"} # type: ignore + + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -379,14 +396,19 @@ async def begin_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: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in 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) + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageTemplate"] lro_delay = kwargs.pop( @@ -399,27 +421,22 @@ async def begin_update( resource_group_name=resource_group_name, image_template_name=image_template_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_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) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -429,10 +446,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + 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 + @distributed_trace_async async def get( self, resource_group_name: str, @@ -455,28 +473,25 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - 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') + api_version = kwargs.pop('api_version', "2022-02-14") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + image_template_name=image_template_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -489,9 +504,11 @@ async def get( 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( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, image_template_name: str, @@ -502,28 +519,25 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - 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') + api_version = kwargs.pop('api_version', "2022-02-14") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + image_template_name=image_template_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -533,9 +547,11 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}"} # type: ignore + - async def begin_delete( + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, image_template_name: str, @@ -549,14 +565,17 @@ async def begin_delete( :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: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in 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. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-02-14") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -568,24 +587,18 @@ async def begin_delete( raw_result = await self._delete_initial( resource_group_name=resource_group_name, image_template_name=image_template_name, + api_version=api_version, 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) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -595,11 +608,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _run_initial( + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}"} # type: ignore + + async def _run_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, image_template_name: str, @@ -610,28 +623,25 @@ async def _run_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - 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') + api_version = kwargs.pop('api_version', "2022-02-14") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_run_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + image_template_name=image_template_name, + api_version=api_version, + template_url=self._run_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -641,9 +651,11 @@ async def _run_initial( if cls: return cls(pipeline_response, None, {}) - _run_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/run'} # type: ignore + _run_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/run"} # type: ignore + - async def begin_run( + @distributed_trace_async + async def begin_run( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, image_template_name: str, @@ -657,14 +669,17 @@ async def begin_run( :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: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in 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. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-02-14") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -676,24 +691,18 @@ async def begin_run( raw_result = await self._run_initial( resource_group_name=resource_group_name, image_template_name=image_template_name, + api_version=api_version, 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) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -703,11 +712,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_run.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/run'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _cancel_initial( + begin_run.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/run"} # type: ignore + + async def _cancel_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, image_template_name: str, @@ -718,28 +727,25 @@ async def _cancel_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - 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') + api_version = kwargs.pop('api_version', "2022-02-14") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + image_template_name=image_template_name, + api_version=api_version, + template_url=self._cancel_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -749,9 +755,11 @@ async def _cancel_initial( if cls: return cls(pipeline_response, None, {}) - _cancel_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/cancel'} # type: ignore + _cancel_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/cancel"} # type: ignore + - async def begin_cancel( + @distributed_trace_async + async def begin_cancel( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, image_template_name: str, @@ -765,14 +773,17 @@ async def begin_cancel( :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: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in 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. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-02-14") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -784,24 +795,18 @@ async def begin_cancel( raw_result = await self._cancel_initial( resource_group_name=resource_group_name, image_template_name=image_template_name, + api_version=api_version, 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) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -811,10 +816,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/cancel'} # type: ignore + 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 + @distributed_trace def list_run_outputs( self, resource_group_name: str, @@ -829,44 +835,46 @@ def list_run_outputs( :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] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.imagebuilder.models.RunOutputCollection] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + 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 = "2021-10-01" - 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) + + request = build_list_run_outputs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + image_template_name=image_template_name, + api_version=api_version, + template_url=self.list_run_outputs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_run_outputs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + image_template_name=image_template_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RunOutputCollection', pipeline_response) + deserialized = self._deserialize("RunOutputCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -875,7 +883,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -884,11 +896,13 @@ async def get_next(next_link=None): 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 + list_run_outputs.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/runOutputs"} # type: ignore + @distributed_trace_async async def get_run_output( self, resource_group_name: str, @@ -914,29 +928,26 @@ async def get_run_output( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - 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') + api_version = kwargs.pop('api_version', "2022-02-14") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_run_output_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + image_template_name=image_template_name, + run_output_name=run_output_name, + api_version=api_version, + template_url=self.get_run_output.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -949,4 +960,6 @@ async def get_run_output( 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 + + 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 1ee02c1268965..31ca72bc7a71f 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 @@ -6,76 +6,45 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import CloudErrorBody - 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 ImageTemplateLastRunStatus - from ._models_py3 import ImageTemplateListResult - from ._models_py3 import ImageTemplateManagedImageDistributor - from ._models_py3 import ImageTemplateManagedImageSource - from ._models_py3 import ImageTemplatePlatformImageSource - from ._models_py3 import ImageTemplatePowerShellCustomizer - from ._models_py3 import ImageTemplateRestartCustomizer - from ._models_py3 import ImageTemplateSharedImageDistributor - from ._models_py3 import ImageTemplateSharedImageVersionSource - from ._models_py3 import ImageTemplateShellCustomizer - from ._models_py3 import ImageTemplateSource - from ._models_py3 import ImageTemplateUpdateParameters - from ._models_py3 import ImageTemplateVhdDistributor - from ._models_py3 import ImageTemplateVmProfile - from ._models_py3 import ImageTemplateWindowsUpdateCustomizer - 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 SystemData - from ._models_py3 import TrackedResource - from ._models_py3 import VirtualNetworkConfig -except (SyntaxError, ImportError): - from ._models import CloudErrorBody # 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 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 SystemData # type: ignore - from ._models import TrackedResource # type: ignore - from ._models import VirtualNetworkConfig # type: ignore +from ._models_py3 import CloudErrorBody +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 ImageTemplateInVMValidator +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 +from ._models_py3 import ImageTemplatePowerShellCustomizer +from ._models_py3 import ImageTemplatePowerShellValidator +from ._models_py3 import ImageTemplatePropertiesValidate +from ._models_py3 import ImageTemplateRestartCustomizer +from ._models_py3 import ImageTemplateSharedImageDistributor +from ._models_py3 import ImageTemplateSharedImageVersionSource +from ._models_py3 import ImageTemplateShellCustomizer +from ._models_py3 import ImageTemplateShellValidator +from ._models_py3 import ImageTemplateSource +from ._models_py3 import ImageTemplateUpdateParameters +from ._models_py3 import ImageTemplateVhdDistributor +from ._models_py3 import ImageTemplateVmProfile +from ._models_py3 import ImageTemplateWindowsUpdateCustomizer +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 ProxyResource +from ._models_py3 import Resource +from ._models_py3 import RunOutput +from ._models_py3 import RunOutputCollection +from ._models_py3 import SystemData +from ._models_py3 import TrackedResource +from ._models_py3 import VirtualNetworkConfig + from ._image_builder_client_enums import ( CreatedByType, @@ -95,16 +64,20 @@ 'ImageTemplateDistributor', 'ImageTemplateFileCustomizer', 'ImageTemplateIdentity', + 'ImageTemplateInVMValidator', 'ImageTemplateLastRunStatus', 'ImageTemplateListResult', 'ImageTemplateManagedImageDistributor', 'ImageTemplateManagedImageSource', 'ImageTemplatePlatformImageSource', 'ImageTemplatePowerShellCustomizer', + 'ImageTemplatePowerShellValidator', + 'ImageTemplatePropertiesValidate', 'ImageTemplateRestartCustomizer', 'ImageTemplateSharedImageDistributor', 'ImageTemplateSharedImageVersionSource', 'ImageTemplateShellCustomizer', + 'ImageTemplateShellValidator', 'ImageTemplateSource', 'ImageTemplateUpdateParameters', 'ImageTemplateVhdDistributor', @@ -115,10 +88,10 @@ 'OperationListResult', 'PlatformImagePurchasePlan', 'ProvisioningError', + 'ProxyResource', 'Resource', 'RunOutput', 'RunOutputCollection', - 'SubResource', 'SystemData', 'TrackedResource', 'VirtualNetworkConfig', 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 9fe5eaae89eea..fe8f979aae5f5 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 @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -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 CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -35,7 +20,7 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class ProvisioningErrorCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningErrorCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Error code of the provisioning failure """ @@ -46,12 +31,16 @@ class ProvisioningErrorCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) BAD_CUSTOMIZER_TYPE = "BadCustomizerType" UNSUPPORTED_CUSTOMIZER_TYPE = "UnsupportedCustomizerType" NO_CUSTOMIZER_SCRIPT = "NoCustomizerScript" + BAD_VALIDATOR_TYPE = "BadValidatorType" + UNSUPPORTED_VALIDATOR_TYPE = "UnsupportedValidatorType" + NO_VALIDATOR_SCRIPT = "NoValidatorScript" BAD_DISTRIBUTE_TYPE = "BadDistributeType" BAD_SHARED_IMAGE_DISTRIBUTE = "BadSharedImageDistribute" + BAD_STAGING_RESOURCE_GROUP = "BadStagingResourceGroup" SERVER_ERROR = "ServerError" OTHER = "Other" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Provisioning state of the resource """ @@ -61,7 +50,7 @@ class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" DELETING = "Deleting" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +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. """ @@ -69,7 +58,7 @@ class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): USER_ASSIGNED = "UserAssigned" NONE = "None" -class RunState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RunState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """State of the last run """ @@ -80,16 +69,17 @@ class RunState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" CANCELED = "Canceled" -class RunSubState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RunSubState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Sub-state of the last run """ QUEUED = "Queued" BUILDING = "Building" CUSTOMIZING = "Customizing" + VALIDATING = "Validating" DISTRIBUTING = "Distributing" -class SharedImageStorageAccountType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +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). """ 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 deleted file mode 100644 index 55b7ab8831873..0000000000000 --- a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_models.py +++ /dev/null @@ -1,1317 +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. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class CloudErrorBody(msrest.serialization.Model): - """An error response from the Azure VM Image Builder service. - - :param code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user - interface. - :type message: str - :param target: The target of the particular error. For example, the name of the property in - error. - :type target: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.imagebuilder.models.CloudErrorBody] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.target = kwargs.get('target', None) - self.details = kwargs.get('details', None) - - -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(msrest.serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. - - 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: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.location = kwargs['location'] - - -class ImageTemplate(TrackedResource): - """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. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param identity: Required. The identity of the image template, if configured. - :type identity: ~azure.mgmt.imagebuilder.models.ImageTemplateIdentity - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.imagebuilder.models.SystemData - :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: 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. - :type vm_profile: ~azure.mgmt.imagebuilder.models.ImageTemplateVmProfile - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'identity': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'provisioning_error': {'readonly': True}, - 'last_run_status': {'readonly': True}, - 'build_timeout_in_minutes': {'maximum': 960, 'minimum': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ImageTemplateIdentity'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'source': {'key': 'properties.source', 'type': 'ImageTemplateSource'}, - 'customize': {'key': 'properties.customize', 'type': '[ImageTemplateCustomizer]'}, - 'distribute': {'key': 'properties.distribute', 'type': '[ImageTemplateDistributor]'}, - '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'}, - } - - def __init__( - self, - **kwargs - ): - super(ImageTemplate, self).__init__(**kwargs) - self.identity = kwargs['identity'] - self.system_data = None - 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', 0) - self.vm_profile = kwargs.get('vm_profile', None) - - -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: ImageTemplateFileCustomizer, ImageTemplatePowerShellCustomizer, ImageTemplateShellCustomizer, ImageTemplateRestartCustomizer, ImageTemplateWindowsUpdateCustomizer. - - All required parameters must be populated in order to send to Azure. - - :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 = { - 'type': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - _subtype_map = { - 'type': {'File': 'ImageTemplateFileCustomizer', 'PowerShell': 'ImageTemplatePowerShellCustomizer', 'Shell': 'ImageTemplateShellCustomizer', 'WindowsRestart': 'ImageTemplateRestartCustomizer', 'WindowsUpdate': 'ImageTemplateWindowsUpdateCustomizer'} - } - - def __init__( - self, - **kwargs - ): - super(ImageTemplateCustomizer, self).__init__(**kwargs) - self.type = None # type: Optional[str] - self.name = kwargs.get('name', None) - - -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. - - All required parameters must be populated in order to send to Azure. - - :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. - :type artifact_tags: dict[str, str] - """ - - _validation = { - '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}'}, - } - - _subtype_map = { - 'type': {'ManagedImage': 'ImageTemplateManagedImageDistributor', 'SharedImage': 'ImageTemplateSharedImageDistributor', 'VHD': 'ImageTemplateVhdDistributor'} - } - - def __init__( - self, - **kwargs - ): - super(ImageTemplateDistributor, self).__init__(**kwargs) - self.type = None # type: Optional[str] - self.run_output_name = kwargs['run_output_name'] - self.artifact_tags = kwargs.get('artifact_tags', None) - - -class ImageTemplateFileCustomizer(ImageTemplateCustomizer): - """Uploads files to VMs (Linux, Windows). Corresponds to Packer file provisioner. - - All required parameters must be populated in order to send to Azure. - - :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 - :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. - :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. - :type destination: str - """ - - _validation = { - 'type': {'required': True}, - } - - _attribute_map = { - '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 - ): - 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', "") - self.destination = kwargs.get('destination', None) - - -class ImageTemplateIdentity(msrest.serialization.Model): - """Identity for the image template. - - :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: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :type user_assigned_identities: dict[str, - ~azure.mgmt.imagebuilder.models.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties] - """ - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties}'}, - } - - 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 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.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". - :type run_sub_state: str or ~azure.mgmt.imagebuilder.models.RunSubState - :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': 'str'}, - 'run_sub_state': {'key': 'runSubState', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - 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) - self.run_state = kwargs.get('run_state', None) - self.run_sub_state = kwargs.get('run_sub_state', None) - 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 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. - :type artifact_tags: dict[str, str] - :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. - :type location: str - """ - - _validation = { - '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}'}, - 'image_id': {'key': 'imageId', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ImageTemplateManagedImageDistributor, self).__init__(**kwargs) - self.type = 'ManagedImage' # type: str - self.image_id = kwargs['image_id'] - self.location = kwargs['location'] - - -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: ImageTemplateManagedImageSource, ImageTemplatePlatformImageSource, ImageTemplateSharedImageVersionSource. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. Specifies the type of source image you want to start with.Constant - filled by server. - :type type: str - """ - - _validation = { - 'type': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - } - - _subtype_map = { - 'type': {'ManagedImage': 'ImageTemplateManagedImageSource', 'PlatformImage': 'ImageTemplatePlatformImageSource', 'SharedImageVersion': 'ImageTemplateSharedImageVersionSource'} - } - - def __init__( - self, - **kwargs - ): - super(ImageTemplateSource, self).__init__(**kwargs) - self.type = None # type: Optional[str] - - -class ImageTemplateManagedImageSource(ImageTemplateSource): - """Describes an image source that is a managed image in customer subscription. - - All required parameters must be populated in order to send to Azure. - - :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. - :type image_id: str - """ - - _validation = { - 'type': {'required': True}, - 'image_id': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'image_id': {'key': 'imageId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ImageTemplateManagedImageSource, self).__init__(**kwargs) - self.type = 'ManagedImage' # type: str - self.image_id = kwargs['image_id'] - - -class ImageTemplatePlatformImageSource(ImageTemplateSource): - """Describes an image source from `Azure Gallery Images `_. - - 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. - - :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 - `_. - :type publisher: str - :param offer: Image offer from the `Azure Gallery Images - `_. - :type offer: str - :param sku: Image sku from the `Azure Gallery Images - `_. - :type sku: str - :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. - :type version: str - :ivar exact_version: Image version from the `Azure Gallery Images - `_. This readonly field - differs from 'version', only if the value specified in 'version' field is 'latest'. - :vartype exact_version: str - :param plan_info: Optional configuration of purchase plan for platform image. - :type plan_info: ~azure.mgmt.imagebuilder.models.PlatformImagePurchasePlan - """ - - _validation = { - 'type': {'required': True}, - 'exact_version': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'offer': {'key': 'offer', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'exact_version': {'key': 'exactVersion', 'type': 'str'}, - 'plan_info': {'key': 'planInfo', 'type': 'PlatformImagePurchasePlan'}, - } - - 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.exact_version = None - self.plan_info = kwargs.get('plan_info', None) - - -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. - - All required parameters must be populated in order to send to Azure. - - :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 - :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. - :type sha256_checksum: str - :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. - :type run_elevated: bool - :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] - """ - - _validation = { - 'type': {'required': True}, - } - - _attribute_map = { - '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 - ): - 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', "") - self.inline = kwargs.get('inline', 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) - - -class ImageTemplateRestartCustomizer(ImageTemplateCustomizer): - """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 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 - :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: '']. - :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']. - :type restart_timeout: str - """ - - _validation = { - 'type': {'required': True}, - } - - _attribute_map = { - '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 - ): - 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) - - -class ImageTemplateSharedImageDistributor(ImageTemplateDistributor): - """Distribute via Shared Image Gallery. - - All required parameters must be populated in order to send to Azure. - - :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. - :type artifact_tags: dict[str, str] - :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. - :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). - :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". - :type storage_account_type: str or - ~azure.mgmt.imagebuilder.models.SharedImageStorageAccountType - """ - - _validation = { - '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}'}, - '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 - ): - super(ImageTemplateSharedImageDistributor, self).__init__(**kwargs) - 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) - - -class ImageTemplateSharedImageVersionSource(ImageTemplateSource): - """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. 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. - :type image_version_id: str - """ - - _validation = { - 'type': {'required': True}, - 'image_version_id': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'image_version_id': {'key': 'imageVersionId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ImageTemplateSharedImageVersionSource, self).__init__(**kwargs) - 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. - - All required parameters must be populated in order to send to Azure. - - :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 - :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. - :type sha256_checksum: str - :param inline: Array of shell commands to execute. - :type inline: list[str] - """ - - _validation = { - 'type': {'required': True}, - } - - _attribute_map = { - '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 - ): - 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', "") - self.inline = kwargs.get('inline', None) - - -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: A set of tags. The user-specified tags associated with the image template. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'identity': {'key': 'identity', 'type': 'ImageTemplateIdentity'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ImageTemplateUpdateParameters, self).__init__(**kwargs) - self.identity = kwargs.get('identity', None) - self.tags = kwargs.get('tags', None) - - -class ImageTemplateVhdDistributor(ImageTemplateDistributor): - """Distribute via VHD in a storage account. - - All required parameters must be populated in order to send to Azure. - - :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. - :type artifact_tags: dict[str, str] - """ - - _validation = { - '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}'}, - } - - def __init__( - self, - **kwargs - ): - super(ImageTemplateVhdDistributor, self).__init__(**kwargs) - self.type = 'VHD' # type: str - - -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_D2ds_v4). - :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. - :type os_disk_size_gb: int - :param user_assigned_identities: Optional array of resource IDs of user assigned managed - identities to be configured on the build VM. This may include the identity of the image - template. - :type user_assigned_identities: list[str] - :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 - """ - - _validation = { - 'os_disk_size_gb': {'minimum': 0}, - } - - _attribute_map = { - 'vm_size': {'key': 'vmSize', 'type': 'str'}, - 'os_disk_size_gb': {'key': 'osDiskSizeGB', 'type': 'int'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '[str]'}, - 'vnet_config': {'key': 'vnetConfig', 'type': 'VirtualNetworkConfig'}, - } - - def __init__( - self, - **kwargs - ): - super(ImageTemplateVmProfile, self).__init__(**kwargs) - self.vm_size = kwargs.get('vm_size', "") - self.os_disk_size_gb = kwargs.get('os_disk_size_gb', 0) - self.user_assigned_identities = kwargs.get('user_assigned_identities', None) - 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). - - All required parameters must be populated in order to send to Azure. - - :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 - :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. - :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). - :type update_limit: int - """ - - _validation = { - 'type': {'required': True}, - 'update_limit': {'minimum': 0}, - } - - _attribute_map = { - '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 - ): - 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) - - -class Operation(msrest.serialization.Model): - """A REST API 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: Any object. - :type properties: any - :param is_data_action: The flag that indicates whether the operation applies to data plane. - :type is_data_action: bool - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - self.properties = kwargs.get('properties', None) - self.is_data_action = kwargs.get('is_data_action', None) - - -class OperationDisplay(msrest.serialization.Model): - """The object that describes the operation. - - :param provider: Friendly name of the resource provider. - :type provider: str - :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 - :param description: The friendly name of the operation. - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.operation = kwargs.get('operation', None) - self.resource = kwargs.get('resource', None) - self.description = kwargs.get('description', None) - - -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. - - :param plan_name: Required. Name of the purchase plan. - :type plan_name: str - :param plan_product: Required. Product of the purchase plan. - :type plan_product: str - :param plan_publisher: Required. Publisher of the purchase plan. - :type plan_publisher: str - """ - - _validation = { - 'plan_name': {'required': True}, - 'plan_product': {'required': True}, - 'plan_publisher': {'required': True}, - } - - _attribute_map = { - 'plan_name': {'key': 'planName', 'type': 'str'}, - 'plan_product': {'key': 'planProduct', 'type': 'str'}, - 'plan_publisher': {'key': 'planPublisher', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PlatformImagePurchasePlan, self).__init__(**kwargs) - self.plan_name = kwargs['plan_name'] - self.plan_product = kwargs['plan_product'] - self.plan_publisher = kwargs['plan_publisher'] - - -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. - :type message: str - """ - - _attribute_map = { - 'provisioning_error_code': {'key': 'provisioningErrorCode', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - 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(msrest.serialization.Model): - """The Sub Resource model definition. - - 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. - :vartype id: str - :param name: Required. Resource name. - :type name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'required': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubResource, self).__init__(**kwargs) - self.id = 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. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource Id. - :vartype id: str - :param name: Required. Resource name. - :type name: str - :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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'required': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - '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': 'str'}, - } - - 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 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 SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.imagebuilder.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.imagebuilder.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) - - -class VirtualNetworkConfig(msrest.serialization.Model): - """Virtual Network configuration. - - :param subnet_id: Resource id of a pre-existing subnet. - :type subnet_id: str - :param proxy_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 for Gen1 images and - Standard_D2ds_v4 for Gen2 images). - :type proxy_vm_size: str - """ - - _attribute_map = { - 'subnet_id': {'key': 'subnetId', 'type': 'str'}, - 'proxy_vm_size': {'key': 'proxyVmSize', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualNetworkConfig, self).__init__(**kwargs) - self.subnet_id = kwargs.get('subnet_id', None) - self.proxy_vm_size = kwargs.get('proxy_vm_size', "") 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 952fa5613a6bb..0fd812da71c2d 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 @@ -17,17 +17,17 @@ class CloudErrorBody(msrest.serialization.Model): """An error response from the Azure VM Image Builder service. - :param code: An identifier for the error. Codes are invariant and are intended to be consumed + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user interface. - :type message: str - :param target: The target of the particular error. For example, the name of the property in + :vartype message: str + :ivar target: The target of the particular error. For example, the name of the property in error. - :type target: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.imagebuilder.models.CloudErrorBody] + :vartype target: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.imagebuilder.models.CloudErrorBody] """ _attribute_map = { @@ -46,6 +46,19 @@ def __init__( details: Optional[List["CloudErrorBody"]] = None, **kwargs ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword target: The target of the particular error. For example, the name of the property in + error. + :paramtype target: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.imagebuilder.models.CloudErrorBody] + """ super(CloudErrorBody, self).__init__(**kwargs) self.code = code self.message = message @@ -78,6 +91,8 @@ def __init__( self, **kwargs ): + """ + """ super(ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -96,28 +111,36 @@ class Resource(msrest.serialization.Model): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.imagebuilder.models.SystemData """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'system_data': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None self.type = None + self.system_data = None class TrackedResource(Resource): @@ -135,16 +158,20 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.imagebuilder.models.SystemData + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'system_data': {'readonly': True}, 'location': {'required': True}, } @@ -152,6 +179,7 @@ class TrackedResource(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'location': {'key': 'location', 'type': 'str'}, } @@ -163,6 +191,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + """ super(TrackedResource, self).__init__(**kwargs) self.tags = tags self.location = location @@ -183,21 +217,25 @@ class ImageTemplate(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param identity: Required. The identity of the image template, if configured. - :type identity: ~azure.mgmt.imagebuilder.models.ImageTemplateIdentity - :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. :vartype system_data: ~azure.mgmt.imagebuilder.models.SystemData - :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 + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar identity: Required. The identity of the image template, if configured. + :vartype identity: ~azure.mgmt.imagebuilder.models.ImageTemplateIdentity + :ivar source: Specifies the properties used to describe the source image. + :vartype source: ~azure.mgmt.imagebuilder.models.ImageTemplateSource + :ivar 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] + :vartype customize: list[~azure.mgmt.imagebuilder.models.ImageTemplateCustomizer] + :ivar validate: Configuration options and list of validations to be performed on the resulting + image. + :vartype validate: ~azure.mgmt.imagebuilder.models.ImageTemplatePropertiesValidate + :ivar distribute: The distribution targets where the image output needs to go to. + :vartype 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 @@ -205,42 +243,61 @@ class ImageTemplate(TrackedResource): :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. - :type vm_profile: ~azure.mgmt.imagebuilder.models.ImageTemplateVmProfile + :ivar build_timeout_in_minutes: Maximum duration to wait while building the image template + (includes all customizations, validations, and distributions). Omit or specify 0 to use the + default (4 hours). + :vartype build_timeout_in_minutes: long + :ivar vm_profile: Describes how virtual machine is set up to build images. + :vartype vm_profile: ~azure.mgmt.imagebuilder.models.ImageTemplateVmProfile + :ivar staging_resource_group: The staging resource group id in the same subscription as the + image template that will be used to build the image. If this field is empty, a resource group + with a random name will be created. If the resource group specified in this field doesn't + exist, it will be created with the same name. If the resource group specified exists, it must + be empty and in the same region as the image template. The resource group created will be + deleted during template deletion if this field is empty or the resource group specified doesn't + exist, but if the resource group specified exists the resources created in the resource group + will be deleted during template deletion and the resource group itself will remain. + :vartype staging_resource_group: str + :ivar exact_staging_resource_group: The staging resource group id in the same subscription as + the image template that will be used to build the image. This read-only field differs from + 'stagingResourceGroup' only if the value specified in the 'stagingResourceGroup' field is + empty. + :vartype exact_staging_resource_group: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'system_data': {'readonly': True}, 'location': {'required': True}, 'identity': {'required': True}, - 'system_data': {'readonly': True}, 'provisioning_state': {'readonly': True}, 'provisioning_error': {'readonly': True}, 'last_run_status': {'readonly': True}, 'build_timeout_in_minutes': {'maximum': 960, 'minimum': 0}, + 'exact_staging_resource_group': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'location': {'key': 'location', 'type': 'str'}, 'identity': {'key': 'identity', 'type': 'ImageTemplateIdentity'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'source': {'key': 'properties.source', 'type': 'ImageTemplateSource'}, 'customize': {'key': 'properties.customize', 'type': '[ImageTemplateCustomizer]'}, + 'validate': {'key': 'properties.validate', 'type': 'ImageTemplatePropertiesValidate'}, 'distribute': {'key': 'properties.distribute', 'type': '[ImageTemplateDistributor]'}, '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'}, + 'build_timeout_in_minutes': {'key': 'properties.buildTimeoutInMinutes', 'type': 'long'}, 'vm_profile': {'key': 'properties.vmProfile', 'type': 'ImageTemplateVmProfile'}, + 'staging_resource_group': {'key': 'properties.stagingResourceGroup', 'type': 'str'}, + 'exact_staging_resource_group': {'key': 'properties.exactStagingResourceGroup', 'type': 'str'}, } def __init__( @@ -251,22 +308,59 @@ def __init__( tags: Optional[Dict[str, str]] = None, source: Optional["ImageTemplateSource"] = None, customize: Optional[List["ImageTemplateCustomizer"]] = None, + validate: Optional["ImageTemplatePropertiesValidate"] = None, distribute: Optional[List["ImageTemplateDistributor"]] = None, build_timeout_in_minutes: Optional[int] = 0, vm_profile: Optional["ImageTemplateVmProfile"] = None, + staging_resource_group: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword identity: Required. The identity of the image template, if configured. + :paramtype identity: ~azure.mgmt.imagebuilder.models.ImageTemplateIdentity + :keyword source: Specifies the properties used to describe the source image. + :paramtype source: ~azure.mgmt.imagebuilder.models.ImageTemplateSource + :keyword customize: Specifies the properties used to describe the customization steps of the + image, like Image source etc. + :paramtype customize: list[~azure.mgmt.imagebuilder.models.ImageTemplateCustomizer] + :keyword validate: Configuration options and list of validations to be performed on the + resulting image. + :paramtype validate: ~azure.mgmt.imagebuilder.models.ImageTemplatePropertiesValidate + :keyword distribute: The distribution targets where the image output needs to go to. + :paramtype distribute: list[~azure.mgmt.imagebuilder.models.ImageTemplateDistributor] + :keyword build_timeout_in_minutes: Maximum duration to wait while building the image template + (includes all customizations, validations, and distributions). Omit or specify 0 to use the + default (4 hours). + :paramtype build_timeout_in_minutes: long + :keyword vm_profile: Describes how virtual machine is set up to build images. + :paramtype vm_profile: ~azure.mgmt.imagebuilder.models.ImageTemplateVmProfile + :keyword staging_resource_group: The staging resource group id in the same subscription as the + image template that will be used to build the image. If this field is empty, a resource group + with a random name will be created. If the resource group specified in this field doesn't + exist, it will be created with the same name. If the resource group specified exists, it must + be empty and in the same region as the image template. The resource group created will be + deleted during template deletion if this field is empty or the resource group specified doesn't + exist, but if the resource group specified exists the resources created in the resource group + will be deleted during template deletion and the resource group itself will remain. + :paramtype staging_resource_group: str + """ super(ImageTemplate, self).__init__(tags=tags, location=location, **kwargs) self.identity = identity - self.system_data = None self.source = source self.customize = customize + self.validate = validate self.distribute = distribute self.provisioning_state = None self.provisioning_error = None self.last_run_status = None self.build_timeout_in_minutes = build_timeout_in_minutes self.vm_profile = vm_profile + self.staging_resource_group = staging_resource_group + self.exact_staging_resource_group = None class ImageTemplateCustomizer(msrest.serialization.Model): @@ -277,11 +371,11 @@ class ImageTemplateCustomizer(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :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 + :ivar 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. + :vartype type: str + :ivar name: Friendly Name to provide context on what this customization step does. + :vartype name: str """ _validation = { @@ -303,6 +397,10 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword name: Friendly Name to provide context on what this customization step does. + :paramtype name: str + """ super(ImageTemplateCustomizer, self).__init__(**kwargs) self.type = None # type: Optional[str] self.name = name @@ -316,13 +414,13 @@ class ImageTemplateDistributor(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :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. - :type artifact_tags: dict[str, str] + :ivar type: Required. Type of distribution.Constant filled by server. + :vartype type: str + :ivar run_output_name: Required. The name to be used for the associated RunOutput. + :vartype run_output_name: str + :ivar artifact_tags: Tags that will be applied to the artifact once it has been created/updated + by the distributor. + :vartype artifact_tags: dict[str, str] """ _validation = { @@ -347,6 +445,13 @@ def __init__( artifact_tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword run_output_name: Required. The name to be used for the associated RunOutput. + :paramtype run_output_name: str + :keyword artifact_tags: Tags that will be applied to the artifact once it has been + created/updated by the distributor. + :paramtype artifact_tags: dict[str, str] + """ super(ImageTemplateDistributor, self).__init__(**kwargs) self.type = None # type: Optional[str] self.run_output_name = run_output_name @@ -358,19 +463,19 @@ class ImageTemplateFileCustomizer(ImageTemplateCustomizer): All required parameters must be populated in order to send to Azure. - :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 - :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. - :type sha256_checksum: str - :param destination: The absolute path to a file (with nested directory structures already + :ivar 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. + :vartype type: str + :ivar name: Friendly Name to provide context on what this customization step does. + :vartype name: str + :ivar 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. + :vartype source_uri: str + :ivar sha256_checksum: SHA256 checksum of the file provided in the sourceUri field above. + :vartype sha256_checksum: str + :ivar 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 + :vartype destination: str """ _validation = { @@ -394,6 +499,18 @@ def __init__( destination: Optional[str] = None, **kwargs ): + """ + :keyword name: Friendly Name to provide context on what this customization step does. + :paramtype name: str + :keyword 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. + :paramtype source_uri: str + :keyword sha256_checksum: SHA256 checksum of the file provided in the sourceUri field above. + :paramtype sha256_checksum: str + :keyword 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. + :paramtype destination: str + """ super(ImageTemplateFileCustomizer, self).__init__(name=name, **kwargs) self.type = 'File' # type: str self.source_uri = source_uri @@ -404,13 +521,13 @@ def __init__( class ImageTemplateIdentity(msrest.serialization.Model): """Identity for the image template. - :param type: The type of identity used for the image template. The type 'None' will remove any + :ivar 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: + :vartype type: str or ~azure.mgmt.imagebuilder.models.ResourceIdentityType + :ivar 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, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.imagebuilder.models.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties] """ @@ -426,26 +543,79 @@ def __init__( user_assigned_identities: Optional[Dict[str, "ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, **kwargs ): + """ + :keyword 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". + :paramtype type: str or ~azure.mgmt.imagebuilder.models.ResourceIdentityType + :keyword 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}'. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.imagebuilder.models.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties] + """ super(ImageTemplateIdentity, self).__init__(**kwargs) self.type = type self.user_assigned_identities = user_assigned_identities +class ImageTemplateInVMValidator(msrest.serialization.Model): + """Describes a unit of in-VM validation of image. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: ImageTemplatePowerShellValidator, ImageTemplateShellValidator. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Required. The type of validation you want to use on the Image. For example, "Shell" + can be shell validation.Constant filled by server. + :vartype type: str + :ivar name: Friendly Name to provide context on what this validation step does. + :vartype name: str + """ + + _validation = { + 'type': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + _subtype_map = { + 'type': {'PowerShell': 'ImageTemplatePowerShellValidator', 'Shell': 'ImageTemplateShellValidator'} + } + + def __init__( + self, + *, + name: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Friendly Name to provide context on what this validation step does. + :paramtype name: str + """ + super(ImageTemplateInVMValidator, self).__init__(**kwargs) + self.type = None # type: Optional[str] + self.name = name + + 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.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", + :ivar start_time: Start time of the last run (UTC). + :vartype start_time: ~datetime.datetime + :ivar end_time: End time of the last run (UTC). + :vartype end_time: ~datetime.datetime + :ivar 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". - :type run_sub_state: str or ~azure.mgmt.imagebuilder.models.RunSubState - :param message: Verbose information about the last run state. - :type message: str + :vartype run_state: str or ~azure.mgmt.imagebuilder.models.RunState + :ivar run_sub_state: Sub-state of the last run. Possible values include: "Queued", "Building", + "Customizing", "Validating", "Distributing". + :vartype run_sub_state: str or ~azure.mgmt.imagebuilder.models.RunSubState + :ivar message: Verbose information about the last run state. + :vartype message: str """ _attribute_map = { @@ -466,6 +636,20 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword start_time: Start time of the last run (UTC). + :paramtype start_time: ~datetime.datetime + :keyword end_time: End time of the last run (UTC). + :paramtype end_time: ~datetime.datetime + :keyword run_state: State of the last run. Possible values include: "Running", "Canceling", + "Succeeded", "PartiallySucceeded", "Failed", "Canceled". + :paramtype run_state: str or ~azure.mgmt.imagebuilder.models.RunState + :keyword run_sub_state: Sub-state of the last run. Possible values include: "Queued", + "Building", "Customizing", "Validating", "Distributing". + :paramtype run_sub_state: str or ~azure.mgmt.imagebuilder.models.RunSubState + :keyword message: Verbose information about the last run state. + :paramtype message: str + """ super(ImageTemplateLastRunStatus, self).__init__(**kwargs) self.start_time = start_time self.end_time = end_time @@ -477,10 +661,10 @@ def __init__( 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 + :ivar value: An array of image templates. + :vartype value: list[~azure.mgmt.imagebuilder.models.ImageTemplate] + :ivar next_link: The continuation token. + :vartype next_link: str """ _attribute_map = { @@ -495,6 +679,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of image templates. + :paramtype value: list[~azure.mgmt.imagebuilder.models.ImageTemplate] + :keyword next_link: The continuation token. + :paramtype next_link: str + """ super(ImageTemplateListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -505,17 +695,17 @@ class ImageTemplateManagedImageDistributor(ImageTemplateDistributor): All required parameters must be populated in order to send to Azure. - :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. - :type artifact_tags: dict[str, str] - :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. - :type location: str + :ivar type: Required. Type of distribution.Constant filled by server. + :vartype type: str + :ivar run_output_name: Required. The name to be used for the associated RunOutput. + :vartype run_output_name: str + :ivar artifact_tags: Tags that will be applied to the artifact once it has been created/updated + by the distributor. + :vartype artifact_tags: dict[str, str] + :ivar image_id: Required. Resource Id of the Managed Disk Image. + :vartype image_id: str + :ivar location: Required. Azure location for the image, should match if image already exists. + :vartype location: str """ _validation = { @@ -542,6 +732,18 @@ def __init__( artifact_tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword run_output_name: Required. The name to be used for the associated RunOutput. + :paramtype run_output_name: str + :keyword artifact_tags: Tags that will be applied to the artifact once it has been + created/updated by the distributor. + :paramtype artifact_tags: dict[str, str] + :keyword image_id: Required. Resource Id of the Managed Disk Image. + :paramtype image_id: str + :keyword location: Required. Azure location for the image, should match if image already + exists. + :paramtype location: str + """ 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 @@ -556,9 +758,9 @@ class ImageTemplateSource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. Specifies the type of source image you want to start with.Constant - filled by server. - :type type: str + :ivar type: Required. Specifies the type of source image you want to start with.Constant filled + by server. + :vartype type: str """ _validation = { @@ -577,20 +779,22 @@ def __init__( self, **kwargs ): + """ + """ super(ImageTemplateSource, self).__init__(**kwargs) self.type = None # type: Optional[str] class ImageTemplateManagedImageSource(ImageTemplateSource): - """Describes an image source that is a managed image in customer subscription. + """Describes an image source that is a managed image in customer subscription. This image must reside in the same subscription and region as the Image Builder template. All required parameters must be populated in order to send to Azure. - :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. - :type image_id: str + :ivar type: Required. Specifies the type of source image you want to start with.Constant filled + by server. + :vartype type: str + :ivar image_id: Required. ARM resource id of the managed image in customer subscription. + :vartype image_id: str """ _validation = { @@ -609,6 +813,10 @@ def __init__( image_id: str, **kwargs ): + """ + :keyword image_id: Required. ARM resource id of the managed image in customer subscription. + :paramtype image_id: str + """ super(ImageTemplateManagedImageSource, self).__init__(**kwargs) self.type = 'ManagedImage' # type: str self.image_id = image_id @@ -621,29 +829,29 @@ class ImageTemplatePlatformImageSource(ImageTemplateSource): All required parameters must be populated in order to send to Azure. - :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 + :ivar type: Required. Specifies the type of source image you want to start with.Constant filled + by server. + :vartype type: str + :ivar publisher: Image Publisher in `Azure Gallery Images `_. - :type publisher: str - :param offer: Image offer from the `Azure Gallery Images + :vartype publisher: str + :ivar offer: Image offer from the `Azure Gallery Images `_. - :type offer: str - :param sku: Image sku from the `Azure Gallery Images + :vartype offer: str + :ivar sku: Image sku from the `Azure Gallery Images `_. - :type sku: str - :param version: Image version from the `Azure Gallery Images + :vartype sku: str + :ivar 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. - :type version: str + :vartype version: str :ivar exact_version: Image version from the `Azure Gallery Images `_. This readonly field differs from 'version', only if the value specified in 'version' field is 'latest'. :vartype exact_version: str - :param plan_info: Optional configuration of purchase plan for platform image. - :type plan_info: ~azure.mgmt.imagebuilder.models.PlatformImagePurchasePlan + :ivar plan_info: Optional configuration of purchase plan for platform image. + :vartype plan_info: ~azure.mgmt.imagebuilder.models.PlatformImagePurchasePlan """ _validation = { @@ -671,6 +879,24 @@ def __init__( plan_info: Optional["PlatformImagePurchasePlan"] = None, **kwargs ): + """ + :keyword publisher: Image Publisher in `Azure Gallery Images + `_. + :paramtype publisher: str + :keyword offer: Image offer from the `Azure Gallery Images + `_. + :paramtype offer: str + :keyword sku: Image sku from the `Azure Gallery Images + `_. + :paramtype sku: str + :keyword 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. + :paramtype version: str + :keyword plan_info: Optional configuration of purchase plan for platform image. + :paramtype plan_info: ~azure.mgmt.imagebuilder.models.PlatformImagePurchasePlan + """ super(ImageTemplatePlatformImageSource, self).__init__(**kwargs) self.type = 'PlatformImage' # type: str self.publisher = publisher @@ -686,26 +912,26 @@ class ImageTemplatePowerShellCustomizer(ImageTemplateCustomizer): All required parameters must be populated in order to send to Azure. - :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 - :param script_uri: URI of the PowerShell script to be run for customizing. It can be a github + :ivar 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. + :vartype type: str + :ivar name: Friendly Name to provide context on what this customization step does. + :vartype name: str + :ivar 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 + :vartype script_uri: str + :ivar 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. - :type inline: list[str] - :param run_elevated: If specified, the PowerShell script will be run with elevated privileges. - :type run_elevated: bool - :param run_as_system: If specified, the PowerShell script will be run with elevated privileges + :vartype sha256_checksum: str + :ivar inline: Array of PowerShell commands to execute. + :vartype inline: list[str] + :ivar run_elevated: If specified, the PowerShell script will be run with elevated privileges. + :vartype run_elevated: bool + :ivar 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] + :vartype run_as_system: bool + :ivar valid_exit_codes: Valid exit codes for the PowerShell script. [Default: 0]. + :vartype valid_exit_codes: list[long] """ _validation = { @@ -720,7 +946,7 @@ class ImageTemplatePowerShellCustomizer(ImageTemplateCustomizer): '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]'}, + 'valid_exit_codes': {'key': 'validExitCodes', 'type': '[long]'}, } def __init__( @@ -735,6 +961,27 @@ def __init__( valid_exit_codes: Optional[List[int]] = None, **kwargs ): + """ + :keyword name: Friendly Name to provide context on what this customization step does. + :paramtype name: str + :keyword script_uri: URI of the PowerShell script to be run for customizing. It can be a github + link, SAS URI for Azure Storage, etc. + :paramtype script_uri: str + :keyword sha256_checksum: SHA256 checksum of the power shell script provided in the scriptUri + field above. + :paramtype sha256_checksum: str + :keyword inline: Array of PowerShell commands to execute. + :paramtype inline: list[str] + :keyword run_elevated: If specified, the PowerShell script will be run with elevated + privileges. + :paramtype run_elevated: bool + :keyword 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. + :paramtype run_as_system: bool + :keyword valid_exit_codes: Valid exit codes for the PowerShell script. [Default: 0]. + :paramtype valid_exit_codes: list[long] + """ super(ImageTemplatePowerShellCustomizer, self).__init__(name=name, **kwargs) self.type = 'PowerShell' # type: str self.script_uri = script_uri @@ -745,24 +992,162 @@ def __init__( self.valid_exit_codes = valid_exit_codes +class ImageTemplatePowerShellValidator(ImageTemplateInVMValidator): + """Runs the specified PowerShell script during the validation phase (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. + + :ivar type: Required. The type of validation you want to use on the Image. For example, "Shell" + can be shell validation.Constant filled by server. + :vartype type: str + :ivar name: Friendly Name to provide context on what this validation step does. + :vartype name: str + :ivar script_uri: URI of the PowerShell script to be run for validation. It can be a github + link, Azure Storage URI, etc. + :vartype script_uri: str + :ivar sha256_checksum: SHA256 checksum of the power shell script provided in the scriptUri + field above. + :vartype sha256_checksum: str + :ivar inline: Array of PowerShell commands to execute. + :vartype inline: list[str] + :ivar run_elevated: If specified, the PowerShell script will be run with elevated privileges. + :vartype run_elevated: bool + :ivar 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. + :vartype run_as_system: bool + :ivar valid_exit_codes: Valid exit codes for the PowerShell script. [Default: 0]. + :vartype valid_exit_codes: list[int] + """ + + _validation = { + 'type': {'required': True}, + } + + _attribute_map = { + '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: 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 + ): + """ + :keyword name: Friendly Name to provide context on what this validation step does. + :paramtype name: str + :keyword script_uri: URI of the PowerShell script to be run for validation. It can be a github + link, Azure Storage URI, etc. + :paramtype script_uri: str + :keyword sha256_checksum: SHA256 checksum of the power shell script provided in the scriptUri + field above. + :paramtype sha256_checksum: str + :keyword inline: Array of PowerShell commands to execute. + :paramtype inline: list[str] + :keyword run_elevated: If specified, the PowerShell script will be run with elevated + privileges. + :paramtype run_elevated: bool + :keyword 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. + :paramtype run_as_system: bool + :keyword valid_exit_codes: Valid exit codes for the PowerShell script. [Default: 0]. + :paramtype valid_exit_codes: list[int] + """ + super(ImageTemplatePowerShellValidator, 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 + + +class ImageTemplatePropertiesValidate(msrest.serialization.Model): + """Configuration options and list of validations to be performed on the resulting image. + + :ivar continue_distribute_on_failure: If validation fails and this field is set to false, + output image(s) will not be distributed. This is the default behavior. If validation fails and + this field is set to true, output image(s) will still be distributed. Please use this option + with caution as it may result in bad images being distributed for use. In either case (true or + false), the end to end image run will be reported as having failed in case of a validation + failure. [Note: This field has no effect if validation succeeds.]. + :vartype continue_distribute_on_failure: bool + :ivar source_validation_only: If this field is set to true, the image specified in the 'source' + section will directly be validated. No separate build will be run to generate and then validate + a customized image. + :vartype source_validation_only: bool + :ivar in_vm_validations: List of validations to be performed. + :vartype in_vm_validations: list[~azure.mgmt.imagebuilder.models.ImageTemplateInVMValidator] + """ + + _attribute_map = { + 'continue_distribute_on_failure': {'key': 'continueDistributeOnFailure', 'type': 'bool'}, + 'source_validation_only': {'key': 'sourceValidationOnly', 'type': 'bool'}, + 'in_vm_validations': {'key': 'inVMValidations', 'type': '[ImageTemplateInVMValidator]'}, + } + + def __init__( + self, + *, + continue_distribute_on_failure: Optional[bool] = False, + source_validation_only: Optional[bool] = False, + in_vm_validations: Optional[List["ImageTemplateInVMValidator"]] = None, + **kwargs + ): + """ + :keyword continue_distribute_on_failure: If validation fails and this field is set to false, + output image(s) will not be distributed. This is the default behavior. If validation fails and + this field is set to true, output image(s) will still be distributed. Please use this option + with caution as it may result in bad images being distributed for use. In either case (true or + false), the end to end image run will be reported as having failed in case of a validation + failure. [Note: This field has no effect if validation succeeds.]. + :paramtype continue_distribute_on_failure: bool + :keyword source_validation_only: If this field is set to true, the image specified in the + 'source' section will directly be validated. No separate build will be run to generate and then + validate a customized image. + :paramtype source_validation_only: bool + :keyword in_vm_validations: List of validations to be performed. + :paramtype in_vm_validations: list[~azure.mgmt.imagebuilder.models.ImageTemplateInVMValidator] + """ + super(ImageTemplatePropertiesValidate, self).__init__(**kwargs) + self.continue_distribute_on_failure = continue_distribute_on_failure + self.source_validation_only = source_validation_only + self.in_vm_validations = in_vm_validations + + class ImageTemplateRestartCustomizer(ImageTemplateCustomizer): """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 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 - :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: '']. - :type restart_check_command: str - :param restart_timeout: Restart timeout specified as a string of magnitude and unit, e.g. '5m' + :ivar 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. + :vartype type: str + :ivar name: Friendly Name to provide context on what this customization step does. + :vartype name: str + :ivar restart_command: Command to execute the restart [Default: 'shutdown /r /f /t 0 /c "packer + restart"']. + :vartype restart_command: str + :ivar restart_check_command: Command to check if restart succeeded [Default: '']. + :vartype restart_check_command: str + :ivar 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 + :vartype restart_timeout: str """ _validation = { @@ -786,6 +1171,18 @@ def __init__( restart_timeout: Optional[str] = None, **kwargs ): + """ + :keyword name: Friendly Name to provide context on what this customization step does. + :paramtype name: str + :keyword restart_command: Command to execute the restart [Default: 'shutdown /r /f /t 0 /c + "packer restart"']. + :paramtype restart_command: str + :keyword restart_check_command: Command to check if restart succeeded [Default: '']. + :paramtype restart_check_command: str + :keyword restart_timeout: Restart timeout specified as a string of magnitude and unit, e.g. + '5m' (5 minutes) or '2h' (2 hours) [Default: '5m']. + :paramtype restart_timeout: str + """ super(ImageTemplateRestartCustomizer, self).__init__(name=name, **kwargs) self.type = 'WindowsRestart' # type: str self.restart_command = restart_command @@ -798,23 +1195,23 @@ class ImageTemplateSharedImageDistributor(ImageTemplateDistributor): All required parameters must be populated in order to send to Azure. - :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. - :type artifact_tags: dict[str, str] - :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. - :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). - :type exclude_from_latest: bool - :param storage_account_type: Storage account type to be used to store the shared image. Omit to + :ivar type: Required. Type of distribution.Constant filled by server. + :vartype type: str + :ivar run_output_name: Required. The name to be used for the associated RunOutput. + :vartype run_output_name: str + :ivar artifact_tags: Tags that will be applied to the artifact once it has been created/updated + by the distributor. + :vartype artifact_tags: dict[str, str] + :ivar gallery_image_id: Required. Resource Id of the Shared Image Gallery image. + :vartype gallery_image_id: str + :ivar replication_regions: Required. A list of regions that the image will be replicated to. + :vartype replication_regions: list[str] + :ivar exclude_from_latest: Flag that indicates whether created image version should be excluded + from latest. Omit to use the default (false). + :vartype exclude_from_latest: bool + :ivar 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 + :vartype storage_account_type: str or ~azure.mgmt.imagebuilder.models.SharedImageStorageAccountType """ @@ -846,6 +1243,24 @@ def __init__( storage_account_type: Optional[Union[str, "SharedImageStorageAccountType"]] = None, **kwargs ): + """ + :keyword run_output_name: Required. The name to be used for the associated RunOutput. + :paramtype run_output_name: str + :keyword artifact_tags: Tags that will be applied to the artifact once it has been + created/updated by the distributor. + :paramtype artifact_tags: dict[str, str] + :keyword gallery_image_id: Required. Resource Id of the Shared Image Gallery image. + :paramtype gallery_image_id: str + :keyword replication_regions: Required. A list of regions that the image will be replicated to. + :paramtype replication_regions: list[str] + :keyword exclude_from_latest: Flag that indicates whether created image version should be + excluded from latest. Omit to use the default (false). + :paramtype exclude_from_latest: bool + :keyword 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". + :paramtype storage_account_type: str or + ~azure.mgmt.imagebuilder.models.SharedImageStorageAccountType + """ 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 @@ -859,12 +1274,12 @@ class ImageTemplateSharedImageVersionSource(ImageTemplateSource): All required parameters must be populated in order to send to Azure. - :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 + :ivar type: Required. Specifies the type of source image you want to start with.Constant filled + by server. + :vartype type: str + :ivar image_version_id: Required. ARM resource id of the image version in the shared image gallery. - :type image_version_id: str + :vartype image_version_id: str """ _validation = { @@ -883,6 +1298,11 @@ def __init__( image_version_id: str, **kwargs ): + """ + :keyword image_version_id: Required. ARM resource id of the image version in the shared image + gallery. + :paramtype image_version_id: str + """ super(ImageTemplateSharedImageVersionSource, self).__init__(**kwargs) self.type = 'SharedImageVersion' # type: str self.image_version_id = image_version_id @@ -893,18 +1313,18 @@ class ImageTemplateShellCustomizer(ImageTemplateCustomizer): All required parameters must be populated in order to send to Azure. - :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 - :param script_uri: URI of the shell script to be run for customizing. It can be a github link, + :ivar 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. + :vartype type: str + :ivar name: Friendly Name to provide context on what this customization step does. + :vartype name: str + :ivar 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. - :type sha256_checksum: str - :param inline: Array of shell commands to execute. - :type inline: list[str] + :vartype script_uri: str + :ivar sha256_checksum: SHA256 checksum of the shell script provided in the scriptUri field. + :vartype sha256_checksum: str + :ivar inline: Array of shell commands to execute. + :vartype inline: list[str] """ _validation = { @@ -928,6 +1348,17 @@ def __init__( inline: Optional[List[str]] = None, **kwargs ): + """ + :keyword name: Friendly Name to provide context on what this customization step does. + :paramtype name: str + :keyword script_uri: URI of the shell script to be run for customizing. It can be a github + link, SAS URI for Azure Storage, etc. + :paramtype script_uri: str + :keyword sha256_checksum: SHA256 checksum of the shell script provided in the scriptUri field. + :paramtype sha256_checksum: str + :keyword inline: Array of shell commands to execute. + :paramtype inline: list[str] + """ super(ImageTemplateShellCustomizer, self).__init__(name=name, **kwargs) self.type = 'Shell' # type: str self.script_uri = script_uri @@ -935,13 +1366,71 @@ def __init__( self.inline = inline +class ImageTemplateShellValidator(ImageTemplateInVMValidator): + """Runs the specified shell script during the validation 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. + + :ivar type: Required. The type of validation you want to use on the Image. For example, "Shell" + can be shell validation.Constant filled by server. + :vartype type: str + :ivar name: Friendly Name to provide context on what this validation step does. + :vartype name: str + :ivar script_uri: URI of the shell script to be run for validation. It can be a github link, + Azure Storage URI, etc. + :vartype script_uri: str + :ivar sha256_checksum: SHA256 checksum of the shell script provided in the scriptUri field. + :vartype sha256_checksum: str + :ivar inline: Array of shell commands to execute. + :vartype inline: list[str] + """ + + _validation = { + 'type': {'required': True}, + } + + _attribute_map = { + '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: Optional[str] = None, + script_uri: Optional[str] = None, + sha256_checksum: Optional[str] = "", + inline: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword name: Friendly Name to provide context on what this validation step does. + :paramtype name: str + :keyword script_uri: URI of the shell script to be run for validation. It can be a github link, + Azure Storage URI, etc. + :paramtype script_uri: str + :keyword sha256_checksum: SHA256 checksum of the shell script provided in the scriptUri field. + :paramtype sha256_checksum: str + :keyword inline: Array of shell commands to execute. + :paramtype inline: list[str] + """ + super(ImageTemplateShellValidator, self).__init__(name=name, **kwargs) + self.type = 'Shell' # type: str + self.script_uri = script_uri + self.sha256_checksum = sha256_checksum + self.inline = inline + + 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: A set of tags. The user-specified tags associated with the image template. - :type tags: dict[str, str] + :ivar identity: The identity of the image template, if configured. + :vartype identity: ~azure.mgmt.imagebuilder.models.ImageTemplateIdentity + :ivar tags: A set of tags. The user-specified tags associated with the image template. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -956,6 +1445,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword identity: The identity of the image template, if configured. + :paramtype identity: ~azure.mgmt.imagebuilder.models.ImageTemplateIdentity + :keyword tags: A set of tags. The user-specified tags associated with the image template. + :paramtype tags: dict[str, str] + """ super(ImageTemplateUpdateParameters, self).__init__(**kwargs) self.identity = identity self.tags = tags @@ -966,13 +1461,13 @@ class ImageTemplateVhdDistributor(ImageTemplateDistributor): All required parameters must be populated in order to send to Azure. - :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. - :type artifact_tags: dict[str, str] + :ivar type: Required. Type of distribution.Constant filled by server. + :vartype type: str + :ivar run_output_name: Required. The name to be used for the associated RunOutput. + :vartype run_output_name: str + :ivar artifact_tags: Tags that will be applied to the artifact once it has been created/updated + by the distributor. + :vartype artifact_tags: dict[str, str] """ _validation = { @@ -993,26 +1488,34 @@ def __init__( artifact_tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword run_output_name: Required. The name to be used for the associated RunOutput. + :paramtype run_output_name: str + :keyword artifact_tags: Tags that will be applied to the artifact once it has been + created/updated by the distributor. + :paramtype artifact_tags: dict[str, str] + """ super(ImageTemplateVhdDistributor, self).__init__(run_output_name=run_output_name, artifact_tags=artifact_tags, **kwargs) self.type = 'VHD' # type: str class ImageTemplateVmProfile(msrest.serialization.Model): - """Describes the virtual machine used to build, customize and capture images. + """Describes the virtual machines used to build and validate 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_D2ds_v4). - :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 + :ivar 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 for Gen1 images and Standard_D2ds_v4 + for Gen2 images). + :vartype vm_size: str + :ivar 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 user_assigned_identities: Optional array of resource IDs of user assigned managed - identities to be configured on the build VM. This may include the identity of the image - template. - :type user_assigned_identities: list[str] - :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 + :vartype os_disk_size_gb: long + :ivar user_assigned_identities: Optional array of resource IDs of user assigned managed + identities to be configured on the build VM and validation VM. This may include the identity of + the image template. + :vartype user_assigned_identities: list[str] + :ivar vnet_config: Optional configuration of the virtual network to use to deploy the build VM + and validation VM in. Omit if no specific virtual network needs to be used. + :vartype vnet_config: ~azure.mgmt.imagebuilder.models.VirtualNetworkConfig """ _validation = { @@ -1021,7 +1524,7 @@ class ImageTemplateVmProfile(msrest.serialization.Model): _attribute_map = { 'vm_size': {'key': 'vmSize', 'type': 'str'}, - 'os_disk_size_gb': {'key': 'osDiskSizeGB', 'type': 'int'}, + 'os_disk_size_gb': {'key': 'osDiskSizeGB', 'type': 'long'}, 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '[str]'}, 'vnet_config': {'key': 'vnetConfig', 'type': 'VirtualNetworkConfig'}, } @@ -1035,6 +1538,22 @@ def __init__( vnet_config: Optional["VirtualNetworkConfig"] = None, **kwargs ): + """ + :keyword 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 for Gen1 images and Standard_D2ds_v4 + for Gen2 images). + :paramtype vm_size: str + :keyword os_disk_size_gb: Size of the OS disk in GB. Omit or specify 0 to use Azure's default + OS disk size. + :paramtype os_disk_size_gb: long + :keyword user_assigned_identities: Optional array of resource IDs of user assigned managed + identities to be configured on the build VM and validation VM. This may include the identity of + the image template. + :paramtype user_assigned_identities: list[str] + :keyword vnet_config: Optional configuration of the virtual network to use to deploy the build + VM and validation VM in. Omit if no specific virtual network needs to be used. + :paramtype vnet_config: ~azure.mgmt.imagebuilder.models.VirtualNetworkConfig + """ super(ImageTemplateVmProfile, self).__init__(**kwargs) self.vm_size = vm_size self.os_disk_size_gb = os_disk_size_gb @@ -1047,21 +1566,21 @@ class ImageTemplateWindowsUpdateCustomizer(ImageTemplateCustomizer): All required parameters must be populated in order to send to Azure. - :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 - :param search_criteria: Criteria to search updates. Omit or specify empty string to use the + :ivar 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. + :vartype type: str + :ivar name: Friendly Name to provide context on what this customization step does. + :vartype name: str + :ivar 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 + :vartype search_criteria: str + :ivar 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 + :vartype filters: list[str] + :ivar update_limit: Maximum number of updates to apply at a time. Omit or specify 0 to use the default (1000). - :type update_limit: int + :vartype update_limit: long """ _validation = { @@ -1074,7 +1593,7 @@ class ImageTemplateWindowsUpdateCustomizer(ImageTemplateCustomizer): 'name': {'key': 'name', 'type': 'str'}, 'search_criteria': {'key': 'searchCriteria', 'type': 'str'}, 'filters': {'key': 'filters', 'type': '[str]'}, - 'update_limit': {'key': 'updateLimit', 'type': 'int'}, + 'update_limit': {'key': 'updateLimit', 'type': 'long'}, } def __init__( @@ -1086,6 +1605,20 @@ def __init__( update_limit: Optional[int] = None, **kwargs ): + """ + :keyword name: Friendly Name to provide context on what this customization step does. + :paramtype name: str + :keyword 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. + :paramtype search_criteria: str + :keyword 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. + :paramtype filters: list[str] + :keyword update_limit: Maximum number of updates to apply at a time. Omit or specify 0 to use + the default (1000). + :paramtype update_limit: long + """ super(ImageTemplateWindowsUpdateCustomizer, self).__init__(name=name, **kwargs) self.type = 'WindowsUpdate' # type: str self.search_criteria = search_criteria @@ -1096,16 +1629,16 @@ def __init__( class Operation(msrest.serialization.Model): """A REST API 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: Any object. - :type properties: any - :param is_data_action: The flag that indicates whether the operation applies to data plane. - :type is_data_action: bool + :ivar name: This is of the format {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that describes the operation. + :vartype display: ~azure.mgmt.imagebuilder.models.OperationDisplay + :ivar origin: The intended executor of the operation. + :vartype origin: str + :ivar properties: Any object. + :vartype properties: any + :ivar is_data_action: The flag that indicates whether the operation applies to data plane. + :vartype is_data_action: bool """ _attribute_map = { @@ -1126,6 +1659,18 @@ def __init__( is_data_action: Optional[bool] = None, **kwargs ): + """ + :keyword name: This is of the format {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that describes the operation. + :paramtype display: ~azure.mgmt.imagebuilder.models.OperationDisplay + :keyword origin: The intended executor of the operation. + :paramtype origin: str + :keyword properties: Any object. + :paramtype properties: any + :keyword is_data_action: The flag that indicates whether the operation applies to data plane. + :paramtype is_data_action: bool + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -1137,14 +1682,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that describes the operation. - :param provider: Friendly name of the resource provider. - :type provider: str - :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 - :param description: The friendly name of the operation. - :type description: str + :ivar provider: Friendly name of the resource provider. + :vartype provider: str + :ivar operation: For example: read, write, delete, or listKeys/action. + :vartype operation: str + :ivar resource: The resource type on which the operation is performed. + :vartype resource: str + :ivar description: The friendly name of the operation. + :vartype description: str """ _attribute_map = { @@ -1163,6 +1708,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Friendly name of the resource provider. + :paramtype provider: str + :keyword operation: For example: read, write, delete, or listKeys/action. + :paramtype operation: str + :keyword resource: The resource type on which the operation is performed. + :paramtype resource: str + :keyword description: The friendly name of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.operation = operation @@ -1173,10 +1728,10 @@ def __init__( 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 + :ivar value: The list of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.imagebuilder.models.Operation] + :ivar next_link: The URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1191,6 +1746,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of operations supported by the resource provider. + :paramtype value: list[~azure.mgmt.imagebuilder.models.Operation] + :keyword next_link: The URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1201,12 +1762,12 @@ class PlatformImagePurchasePlan(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param plan_name: Required. Name of the purchase plan. - :type plan_name: str - :param plan_product: Required. Product of the purchase plan. - :type plan_product: str - :param plan_publisher: Required. Publisher of the purchase plan. - :type plan_publisher: str + :ivar plan_name: Required. Name of the purchase plan. + :vartype plan_name: str + :ivar plan_product: Required. Product of the purchase plan. + :vartype plan_product: str + :ivar plan_publisher: Required. Publisher of the purchase plan. + :vartype plan_publisher: str """ _validation = { @@ -1229,6 +1790,14 @@ def __init__( plan_publisher: str, **kwargs ): + """ + :keyword plan_name: Required. Name of the purchase plan. + :paramtype plan_name: str + :keyword plan_product: Required. Product of the purchase plan. + :paramtype plan_product: str + :keyword plan_publisher: Required. Publisher of the purchase plan. + :paramtype plan_publisher: str + """ super(PlatformImagePurchasePlan, self).__init__(**kwargs) self.plan_name = plan_name self.plan_product = plan_product @@ -1238,13 +1807,14 @@ def __init__( 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. - :type message: str + :ivar provisioning_error_code: Error code of the provisioning failure. Possible values include: + "BadSourceType", "BadPIRSource", "BadManagedImageSource", "BadSharedImageVersionSource", + "BadCustomizerType", "UnsupportedCustomizerType", "NoCustomizerScript", "BadValidatorType", + "UnsupportedValidatorType", "NoValidatorScript", "BadDistributeType", + "BadSharedImageDistribute", "BadStagingResourceGroup", "ServerError", "Other". + :vartype provisioning_error_code: str or ~azure.mgmt.imagebuilder.models.ProvisioningErrorCode + :ivar message: Verbose error message about the provisioning failure. + :vartype message: str """ _attribute_map = { @@ -1259,67 +1829,84 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword provisioning_error_code: Error code of the provisioning failure. Possible values + include: "BadSourceType", "BadPIRSource", "BadManagedImageSource", + "BadSharedImageVersionSource", "BadCustomizerType", "UnsupportedCustomizerType", + "NoCustomizerScript", "BadValidatorType", "UnsupportedValidatorType", "NoValidatorScript", + "BadDistributeType", "BadSharedImageDistribute", "BadStagingResourceGroup", "ServerError", + "Other". + :paramtype provisioning_error_code: str or + ~azure.mgmt.imagebuilder.models.ProvisioningErrorCode + :keyword message: Verbose error message about the provisioning failure. + :paramtype message: str + """ super(ProvisioningError, self).__init__(**kwargs) self.provisioning_error_code = provisioning_error_code self.message = message -class SubResource(msrest.serialization.Model): - """The Sub Resource model definition. +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. 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: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :param name: Required. Resource name. - :type name: str - :ivar type: Resource type. + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.imagebuilder.models.SystemData """ _validation = { 'id': {'readonly': True}, - 'name': {'required': True}, + 'name': {'readonly': True}, 'type': {'readonly': True}, + 'system_data': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( self, - *, - name: str, **kwargs ): - super(SubResource, self).__init__(**kwargs) - self.id = None - self.name = name - self.type = None + """ + """ + super(ProxyResource, self).__init__(**kwargs) -class RunOutput(SubResource): +class RunOutput(ProxyResource): """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. - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :param name: Required. Resource name. - :type name: str - :ivar type: Resource type. + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.imagebuilder.models.SystemData + :ivar artifact_id: The resource id of the artifact. + :vartype artifact_id: str + :ivar artifact_uri: The location URI of the artifact. + :vartype 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 @@ -1327,8 +1914,9 @@ class RunOutput(SubResource): _validation = { 'id': {'readonly': True}, - 'name': {'required': True}, + 'name': {'readonly': True}, 'type': {'readonly': True}, + 'system_data': {'readonly': True}, 'provisioning_state': {'readonly': True}, } @@ -1336,6 +1924,7 @@ class RunOutput(SubResource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'artifact_id': {'key': 'properties.artifactId', 'type': 'str'}, 'artifact_uri': {'key': 'properties.artifactUri', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, @@ -1344,12 +1933,17 @@ class RunOutput(SubResource): def __init__( self, *, - name: str, artifact_id: Optional[str] = None, artifact_uri: Optional[str] = None, **kwargs ): - super(RunOutput, self).__init__(name=name, **kwargs) + """ + :keyword artifact_id: The resource id of the artifact. + :paramtype artifact_id: str + :keyword artifact_uri: The location URI of the artifact. + :paramtype artifact_uri: str + """ + super(RunOutput, self).__init__(**kwargs) self.artifact_id = artifact_id self.artifact_uri = artifact_uri self.provisioning_state = None @@ -1358,10 +1952,10 @@ def __init__( 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 + :ivar value: An array of run outputs. + :vartype value: list[~azure.mgmt.imagebuilder.models.RunOutput] + :ivar next_link: The continuation token. + :vartype next_link: str """ _attribute_map = { @@ -1376,6 +1970,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of run outputs. + :paramtype value: list[~azure.mgmt.imagebuilder.models.RunOutput] + :keyword next_link: The continuation token. + :paramtype next_link: str + """ super(RunOutputCollection, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1384,20 +1984,20 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.imagebuilder.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.imagebuilder.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.imagebuilder.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :vartype last_modified_by_type: str or ~azure.mgmt.imagebuilder.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -1420,6 +2020,22 @@ def __init__( last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.imagebuilder.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.imagebuilder.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ super(SystemData, self).__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type @@ -1432,12 +2048,11 @@ def __init__( class VirtualNetworkConfig(msrest.serialization.Model): """Virtual Network configuration. - :param subnet_id: Resource id of a pre-existing subnet. - :type subnet_id: str - :param proxy_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 for Gen1 images and - Standard_D2ds_v4 for Gen2 images). - :type proxy_vm_size: str + :ivar subnet_id: Resource id of a pre-existing subnet. + :vartype subnet_id: str + :ivar proxy_vm_size: Size of the proxy virtual machine used to pass traffic to the build VM and + validation VM. Omit or specify empty string to use the default (Standard_A1_v2). + :vartype proxy_vm_size: str """ _attribute_map = { @@ -1452,6 +2067,13 @@ def __init__( proxy_vm_size: Optional[str] = "", **kwargs ): + """ + :keyword subnet_id: Resource id of a pre-existing subnet. + :paramtype subnet_id: str + :keyword proxy_vm_size: Size of the proxy virtual machine used to pass traffic to the build VM + and validation VM. Omit or specify empty string to use the default (Standard_A1_v2). + :paramtype proxy_vm_size: str + """ super(VirtualNetworkConfig, self).__init__(**kwargs) self.subnet_id = subnet_id self.proxy_vm_size = proxy_vm_size 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 c93f96d6743a8..acf5b9ffc6186 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,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,50 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.VirtualMachineImages/operations") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +73,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> 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 @@ -57,35 +85,36 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.imagebuilder.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - 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 = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,7 +123,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,7 +136,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.VirtualMachineImages/operations'} # type: ignore + 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 0dc963c6e15bf..107f8b834cbe9 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,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,25 +6,399 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer 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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling 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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.VirtualMachineImages/imageTemplates") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + image_template_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "imageTemplateName": _SERIALIZER.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + image_template_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "imageTemplateName": _SERIALIZER.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + image_template_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "imageTemplateName": _SERIALIZER.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + image_template_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "imageTemplateName": _SERIALIZER.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_run_request_initial( + subscription_id: str, + resource_group_name: str, + image_template_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/run") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "imageTemplateName": _SERIALIZER.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_cancel_request_initial( + subscription_id: str, + resource_group_name: str, + image_template_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/cancel") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "imageTemplateName": _SERIALIZER.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_run_outputs_request( + subscription_id: str, + resource_group_name: str, + image_template_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/runOutputs") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "imageTemplateName": _SERIALIZER.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_run_output_request( + subscription_id: str, + resource_group_name: str, + image_template_name: str, + run_output_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/runOutputs/{runOutputName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "imageTemplateName": _SERIALIZER.url("image_template_name", image_template_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + "runOutputName": _SERIALIZER.url("run_output_name", run_output_name, 'str', pattern=r'^[A-Za-z0-9-_.]{1,64}$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class VirtualMachineImageTemplatesOperations(object): """VirtualMachineImageTemplatesOperations operations. @@ -47,51 +422,51 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ImageTemplateListResult"] + **kwargs: Any + ) -> 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) + :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 """ + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + 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 = "2021-10-01" - 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) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ImageTemplateListResult', pipeline_response) + deserialized = self._deserialize("ImageTemplateListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -100,7 +475,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,60 +488,62 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.VirtualMachineImages/imageTemplates'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.VirtualMachineImages/imageTemplates"} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ImageTemplateListResult"] + resource_group_name: str, + **kwargs: Any + ) -> 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 :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) + :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 """ + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + 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 = "2021-10-01" - 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) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ImageTemplateListResult', pipeline_response) + deserialized = self._deserialize("ImageTemplateListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -171,7 +552,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -180,51 +565,47 @@ def get_next(next_link=None): 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 + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates"} # type: ignore def _create_or_update_initial( self, - resource_group_name, # type: str - image_template_name, # type: str - parameters, # type: "_models.ImageTemplate" - **kwargs # type: Any - ): - # type: (...) -> "_models.ImageTemplate" + resource_group_name: str, + image_template_name: str, + parameters: "_models.ImageTemplate", + **kwargs: Any + ) -> "_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 = "2021-10-01" - 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 = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ImageTemplate') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + image_template_name=image_template_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -241,16 +622,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}"} # type: ignore + + + @distributed_trace 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"] + resource_group_name: str, + image_template_name: str, + parameters: "_models.ImageTemplate", + **kwargs: Any + ) -> LROPoller["_models.ImageTemplate"]: """Create or update a virtual machine image template. :param resource_group_name: The name of the resource group. @@ -261,14 +644,19 @@ def begin_create_or_update( :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: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in 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) + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageTemplate"] lro_delay = kwargs.pop( @@ -281,27 +669,22 @@ def begin_create_or_update( resource_group_name=resource_group_name, image_template_name=image_template_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_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 = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -311,50 +694,45 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + 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, # type: str - image_template_name, # type: str - parameters, # type: "_models.ImageTemplateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ImageTemplate"] + resource_group_name: str, + image_template_name: str, + parameters: "_models.ImageTemplateUpdateParameters", + **kwargs: Any + ) -> 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 = "2021-10-01" - 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 = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ImageTemplateUpdateParameters') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + image_template_name=image_template_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -369,16 +747,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}"} # type: ignore + + + @distributed_trace 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"] + resource_group_name: str, + image_template_name: str, + parameters: "_models.ImageTemplateUpdateParameters", + **kwargs: Any + ) -> LROPoller["_models.ImageTemplate"]: """Update the tags for this Virtual Machine Image Template. :param resource_group_name: The name of the resource group. @@ -389,14 +769,19 @@ def begin_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: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in 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) + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageTemplate"] lro_delay = kwargs.pop( @@ -409,27 +794,22 @@ def begin_update( resource_group_name=resource_group_name, image_template_name=image_template_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_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 = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -439,17 +819,17 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + 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 + @distributed_trace def get( self, - resource_group_name, # type: str - image_template_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ImageTemplate" + resource_group_name: str, + image_template_name: str, + **kwargs: Any + ) -> "_models.ImageTemplate": """Get information about a virtual machine image template. :param resource_group_name: The name of the resource group. @@ -466,28 +846,25 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - 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') + api_version = kwargs.pop('api_version', "2022-02-14") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + image_template_name=image_template_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -500,42 +877,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore - def _delete_initial( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}"} # type: ignore + + + def _delete_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - image_template_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + image_template_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - 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') + api_version = kwargs.pop('api_version', "2022-02-14") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + image_template_name=image_template_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -545,15 +920,16 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}"} # type: ignore - def begin_delete( + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - image_template_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + image_template_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Delete a virtual machine image template. :param resource_group_name: The name of the resource group. @@ -562,14 +938,17 @@ def begin_delete( :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: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in 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. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-02-14") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -581,24 +960,18 @@ def begin_delete( raw_result = self._delete_initial( resource_group_name=resource_group_name, image_template_name=image_template_name, + api_version=api_version, 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 = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -608,44 +981,40 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}'} # type: ignore + 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( + def _run_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - image_template_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + image_template_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - 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') + api_version = kwargs.pop('api_version', "2022-02-14") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_run_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + image_template_name=image_template_name, + api_version=api_version, + template_url=self._run_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -655,15 +1024,16 @@ def _run_initial( if cls: return cls(pipeline_response, None, {}) - _run_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/run'} # type: ignore + _run_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/run"} # type: ignore + - def begin_run( + @distributed_trace + def begin_run( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - image_template_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + image_template_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Create artifacts from a existing image template. :param resource_group_name: The name of the resource group. @@ -672,14 +1042,17 @@ def begin_run( :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: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in 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. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-02-14") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -691,24 +1064,18 @@ def begin_run( raw_result = self._run_initial( resource_group_name=resource_group_name, image_template_name=image_template_name, + api_version=api_version, 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 = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -718,44 +1085,40 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_run.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/run'} # type: ignore + 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( + def _cancel_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - image_template_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + image_template_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - 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') + api_version = kwargs.pop('api_version', "2022-02-14") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + image_template_name=image_template_name, + api_version=api_version, + template_url=self._cancel_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -765,15 +1128,16 @@ def _cancel_initial( if cls: return cls(pipeline_response, None, {}) - _cancel_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/cancel'} # type: ignore + _cancel_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/cancel"} # type: ignore + - def begin_cancel( + @distributed_trace + def begin_cancel( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - image_template_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + image_template_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Cancel the long running image build based on the image template. :param resource_group_name: The name of the resource group. @@ -782,14 +1146,17 @@ def begin_cancel( :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: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in 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. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-02-14") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -801,24 +1168,18 @@ def begin_cancel( raw_result = self._cancel_initial( resource_group_name=resource_group_name, image_template_name=image_template_name, + api_version=api_version, 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 = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -828,17 +1189,17 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/cancel'} # type: ignore + 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 + + @distributed_trace def list_run_outputs( self, - resource_group_name, # type: str - image_template_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RunOutputCollection"] + resource_group_name: str, + image_template_name: str, + **kwargs: Any + ) -> Iterable["_models.RunOutputCollection"]: """List all run outputs for the specified Image Template resource. :param resource_group_name: The name of the resource group. @@ -850,41 +1211,42 @@ def list_run_outputs( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.imagebuilder.models.RunOutputCollection] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-02-14") # type: str + 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 = "2021-10-01" - 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) + + request = build_list_run_outputs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + image_template_name=image_template_name, + api_version=api_version, + template_url=self.list_run_outputs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_run_outputs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + image_template_name=image_template_name, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RunOutputCollection', pipeline_response) + deserialized = self._deserialize("RunOutputCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -893,7 +1255,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -902,19 +1268,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_run_outputs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/runOutputs'} # type: ignore + list_run_outputs.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/runOutputs"} # type: ignore + @distributed_trace def get_run_output( self, - resource_group_name, # type: str - image_template_name, # type: str - run_output_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RunOutput" + resource_group_name: str, + image_template_name: str, + run_output_name: str, + **kwargs: Any + ) -> "_models.RunOutput": """Get the specified run output for the specified image template resource. :param resource_group_name: The name of the resource group. @@ -933,29 +1300,26 @@ def get_run_output( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - 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') + api_version = kwargs.pop('api_version', "2022-02-14") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_run_output_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + image_template_name=image_template_name, + run_output_name=run_output_name, + api_version=api_version, + template_url=self.get_run_output.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -968,4 +1332,6 @@ def get_run_output( 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 + + get_run_output.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/runOutputs/{runOutputName}"} # type: ignore +