From f87414e6087ebc1b7a5428ad0b8986252b5b86ba Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Tue, 5 Jan 2021 15:11:29 -0800 Subject: [PATCH 1/3] testing --- .../aio/operations/_blob_operations.py | 1 - .../aio/operations/_block_blob_operations.py | 6 -- .../aio/operations/_container_operations.py | 90 +++++++++++++++++- .../aio/operations/_service_operations.py | 1 - .../blob/_generated/models/__init__.py | 6 +- .../storage/blob/_generated/models/_models.py | 11 ++- .../blob/_generated/models/_models_py3.py | 13 +-- .../_generated/operations/_blob_operations.py | 1 - .../operations/_block_blob_operations.py | 6 -- .../operations/_container_operations.py | 91 ++++++++++++++++++- .../operations/_service_operations.py | 1 - .../azure-storage-blob/swagger/README.md | 2 +- 12 files changed, 196 insertions(+), 33 deletions(-) diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_blob_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_blob_operations.py index 687bcd30dad6..0fe69972991d 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_blob_operations.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_blob_operations.py @@ -253,7 +253,6 @@ async def download( response_headers['x-ms-client-request-id']=self._deserialize('str', response.headers.get('x-ms-client-request-id')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-version']=self._deserialize('str', response.headers.get('x-ms-version')) - response_headers['x-ms-version-id']=self._deserialize('str', response.headers.get('x-ms-version-id')) response_headers['Accept-Ranges']=self._deserialize('str', response.headers.get('Accept-Ranges')) response_headers['Date']=self._deserialize('rfc-1123', response.headers.get('Date')) response_headers['x-ms-blob-committed-block-count']=self._deserialize('int', response.headers.get('x-ms-blob-committed-block-count')) diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_block_blob_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_block_blob_operations.py index 67c90b0bf9d4..d73c564c9031 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_block_blob_operations.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_block_blob_operations.py @@ -255,7 +255,6 @@ async def put_blob_from_url( encryption_algorithm: Optional[str] = "AES256", tier: Optional[Union[str, "_models.AccessTierOptional"]] = None, request_id_parameter: Optional[str] = None, - source_content_md5: Optional[bytearray] = None, blob_tags_string: Optional[str] = None, copy_source_blob_properties: Optional[bool] = None, blob_http_headers: Optional["_models.BlobHTTPHeaders"] = None, @@ -303,9 +302,6 @@ async def put_blob_from_url( :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. :type request_id_parameter: str - :param source_content_md5: Specify the md5 calculated for the range of bytes that must be read - from the copy source. - :type source_content_md5: bytearray :param blob_tags_string: Optional. Used to set blob tags in various blob operations. :type blob_tags_string: str :param copy_source_blob_properties: Optional, default is true. Indicates if properties from @@ -450,8 +446,6 @@ async def put_blob_from_url( header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') if request_id_parameter is not None: header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id_parameter", request_id_parameter, 'str') - if source_content_md5 is not None: - header_parameters['x-ms-source-content-md5'] = self._serialize.header("source_content_md5", source_content_md5, 'bytearray') if blob_tags_string is not None: header_parameters['x-ms-tags'] = self._serialize.header("blob_tags_string", blob_tags_string, 'str') header_parameters['x-ms-copy-source'] = self._serialize.header("copy_source", copy_source, 'str') diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_container_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_container_operations.py index ed32bc96241b..432ecf751b2d 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_container_operations.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_container_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Generic, IO, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -699,6 +699,94 @@ async def restore( restore.metadata = {'url': '/{containerName}'} # type: ignore + async def submit_batch( + self, + content_length: int, + multipart_content_type: str, + body: IO, + timeout: Optional[int] = None, + request_id_parameter: Optional[str] = None, + **kwargs + ) -> IO: + """The Batch operation allows multiple API calls to be embedded into a single HTTP request. + + :param content_length: The length of the request. + :type content_length: long + :param multipart_content_type: Required. The value of this header must be multipart/mixed with + a batch boundary. Example header value: multipart/mixed; boundary=batch_:code:``. + :type multipart_content_type: str + :param body: Initial data. + :type body: IO + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`Setting Timeouts for Blob Service Operations.`. + :type timeout: int + :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character + limit that is recorded in the analytics logs when storage analytics logging is enabled. + :type request_id_parameter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IO, or the result of cls(response) + :rtype: IO + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[IO] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + restype = "container" + comp = "batch" + content_type = kwargs.pop("content_type", "application/xml") + accept = "application/xml" + + # Construct URL + url = self.submit_batch.metadata['url'] # type: ignore + path_format_arguments = { + 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['restype'] = self._serialize.query("restype", restype, 'str') + query_parameters['comp'] = self._serialize.query("comp", comp, 'str') + if timeout is not None: + query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Length'] = self._serialize.header("content_length", content_length, 'long') + header_parameters['Content-Type'] = self._serialize.header("multipart_content_type", multipart_content_type, 'str') + header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') + if request_id_parameter is not None: + header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id_parameter", request_id_parameter, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'IO', is_xml=True) + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.StorageError, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Content-Type']=self._deserialize('str', response.headers.get('Content-Type')) + response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) + response_headers['x-ms-version']=self._deserialize('str', response.headers.get('x-ms-version')) + deserialized = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + submit_batch.metadata = {'url': '/{containerName}'} # type: ignore + async def acquire_lease( self, timeout: Optional[int] = None, diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_service_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_service_operations.py index 91a064680562..b49a5eaa04fe 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_service_operations.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_service_operations.py @@ -499,7 +499,6 @@ async def get_account_info( response_headers['Date']=self._deserialize('rfc-1123', response.headers.get('Date')) response_headers['x-ms-sku-name']=self._deserialize('str', response.headers.get('x-ms-sku-name')) response_headers['x-ms-account-kind']=self._deserialize('str', response.headers.get('x-ms-account-kind')) - response_headers['x-ms-is-hns-enabled']=self._deserialize('bool', response.headers.get('x-ms-is-hns-enabled')) if cls: return cls(pipeline_response, None, response_headers) diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/models/__init__.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/models/__init__.py index 9c98989e6847..831bfa90ca91 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/models/__init__.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/models/__init__.py @@ -31,7 +31,7 @@ from ._models_py3 import CpkInfo from ._models_py3 import CpkScopeInfo from ._models_py3 import DataLakeStorageError - from ._models_py3 import DataLakeStorageErrorDetails + from ._models_py3 import DataLakeStorageErrorAutoGenerated from ._models_py3 import DelimitedTextConfiguration from ._models_py3 import DirectoryHttpHeaders from ._models_py3 import FilterBlobItem @@ -85,7 +85,7 @@ from ._models import CpkInfo # type: ignore from ._models import CpkScopeInfo # type: ignore from ._models import DataLakeStorageError # type: ignore - from ._models import DataLakeStorageErrorDetails # type: ignore + from ._models import DataLakeStorageErrorAutoGenerated # type: ignore from ._models import DelimitedTextConfiguration # type: ignore from ._models import DirectoryHttpHeaders # type: ignore from ._models import FilterBlobItem # type: ignore @@ -167,7 +167,7 @@ 'CpkInfo', 'CpkScopeInfo', 'DataLakeStorageError', - 'DataLakeStorageErrorDetails', + 'DataLakeStorageErrorAutoGenerated', 'DelimitedTextConfiguration', 'DirectoryHttpHeaders', 'FilterBlobItem', diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/models/_models.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/models/_models.py index a92bc6b05f34..dda244891db0 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/models/_models.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/models/_models.py @@ -279,7 +279,7 @@ class BlobItemInternal(msrest.serialization.Model): 'properties': {'key': 'Properties', 'type': 'BlobPropertiesInternal'}, 'metadata': {'key': 'Metadata', 'type': 'BlobMetadata'}, 'blob_tags': {'key': 'BlobTags', 'type': 'BlobTags'}, - 'object_replication_metadata': {'key': 'OrMetadata', 'type': '{str}'}, + 'object_replication_metadata': {'key': 'ObjectReplicationMetadata', 'type': '{str}'}, } _xml_map = { 'name': 'Blob' @@ -955,11 +955,12 @@ class DataLakeStorageError(msrest.serialization.Model): """DataLakeStorageError. :param data_lake_storage_error_details: The service error response object. - :type data_lake_storage_error_details: ~azure.storage.blob.models.DataLakeStorageErrorDetails + :type data_lake_storage_error_details: + ~azure.storage.blob.models.DataLakeStorageErrorAutoGenerated """ _attribute_map = { - 'data_lake_storage_error_details': {'key': 'error', 'type': 'DataLakeStorageErrorDetails'}, + 'data_lake_storage_error_details': {'key': 'error', 'type': 'DataLakeStorageErrorAutoGenerated'}, } def __init__( @@ -970,7 +971,7 @@ def __init__( self.data_lake_storage_error_details = kwargs.get('data_lake_storage_error_details', None) -class DataLakeStorageErrorDetails(msrest.serialization.Model): +class DataLakeStorageErrorAutoGenerated(msrest.serialization.Model): """The service error response object. :param code: The service error code. @@ -988,7 +989,7 @@ def __init__( self, **kwargs ): - super(DataLakeStorageErrorDetails, self).__init__(**kwargs) + super(DataLakeStorageErrorAutoGenerated, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/models/_models_py3.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/models/_models_py3.py index b1339f08fbdc..272746ca5f15 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/models/_models_py3.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/models/_models_py3.py @@ -310,7 +310,7 @@ class BlobItemInternal(msrest.serialization.Model): 'properties': {'key': 'Properties', 'type': 'BlobPropertiesInternal'}, 'metadata': {'key': 'Metadata', 'type': 'BlobMetadata'}, 'blob_tags': {'key': 'BlobTags', 'type': 'BlobTags'}, - 'object_replication_metadata': {'key': 'OrMetadata', 'type': '{str}'}, + 'object_replication_metadata': {'key': 'ObjectReplicationMetadata', 'type': '{str}'}, } _xml_map = { 'name': 'Blob' @@ -1090,24 +1090,25 @@ class DataLakeStorageError(msrest.serialization.Model): """DataLakeStorageError. :param data_lake_storage_error_details: The service error response object. - :type data_lake_storage_error_details: ~azure.storage.blob.models.DataLakeStorageErrorDetails + :type data_lake_storage_error_details: + ~azure.storage.blob.models.DataLakeStorageErrorAutoGenerated """ _attribute_map = { - 'data_lake_storage_error_details': {'key': 'error', 'type': 'DataLakeStorageErrorDetails'}, + 'data_lake_storage_error_details': {'key': 'error', 'type': 'DataLakeStorageErrorAutoGenerated'}, } def __init__( self, *, - data_lake_storage_error_details: Optional["DataLakeStorageErrorDetails"] = None, + data_lake_storage_error_details: Optional["DataLakeStorageErrorAutoGenerated"] = None, **kwargs ): super(DataLakeStorageError, self).__init__(**kwargs) self.data_lake_storage_error_details = data_lake_storage_error_details -class DataLakeStorageErrorDetails(msrest.serialization.Model): +class DataLakeStorageErrorAutoGenerated(msrest.serialization.Model): """The service error response object. :param code: The service error code. @@ -1128,7 +1129,7 @@ def __init__( message: Optional[str] = None, **kwargs ): - super(DataLakeStorageErrorDetails, self).__init__(**kwargs) + super(DataLakeStorageErrorAutoGenerated, self).__init__(**kwargs) self.code = code self.message = message diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_blob_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_blob_operations.py index 730a5648e0f7..1298e10ccff3 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_blob_operations.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_blob_operations.py @@ -258,7 +258,6 @@ def download( response_headers['x-ms-client-request-id']=self._deserialize('str', response.headers.get('x-ms-client-request-id')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-version']=self._deserialize('str', response.headers.get('x-ms-version')) - response_headers['x-ms-version-id']=self._deserialize('str', response.headers.get('x-ms-version-id')) response_headers['Accept-Ranges']=self._deserialize('str', response.headers.get('Accept-Ranges')) response_headers['Date']=self._deserialize('rfc-1123', response.headers.get('Date')) response_headers['x-ms-blob-committed-block-count']=self._deserialize('int', response.headers.get('x-ms-blob-committed-block-count')) diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_block_blob_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_block_blob_operations.py index 7bb13abc2b7f..f60869d06ec7 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_block_blob_operations.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_block_blob_operations.py @@ -260,7 +260,6 @@ def put_blob_from_url( encryption_algorithm="AES256", # type: Optional[str] tier=None, # type: Optional[Union[str, "_models.AccessTierOptional"]] request_id_parameter=None, # type: Optional[str] - source_content_md5=None, # type: Optional[bytearray] blob_tags_string=None, # type: Optional[str] copy_source_blob_properties=None, # type: Optional[bool] blob_http_headers=None, # type: Optional["_models.BlobHTTPHeaders"] @@ -309,9 +308,6 @@ def put_blob_from_url( :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. :type request_id_parameter: str - :param source_content_md5: Specify the md5 calculated for the range of bytes that must be read - from the copy source. - :type source_content_md5: bytearray :param blob_tags_string: Optional. Used to set blob tags in various blob operations. :type blob_tags_string: str :param copy_source_blob_properties: Optional, default is true. Indicates if properties from @@ -456,8 +452,6 @@ def put_blob_from_url( header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') if request_id_parameter is not None: header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id_parameter", request_id_parameter, 'str') - if source_content_md5 is not None: - header_parameters['x-ms-source-content-md5'] = self._serialize.header("source_content_md5", source_content_md5, 'bytearray') if blob_tags_string is not None: header_parameters['x-ms-tags'] = self._serialize.header("blob_tags_string", blob_tags_string, 'str') header_parameters['x-ms-copy-source'] = self._serialize.header("copy_source", copy_source, 'str') diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_container_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_container_operations.py index 41a1c8aa2daf..2bf7bcdabc75 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_container_operations.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_container_operations.py @@ -17,7 +17,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union + from typing import Any, Callable, Dict, Generic, IO, List, Optional, TypeVar, Union T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -710,6 +710,95 @@ def restore( restore.metadata = {'url': '/{containerName}'} # type: ignore + def submit_batch( + self, + content_length, # type: int + multipart_content_type, # type: str + body, # type: IO + timeout=None, # type: Optional[int] + request_id_parameter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> IO + """The Batch operation allows multiple API calls to be embedded into a single HTTP request. + + :param content_length: The length of the request. + :type content_length: long + :param multipart_content_type: Required. The value of this header must be multipart/mixed with + a batch boundary. Example header value: multipart/mixed; boundary=batch_:code:``. + :type multipart_content_type: str + :param body: Initial data. + :type body: IO + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`Setting Timeouts for Blob Service Operations.`. + :type timeout: int + :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character + limit that is recorded in the analytics logs when storage analytics logging is enabled. + :type request_id_parameter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IO, or the result of cls(response) + :rtype: IO + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[IO] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + restype = "container" + comp = "batch" + content_type = kwargs.pop("content_type", "application/xml") + accept = "application/xml" + + # Construct URL + url = self.submit_batch.metadata['url'] # type: ignore + path_format_arguments = { + 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['restype'] = self._serialize.query("restype", restype, 'str') + query_parameters['comp'] = self._serialize.query("comp", comp, 'str') + if timeout is not None: + query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Length'] = self._serialize.header("content_length", content_length, 'long') + header_parameters['Content-Type'] = self._serialize.header("multipart_content_type", multipart_content_type, 'str') + header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') + if request_id_parameter is not None: + header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id_parameter", request_id_parameter, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'IO', is_xml=True) + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.StorageError, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Content-Type']=self._deserialize('str', response.headers.get('Content-Type')) + response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) + response_headers['x-ms-version']=self._deserialize('str', response.headers.get('x-ms-version')) + deserialized = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + submit_batch.metadata = {'url': '/{containerName}'} # type: ignore + def acquire_lease( self, timeout=None, # type: Optional[int] diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_service_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_service_operations.py index 72f7a73fdf50..2a8102fcfd12 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_service_operations.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_service_operations.py @@ -509,7 +509,6 @@ def get_account_info( response_headers['Date']=self._deserialize('rfc-1123', response.headers.get('Date')) response_headers['x-ms-sku-name']=self._deserialize('str', response.headers.get('x-ms-sku-name')) response_headers['x-ms-account-kind']=self._deserialize('str', response.headers.get('x-ms-account-kind')) - response_headers['x-ms-is-hns-enabled']=self._deserialize('bool', response.headers.get('x-ms-is-hns-enabled')) if cls: return cls(pipeline_response, None, response_headers) diff --git a/sdk/storage/azure-storage-blob/swagger/README.md b/sdk/storage/azure-storage-blob/swagger/README.md index 2927bfb86fe7..28e859857a98 100644 --- a/sdk/storage/azure-storage-blob/swagger/README.md +++ b/sdk/storage/azure-storage-blob/swagger/README.md @@ -19,7 +19,7 @@ autorest --use=C:/work/autorest.python --version=2.0.4280 ### Settings ``` yaml -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/storage-dataplane-preview/specification/storage/data-plane/Microsoft.BlobStorage/preview/2020-04-08/blob.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/68456352e4d051f9d88f071de5a910b0b92f11ac/specification/storage/data-plane/Microsoft.BlobStorage/preview/2020-04-08/blob.json output-folder: ../azure/storage/blob/_generated namespace: azure.storage.blob no-namespace-folders: true From 502ddba4ef3ca525148613052a852dd68e9a0481 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Tue, 5 Jan 2021 15:36:12 -0800 Subject: [PATCH 2/3] testing --- .../blob/_generated/aio/operations/_blob_operations.py | 3 +++ .../_generated/aio/operations/_block_blob_operations.py | 6 ++++++ .../blob/_generated/aio/operations/_service_operations.py | 1 + .../storage/blob/_generated/operations/_blob_operations.py | 3 +++ .../blob/_generated/operations/_block_blob_operations.py | 6 ++++++ .../blob/_generated/operations/_service_operations.py | 1 + sdk/storage/azure-storage-blob/swagger/README.md | 2 +- 7 files changed, 21 insertions(+), 1 deletion(-) diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_blob_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_blob_operations.py index 0fe69972991d..af2d12e92779 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_blob_operations.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_blob_operations.py @@ -212,6 +212,7 @@ async def download( response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-version']=self._deserialize('str', response.headers.get('x-ms-version')) response_headers['x-ms-version-id']=self._deserialize('str', response.headers.get('x-ms-version-id')) + response_headers['x-ms-is-current-version']=self._deserialize('bool', response.headers.get('x-ms-is-current-version')) response_headers['Accept-Ranges']=self._deserialize('str', response.headers.get('Accept-Ranges')) response_headers['Date']=self._deserialize('rfc-1123', response.headers.get('Date')) response_headers['x-ms-blob-committed-block-count']=self._deserialize('int', response.headers.get('x-ms-blob-committed-block-count')) @@ -253,6 +254,8 @@ async def download( response_headers['x-ms-client-request-id']=self._deserialize('str', response.headers.get('x-ms-client-request-id')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-version']=self._deserialize('str', response.headers.get('x-ms-version')) + response_headers['x-ms-version-id']=self._deserialize('str', response.headers.get('x-ms-version-id')) + response_headers['x-ms-is-current-version']=self._deserialize('bool', response.headers.get('x-ms-is-current-version')) response_headers['Accept-Ranges']=self._deserialize('str', response.headers.get('Accept-Ranges')) response_headers['Date']=self._deserialize('rfc-1123', response.headers.get('Date')) response_headers['x-ms-blob-committed-block-count']=self._deserialize('int', response.headers.get('x-ms-blob-committed-block-count')) diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_block_blob_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_block_blob_operations.py index d73c564c9031..67c90b0bf9d4 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_block_blob_operations.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_block_blob_operations.py @@ -255,6 +255,7 @@ async def put_blob_from_url( encryption_algorithm: Optional[str] = "AES256", tier: Optional[Union[str, "_models.AccessTierOptional"]] = None, request_id_parameter: Optional[str] = None, + source_content_md5: Optional[bytearray] = None, blob_tags_string: Optional[str] = None, copy_source_blob_properties: Optional[bool] = None, blob_http_headers: Optional["_models.BlobHTTPHeaders"] = None, @@ -302,6 +303,9 @@ async def put_blob_from_url( :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. :type request_id_parameter: str + :param source_content_md5: Specify the md5 calculated for the range of bytes that must be read + from the copy source. + :type source_content_md5: bytearray :param blob_tags_string: Optional. Used to set blob tags in various blob operations. :type blob_tags_string: str :param copy_source_blob_properties: Optional, default is true. Indicates if properties from @@ -446,6 +450,8 @@ async def put_blob_from_url( header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') if request_id_parameter is not None: header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id_parameter", request_id_parameter, 'str') + if source_content_md5 is not None: + header_parameters['x-ms-source-content-md5'] = self._serialize.header("source_content_md5", source_content_md5, 'bytearray') if blob_tags_string is not None: header_parameters['x-ms-tags'] = self._serialize.header("blob_tags_string", blob_tags_string, 'str') header_parameters['x-ms-copy-source'] = self._serialize.header("copy_source", copy_source, 'str') diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_service_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_service_operations.py index b49a5eaa04fe..91a064680562 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_service_operations.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_service_operations.py @@ -499,6 +499,7 @@ async def get_account_info( response_headers['Date']=self._deserialize('rfc-1123', response.headers.get('Date')) response_headers['x-ms-sku-name']=self._deserialize('str', response.headers.get('x-ms-sku-name')) response_headers['x-ms-account-kind']=self._deserialize('str', response.headers.get('x-ms-account-kind')) + response_headers['x-ms-is-hns-enabled']=self._deserialize('bool', response.headers.get('x-ms-is-hns-enabled')) if cls: return cls(pipeline_response, None, response_headers) diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_blob_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_blob_operations.py index 1298e10ccff3..bfa782f98d6b 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_blob_operations.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_blob_operations.py @@ -217,6 +217,7 @@ def download( response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-version']=self._deserialize('str', response.headers.get('x-ms-version')) response_headers['x-ms-version-id']=self._deserialize('str', response.headers.get('x-ms-version-id')) + response_headers['x-ms-is-current-version']=self._deserialize('bool', response.headers.get('x-ms-is-current-version')) response_headers['Accept-Ranges']=self._deserialize('str', response.headers.get('Accept-Ranges')) response_headers['Date']=self._deserialize('rfc-1123', response.headers.get('Date')) response_headers['x-ms-blob-committed-block-count']=self._deserialize('int', response.headers.get('x-ms-blob-committed-block-count')) @@ -258,6 +259,8 @@ def download( response_headers['x-ms-client-request-id']=self._deserialize('str', response.headers.get('x-ms-client-request-id')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-version']=self._deserialize('str', response.headers.get('x-ms-version')) + response_headers['x-ms-version-id']=self._deserialize('str', response.headers.get('x-ms-version-id')) + response_headers['x-ms-is-current-version']=self._deserialize('bool', response.headers.get('x-ms-is-current-version')) response_headers['Accept-Ranges']=self._deserialize('str', response.headers.get('Accept-Ranges')) response_headers['Date']=self._deserialize('rfc-1123', response.headers.get('Date')) response_headers['x-ms-blob-committed-block-count']=self._deserialize('int', response.headers.get('x-ms-blob-committed-block-count')) diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_block_blob_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_block_blob_operations.py index f60869d06ec7..7bb13abc2b7f 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_block_blob_operations.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_block_blob_operations.py @@ -260,6 +260,7 @@ def put_blob_from_url( encryption_algorithm="AES256", # type: Optional[str] tier=None, # type: Optional[Union[str, "_models.AccessTierOptional"]] request_id_parameter=None, # type: Optional[str] + source_content_md5=None, # type: Optional[bytearray] blob_tags_string=None, # type: Optional[str] copy_source_blob_properties=None, # type: Optional[bool] blob_http_headers=None, # type: Optional["_models.BlobHTTPHeaders"] @@ -308,6 +309,9 @@ def put_blob_from_url( :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. :type request_id_parameter: str + :param source_content_md5: Specify the md5 calculated for the range of bytes that must be read + from the copy source. + :type source_content_md5: bytearray :param blob_tags_string: Optional. Used to set blob tags in various blob operations. :type blob_tags_string: str :param copy_source_blob_properties: Optional, default is true. Indicates if properties from @@ -452,6 +456,8 @@ def put_blob_from_url( header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') if request_id_parameter is not None: header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id_parameter", request_id_parameter, 'str') + if source_content_md5 is not None: + header_parameters['x-ms-source-content-md5'] = self._serialize.header("source_content_md5", source_content_md5, 'bytearray') if blob_tags_string is not None: header_parameters['x-ms-tags'] = self._serialize.header("blob_tags_string", blob_tags_string, 'str') header_parameters['x-ms-copy-source'] = self._serialize.header("copy_source", copy_source, 'str') diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_service_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_service_operations.py index 2a8102fcfd12..72f7a73fdf50 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_service_operations.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_service_operations.py @@ -509,6 +509,7 @@ def get_account_info( response_headers['Date']=self._deserialize('rfc-1123', response.headers.get('Date')) response_headers['x-ms-sku-name']=self._deserialize('str', response.headers.get('x-ms-sku-name')) response_headers['x-ms-account-kind']=self._deserialize('str', response.headers.get('x-ms-account-kind')) + response_headers['x-ms-is-hns-enabled']=self._deserialize('bool', response.headers.get('x-ms-is-hns-enabled')) if cls: return cls(pipeline_response, None, response_headers) diff --git a/sdk/storage/azure-storage-blob/swagger/README.md b/sdk/storage/azure-storage-blob/swagger/README.md index 28e859857a98..633f00307e5e 100644 --- a/sdk/storage/azure-storage-blob/swagger/README.md +++ b/sdk/storage/azure-storage-blob/swagger/README.md @@ -19,7 +19,7 @@ autorest --use=C:/work/autorest.python --version=2.0.4280 ### Settings ``` yaml -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/68456352e4d051f9d88f071de5a910b0b92f11ac/specification/storage/data-plane/Microsoft.BlobStorage/preview/2020-04-08/blob.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/0e813b035ae54f936f7282fc9095a6f4f935f8d8/specification/storage/data-plane/Microsoft.BlobStorage/preview/2020-04-08/blob.json output-folder: ../azure/storage/blob/_generated namespace: azure.storage.blob no-namespace-folders: true From 0eb24e5fa753c6cda4acad344b554aefd212c06b Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Tue, 5 Jan 2021 15:43:21 -0800 Subject: [PATCH 3/3] testing --- .../aio/operations/_blob_operations.py | 3 - .../aio/operations/_container_operations.py | 62 ++++++++----------- .../aio/operations/_service_operations.py | 1 - .../_generated/operations/_blob_operations.py | 3 - .../operations/_container_operations.py | 62 ++++++++----------- .../operations/_service_operations.py | 1 - .../azure-storage-blob/swagger/README.md | 2 +- 7 files changed, 55 insertions(+), 79 deletions(-) diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_blob_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_blob_operations.py index af2d12e92779..0fe69972991d 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_blob_operations.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_blob_operations.py @@ -212,7 +212,6 @@ async def download( response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-version']=self._deserialize('str', response.headers.get('x-ms-version')) response_headers['x-ms-version-id']=self._deserialize('str', response.headers.get('x-ms-version-id')) - response_headers['x-ms-is-current-version']=self._deserialize('bool', response.headers.get('x-ms-is-current-version')) response_headers['Accept-Ranges']=self._deserialize('str', response.headers.get('Accept-Ranges')) response_headers['Date']=self._deserialize('rfc-1123', response.headers.get('Date')) response_headers['x-ms-blob-committed-block-count']=self._deserialize('int', response.headers.get('x-ms-blob-committed-block-count')) @@ -254,8 +253,6 @@ async def download( response_headers['x-ms-client-request-id']=self._deserialize('str', response.headers.get('x-ms-client-request-id')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-version']=self._deserialize('str', response.headers.get('x-ms-version')) - response_headers['x-ms-version-id']=self._deserialize('str', response.headers.get('x-ms-version-id')) - response_headers['x-ms-is-current-version']=self._deserialize('bool', response.headers.get('x-ms-is-current-version')) response_headers['Accept-Ranges']=self._deserialize('str', response.headers.get('Accept-Ranges')) response_headers['Date']=self._deserialize('rfc-1123', response.headers.get('Date')) response_headers['x-ms-blob-committed-block-count']=self._deserialize('int', response.headers.get('x-ms-blob-committed-block-count')) diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_container_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_container_operations.py index 432ecf751b2d..d4f7aaee4830 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_container_operations.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_container_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -from typing import Any, Callable, Dict, Generic, IO, List, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -699,24 +699,18 @@ async def restore( restore.metadata = {'url': '/{containerName}'} # type: ignore - async def submit_batch( + async def rename( self, - content_length: int, - multipart_content_type: str, - body: IO, + source_container_name: str, timeout: Optional[int] = None, request_id_parameter: Optional[str] = None, + source_lease_id: Optional[str] = None, **kwargs - ) -> IO: - """The Batch operation allows multiple API calls to be embedded into a single HTTP request. - - :param content_length: The length of the request. - :type content_length: long - :param multipart_content_type: Required. The value of this header must be multipart/mixed with - a batch boundary. Example header value: multipart/mixed; boundary=batch_:code:``. - :type multipart_content_type: str - :param body: Initial data. - :type body: IO + ) -> None: + """Renames an existing container. + + :param source_container_name: Required. Specifies the name of the container to rename. + :type source_container_name: str :param timeout: The timeout parameter is expressed in seconds. For more information, see :code:`Setting Timeouts for Blob Service Operations.`. @@ -724,23 +718,25 @@ async def submit_batch( :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. :type request_id_parameter: str + :param source_lease_id: A lease ID for the source path. If specified, the source path must have + an active lease and the lease ID must match. + :type source_lease_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IO, or the result of cls(response) - :rtype: IO + :return: None, or the result of cls(response) + :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[IO] + cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) restype = "container" - comp = "batch" - content_type = kwargs.pop("content_type", "application/xml") + comp = "rename" accept = "application/xml" # Construct URL - url = self.submit_batch.metadata['url'] # type: ignore + url = self.rename.metadata['url'] # type: ignore path_format_arguments = { 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True), } @@ -755,37 +751,33 @@ async def submit_batch( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Length'] = self._serialize.header("content_length", content_length, 'long') - header_parameters['Content-Type'] = self._serialize.header("multipart_content_type", multipart_content_type, 'str') header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') if request_id_parameter is not None: header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id_parameter", request_id_parameter, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['x-ms-source-container-name'] = self._serialize.header("source_container_name", source_container_name, 'str') + if source_lease_id is not None: + header_parameters['x-ms-source-lease-id'] = self._serialize.header("source_lease_id", source_lease_id, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'IO', is_xml=True) - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=True, **kwargs) + 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 [202]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize(_models.StorageError, response) raise HttpResponseError(response=response, model=error) response_headers = {} - response_headers['Content-Type']=self._deserialize('str', response.headers.get('Content-Type')) + response_headers['x-ms-client-request-id']=self._deserialize('str', response.headers.get('x-ms-client-request-id')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-version']=self._deserialize('str', response.headers.get('x-ms-version')) - deserialized = response.stream_download(self._client._pipeline) + response_headers['Date']=self._deserialize('rfc-1123', response.headers.get('Date')) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, None, response_headers) - return deserialized - submit_batch.metadata = {'url': '/{containerName}'} # type: ignore + rename.metadata = {'url': '/{containerName}'} # type: ignore async def acquire_lease( self, diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_service_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_service_operations.py index 91a064680562..b49a5eaa04fe 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_service_operations.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_service_operations.py @@ -499,7 +499,6 @@ async def get_account_info( response_headers['Date']=self._deserialize('rfc-1123', response.headers.get('Date')) response_headers['x-ms-sku-name']=self._deserialize('str', response.headers.get('x-ms-sku-name')) response_headers['x-ms-account-kind']=self._deserialize('str', response.headers.get('x-ms-account-kind')) - response_headers['x-ms-is-hns-enabled']=self._deserialize('bool', response.headers.get('x-ms-is-hns-enabled')) if cls: return cls(pipeline_response, None, response_headers) diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_blob_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_blob_operations.py index bfa782f98d6b..1298e10ccff3 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_blob_operations.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_blob_operations.py @@ -217,7 +217,6 @@ def download( response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-version']=self._deserialize('str', response.headers.get('x-ms-version')) response_headers['x-ms-version-id']=self._deserialize('str', response.headers.get('x-ms-version-id')) - response_headers['x-ms-is-current-version']=self._deserialize('bool', response.headers.get('x-ms-is-current-version')) response_headers['Accept-Ranges']=self._deserialize('str', response.headers.get('Accept-Ranges')) response_headers['Date']=self._deserialize('rfc-1123', response.headers.get('Date')) response_headers['x-ms-blob-committed-block-count']=self._deserialize('int', response.headers.get('x-ms-blob-committed-block-count')) @@ -259,8 +258,6 @@ def download( response_headers['x-ms-client-request-id']=self._deserialize('str', response.headers.get('x-ms-client-request-id')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-version']=self._deserialize('str', response.headers.get('x-ms-version')) - response_headers['x-ms-version-id']=self._deserialize('str', response.headers.get('x-ms-version-id')) - response_headers['x-ms-is-current-version']=self._deserialize('bool', response.headers.get('x-ms-is-current-version')) response_headers['Accept-Ranges']=self._deserialize('str', response.headers.get('Accept-Ranges')) response_headers['Date']=self._deserialize('rfc-1123', response.headers.get('Date')) response_headers['x-ms-blob-committed-block-count']=self._deserialize('int', response.headers.get('x-ms-blob-committed-block-count')) diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_container_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_container_operations.py index 2bf7bcdabc75..0b51ffdfe256 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_container_operations.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_container_operations.py @@ -17,7 +17,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, IO, List, Optional, TypeVar, Union + from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -710,25 +710,19 @@ def restore( restore.metadata = {'url': '/{containerName}'} # type: ignore - def submit_batch( + def rename( self, - content_length, # type: int - multipart_content_type, # type: str - body, # type: IO + source_container_name, # type: str timeout=None, # type: Optional[int] request_id_parameter=None, # type: Optional[str] + source_lease_id=None, # type: Optional[str] **kwargs # type: Any ): - # type: (...) -> IO - """The Batch operation allows multiple API calls to be embedded into a single HTTP request. - - :param content_length: The length of the request. - :type content_length: long - :param multipart_content_type: Required. The value of this header must be multipart/mixed with - a batch boundary. Example header value: multipart/mixed; boundary=batch_:code:``. - :type multipart_content_type: str - :param body: Initial data. - :type body: IO + # type: (...) -> None + """Renames an existing container. + + :param source_container_name: Required. Specifies the name of the container to rename. + :type source_container_name: str :param timeout: The timeout parameter is expressed in seconds. For more information, see :code:`Setting Timeouts for Blob Service Operations.`. @@ -736,23 +730,25 @@ def submit_batch( :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. :type request_id_parameter: str + :param source_lease_id: A lease ID for the source path. If specified, the source path must have + an active lease and the lease ID must match. + :type source_lease_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IO, or the result of cls(response) - :rtype: IO + :return: None, or the result of cls(response) + :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[IO] + cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) restype = "container" - comp = "batch" - content_type = kwargs.pop("content_type", "application/xml") + comp = "rename" accept = "application/xml" # Construct URL - url = self.submit_batch.metadata['url'] # type: ignore + url = self.rename.metadata['url'] # type: ignore path_format_arguments = { 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True), } @@ -767,37 +763,33 @@ def submit_batch( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Length'] = self._serialize.header("content_length", content_length, 'long') - header_parameters['Content-Type'] = self._serialize.header("multipart_content_type", multipart_content_type, 'str') header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') if request_id_parameter is not None: header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id_parameter", request_id_parameter, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['x-ms-source-container-name'] = self._serialize.header("source_container_name", source_container_name, 'str') + if source_lease_id is not None: + header_parameters['x-ms-source-lease-id'] = self._serialize.header("source_lease_id", source_lease_id, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'IO', is_xml=True) - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=True, **kwargs) + request = self._client.put(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [202]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize(_models.StorageError, response) raise HttpResponseError(response=response, model=error) response_headers = {} - response_headers['Content-Type']=self._deserialize('str', response.headers.get('Content-Type')) + response_headers['x-ms-client-request-id']=self._deserialize('str', response.headers.get('x-ms-client-request-id')) response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) response_headers['x-ms-version']=self._deserialize('str', response.headers.get('x-ms-version')) - deserialized = response.stream_download(self._client._pipeline) + response_headers['Date']=self._deserialize('rfc-1123', response.headers.get('Date')) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, None, response_headers) - return deserialized - submit_batch.metadata = {'url': '/{containerName}'} # type: ignore + rename.metadata = {'url': '/{containerName}'} # type: ignore def acquire_lease( self, diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_service_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_service_operations.py index 72f7a73fdf50..2a8102fcfd12 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_service_operations.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_service_operations.py @@ -509,7 +509,6 @@ def get_account_info( response_headers['Date']=self._deserialize('rfc-1123', response.headers.get('Date')) response_headers['x-ms-sku-name']=self._deserialize('str', response.headers.get('x-ms-sku-name')) response_headers['x-ms-account-kind']=self._deserialize('str', response.headers.get('x-ms-account-kind')) - response_headers['x-ms-is-hns-enabled']=self._deserialize('bool', response.headers.get('x-ms-is-hns-enabled')) if cls: return cls(pipeline_response, None, response_headers) diff --git a/sdk/storage/azure-storage-blob/swagger/README.md b/sdk/storage/azure-storage-blob/swagger/README.md index 633f00307e5e..ca9243fa2773 100644 --- a/sdk/storage/azure-storage-blob/swagger/README.md +++ b/sdk/storage/azure-storage-blob/swagger/README.md @@ -19,7 +19,7 @@ autorest --use=C:/work/autorest.python --version=2.0.4280 ### Settings ``` yaml -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/0e813b035ae54f936f7282fc9095a6f4f935f8d8/specification/storage/data-plane/Microsoft.BlobStorage/preview/2020-04-08/blob.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/7184eaab3308c16dd935a4020209b765d8296fbe/specification/storage/data-plane/Microsoft.BlobStorage/preview/2020-04-08/blob.json output-folder: ../azure/storage/blob/_generated namespace: azure.storage.blob no-namespace-folders: true