diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/__init__.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/__init__.py index 010d2c212913..310130e5455a 100644 --- a/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/__init__.py +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/__init__.py @@ -55,6 +55,8 @@ from .legal_hold_py3 import LegalHold from .list_container_item_py3 import ListContainerItem from .list_container_items_py3 import ListContainerItems + from .lease_container_request_py3 import LeaseContainerRequest + from .lease_container_response_py3 import LeaseContainerResponse except (SyntaxError, ImportError): from .operation_display import OperationDisplay from .dimension import Dimension @@ -101,6 +103,8 @@ from .legal_hold import LegalHold from .list_container_item import ListContainerItem from .list_container_items import ListContainerItems + from .lease_container_request import LeaseContainerRequest + from .lease_container_response import LeaseContainerResponse from .operation_paged import OperationPaged from .sku_paged import SkuPaged from .storage_account_paged import StorageAccountPaged @@ -180,6 +184,8 @@ 'LegalHold', 'ListContainerItem', 'ListContainerItems', + 'LeaseContainerRequest', + 'LeaseContainerResponse', 'OperationPaged', 'SkuPaged', 'StorageAccountPaged', diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/lease_container_request.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/lease_container_request.py new file mode 100644 index 000000000000..77fb6929b8fa --- /dev/null +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/lease_container_request.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LeaseContainerRequest(Model): + """Lease Container request schema. + + All required parameters must be populated in order to send to Azure. + + :param action: Required. Specifies the lease action. Can be one of the + available actions. Possible values include: 'Acquire', 'Renew', 'Change', + 'Release', 'Break' + :type action: str or ~azure.mgmt.storage.v2018_02_01.models.enum + :param lease_id: Identifies the lease. Can be specified in any valid GUID + string format. + :type lease_id: str + :param break_period: Optional. For a break action, proposed duration the + lease should continue before it is broken, in seconds, between 0 and 60. + :type break_period: int + :param lease_duration: Required for acquire. Specifies the duration of the + lease, in seconds, or negative one (-1) for a lease that never expires. + :type lease_duration: int + :param proposed_lease_id: Optional for acquire, required for change. + Proposed lease ID, in a GUID string format. + :type proposed_lease_id: str + """ + + _validation = { + 'action': {'required': True}, + } + + _attribute_map = { + 'action': {'key': 'action', 'type': 'str'}, + 'lease_id': {'key': 'leaseId', 'type': 'str'}, + 'break_period': {'key': 'breakPeriod', 'type': 'int'}, + 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, + 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(LeaseContainerRequest, self).__init__(**kwargs) + self.action = kwargs.get('action', None) + self.lease_id = kwargs.get('lease_id', None) + self.break_period = kwargs.get('break_period', None) + self.lease_duration = kwargs.get('lease_duration', None) + self.proposed_lease_id = kwargs.get('proposed_lease_id', None) diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/lease_container_request_py3.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/lease_container_request_py3.py new file mode 100644 index 000000000000..2708ec47e7c1 --- /dev/null +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/lease_container_request_py3.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LeaseContainerRequest(Model): + """Lease Container request schema. + + All required parameters must be populated in order to send to Azure. + + :param action: Required. Specifies the lease action. Can be one of the + available actions. Possible values include: 'Acquire', 'Renew', 'Change', + 'Release', 'Break' + :type action: str or ~azure.mgmt.storage.v2018_02_01.models.enum + :param lease_id: Identifies the lease. Can be specified in any valid GUID + string format. + :type lease_id: str + :param break_period: Optional. For a break action, proposed duration the + lease should continue before it is broken, in seconds, between 0 and 60. + :type break_period: int + :param lease_duration: Required for acquire. Specifies the duration of the + lease, in seconds, or negative one (-1) for a lease that never expires. + :type lease_duration: int + :param proposed_lease_id: Optional for acquire, required for change. + Proposed lease ID, in a GUID string format. + :type proposed_lease_id: str + """ + + _validation = { + 'action': {'required': True}, + } + + _attribute_map = { + 'action': {'key': 'action', 'type': 'str'}, + 'lease_id': {'key': 'leaseId', 'type': 'str'}, + 'break_period': {'key': 'breakPeriod', 'type': 'int'}, + 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, + 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + } + + def __init__(self, *, action, lease_id: str=None, break_period: int=None, lease_duration: int=None, proposed_lease_id: str=None, **kwargs) -> None: + super(LeaseContainerRequest, self).__init__(**kwargs) + self.action = action + self.lease_id = lease_id + self.break_period = break_period + self.lease_duration = lease_duration + self.proposed_lease_id = proposed_lease_id diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/lease_container_response.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/lease_container_response.py new file mode 100644 index 000000000000..666f0e899f1e --- /dev/null +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/lease_container_response.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LeaseContainerResponse(Model): + """Lease Container response schema. + + :param lease_id: Returned unique lease ID that must be included with any + request to delete the container, or to renew, change, or release the + lease. + :type lease_id: str + :param lease_time_seconds: Approximate time remaining in the lease period, + in seconds. + :type lease_time_seconds: str + """ + + _attribute_map = { + 'lease_id': {'key': 'leaseId', 'type': 'str'}, + 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(LeaseContainerResponse, self).__init__(**kwargs) + self.lease_id = kwargs.get('lease_id', None) + self.lease_time_seconds = kwargs.get('lease_time_seconds', None) diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/lease_container_response_py3.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/lease_container_response_py3.py new file mode 100644 index 000000000000..fa87d930571d --- /dev/null +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/lease_container_response_py3.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LeaseContainerResponse(Model): + """Lease Container response schema. + + :param lease_id: Returned unique lease ID that must be included with any + request to delete the container, or to renew, change, or release the + lease. + :type lease_id: str + :param lease_time_seconds: Approximate time remaining in the lease period, + in seconds. + :type lease_time_seconds: str + """ + + _attribute_map = { + 'lease_id': {'key': 'leaseId', 'type': 'str'}, + 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + } + + def __init__(self, *, lease_id: str=None, lease_time_seconds: str=None, **kwargs) -> None: + super(LeaseContainerResponse, self).__init__(**kwargs) + self.lease_id = lease_id + self.lease_time_seconds = lease_time_seconds diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/blob_containers_operations.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/blob_containers_operations.py index 5d79aa599054..de7148005453 100644 --- a/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/blob_containers_operations.py +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/blob_containers_operations.py @@ -1042,3 +1042,87 @@ def extend_immutability_policy( return deserialized extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} + + def lease( + self, resource_group_name, account_name, container_name, parameters=None, custom_headers=None, raw=False, **operation_config): + """The Lease Container operation establishes and manages a lock on a + container for delete operations. The lock duration can be 15 to 60 + seconds, or can be infinite. + + :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 + :param parameters: Lease Container request body. + :type parameters: + ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerRequest + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: LeaseContainerResponse or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerResponse + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.lease.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + if parameters is not None: + body_content = self._serialize.body(parameters, 'LeaseContainerRequest') + else: + body_content = None + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('LeaseContainerResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/__init__.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/__init__.py index d5121718507f..d94f1af1a327 100644 --- a/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/__init__.py +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/__init__.py @@ -57,6 +57,8 @@ from .legal_hold_py3 import LegalHold from .list_container_item_py3 import ListContainerItem from .list_container_items_py3 import ListContainerItems + from .lease_container_request_py3 import LeaseContainerRequest + from .lease_container_response_py3 import LeaseContainerResponse except (SyntaxError, ImportError): from .operation_display import OperationDisplay from .dimension import Dimension @@ -105,6 +107,8 @@ from .legal_hold import LegalHold from .list_container_item import ListContainerItem from .list_container_items import ListContainerItems + from .lease_container_request import LeaseContainerRequest + from .lease_container_response import LeaseContainerResponse from .operation_paged import OperationPaged from .sku_paged import SkuPaged from .storage_account_paged import StorageAccountPaged @@ -186,6 +190,8 @@ 'LegalHold', 'ListContainerItem', 'ListContainerItems', + 'LeaseContainerRequest', + 'LeaseContainerResponse', 'OperationPaged', 'SkuPaged', 'StorageAccountPaged', diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/lease_container_request.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/lease_container_request.py new file mode 100644 index 000000000000..a2a5f4b647ba --- /dev/null +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/lease_container_request.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LeaseContainerRequest(Model): + """Lease Container request schema. + + All required parameters must be populated in order to send to Azure. + + :param action: Required. Specifies the lease action. Can be one of the + available actions. Possible values include: 'Acquire', 'Renew', 'Change', + 'Release', 'Break' + :type action: str or ~azure.mgmt.storage.v2018_03_01_preview.models.enum + :param lease_id: Identifies the lease. Can be specified in any valid GUID + string format. + :type lease_id: str + :param break_period: Optional. For a break action, proposed duration the + lease should continue before it is broken, in seconds, between 0 and 60. + :type break_period: int + :param lease_duration: Required for acquire. Specifies the duration of the + lease, in seconds, or negative one (-1) for a lease that never expires. + :type lease_duration: int + :param proposed_lease_id: Optional for acquire, required for change. + Proposed lease ID, in a GUID string format. + :type proposed_lease_id: str + """ + + _validation = { + 'action': {'required': True}, + } + + _attribute_map = { + 'action': {'key': 'action', 'type': 'str'}, + 'lease_id': {'key': 'leaseId', 'type': 'str'}, + 'break_period': {'key': 'breakPeriod', 'type': 'int'}, + 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, + 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(LeaseContainerRequest, self).__init__(**kwargs) + self.action = kwargs.get('action', None) + self.lease_id = kwargs.get('lease_id', None) + self.break_period = kwargs.get('break_period', None) + self.lease_duration = kwargs.get('lease_duration', None) + self.proposed_lease_id = kwargs.get('proposed_lease_id', None) diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/lease_container_request_py3.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/lease_container_request_py3.py new file mode 100644 index 000000000000..d826237f18c5 --- /dev/null +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/lease_container_request_py3.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LeaseContainerRequest(Model): + """Lease Container request schema. + + All required parameters must be populated in order to send to Azure. + + :param action: Required. Specifies the lease action. Can be one of the + available actions. Possible values include: 'Acquire', 'Renew', 'Change', + 'Release', 'Break' + :type action: str or ~azure.mgmt.storage.v2018_03_01_preview.models.enum + :param lease_id: Identifies the lease. Can be specified in any valid GUID + string format. + :type lease_id: str + :param break_period: Optional. For a break action, proposed duration the + lease should continue before it is broken, in seconds, between 0 and 60. + :type break_period: int + :param lease_duration: Required for acquire. Specifies the duration of the + lease, in seconds, or negative one (-1) for a lease that never expires. + :type lease_duration: int + :param proposed_lease_id: Optional for acquire, required for change. + Proposed lease ID, in a GUID string format. + :type proposed_lease_id: str + """ + + _validation = { + 'action': {'required': True}, + } + + _attribute_map = { + 'action': {'key': 'action', 'type': 'str'}, + 'lease_id': {'key': 'leaseId', 'type': 'str'}, + 'break_period': {'key': 'breakPeriod', 'type': 'int'}, + 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, + 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + } + + def __init__(self, *, action, lease_id: str=None, break_period: int=None, lease_duration: int=None, proposed_lease_id: str=None, **kwargs) -> None: + super(LeaseContainerRequest, self).__init__(**kwargs) + self.action = action + self.lease_id = lease_id + self.break_period = break_period + self.lease_duration = lease_duration + self.proposed_lease_id = proposed_lease_id diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/lease_container_response.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/lease_container_response.py new file mode 100644 index 000000000000..666f0e899f1e --- /dev/null +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/lease_container_response.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LeaseContainerResponse(Model): + """Lease Container response schema. + + :param lease_id: Returned unique lease ID that must be included with any + request to delete the container, or to renew, change, or release the + lease. + :type lease_id: str + :param lease_time_seconds: Approximate time remaining in the lease period, + in seconds. + :type lease_time_seconds: str + """ + + _attribute_map = { + 'lease_id': {'key': 'leaseId', 'type': 'str'}, + 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(LeaseContainerResponse, self).__init__(**kwargs) + self.lease_id = kwargs.get('lease_id', None) + self.lease_time_seconds = kwargs.get('lease_time_seconds', None) diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/lease_container_response_py3.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/lease_container_response_py3.py new file mode 100644 index 000000000000..fa87d930571d --- /dev/null +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/lease_container_response_py3.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LeaseContainerResponse(Model): + """Lease Container response schema. + + :param lease_id: Returned unique lease ID that must be included with any + request to delete the container, or to renew, change, or release the + lease. + :type lease_id: str + :param lease_time_seconds: Approximate time remaining in the lease period, + in seconds. + :type lease_time_seconds: str + """ + + _attribute_map = { + 'lease_id': {'key': 'leaseId', 'type': 'str'}, + 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + } + + def __init__(self, *, lease_id: str=None, lease_time_seconds: str=None, **kwargs) -> None: + super(LeaseContainerResponse, self).__init__(**kwargs) + self.lease_id = lease_id + self.lease_time_seconds = lease_time_seconds diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/blob_containers_operations.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/blob_containers_operations.py index 8d69bbcdf38e..9b1ce276d01b 100644 --- a/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/blob_containers_operations.py +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/blob_containers_operations.py @@ -1048,3 +1048,88 @@ def extend_immutability_policy( return deserialized extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} + + def lease( + self, resource_group_name, account_name, container_name, parameters=None, custom_headers=None, raw=False, **operation_config): + """The Lease Container operation establishes and manages a lock on a + container for delete operations. The lock duration can be 15 to 60 + seconds, or can be infinite. + + :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 + :param parameters: Lease Container request body. + :type parameters: + ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerRequest + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: LeaseContainerResponse or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerResponse + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.lease.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + if parameters is not None: + body_content = self._serialize.body(parameters, 'LeaseContainerRequest') + else: + body_content = None + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('LeaseContainerResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/__init__.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/__init__.py index 10fdba5e08a3..e5e20c59f10f 100644 --- a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/__init__.py +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/__init__.py @@ -60,6 +60,8 @@ from .cors_rules_py3 import CorsRules from .delete_retention_policy_py3 import DeleteRetentionPolicy from .blob_service_properties_py3 import BlobServiceProperties + from .lease_container_request_py3 import LeaseContainerRequest + from .lease_container_response_py3 import LeaseContainerResponse from .storage_account_management_policies_py3 import StorageAccountManagementPolicies from .management_policies_rules_set_parameter_py3 import ManagementPoliciesRulesSetParameter except (SyntaxError, ImportError): @@ -113,6 +115,8 @@ from .cors_rules import CorsRules from .delete_retention_policy import DeleteRetentionPolicy from .blob_service_properties import BlobServiceProperties + from .lease_container_request import LeaseContainerRequest + from .lease_container_response import LeaseContainerResponse from .storage_account_management_policies import StorageAccountManagementPolicies from .management_policies_rules_set_parameter import ManagementPoliciesRulesSetParameter from .operation_paged import OperationPaged @@ -201,6 +205,8 @@ 'CorsRules', 'DeleteRetentionPolicy', 'BlobServiceProperties', + 'LeaseContainerRequest', + 'LeaseContainerResponse', 'StorageAccountManagementPolicies', 'ManagementPoliciesRulesSetParameter', 'OperationPaged', diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/lease_container_request.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/lease_container_request.py new file mode 100644 index 000000000000..1c9bcd18dba9 --- /dev/null +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/lease_container_request.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LeaseContainerRequest(Model): + """Lease Container request schema. + + All required parameters must be populated in order to send to Azure. + + :param action: Required. Specifies the lease action. Can be one of the + available actions. Possible values include: 'Acquire', 'Renew', 'Change', + 'Release', 'Break' + :type action: str or ~azure.mgmt.storage.v2018_07_01.models.enum + :param lease_id: Identifies the lease. Can be specified in any valid GUID + string format. + :type lease_id: str + :param break_period: Optional. For a break action, proposed duration the + lease should continue before it is broken, in seconds, between 0 and 60. + :type break_period: int + :param lease_duration: Required for acquire. Specifies the duration of the + lease, in seconds, or negative one (-1) for a lease that never expires. + :type lease_duration: int + :param proposed_lease_id: Optional for acquire, required for change. + Proposed lease ID, in a GUID string format. + :type proposed_lease_id: str + """ + + _validation = { + 'action': {'required': True}, + } + + _attribute_map = { + 'action': {'key': 'action', 'type': 'str'}, + 'lease_id': {'key': 'leaseId', 'type': 'str'}, + 'break_period': {'key': 'breakPeriod', 'type': 'int'}, + 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, + 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(LeaseContainerRequest, self).__init__(**kwargs) + self.action = kwargs.get('action', None) + self.lease_id = kwargs.get('lease_id', None) + self.break_period = kwargs.get('break_period', None) + self.lease_duration = kwargs.get('lease_duration', None) + self.proposed_lease_id = kwargs.get('proposed_lease_id', None) diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/lease_container_request_py3.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/lease_container_request_py3.py new file mode 100644 index 000000000000..c8cf4b1df78f --- /dev/null +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/lease_container_request_py3.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LeaseContainerRequest(Model): + """Lease Container request schema. + + All required parameters must be populated in order to send to Azure. + + :param action: Required. Specifies the lease action. Can be one of the + available actions. Possible values include: 'Acquire', 'Renew', 'Change', + 'Release', 'Break' + :type action: str or ~azure.mgmt.storage.v2018_07_01.models.enum + :param lease_id: Identifies the lease. Can be specified in any valid GUID + string format. + :type lease_id: str + :param break_period: Optional. For a break action, proposed duration the + lease should continue before it is broken, in seconds, between 0 and 60. + :type break_period: int + :param lease_duration: Required for acquire. Specifies the duration of the + lease, in seconds, or negative one (-1) for a lease that never expires. + :type lease_duration: int + :param proposed_lease_id: Optional for acquire, required for change. + Proposed lease ID, in a GUID string format. + :type proposed_lease_id: str + """ + + _validation = { + 'action': {'required': True}, + } + + _attribute_map = { + 'action': {'key': 'action', 'type': 'str'}, + 'lease_id': {'key': 'leaseId', 'type': 'str'}, + 'break_period': {'key': 'breakPeriod', 'type': 'int'}, + 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, + 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + } + + def __init__(self, *, action, lease_id: str=None, break_period: int=None, lease_duration: int=None, proposed_lease_id: str=None, **kwargs) -> None: + super(LeaseContainerRequest, self).__init__(**kwargs) + self.action = action + self.lease_id = lease_id + self.break_period = break_period + self.lease_duration = lease_duration + self.proposed_lease_id = proposed_lease_id diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/lease_container_response.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/lease_container_response.py new file mode 100644 index 000000000000..666f0e899f1e --- /dev/null +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/lease_container_response.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LeaseContainerResponse(Model): + """Lease Container response schema. + + :param lease_id: Returned unique lease ID that must be included with any + request to delete the container, or to renew, change, or release the + lease. + :type lease_id: str + :param lease_time_seconds: Approximate time remaining in the lease period, + in seconds. + :type lease_time_seconds: str + """ + + _attribute_map = { + 'lease_id': {'key': 'leaseId', 'type': 'str'}, + 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(LeaseContainerResponse, self).__init__(**kwargs) + self.lease_id = kwargs.get('lease_id', None) + self.lease_time_seconds = kwargs.get('lease_time_seconds', None) diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/lease_container_response_py3.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/lease_container_response_py3.py new file mode 100644 index 000000000000..fa87d930571d --- /dev/null +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/lease_container_response_py3.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LeaseContainerResponse(Model): + """Lease Container response schema. + + :param lease_id: Returned unique lease ID that must be included with any + request to delete the container, or to renew, change, or release the + lease. + :type lease_id: str + :param lease_time_seconds: Approximate time remaining in the lease period, + in seconds. + :type lease_time_seconds: str + """ + + _attribute_map = { + 'lease_id': {'key': 'leaseId', 'type': 'str'}, + 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + } + + def __init__(self, *, lease_id: str=None, lease_time_seconds: str=None, **kwargs) -> None: + super(LeaseContainerResponse, self).__init__(**kwargs) + self.lease_id = lease_id + self.lease_time_seconds = lease_time_seconds diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/blob_containers_operations.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/blob_containers_operations.py index cb251bb1aec7..46b53c34d5c2 100644 --- a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/blob_containers_operations.py +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/blob_containers_operations.py @@ -1042,3 +1042,87 @@ def extend_immutability_policy( return deserialized extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} + + def lease( + self, resource_group_name, account_name, container_name, parameters=None, custom_headers=None, raw=False, **operation_config): + """The Lease Container operation establishes and manages a lock on a + container for delete operations. The lock duration can be 15 to 60 + seconds, or can be infinite. + + :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 + :param parameters: Lease Container request body. + :type parameters: + ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerRequest + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: LeaseContainerResponse or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerResponse + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.lease.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + if parameters is not None: + body_content = self._serialize.body(parameters, 'LeaseContainerRequest') + else: + body_content = None + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('LeaseContainerResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/__init__.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/__init__.py index 1638fbb648e8..1e5d1a426aaf 100644 --- a/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/__init__.py +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/__init__.py @@ -70,6 +70,8 @@ from .cors_rules_py3 import CorsRules from .delete_retention_policy_py3 import DeleteRetentionPolicy from .blob_service_properties_py3 import BlobServiceProperties + from .lease_container_request_py3 import LeaseContainerRequest + from .lease_container_response_py3 import LeaseContainerResponse except (SyntaxError, ImportError): from .operation_display import OperationDisplay from .dimension import Dimension @@ -131,6 +133,8 @@ from .cors_rules import CorsRules from .delete_retention_policy import DeleteRetentionPolicy from .blob_service_properties import BlobServiceProperties + from .lease_container_request import LeaseContainerRequest + from .lease_container_response import LeaseContainerResponse from .operation_paged import OperationPaged from .sku_paged import SkuPaged from .storage_account_paged import StorageAccountPaged @@ -227,6 +231,8 @@ 'CorsRules', 'DeleteRetentionPolicy', 'BlobServiceProperties', + 'LeaseContainerRequest', + 'LeaseContainerResponse', 'OperationPaged', 'SkuPaged', 'StorageAccountPaged', diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/lease_container_request.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/lease_container_request.py new file mode 100644 index 000000000000..246893817045 --- /dev/null +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/lease_container_request.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LeaseContainerRequest(Model): + """Lease Container request schema. + + All required parameters must be populated in order to send to Azure. + + :param action: Required. Specifies the lease action. Can be one of the + available actions. Possible values include: 'Acquire', 'Renew', 'Change', + 'Release', 'Break' + :type action: str or ~azure.mgmt.storage.v2018_11_01.models.enum + :param lease_id: Identifies the lease. Can be specified in any valid GUID + string format. + :type lease_id: str + :param break_period: Optional. For a break action, proposed duration the + lease should continue before it is broken, in seconds, between 0 and 60. + :type break_period: int + :param lease_duration: Required for acquire. Specifies the duration of the + lease, in seconds, or negative one (-1) for a lease that never expires. + :type lease_duration: int + :param proposed_lease_id: Optional for acquire, required for change. + Proposed lease ID, in a GUID string format. + :type proposed_lease_id: str + """ + + _validation = { + 'action': {'required': True}, + } + + _attribute_map = { + 'action': {'key': 'action', 'type': 'str'}, + 'lease_id': {'key': 'leaseId', 'type': 'str'}, + 'break_period': {'key': 'breakPeriod', 'type': 'int'}, + 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, + 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(LeaseContainerRequest, self).__init__(**kwargs) + self.action = kwargs.get('action', None) + self.lease_id = kwargs.get('lease_id', None) + self.break_period = kwargs.get('break_period', None) + self.lease_duration = kwargs.get('lease_duration', None) + self.proposed_lease_id = kwargs.get('proposed_lease_id', None) diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/lease_container_request_py3.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/lease_container_request_py3.py new file mode 100644 index 000000000000..06f0d83d4740 --- /dev/null +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/lease_container_request_py3.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LeaseContainerRequest(Model): + """Lease Container request schema. + + All required parameters must be populated in order to send to Azure. + + :param action: Required. Specifies the lease action. Can be one of the + available actions. Possible values include: 'Acquire', 'Renew', 'Change', + 'Release', 'Break' + :type action: str or ~azure.mgmt.storage.v2018_11_01.models.enum + :param lease_id: Identifies the lease. Can be specified in any valid GUID + string format. + :type lease_id: str + :param break_period: Optional. For a break action, proposed duration the + lease should continue before it is broken, in seconds, between 0 and 60. + :type break_period: int + :param lease_duration: Required for acquire. Specifies the duration of the + lease, in seconds, or negative one (-1) for a lease that never expires. + :type lease_duration: int + :param proposed_lease_id: Optional for acquire, required for change. + Proposed lease ID, in a GUID string format. + :type proposed_lease_id: str + """ + + _validation = { + 'action': {'required': True}, + } + + _attribute_map = { + 'action': {'key': 'action', 'type': 'str'}, + 'lease_id': {'key': 'leaseId', 'type': 'str'}, + 'break_period': {'key': 'breakPeriod', 'type': 'int'}, + 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, + 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + } + + def __init__(self, *, action, lease_id: str=None, break_period: int=None, lease_duration: int=None, proposed_lease_id: str=None, **kwargs) -> None: + super(LeaseContainerRequest, self).__init__(**kwargs) + self.action = action + self.lease_id = lease_id + self.break_period = break_period + self.lease_duration = lease_duration + self.proposed_lease_id = proposed_lease_id diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/lease_container_response.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/lease_container_response.py new file mode 100644 index 000000000000..666f0e899f1e --- /dev/null +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/lease_container_response.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LeaseContainerResponse(Model): + """Lease Container response schema. + + :param lease_id: Returned unique lease ID that must be included with any + request to delete the container, or to renew, change, or release the + lease. + :type lease_id: str + :param lease_time_seconds: Approximate time remaining in the lease period, + in seconds. + :type lease_time_seconds: str + """ + + _attribute_map = { + 'lease_id': {'key': 'leaseId', 'type': 'str'}, + 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(LeaseContainerResponse, self).__init__(**kwargs) + self.lease_id = kwargs.get('lease_id', None) + self.lease_time_seconds = kwargs.get('lease_time_seconds', None) diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/lease_container_response_py3.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/lease_container_response_py3.py new file mode 100644 index 000000000000..fa87d930571d --- /dev/null +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/lease_container_response_py3.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LeaseContainerResponse(Model): + """Lease Container response schema. + + :param lease_id: Returned unique lease ID that must be included with any + request to delete the container, or to renew, change, or release the + lease. + :type lease_id: str + :param lease_time_seconds: Approximate time remaining in the lease period, + in seconds. + :type lease_time_seconds: str + """ + + _attribute_map = { + 'lease_id': {'key': 'leaseId', 'type': 'str'}, + 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + } + + def __init__(self, *, lease_id: str=None, lease_time_seconds: str=None, **kwargs) -> None: + super(LeaseContainerResponse, self).__init__(**kwargs) + self.lease_id = lease_id + self.lease_time_seconds = lease_time_seconds diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/blob_containers_operations.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/blob_containers_operations.py index 80e2f60563c7..3131f31863a2 100644 --- a/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/blob_containers_operations.py +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/blob_containers_operations.py @@ -1044,3 +1044,87 @@ def extend_immutability_policy( return deserialized extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} + + def lease( + self, resource_group_name, account_name, container_name, parameters=None, custom_headers=None, raw=False, **operation_config): + """The Lease Container operation establishes and manages a lock on a + container for delete operations. The lock duration can be 15 to 60 + seconds, or can be infinite. + + :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 + :param parameters: Lease Container request body. + :type parameters: + ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerRequest + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: LeaseContainerResponse or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerResponse + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.lease.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + if parameters is not None: + body_content = self._serialize.body(parameters, 'LeaseContainerRequest') + else: + body_content = None + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('LeaseContainerResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'}