Skip to content

Commit

Permalink
CodeGen from PR 13333 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Merge 7edd466b7e24db9ee6dc1752627d8d10752a1c65 into ff541d8
  • Loading branch information
SDKAuto committed Mar 11, 2021
1 parent 6286f95 commit 05e43c0
Show file tree
Hide file tree
Showing 6 changed files with 324 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling

from ... import models as _models

Expand Down Expand Up @@ -1080,3 +1082,124 @@ async def lease(

return deserialized
lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore

async def _version_level_worm_initial(
self,
resource_group_name: str,
account_name: str,
container_name: str,
**kwargs
) -> None:
cls = kwargs.pop('cls', None) # type: ClsType[None]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2021-01-01"

# Construct URL
url = self._version_level_worm_initial.metadata['url'] # type: ignore
path_format_arguments = {
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'),
'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3),
'containerName': self._serialize.url("container_name", container_name, 'str', max_length=63, min_length=3),
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1),
}
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]

request = self._client.put(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response

if response.status_code not in [200, 202]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)

if cls:
return cls(pipeline_response, None, {})

_version_level_worm_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate'} # type: ignore

async def begin_version_level_worm(
self,
resource_group_name: str,
account_name: str,
container_name: str,
**kwargs
) -> AsyncLROPoller[None]:
"""This operation migrates a blob container from container level WORM to version level WORM
enabled container. Prerequisites require a container level immutability policy either in locked
or unlocked state, Account level versioning must be enabled and there should be no Legal holds.
:param resource_group_name: The name of the resource group within the user's subscription. The
name is case insensitive.
:type resource_group_name: str
:param account_name: The name of the storage account within the specified resource group.
Storage account names must be between 3 and 24 characters in length and use numbers and lower-
case letters only.
:type account_name: str
:param container_name: The name of the blob container within the specified storage account.
Blob container names must be between 3 and 63 characters in length and use numbers, lower-case
letters and dash (-) only. Every dash (-) character must be immediately preceded and followed
by a letter or number.
:type container_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: True for ARMPolling, False for no polling, or a
polling object for personal polling strategy
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod]
cls = kwargs.pop('cls', None) # type: ClsType[None]
lro_delay = kwargs.pop(
'polling_interval',
self._config.polling_interval
)
cont_token = kwargs.pop('continuation_token', None) # type: Optional[str]
if cont_token is None:
raw_result = await self._version_level_worm_initial(
resource_group_name=resource_group_name,
account_name=account_name,
container_name=container_name,
cls=lambda x,y,z: x,
**kwargs
)

kwargs.pop('error_map', None)
kwargs.pop('content_type', None)

def get_long_running_output(pipeline_response):
if cls:
return cls(pipeline_response, None, {})

path_format_arguments = {
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'),
'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3),
'containerName': self._serialize.url("container_name", container_name, 'str', max_length=63, min_length=3),
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1),
}

if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs)
elif polling is False: polling_method = AsyncNoPolling()
else: polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output
)
else:
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method)
begin_version_level_worm.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate'} # type: ignore
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@
ListContainersInclude,
ListSharesExpand,
ManagementPolicyName,
MigrationState,
MinimumTlsVersion,
Name,
Permissions,
Expand Down Expand Up @@ -481,6 +482,7 @@
'ListContainersInclude',
'ListSharesExpand',
'ManagementPolicyName',
'MigrationState',
'MinimumTlsVersion',
'Name',
'Permissions',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,14 @@ class BlobContainer(AzureEntityResource):
if ImmutabilityPolicy has been created for this container. The hasImmutabilityPolicy public
property is set to false by SRP if ImmutabilityPolicy has not been created for this container.
:vartype has_immutability_policy: bool
:param enabled: This is an immutable property, when set to true enables version level worm at
the container level.
:type enabled: bool
:ivar time_stamp: Returns the date and time the version level worm was enabled.
:vartype time_stamp: ~datetime.datetime
:ivar migration_state: This property denotes the container level worm to version level worm
migration state. Possible values include: "InProgress", "Completed", "Abort".
:vartype migration_state: str or ~azure.mgmt.storage.v2021_01_01.models.MigrationState
"""

_validation = {
Expand All @@ -312,6 +320,8 @@ class BlobContainer(AzureEntityResource):
'legal_hold': {'readonly': True},
'has_legal_hold': {'readonly': True},
'has_immutability_policy': {'readonly': True},
'time_stamp': {'readonly': True},
'migration_state': {'readonly': True},
}

_attribute_map = {
Expand All @@ -335,6 +345,9 @@ class BlobContainer(AzureEntityResource):
'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'},
'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'},
'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'},
'enabled': {'key': 'properties.versionLevelWorm.enabled', 'type': 'bool'},
'time_stamp': {'key': 'properties.versionLevelWorm.timeStamp', 'type': 'iso-8601'},
'migration_state': {'key': 'properties.versionLevelWorm.migrationState', 'type': 'str'},
}

def __init__(
Expand All @@ -358,6 +371,9 @@ def __init__(
self.legal_hold = None
self.has_legal_hold = None
self.has_immutability_policy = None
self.enabled = kwargs.get('enabled', None)
self.time_stamp = None
self.migration_state = None


class BlobInventoryPolicy(Resource):
Expand Down Expand Up @@ -2482,6 +2498,14 @@ class ListContainerItem(AzureEntityResource):
if ImmutabilityPolicy has been created for this container. The hasImmutabilityPolicy public
property is set to false by SRP if ImmutabilityPolicy has not been created for this container.
:vartype has_immutability_policy: bool
:param enabled: This is an immutable property, when set to true enables version level worm at
the container level.
:type enabled: bool
:ivar time_stamp: Returns the date and time the version level worm was enabled.
:vartype time_stamp: ~datetime.datetime
:ivar migration_state: This property denotes the container level worm to version level worm
migration state. Possible values include: "InProgress", "Completed", "Abort".
:vartype migration_state: str or ~azure.mgmt.storage.v2021_01_01.models.MigrationState
"""

_validation = {
Expand All @@ -2501,6 +2525,8 @@ class ListContainerItem(AzureEntityResource):
'legal_hold': {'readonly': True},
'has_legal_hold': {'readonly': True},
'has_immutability_policy': {'readonly': True},
'time_stamp': {'readonly': True},
'migration_state': {'readonly': True},
}

_attribute_map = {
Expand All @@ -2524,6 +2550,9 @@ class ListContainerItem(AzureEntityResource):
'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'},
'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'},
'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'},
'enabled': {'key': 'properties.versionLevelWorm.enabled', 'type': 'bool'},
'time_stamp': {'key': 'properties.versionLevelWorm.timeStamp', 'type': 'iso-8601'},
'migration_state': {'key': 'properties.versionLevelWorm.migrationState', 'type': 'str'},
}

def __init__(
Expand All @@ -2547,6 +2576,9 @@ def __init__(
self.legal_hold = None
self.has_legal_hold = None
self.has_immutability_policy = None
self.enabled = kwargs.get('enabled', None)
self.time_stamp = None
self.migration_state = None


class ListContainerItems(msrest.serialization.Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,14 @@ class BlobContainer(AzureEntityResource):
if ImmutabilityPolicy has been created for this container. The hasImmutabilityPolicy public
property is set to false by SRP if ImmutabilityPolicy has not been created for this container.
:vartype has_immutability_policy: bool
:param enabled: This is an immutable property, when set to true enables version level worm at
the container level.
:type enabled: bool
:ivar time_stamp: Returns the date and time the version level worm was enabled.
:vartype time_stamp: ~datetime.datetime
:ivar migration_state: This property denotes the container level worm to version level worm
migration state. Possible values include: "InProgress", "Completed", "Abort".
:vartype migration_state: str or ~azure.mgmt.storage.v2021_01_01.models.MigrationState
"""

_validation = {
Expand All @@ -336,6 +344,8 @@ class BlobContainer(AzureEntityResource):
'legal_hold': {'readonly': True},
'has_legal_hold': {'readonly': True},
'has_immutability_policy': {'readonly': True},
'time_stamp': {'readonly': True},
'migration_state': {'readonly': True},
}

_attribute_map = {
Expand All @@ -359,6 +369,9 @@ class BlobContainer(AzureEntityResource):
'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'},
'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'},
'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'},
'enabled': {'key': 'properties.versionLevelWorm.enabled', 'type': 'bool'},
'time_stamp': {'key': 'properties.versionLevelWorm.timeStamp', 'type': 'iso-8601'},
'migration_state': {'key': 'properties.versionLevelWorm.migrationState', 'type': 'str'},
}

def __init__(
Expand All @@ -368,6 +381,7 @@ def __init__(
deny_encryption_scope_override: Optional[bool] = None,
public_access: Optional[Union[str, "PublicAccess"]] = None,
metadata: Optional[Dict[str, str]] = None,
enabled: Optional[bool] = None,
**kwargs
):
super(BlobContainer, self).__init__(**kwargs)
Expand All @@ -387,6 +401,9 @@ def __init__(
self.legal_hold = None
self.has_legal_hold = None
self.has_immutability_policy = None
self.enabled = enabled
self.time_stamp = None
self.migration_state = None


class BlobInventoryPolicy(Resource):
Expand Down Expand Up @@ -2661,6 +2678,14 @@ class ListContainerItem(AzureEntityResource):
if ImmutabilityPolicy has been created for this container. The hasImmutabilityPolicy public
property is set to false by SRP if ImmutabilityPolicy has not been created for this container.
:vartype has_immutability_policy: bool
:param enabled: This is an immutable property, when set to true enables version level worm at
the container level.
:type enabled: bool
:ivar time_stamp: Returns the date and time the version level worm was enabled.
:vartype time_stamp: ~datetime.datetime
:ivar migration_state: This property denotes the container level worm to version level worm
migration state. Possible values include: "InProgress", "Completed", "Abort".
:vartype migration_state: str or ~azure.mgmt.storage.v2021_01_01.models.MigrationState
"""

_validation = {
Expand All @@ -2680,6 +2705,8 @@ class ListContainerItem(AzureEntityResource):
'legal_hold': {'readonly': True},
'has_legal_hold': {'readonly': True},
'has_immutability_policy': {'readonly': True},
'time_stamp': {'readonly': True},
'migration_state': {'readonly': True},
}

_attribute_map = {
Expand All @@ -2703,6 +2730,9 @@ class ListContainerItem(AzureEntityResource):
'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'},
'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'},
'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'},
'enabled': {'key': 'properties.versionLevelWorm.enabled', 'type': 'bool'},
'time_stamp': {'key': 'properties.versionLevelWorm.timeStamp', 'type': 'iso-8601'},
'migration_state': {'key': 'properties.versionLevelWorm.migrationState', 'type': 'str'},
}

def __init__(
Expand All @@ -2712,6 +2742,7 @@ def __init__(
deny_encryption_scope_override: Optional[bool] = None,
public_access: Optional[Union[str, "PublicAccess"]] = None,
metadata: Optional[Dict[str, str]] = None,
enabled: Optional[bool] = None,
**kwargs
):
super(ListContainerItem, self).__init__(**kwargs)
Expand All @@ -2731,6 +2762,9 @@ def __init__(
self.legal_hold = None
self.has_legal_hold = None
self.has_immutability_policy = None
self.enabled = enabled
self.time_stamp = None
self.migration_state = None


class ListContainerItems(msrest.serialization.Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ class ManagementPolicyName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):

DEFAULT = "default"

class MigrationState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
"""This property denotes the container level worm to version level worm migration state.
"""

IN_PROGRESS = "InProgress"
COMPLETED = "Completed"
ABORT = "Abort"

class MinimumTlsVersion(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
"""Set the minimum TLS version to be permitted on requests to storage. The default interpretation
is TLS 1.0 for this property.
Expand Down
Loading

0 comments on commit 05e43c0

Please sign in to comment.