Skip to content

Commit 14496e7

Browse files
authored
Feature/storage stg79 (Azure#21286)
* update swagger * encryption scope sas * permanent delete sas * sync copy from url with encryption scope * manually edit swagger * Update _version.py
1 parent fee8f87 commit 14496e7

File tree

26 files changed

+878
-1534
lines changed

26 files changed

+878
-1534
lines changed

sdk/storage/azure-storage-blob/azure/storage/blob/_blob_client.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,9 +1872,21 @@ def _start_copy_from_url_options(self, source_url, metadata=None, incremental_co
18721872

18731873
tier = kwargs.pop('premium_page_blob_tier', None) or kwargs.pop('standard_blob_tier', None)
18741874
requires_sync = kwargs.pop('requires_sync', None)
1875+
encryption_scope_str = kwargs.pop('encryption_scope', None)
18751876
source_authorization = kwargs.pop('source_authorization', None)
1877+
1878+
if not requires_sync and encryption_scope_str:
1879+
raise ValueError("Encryption_scope is only supported for sync copy, please specify requires_sync=True")
18761880
if source_authorization and incremental_copy:
18771881
raise ValueError("Source authorization tokens are not applicable for incremental copying.")
1882+
#
1883+
# TODO: refactor start_copy_from_url api in _blob_client.py. Call _generated/_blob_operations.py copy_from_url
1884+
# when requires_sync=True is set.
1885+
# Currently both sync copy and async copy are calling _generated/_blob_operations.py start_copy_from_url.
1886+
# As sync copy diverges more from async copy, more problem will surface.
1887+
if encryption_scope_str:
1888+
headers.update({'x-ms-encryption-scope': encryption_scope_str})
1889+
18781890
if requires_sync is True:
18791891
headers['x-ms-requires-sync'] = str(requires_sync)
18801892
if source_authorization:
@@ -2059,6 +2071,17 @@ def start_copy_from_url(self, source_url, metadata=None, incremental_copy=False,
20592071
Authenticate as a service principal using a client secret to access a source blob. Ensure "bearer " is
20602072
the prefix of the source_authorization string. This option is only available when `incremental_copy` is
20612073
set to False and `requires_sync` is set to True.
2074+
2075+
.. versionadded:: 12.9.0
2076+
2077+
:keyword str encryption_scope:
2078+
A predefined encryption scope used to encrypt the data on the sync copied blob. An encryption
2079+
scope can be created using the Management API and referenced here by name. If a default
2080+
encryption scope has been defined at the container, this value will override it if the
2081+
container-level scope is configured to allow overrides. Otherwise an error will be raised.
2082+
2083+
.. versionadded:: 12.10.0
2084+
20622085
:returns: A dictionary of copy properties (etag, last_modified, copy_id, copy_status).
20632086
:rtype: dict[str, Union[str, ~datetime.datetime]]
20642087

sdk/storage/azure-storage-blob/azure/storage/blob/_generated/_configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(
3838
super(AzureBlobStorageConfiguration, self).__init__(**kwargs)
3939

4040
self.url = url
41-
self.version = "2020-10-02"
41+
self.version = "2020-12-06"
4242
kwargs.setdefault('sdk_moniker', 'azureblobstorage/{}'.format(VERSION))
4343
self._configure(**kwargs)
4444

sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/_configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __init__(
3333
super(AzureBlobStorageConfiguration, self).__init__(**kwargs)
3434

3535
self.url = url
36-
self.version = "2020-10-02"
36+
self.version = "2020-12-06"
3737
kwargs.setdefault('sdk_moniker', 'azureblobstorage/{}'.format(VERSION))
3838
self._configure(**kwargs)
3939

sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_blob_operations.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,6 +2139,7 @@ async def copy_from_url(
21392139
source_modified_access_conditions: Optional["_models.SourceModifiedAccessConditions"] = None,
21402140
modified_access_conditions: Optional["_models.ModifiedAccessConditions"] = None,
21412141
lease_access_conditions: Optional["_models.LeaseAccessConditions"] = None,
2142+
cpk_scope_info: Optional["_models.CpkScopeInfo"] = None,
21422143
**kwargs: Any
21432144
) -> None:
21442145
"""The Copy From URL operation copies a blob or an internet resource to a new blob. It will not
@@ -2188,6 +2189,8 @@ async def copy_from_url(
21882189
:type modified_access_conditions: ~azure.storage.blob.models.ModifiedAccessConditions
21892190
:param lease_access_conditions: Parameter group.
21902191
:type lease_access_conditions: ~azure.storage.blob.models.LeaseAccessConditions
2192+
:param cpk_scope_info: Parameter group.
2193+
:type cpk_scope_info: ~azure.storage.blob.models.CpkScopeInfo
21912194
:keyword callable cls: A custom type or function that will be passed the direct response
21922195
:return: None, or the result of cls(response)
21932196
:rtype: None
@@ -2209,6 +2212,9 @@ async def copy_from_url(
22092212
_if_none_match = None
22102213
_if_tags = None
22112214
_lease_id = None
2215+
_encryption_scope = None
2216+
if cpk_scope_info is not None:
2217+
_encryption_scope = cpk_scope_info.encryption_scope
22122218
if lease_access_conditions is not None:
22132219
_lease_id = lease_access_conditions.lease_id
22142220
if modified_access_conditions is not None:
@@ -2280,6 +2286,8 @@ async def copy_from_url(
22802286
header_parameters['x-ms-legal-hold'] = self._serialize.header("legal_hold", legal_hold, 'bool')
22812287
if copy_source_authorization is not None:
22822288
header_parameters['x-ms-copy-source-authorization'] = self._serialize.header("copy_source_authorization", copy_source_authorization, 'str')
2289+
if _encryption_scope is not None:
2290+
header_parameters['x-ms-encryption-scope'] = self._serialize.header("encryption_scope", _encryption_scope, 'str')
22832291
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
22842292

22852293
request = self._client.put(url, query_parameters, header_parameters)
@@ -2303,6 +2311,7 @@ async def copy_from_url(
23032311
response_headers['x-ms-copy-status']=self._deserialize('str', response.headers.get('x-ms-copy-status'))
23042312
response_headers['Content-MD5']=self._deserialize('bytearray', response.headers.get('Content-MD5'))
23052313
response_headers['x-ms-content-crc64']=self._deserialize('bytearray', response.headers.get('x-ms-content-crc64'))
2314+
response_headers['x-ms-encryption-scope']=self._deserialize('str', response.headers.get('x-ms-encryption-scope'))
23062315

23072316
if cls:
23082317
return cls(pipeline_response, None, response_headers)

sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_container_operations.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,6 @@ async def submit_batch(
829829
content_type = kwargs.pop("content_type", "application/xml")
830830
accept = "application/xml"
831831

832-
multipart_content_type = kwargs.pop("content_type", None)
833832
# Construct URL
834833
url = self.submit_batch.metadata['url'] # type: ignore
835834
path_format_arguments = {
@@ -855,7 +854,7 @@ async def submit_batch(
855854
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
856855

857856
body_content_kwargs = {} # type: Dict[str, Any]
858-
body_content = self._serialize.body(body, 'IO')
857+
body_content = self._serialize.body(body, 'IO', is_xml=True)
859858
body_content_kwargs['content'] = body_content
860859
request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs)
861860
pipeline_response = await self._client._pipeline.run(request, stream=True, **kwargs)

0 commit comments

Comments
 (0)