Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add predefined_acl to create_resumable_upload_session #878

Merged
merged 2 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion google/cloud/storage/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -2861,6 +2861,7 @@ def create_resumable_upload_session(
client=None,
timeout=_DEFAULT_TIMEOUT,
checksum=None,
predefined_acl=None,
if_generation_match=None,
if_generation_not_match=None,
if_metageneration_match=None,
Expand Down Expand Up @@ -2942,6 +2943,9 @@ def create_resumable_upload_session(
delete the uploaded object automatically. Supported values
are "md5", "crc32c" and None. The default is None.

:type predefined_acl: str
:param predefined_acl: (Optional) Predefined access control list

:type if_generation_match: long
:param if_generation_match:
(Optional) See :ref:`using-if-generation-match`
Expand Down Expand Up @@ -3015,7 +3019,7 @@ def create_resumable_upload_session(
content_type,
size,
None,
predefined_acl=None,
predefined_acl=predefined_acl,
if_generation_match=if_generation_match,
if_generation_not_match=if_generation_not_match,
if_metageneration_match=if_metageneration_match,
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/test_blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -3572,6 +3572,7 @@ def _create_resumable_upload_session_helper(
origin=None,
side_effect=None,
timeout=None,
predefined_acl=None,
if_generation_match=None,
if_generation_not_match=None,
if_metageneration_match=None,
Expand Down Expand Up @@ -3611,6 +3612,7 @@ def _create_resumable_upload_session_helper(
size=size,
origin=origin,
client=client,
predefined_acl=predefined_acl,
if_generation_match=if_generation_match,
if_generation_not_match=if_generation_not_match,
if_metageneration_match=if_metageneration_match,
Expand All @@ -3629,6 +3631,9 @@ def _create_resumable_upload_session_helper(
)

qs_params = [("uploadType", "resumable")]
if predefined_acl is not None:
qs_params.append(("predefinedAcl", predefined_acl))

if if_generation_match is not None:
qs_params.append(("ifGenerationMatch", if_generation_match))

Expand Down Expand Up @@ -3672,6 +3677,9 @@ def test_create_resumable_upload_session_with_custom_timeout(self):
def test_create_resumable_upload_session_with_origin(self):
self._create_resumable_upload_session_helper(origin="http://google.com")

def test_create_resumable_upload_session_with_predefined_acl(self):
self._create_resumable_upload_session_helper(predefined_acl="private")

def test_create_resumable_upload_session_with_generation_match(self):
self._create_resumable_upload_session_helper(
if_generation_match=123456, if_metageneration_match=2
Expand Down