Skip to content
Merged
41 changes: 36 additions & 5 deletions sdk/storage/azure-storage-blob/azure/storage/blob/_blob_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ def _upload_blob_from_url_options(self, source_url, **kwargs):
tier = kwargs.pop('standard_blob_tier', None)
overwrite = kwargs.pop('overwrite', False)
content_settings = kwargs.pop('content_settings', None)
source_authorization = kwargs.pop('source_authorization', None)
if content_settings:
kwargs['blob_http_headers'] = BlobHTTPHeaders(
blob_cache_control=content_settings.cache_control,
Expand All @@ -443,6 +444,7 @@ def _upload_blob_from_url_options(self, source_url, **kwargs):
encryption_algorithm=cpk.algorithm)

options = {
'copy_source_authorization': source_authorization,
'content_length': 0,
'copy_source_blob_properties': kwargs.pop('include_source_blob_properties', True),
'source_content_md5': kwargs.pop('source_content_md5', None),
Expand Down Expand Up @@ -551,6 +553,9 @@ def upload_blob_from_url(self, source_url, **kwargs):
:keyword ~azure.storage.blob.StandardBlobTier standard_blob_tier:
A standard blob tier value to set the blob to. For this version of the library,
this is only applicable to block blobs on standard storage accounts.
:keyword str source_authorization:
Authenticate as a service principal using a client secret to access a source blob. Ensure "bearer " is
the prefix of the source_authorization string.
"""
options = self._upload_blob_from_url_options(
source_url=self._encode_source_url(source_url),
Expand Down Expand Up @@ -1739,10 +1744,17 @@ def _start_copy_from_url_options(self, source_url, metadata=None, incremental_co
headers['x-ms-source-lease-id'] = source_lease

tier = kwargs.pop('premium_page_blob_tier', None) or kwargs.pop('standard_blob_tier', None)

if kwargs.get('requires_sync'):
headers['x-ms-requires-sync'] = str(kwargs.pop('requires_sync'))

requires_sync = kwargs.pop('requires_sync', None)
source_authorization = kwargs.pop('source_authorization', None)
if source_authorization and incremental_copy:
raise ValueError("Source authorization tokens are not applicable for incremental copying.")
if requires_sync is True:
headers['x-ms-requires-sync'] = str(requires_sync)
if source_authorization:
headers['x-ms-copy-source-authorization'] = source_authorization
else:
if source_authorization:
raise ValueError("Source authorization tokens are only applicable for synchronous copy operations.")
timeout = kwargs.pop('timeout', None)
dest_mod_conditions = get_modify_conditions(kwargs)
blob_tags_string = serialize_blob_tags_header(kwargs.pop('tags', None))
Expand Down Expand Up @@ -1899,6 +1911,10 @@ def start_copy_from_url(self, source_url, metadata=None, incremental_copy=False,

:keyword bool requires_sync:
Enforces that the service will not return a response until the copy is complete.
:keyword str source_authorization:
Authenticate as a service principal using a client secret to access a source blob. Ensure "bearer " is
the prefix of the source_authorization string. This option is only available when `incremental_copy` is
set to False and `requires_sync` is set to True.
:returns: A dictionary of copy properties (etag, last_modified, copy_id, copy_status).
:rtype: dict[str, str or ~datetime.datetime]

Expand Down Expand Up @@ -2193,6 +2209,7 @@ def _stage_block_from_url_options(
**kwargs
):
# type: (...) -> Dict[str, Any]
source_authorization = kwargs.pop('source_authorization', None)
if source_length is not None and source_offset is None:
raise ValueError("Source offset value must not be None if length is set.")
if source_length is not None:
Expand All @@ -2212,6 +2229,7 @@ def _stage_block_from_url_options(
cpk_info = CpkInfo(encryption_key=cpk.key_value, encryption_key_sha256=cpk.key_hash,
encryption_algorithm=cpk.algorithm)
options = {
'copy_source_authorization': source_authorization,
'block_id': block_id,
'content_length': 0,
'source_url': source_url,
Expand All @@ -2228,7 +2246,7 @@ def _stage_block_from_url_options(

@distributed_trace
def stage_block_from_url(
self, block_id, # type: str
self, block_id, # type: Union[str, int]
source_url, # type: str
source_offset=None, # type: Optional[int]
source_length=None, # type: Optional[int]
Expand Down Expand Up @@ -2269,6 +2287,9 @@ def stage_block_from_url(

:keyword int timeout:
The timeout parameter is expressed in seconds.
:keyword str source_authorization:
Authenticate as a service principal using a client secret to access a source blob. Ensure "bearer " is
the prefix of the source_authorization string.
:returns: Blob property dict.
:rtype: dict[str, Any]
"""
Expand Down Expand Up @@ -3134,6 +3155,7 @@ def _upload_pages_from_url_options( # type: ignore
if_sequence_number_less_than=kwargs.pop('if_sequence_number_lt', None),
if_sequence_number_equal_to=kwargs.pop('if_sequence_number_eq', None)
)
source_authorization = kwargs.pop('source_authorization', None)
access_conditions = get_access_conditions(kwargs.pop('lease', None))
mod_conditions = get_modify_conditions(kwargs)
source_mod_conditions = get_source_conditions(kwargs)
Expand All @@ -3148,6 +3170,7 @@ def _upload_pages_from_url_options( # type: ignore
encryption_algorithm=cpk.algorithm)

options = {
'copy_source_authorization': source_authorization,
'source_url': source_url,
'content_length': 0,
'source_range': source_range,
Expand Down Expand Up @@ -3262,6 +3285,9 @@ def upload_pages_from_url(self, source_url, # type: str

:keyword int timeout:
The timeout parameter is expressed in seconds.
:keyword str source_authorization:
Authenticate as a service principal using a client secret to access a source blob. Ensure "bearer " is
the prefix of the source_authorization string.
"""
options = self._upload_pages_from_url_options(
source_url=self._encode_source_url(source_url),
Expand Down Expand Up @@ -3554,6 +3580,7 @@ def _append_block_from_url_options( # type: ignore
max_size=maxsize_condition,
append_position=appendpos_condition
)
source_authorization = kwargs.pop('source_authorization', None)
access_conditions = get_access_conditions(kwargs.pop('lease', None))
mod_conditions = get_modify_conditions(kwargs)
source_mod_conditions = get_source_conditions(kwargs)
Expand All @@ -3567,6 +3594,7 @@ def _append_block_from_url_options( # type: ignore
encryption_algorithm=cpk.algorithm)

options = {
'copy_source_authorization': source_authorization,
'source_url': copy_source_url,
'content_length': 0,
'source_range': source_range,
Expand Down Expand Up @@ -3673,6 +3701,9 @@ def append_block_from_url(self, copy_source_url, # type: str

:keyword int timeout:
The timeout parameter is expressed in seconds.
:keyword str source_authorization:
Authenticate as a service principal using a client secret to access a source blob. Ensure "bearer " is
the prefix of the source_authorization string.
"""
options = self._append_block_from_url_options(
copy_source_url=self._encode_source_url(copy_source_url),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ async def upload_blob_from_url(self, source_url, **kwargs):
:keyword ~azure.storage.blob.StandardBlobTier standard_blob_tier:
A standard blob tier value to set the blob to. For this version of the library,
this is only applicable to block blobs on standard storage accounts.
:keyword str source_authorization:
Authenticate as a service principal using a client secret to access a source blob. Ensure "bearer " is
the prefix of the source_authorization string.
"""
options = self._upload_blob_from_url_options(
source_url=self._encode_source_url(source_url),
Expand Down Expand Up @@ -1161,6 +1164,10 @@ async def start_copy_from_url(self, source_url, metadata=None, incremental_copy=

:keyword bool requires_sync:
Enforces that the service will not return a response until the copy is complete.
:keyword str source_authorization:
Authenticate as a service principal using a client secret to access a source blob. Ensure "bearer " is
the prefix of the source_authorization string. This option is only available when `incremental_copy` is
set to False and `requires_sync` is set to True.
:returns: A dictionary of copy properties (etag, last_modified, copy_id, copy_status).
:rtype: dict[str, str or ~datetime.datetime]

Expand Down Expand Up @@ -1377,7 +1384,7 @@ async def stage_block(

@distributed_trace_async
async def stage_block_from_url(
self, block_id, # type: str
self, block_id, # type: Union[str, int]
source_url, # type: str
source_offset=None, # type: Optional[int]
source_length=None, # type: Optional[int]
Expand Down Expand Up @@ -1418,6 +1425,9 @@ async def stage_block_from_url(

:keyword int timeout:
The timeout parameter is expressed in seconds.
:keyword str source_authorization:
Authenticate as a service principal using a client secret to access a source blob. Ensure "bearer " is
the prefix of the source_authorization string.
:rtype: None
"""
options = self._stage_block_from_url_options(
Expand Down Expand Up @@ -2131,6 +2141,9 @@ async def upload_pages_from_url(self, source_url, # type: str

:keyword int timeout:
The timeout parameter is expressed in seconds.
:keyword str source_authorization:
Authenticate as a service principal using a client secret to access a source blob. Ensure "bearer " is
the prefix of the source_authorization string.
"""

options = self._upload_pages_from_url_options(
Expand Down Expand Up @@ -2391,6 +2404,9 @@ async def append_block_from_url(self, copy_source_url, # type: str

:keyword int timeout:
The timeout parameter is expressed in seconds.
:keyword str source_authorization:
Authenticate as a service principal using a client secret to access a source blob. Ensure "bearer " is
the prefix of the source_authorization string.
"""
options = self._append_block_from_url_options(
copy_source_url=self._encode_source_url(copy_source_url),
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading