Skip to content

Commit

Permalink
[Blob] Added support for container SAS on batch operations (#16211)
Browse files Browse the repository at this point in the history
* generated

* Added support for container SAS for batch operations

* fixed tests and made method more generic

* pylint

* added canadacentral

* added canadacentral

* Delete test_container_async.test_batch_blobs_with_container_sas.yaml

recording is not used ^_^

* Delete test_container.test_batch_blobs_with_container_sas.yaml

* manually fixed test

* manually fixed test

Co-authored-by: Xiaoxi Fu <[email protected]>
  • Loading branch information
tasherif-msft and xiafu-msft authored Jan 22, 2021
1 parent ec5beee commit 9fb8466
Show file tree
Hide file tree
Showing 20 changed files with 2,399 additions and 2,318 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,9 @@ def _generate_delete_blobs_options(self,
if_tags_match_condition = kwargs.pop('if_tags_match_condition', None)
kwargs.update({'raise_on_any_failure': raise_on_any_failure,
'sas': self._query_str.replace('?', '&'),
'timeout': '&timeout=' + str(timeout) if timeout else ""
'timeout': '&timeout=' + str(timeout) if timeout else "",
'path': self.container_name,
'restype': 'restype=container&'
})

reqs = []
Expand Down Expand Up @@ -1259,7 +1261,9 @@ def _generate_set_tiers_options(self,
if_tags = kwargs.pop('if_tags_match_condition', None)
kwargs.update({'raise_on_any_failure': raise_on_any_failure,
'sas': self._query_str.replace('?', '&'),
'timeout': '&timeout=' + str(timeout) if timeout else ""
'timeout': '&timeout=' + str(timeout) if timeout else "",
'path': self.container_name,
'restype': 'restype=container&'
})

reqs = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,17 +262,20 @@ def _create_pipeline(self, credential, **kwargs):
return config, Pipeline(config.transport, policies=policies)

def _batch_send(
self, *reqs, # type: HttpRequest
self,
*reqs, # type: HttpRequest
**kwargs
):
"""Given a series of request, do a Storage batch call.
"""
# Pop it here, so requests doesn't feel bad about additional kwarg
raise_on_any_failure = kwargs.pop("raise_on_any_failure", True)
request = self._client._client.post( # pylint: disable=protected-access
url='{}://{}/?comp=batch{}{}'.format(
url='{}://{}/{}?{}comp=batch{}{}'.format(
self.scheme,
self.primary_hostname,
kwargs.pop('path', ""),
kwargs.pop('restype', ""),
kwargs.pop('sas', ""),
kwargs.pop('timeout', "")
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,22 @@ def _create_pipeline(self, credential, **kwargs):
return config, AsyncPipeline(config.transport, policies=policies)

async def _batch_send(
self, *reqs: 'HttpRequest',
self,
*reqs, # type: HttpRequest
**kwargs
):
"""Given a series of request, do a Storage batch call.
"""
# Pop it here, so requests doesn't feel bad about additional kwarg
raise_on_any_failure = kwargs.pop("raise_on_any_failure", True)
request = self._client._client.post( # pylint: disable=protected-access
url='{}://{}/?comp=batch{}{}'.format(
url='{}://{}/{}?{}comp=batch{}{}'.format(
self.scheme,
self.primary_hostname,
kwargs.pop('sas', None),
kwargs.pop('timeout', None)
kwargs.pop('path', ""),
kwargs.pop('restype', ""),
kwargs.pop('sas', ""),
kwargs.pop('timeout', "")
),
headers={
'x-ms-version': self.api_version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ interactions:
x-ms-version:
- '2019-07-07'
method: POST
uri: https://storagename.blob.core.windows.net/?comp=batch
uri: https://storagename.blob.core.windows.net/containerd5f4183b?restype=container&comp=batch
response:
body:
string: "--batchresponse_78d7e1c5-b832-4902-a2f0-2412a0c529b9\r\nContent-Type:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ interactions:
x-ms-version:
- '2019-07-07'
method: POST
uri: https://storagename.blob.core.windows.net/?comp=batch
uri: https://storagename.blob.core.windows.net/container71811ab8?restype=container&comp=batch
response:
body:
string: "--batchresponse_e14ad61c-425b-4f12-a33b-02674b3de02f\r\nContent-Type:
Expand Down
Loading

0 comments on commit 9fb8466

Please sign in to comment.