From e40054e15d3942df524030b9f345bcbc6cbf14f5 Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Mon, 11 May 2020 06:44:37 +0000 Subject: [PATCH] Update from master --- sdk/compute/azure-mgmt-imagebuilder/README.md | 30 +-- .../imagebuilder/_image_builder_client.py | 2 +- .../mgmt/imagebuilder/models/__init__.py | 14 +- .../models/_image_builder_client_enums.py | 9 +- .../azure/mgmt/imagebuilder/models/_models.py | 242 ++++++++++++----- .../mgmt/imagebuilder/models/_models_py3.py | 252 ++++++++++++------ .../imagebuilder/operations/_operations.py | 4 +- ...tual_machine_image_templates_operations.py | 84 +++++- sdk/compute/azure-mgmt-imagebuilder/setup.py | 5 +- 9 files changed, 463 insertions(+), 179 deletions(-) diff --git a/sdk/compute/azure-mgmt-imagebuilder/README.md b/sdk/compute/azure-mgmt-imagebuilder/README.md index 834c60b36764..b48052132d49 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/README.md +++ b/sdk/compute/azure-mgmt-imagebuilder/README.md @@ -1,29 +1,21 @@ -## Microsoft Azure SDK for Python +# Microsoft Azure SDK for Python This is the Microsoft Azure Image Builder Client Library. +This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. +For a more complete view of Azure libraries, see the [Github repo](https://github.com/Azure/azure-sdk-for-python/) -Azure Resource Manager (ARM) is the next generation of management APIs -that replace the old Azure Service Management (ASM). -This package has been tested with Python 2.7, 3.5, 3.6 and 3.7. +# Usage -For the older Azure Service Management (ASM) libraries, see -[azure-servicemanagement-legacy](https://pypi.python.org/pypi/azure-servicemanagement-legacy) -library. +For code examples, see [Image Builder](https://docs.microsoft.com/python/api/overview/azure/) +on docs.microsoft.com. -For a more complete set of Azure libraries, see the -[azure](https://pypi.python.org/pypi/azure) bundle package. -## Usage +# Provide Feedback -For code examples, see [Image -Builder](https://docs.microsoft.com/python/api/overview/azure/) on -docs.microsoft.com. - -## Provide Feedback - -If you encounter any bugs or have suggestions, please file an issue in -the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) +If you encounter any bugs or have suggestions, please file an issue in the +[Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project. -![image](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-imagebuilder%2FREADME.png) + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-imagebuilder%2FREADME.png) 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 608c1b752f11..6bd34c3eaa9f 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 @@ -46,7 +46,7 @@ def __init__( super(ImageBuilderClient, self).__init__(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self.api_version = '2019-05-01-preview' + self.api_version = '2020-02-14' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) 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 9d60a3c0656e..e011581e72b0 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 @@ -18,7 +18,6 @@ from ._models_py3 import ImageTemplateFileCustomizer from ._models_py3 import ImageTemplateIdentity from ._models_py3 import ImageTemplateIdentityUserAssignedIdentitiesValue - from ._models_py3 import ImageTemplateIsoSource from ._models_py3 import ImageTemplateLastRunStatus from ._models_py3 import ImageTemplateManagedImageDistributor from ._models_py3 import ImageTemplateManagedImageSource @@ -32,13 +31,16 @@ from ._models_py3 import ImageTemplateUpdateParameters from ._models_py3 import ImageTemplateVhdDistributor from ._models_py3 import ImageTemplateVmProfile + from ._models_py3 import ImageTemplateWindowsUpdateCustomizer from ._models_py3 import InnerError from ._models_py3 import Operation from ._models_py3 import OperationDisplay + from ._models_py3 import PlatformImagePurchasePlan from ._models_py3 import ProvisioningError from ._models_py3 import Resource from ._models_py3 import RunOutput from ._models_py3 import SubResource + from ._models_py3 import VirtualNetworkConfig except (SyntaxError, ImportError): from ._models import ApiError, ApiErrorException from ._models import ApiErrorBase @@ -48,7 +50,6 @@ from ._models import ImageTemplateFileCustomizer from ._models import ImageTemplateIdentity from ._models import ImageTemplateIdentityUserAssignedIdentitiesValue - from ._models import ImageTemplateIsoSource from ._models import ImageTemplateLastRunStatus from ._models import ImageTemplateManagedImageDistributor from ._models import ImageTemplateManagedImageSource @@ -62,13 +63,16 @@ from ._models import ImageTemplateUpdateParameters from ._models import ImageTemplateVhdDistributor from ._models import ImageTemplateVmProfile + from ._models import ImageTemplateWindowsUpdateCustomizer from ._models import InnerError from ._models import Operation from ._models import OperationDisplay + from ._models import PlatformImagePurchasePlan from ._models import ProvisioningError from ._models import Resource from ._models import RunOutput from ._models import SubResource + from ._models import VirtualNetworkConfig from ._paged_models import ImageTemplatePaged from ._paged_models import OperationPaged from ._paged_models import RunOutputPaged @@ -78,6 +82,7 @@ RunState, RunSubState, ResourceIdentityType, + SharedImageStorageAccountType, ) __all__ = [ @@ -89,7 +94,6 @@ 'ImageTemplateFileCustomizer', 'ImageTemplateIdentity', 'ImageTemplateIdentityUserAssignedIdentitiesValue', - 'ImageTemplateIsoSource', 'ImageTemplateLastRunStatus', 'ImageTemplateManagedImageDistributor', 'ImageTemplateManagedImageSource', @@ -103,13 +107,16 @@ 'ImageTemplateUpdateParameters', 'ImageTemplateVhdDistributor', 'ImageTemplateVmProfile', + 'ImageTemplateWindowsUpdateCustomizer', 'InnerError', 'Operation', 'OperationDisplay', + 'PlatformImagePurchasePlan', 'ProvisioningError', 'Resource', 'RunOutput', 'SubResource', + 'VirtualNetworkConfig', 'ImageTemplatePaged', 'RunOutputPaged', 'OperationPaged', @@ -118,4 +125,5 @@ 'RunState', 'RunSubState', 'ResourceIdentityType', + 'SharedImageStorageAccountType', ] diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_image_builder_client_enums.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_image_builder_client_enums.py index ef566c6fa713..bfdc57a957c6 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 @@ -25,7 +25,6 @@ class ProvisioningErrorCode(str, Enum): bad_source_type = "BadSourceType" bad_pir_source = "BadPIRSource" - bad_iso_source = "BadISOSource" bad_managed_image_source = "BadManagedImageSource" bad_shared_image_version_source = "BadSharedImageVersionSource" bad_customizer_type = "BadCustomizerType" @@ -40,9 +39,11 @@ class ProvisioningErrorCode(str, Enum): class RunState(str, Enum): running = "Running" + canceling = "Canceling" succeeded = "Succeeded" partially_succeeded = "PartiallySucceeded" failed = "Failed" + canceled = "Canceled" class RunSubState(str, Enum): @@ -57,3 +58,9 @@ class ResourceIdentityType(str, Enum): user_assigned = "UserAssigned" none = "None" + + +class SharedImageStorageAccountType(str, Enum): + + standard_lrs = "Standard_LRS" + standard_zrs = "Standard_ZRS" diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_models.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_models.py index 6e3a2b8ddcce..f3647e179595 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_models.py +++ b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_models.py @@ -179,7 +179,8 @@ class ImageTemplate(Resource): :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 - :param identity: The identity of the image template, if configured. + :param identity: Required. The identity of the image template, if + configured. :type identity: ~azure.mgmt.imagebuilder.models.ImageTemplateIdentity """ @@ -194,6 +195,7 @@ class ImageTemplate(Resource): 'provisioning_error': {'readonly': True}, 'last_run_status': {'readonly': True}, 'build_timeout_in_minutes': {'maximum': 960, 'minimum': 0}, + 'identity': {'required': True}, } _attribute_map = { @@ -231,8 +233,8 @@ class ImageTemplateCustomizer(Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: ImageTemplateShellCustomizer, - ImageTemplateRestartCustomizer, ImageTemplatePowerShellCustomizer, - ImageTemplateFileCustomizer + ImageTemplateRestartCustomizer, ImageTemplateWindowsUpdateCustomizer, + ImageTemplatePowerShellCustomizer, ImageTemplateFileCustomizer All required parameters must be populated in order to send to Azure. @@ -253,7 +255,7 @@ class ImageTemplateCustomizer(Model): } _subtype_map = { - 'type': {'Shell': 'ImageTemplateShellCustomizer', 'WindowsRestart': 'ImageTemplateRestartCustomizer', 'PowerShell': 'ImageTemplatePowerShellCustomizer', 'File': 'ImageTemplateFileCustomizer'} + 'type': {'Shell': 'ImageTemplateShellCustomizer', 'WindowsRestart': 'ImageTemplateRestartCustomizer', 'WindowsUpdate': 'ImageTemplateWindowsUpdateCustomizer', 'PowerShell': 'ImageTemplatePowerShellCustomizer', 'File': 'ImageTemplateFileCustomizer'} } def __init__(self, **kwargs): @@ -400,72 +402,6 @@ def __init__(self, **kwargs): self.client_id = None -class ImageTemplateSource(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: ImageTemplateIsoSource, ImageTemplatePlatformImageSource, - ImageTemplateManagedImageSource, ImageTemplateSharedImageVersionSource - - All required parameters must be populated in order to send to Azure. - - :param type: Required. Constant filled by server. - :type type: str - """ - - _validation = { - 'type': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - } - - _subtype_map = { - 'type': {'ISO': 'ImageTemplateIsoSource', 'PlatformImage': 'ImageTemplatePlatformImageSource', 'ManagedImage': 'ImageTemplateManagedImageSource', 'SharedImageVersion': 'ImageTemplateSharedImageVersionSource'} - } - - def __init__(self, **kwargs): - super(ImageTemplateSource, self).__init__(**kwargs) - self.type = None - - -class ImageTemplateIsoSource(ImageTemplateSource): - """Describes an image source that is an installation ISO. Currently only - supports Red Hat Enterprise Linux 7.2-7.5 ISO's. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. Constant filled by server. - :type type: str - :param source_uri: Required. URI to get the ISO image. This URI has to be - accessible to the resource provider at the time of the image template - creation. - :type source_uri: str - :param sha256_checksum: Required. SHA256 Checksum of the ISO image. - :type sha256_checksum: str - """ - - _validation = { - 'type': {'required': True}, - 'source_uri': {'required': True}, - 'sha256_checksum': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'source_uri': {'key': 'sourceUri', 'type': 'str'}, - 'sha256_checksum': {'key': 'sha256Checksum', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(ImageTemplateIsoSource, self).__init__(**kwargs) - self.source_uri = kwargs.get('source_uri', None) - self.sha256_checksum = kwargs.get('sha256_checksum', None) - self.type = 'ISO' - - class ImageTemplateLastRunStatus(Model): """Describes the latest status of running an image template. @@ -474,7 +410,8 @@ class ImageTemplateLastRunStatus(Model): :param end_time: End time of the last run (UTC) :type end_time: datetime :param run_state: State of the last run. Possible values include: - 'Running', 'Succeeded', 'PartiallySucceeded', 'Failed' + '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' @@ -542,6 +479,37 @@ def __init__(self, **kwargs): self.type = 'ManagedImage' +class ImageTemplateSource(Model): + """Describes a virtual machine image source for building, customizing and + distributing. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: ImageTemplatePlatformImageSource, + ImageTemplateManagedImageSource, ImageTemplateSharedImageVersionSource + + All required parameters must be populated in order to send to Azure. + + :param type: Required. Constant filled by server. + :type type: str + """ + + _validation = { + 'type': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + } + + _subtype_map = { + 'type': {'PlatformImage': 'ImageTemplatePlatformImageSource', 'ManagedImage': 'ImageTemplateManagedImageSource', 'SharedImageVersion': 'ImageTemplateSharedImageVersionSource'} + } + + def __init__(self, **kwargs): + super(ImageTemplateSource, self).__init__(**kwargs) + self.type = None + + class ImageTemplateManagedImageSource(ImageTemplateSource): """Describes an image source that is a managed image in customer subscription. @@ -590,6 +558,9 @@ class ImageTemplatePlatformImageSource(ImageTemplateSource): :param version: Image version from the [Azure Gallery Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). :type version: str + :param plan_info: Optional configuration of purchase plan for platform + image. + :type plan_info: ~azure.mgmt.imagebuilder.models.PlatformImagePurchasePlan """ _validation = { @@ -602,6 +573,7 @@ class ImageTemplatePlatformImageSource(ImageTemplateSource): 'offer': {'key': 'offer', 'type': 'str'}, 'sku': {'key': 'sku', 'type': 'str'}, 'version': {'key': 'version', 'type': 'str'}, + 'plan_info': {'key': 'planInfo', 'type': 'PlatformImagePurchasePlan'}, } def __init__(self, **kwargs): @@ -610,6 +582,7 @@ def __init__(self, **kwargs): self.offer = kwargs.get('offer', None) self.sku = kwargs.get('sku', None) self.version = kwargs.get('version', None) + self.plan_info = kwargs.get('plan_info', None) self.type = 'PlatformImage' @@ -726,6 +699,14 @@ class ImageTemplateSharedImageDistributor(ImageTemplateDistributor): :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 = { @@ -741,12 +722,16 @@ class ImageTemplateSharedImageDistributor(ImageTemplateDistributor): 'type': {'key': 'type', 'type': 'str'}, 'gallery_image_id': {'key': 'galleryImageId', 'type': 'str'}, 'replication_regions': {'key': 'replicationRegions', 'type': '[str]'}, + 'exclude_from_latest': {'key': 'excludeFromLatest', 'type': 'bool'}, + 'storage_account_type': {'key': 'storageAccountType', 'type': 'SharedImageStorageAccountType'}, } def __init__(self, **kwargs): super(ImageTemplateSharedImageDistributor, self).__init__(**kwargs) self.gallery_image_id = kwargs.get('gallery_image_id', None) self.replication_regions = kwargs.get('replication_regions', None) + self.exclude_from_latest = kwargs.get('exclude_from_latest', None) + self.storage_account_type = kwargs.get('storage_account_type', None) self.type = 'SharedImage' @@ -879,15 +864,75 @@ class ImageTemplateVmProfile(Model): capture images. Omit or specify empty string to use the default (Standard_D1_v2). :type vm_size: str + :param os_disk_size_gb: Size of the OS disk in GB. Omit or specify 0 to + use Azure's default OS disk size. + :type os_disk_size_gb: int + :param vnet_config: Optional configuration of the virtual network to use + to deploy the build virtual machine in. Omit if no specific virtual + network needs to be used. + :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'}, + 'vnet_config': {'key': 'vnetConfig', 'type': 'VirtualNetworkConfig'}, } def __init__(self, **kwargs): super(ImageTemplateVmProfile, self).__init__(**kwargs) self.vm_size = kwargs.get('vm_size', None) + self.os_disk_size_gb = kwargs.get('os_disk_size_gb', None) + self.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 name: Friendly Name to provide context on what this customization + step does + :type name: str + :param type: Required. Constant filled by server. + :type type: str + :param search_criteria: Criteria to search updates. Omit or specify empty + string to use the default (search all). Refer to above link for examples + and detailed description of this field. + :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 = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', '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.search_criteria = kwargs.get('search_criteria', None) + self.filters = kwargs.get('filters', None) + self.update_limit = kwargs.get('update_limit', None) + self.type = 'WindowsUpdate' class InnerError(Model): @@ -922,6 +967,9 @@ class Operation(Model): :type origin: str :param properties: Properties of the operation. :type properties: object + :param is_data_action: The flag that indicates whether the operation + applies to data plane. + :type is_data_action: bool """ _attribute_map = { @@ -929,6 +977,7 @@ class Operation(Model): '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): @@ -937,6 +986,7 @@ def __init__(self, **kwargs): 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(Model): @@ -968,11 +1018,43 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) +class PlatformImagePurchasePlan(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.get('plan_name', None) + self.plan_product = kwargs.get('plan_product', None) + self.plan_publisher = kwargs.get('plan_publisher', None) + + class ProvisioningError(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', 'BadISOSource', + Possible values include: 'BadSourceType', 'BadPIRSource', 'BadManagedImageSource', 'BadSharedImageVersionSource', 'BadCustomizerType', 'UnsupportedCustomizerType', 'NoCustomizerScript', 'BadDistributeType', 'BadSharedImageDistribute', 'ServerError', 'Other' @@ -1073,3 +1155,19 @@ def __init__(self, **kwargs): self.artifact_id = kwargs.get('artifact_id', None) self.artifact_uri = kwargs.get('artifact_uri', None) self.provisioning_state = None + + +class VirtualNetworkConfig(Model): + """Virtual Network configuration. + + :param subnet_id: Resource id of a pre-existing subnet. + :type subnet_id: str + """ + + _attribute_map = { + 'subnet_id': {'key': 'subnetId', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(VirtualNetworkConfig, self).__init__(**kwargs) + self.subnet_id = kwargs.get('subnet_id', None) diff --git a/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_models_py3.py b/sdk/compute/azure-mgmt-imagebuilder/azure/mgmt/imagebuilder/models/_models_py3.py index 5751a4708a80..25ed12301ba4 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 @@ -179,7 +179,8 @@ class ImageTemplate(Resource): :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 - :param identity: The identity of the image template, if configured. + :param identity: Required. The identity of the image template, if + configured. :type identity: ~azure.mgmt.imagebuilder.models.ImageTemplateIdentity """ @@ -194,6 +195,7 @@ class ImageTemplate(Resource): 'provisioning_error': {'readonly': True}, 'last_run_status': {'readonly': True}, 'build_timeout_in_minutes': {'maximum': 960, 'minimum': 0}, + 'identity': {'required': True}, } _attribute_map = { @@ -213,7 +215,7 @@ class ImageTemplate(Resource): 'identity': {'key': 'identity', 'type': 'ImageTemplateIdentity'}, } - def __init__(self, *, location: str, source, distribute, tags=None, customize=None, build_timeout_in_minutes: int=None, vm_profile=None, identity=None, **kwargs) -> None: + def __init__(self, *, location: str, source, distribute, identity, tags=None, customize=None, build_timeout_in_minutes: int=None, vm_profile=None, **kwargs) -> None: super(ImageTemplate, self).__init__(location=location, tags=tags, **kwargs) self.source = source self.customize = customize @@ -231,8 +233,8 @@ class ImageTemplateCustomizer(Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: ImageTemplateShellCustomizer, - ImageTemplateRestartCustomizer, ImageTemplatePowerShellCustomizer, - ImageTemplateFileCustomizer + ImageTemplateRestartCustomizer, ImageTemplateWindowsUpdateCustomizer, + ImageTemplatePowerShellCustomizer, ImageTemplateFileCustomizer All required parameters must be populated in order to send to Azure. @@ -253,7 +255,7 @@ class ImageTemplateCustomizer(Model): } _subtype_map = { - 'type': {'Shell': 'ImageTemplateShellCustomizer', 'WindowsRestart': 'ImageTemplateRestartCustomizer', 'PowerShell': 'ImageTemplatePowerShellCustomizer', 'File': 'ImageTemplateFileCustomizer'} + 'type': {'Shell': 'ImageTemplateShellCustomizer', 'WindowsRestart': 'ImageTemplateRestartCustomizer', 'WindowsUpdate': 'ImageTemplateWindowsUpdateCustomizer', 'PowerShell': 'ImageTemplatePowerShellCustomizer', 'File': 'ImageTemplateFileCustomizer'} } def __init__(self, *, name: str=None, **kwargs) -> None: @@ -400,72 +402,6 @@ def __init__(self, **kwargs) -> None: self.client_id = None -class ImageTemplateSource(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: ImageTemplateIsoSource, ImageTemplatePlatformImageSource, - ImageTemplateManagedImageSource, ImageTemplateSharedImageVersionSource - - All required parameters must be populated in order to send to Azure. - - :param type: Required. Constant filled by server. - :type type: str - """ - - _validation = { - 'type': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - } - - _subtype_map = { - 'type': {'ISO': 'ImageTemplateIsoSource', 'PlatformImage': 'ImageTemplatePlatformImageSource', 'ManagedImage': 'ImageTemplateManagedImageSource', 'SharedImageVersion': 'ImageTemplateSharedImageVersionSource'} - } - - def __init__(self, **kwargs) -> None: - super(ImageTemplateSource, self).__init__(**kwargs) - self.type = None - - -class ImageTemplateIsoSource(ImageTemplateSource): - """Describes an image source that is an installation ISO. Currently only - supports Red Hat Enterprise Linux 7.2-7.5 ISO's. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. Constant filled by server. - :type type: str - :param source_uri: Required. URI to get the ISO image. This URI has to be - accessible to the resource provider at the time of the image template - creation. - :type source_uri: str - :param sha256_checksum: Required. SHA256 Checksum of the ISO image. - :type sha256_checksum: str - """ - - _validation = { - 'type': {'required': True}, - 'source_uri': {'required': True}, - 'sha256_checksum': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'source_uri': {'key': 'sourceUri', 'type': 'str'}, - 'sha256_checksum': {'key': 'sha256Checksum', 'type': 'str'}, - } - - def __init__(self, *, source_uri: str, sha256_checksum: str, **kwargs) -> None: - super(ImageTemplateIsoSource, self).__init__(**kwargs) - self.source_uri = source_uri - self.sha256_checksum = sha256_checksum - self.type = 'ISO' - - class ImageTemplateLastRunStatus(Model): """Describes the latest status of running an image template. @@ -474,7 +410,8 @@ class ImageTemplateLastRunStatus(Model): :param end_time: End time of the last run (UTC) :type end_time: datetime :param run_state: State of the last run. Possible values include: - 'Running', 'Succeeded', 'PartiallySucceeded', 'Failed' + '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' @@ -542,6 +479,37 @@ def __init__(self, *, run_output_name: str, image_id: str, location: str, artifa self.type = 'ManagedImage' +class ImageTemplateSource(Model): + """Describes a virtual machine image source for building, customizing and + distributing. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: ImageTemplatePlatformImageSource, + ImageTemplateManagedImageSource, ImageTemplateSharedImageVersionSource + + All required parameters must be populated in order to send to Azure. + + :param type: Required. Constant filled by server. + :type type: str + """ + + _validation = { + 'type': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + } + + _subtype_map = { + 'type': {'PlatformImage': 'ImageTemplatePlatformImageSource', 'ManagedImage': 'ImageTemplateManagedImageSource', 'SharedImageVersion': 'ImageTemplateSharedImageVersionSource'} + } + + def __init__(self, **kwargs) -> None: + super(ImageTemplateSource, self).__init__(**kwargs) + self.type = None + + class ImageTemplateManagedImageSource(ImageTemplateSource): """Describes an image source that is a managed image in customer subscription. @@ -590,6 +558,9 @@ class ImageTemplatePlatformImageSource(ImageTemplateSource): :param version: Image version from the [Azure Gallery Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). :type version: str + :param plan_info: Optional configuration of purchase plan for platform + image. + :type plan_info: ~azure.mgmt.imagebuilder.models.PlatformImagePurchasePlan """ _validation = { @@ -602,14 +573,16 @@ class ImageTemplatePlatformImageSource(ImageTemplateSource): 'offer': {'key': 'offer', 'type': 'str'}, 'sku': {'key': 'sku', 'type': 'str'}, 'version': {'key': 'version', 'type': 'str'}, + 'plan_info': {'key': 'planInfo', 'type': 'PlatformImagePurchasePlan'}, } - def __init__(self, *, publisher: str=None, offer: str=None, sku: str=None, version: str=None, **kwargs) -> None: + def __init__(self, *, publisher: str=None, offer: str=None, sku: str=None, version: str=None, plan_info=None, **kwargs) -> None: super(ImageTemplatePlatformImageSource, self).__init__(**kwargs) self.publisher = publisher self.offer = offer self.sku = sku self.version = version + self.plan_info = plan_info self.type = 'PlatformImage' @@ -726,6 +699,14 @@ class ImageTemplateSharedImageDistributor(ImageTemplateDistributor): :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 = { @@ -741,12 +722,16 @@ class ImageTemplateSharedImageDistributor(ImageTemplateDistributor): 'type': {'key': 'type', 'type': 'str'}, 'gallery_image_id': {'key': 'galleryImageId', 'type': 'str'}, 'replication_regions': {'key': 'replicationRegions', 'type': '[str]'}, + 'exclude_from_latest': {'key': 'excludeFromLatest', 'type': 'bool'}, + 'storage_account_type': {'key': 'storageAccountType', 'type': 'SharedImageStorageAccountType'}, } - def __init__(self, *, run_output_name: str, gallery_image_id: str, replication_regions, artifact_tags=None, **kwargs) -> None: + def __init__(self, *, run_output_name: str, gallery_image_id: str, replication_regions, artifact_tags=None, exclude_from_latest: bool=None, storage_account_type=None, **kwargs) -> None: super(ImageTemplateSharedImageDistributor, self).__init__(run_output_name=run_output_name, artifact_tags=artifact_tags, **kwargs) self.gallery_image_id = gallery_image_id self.replication_regions = replication_regions + self.exclude_from_latest = exclude_from_latest + self.storage_account_type = storage_account_type self.type = 'SharedImage' @@ -879,15 +864,75 @@ class ImageTemplateVmProfile(Model): capture images. Omit or specify empty string to use the default (Standard_D1_v2). :type vm_size: str + :param os_disk_size_gb: Size of the OS disk in GB. Omit or specify 0 to + use Azure's default OS disk size. + :type os_disk_size_gb: int + :param vnet_config: Optional configuration of the virtual network to use + to deploy the build virtual machine in. Omit if no specific virtual + network needs to be used. + :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'}, + 'vnet_config': {'key': 'vnetConfig', 'type': 'VirtualNetworkConfig'}, } - def __init__(self, *, vm_size: str=None, **kwargs) -> None: + def __init__(self, *, vm_size: str=None, os_disk_size_gb: int=None, vnet_config=None, **kwargs) -> None: super(ImageTemplateVmProfile, self).__init__(**kwargs) self.vm_size = vm_size + self.os_disk_size_gb = os_disk_size_gb + self.vnet_config = vnet_config + + +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 name: Friendly Name to provide context on what this customization + step does + :type name: str + :param type: Required. Constant filled by server. + :type type: str + :param search_criteria: Criteria to search updates. Omit or specify empty + string to use the default (search all). Refer to above link for examples + and detailed description of this field. + :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 = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'search_criteria': {'key': 'searchCriteria', 'type': 'str'}, + 'filters': {'key': 'filters', 'type': '[str]'}, + 'update_limit': {'key': 'updateLimit', 'type': 'int'}, + } + + def __init__(self, *, name: str=None, search_criteria: str=None, filters=None, update_limit: int=None, **kwargs) -> None: + super(ImageTemplateWindowsUpdateCustomizer, self).__init__(name=name, **kwargs) + self.search_criteria = search_criteria + self.filters = filters + self.update_limit = update_limit + self.type = 'WindowsUpdate' class InnerError(Model): @@ -922,6 +967,9 @@ class Operation(Model): :type origin: str :param properties: Properties of the operation. :type properties: object + :param is_data_action: The flag that indicates whether the operation + applies to data plane. + :type is_data_action: bool """ _attribute_map = { @@ -929,14 +977,16 @@ class Operation(Model): '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, *, name: str=None, display=None, origin: str=None, properties=None, **kwargs) -> None: + def __init__(self, *, name: str=None, display=None, origin: str=None, properties=None, is_data_action: bool=None, **kwargs) -> None: super(Operation, self).__init__(**kwargs) self.name = name self.display = display self.origin = origin self.properties = properties + self.is_data_action = is_data_action class OperationDisplay(Model): @@ -968,11 +1018,43 @@ def __init__(self, *, provider: str=None, operation: str=None, resource: str=Non self.description = description +class PlatformImagePurchasePlan(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, *, plan_name: str, plan_product: str, plan_publisher: str, **kwargs) -> None: + super(PlatformImagePurchasePlan, self).__init__(**kwargs) + self.plan_name = plan_name + self.plan_product = plan_product + self.plan_publisher = plan_publisher + + class ProvisioningError(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', 'BadISOSource', + Possible values include: 'BadSourceType', 'BadPIRSource', 'BadManagedImageSource', 'BadSharedImageVersionSource', 'BadCustomizerType', 'UnsupportedCustomizerType', 'NoCustomizerScript', 'BadDistributeType', 'BadSharedImageDistribute', 'ServerError', 'Other' @@ -1073,3 +1155,19 @@ def __init__(self, *, name: str, artifact_id: str=None, artifact_uri: str=None, self.artifact_id = artifact_id self.artifact_uri = artifact_uri self.provisioning_state = None + + +class VirtualNetworkConfig(Model): + """Virtual Network configuration. + + :param subnet_id: Resource id of a pre-existing subnet. + :type subnet_id: str + """ + + _attribute_map = { + 'subnet_id': {'key': 'subnetId', 'type': 'str'}, + } + + def __init__(self, *, subnet_id: str=None, **kwargs) -> None: + super(VirtualNetworkConfig, self).__init__(**kwargs) + self.subnet_id = subnet_id 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 cda96e0326f0..e153a10b9548 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 @@ -24,7 +24,7 @@ class Operations(object): :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Client Api Version. Constant value: "2019-05-01-preview". + :ivar api_version: Client Api Version. Constant value: "2020-02-14". """ models = models @@ -34,7 +34,7 @@ def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-05-01-preview" + self.api_version = "2020-02-14" self.config = config 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 f63b5e51599e..bd7ad792e602 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 @@ -26,7 +26,7 @@ class VirtualMachineImageTemplatesOperations(object): :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Client Api Version. Constant value: "2019-05-01-preview". + :ivar api_version: Client Api Version. Constant value: "2020-02-14". """ models = models @@ -36,7 +36,7 @@ def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-05-01-preview" + self.api_version = "2020-02-14" self.config = config @@ -549,7 +549,7 @@ def _run_initial( request = self._client.post(url, query_parameters, header_parameters) response = self._client.send(request, stream=False, **operation_config) - if response.status_code not in [202, 204]: + if response.status_code not in [200, 202, 204]: raise models.ApiErrorException(self._deserialize, response) if raw: @@ -598,6 +598,84 @@ def get_long_running_output(response): return LROPoller(self._client, raw_result, get_long_running_output, polling_method) run.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/run'} + + def _cancel_initial( + self, resource_group_name, image_template_name, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.cancel.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 202, 204]: + raise models.ApiErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + def cancel( + self, resource_group_name, image_template_name, custom_headers=None, raw=False, polling=True, **operation_config): + """Cancel the long running image build based on the image template. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param image_template_name: The name of the image Template + :type image_template_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns None or + ClientRawResponse if raw==True + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] + :raises: + :class:`ApiErrorException` + """ + raw_result = self._cancel_initial( + resource_group_name=resource_group_name, + image_template_name=image_template_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/cancel'} + def list_run_outputs( self, resource_group_name, image_template_name, custom_headers=None, raw=False, **operation_config): """List all run outputs for the specified Image Template resource. diff --git a/sdk/compute/azure-mgmt-imagebuilder/setup.py b/sdk/compute/azure-mgmt-imagebuilder/setup.py index 4fe73ff08a68..09a72a16960f 100644 --- a/sdk/compute/azure-mgmt-imagebuilder/setup.py +++ b/sdk/compute/azure-mgmt-imagebuilder/setup.py @@ -36,7 +36,9 @@ pass # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py'), 'r') as fd: +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) @@ -67,6 +69,7 @@ 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'License :: OSI Approved :: MIT License', ], zip_safe=False,