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

Implement predefined acl #4757

Merged
merged 5 commits into from
Feb 27, 2018

Conversation

chemelnucfin
Copy link
Contributor

Closes #1660

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jan 17, 2018
@chemelnucfin chemelnucfin self-assigned this Jan 17, 2018
@chemelnucfin chemelnucfin added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. api: storage Issues related to the Cloud Storage API. labels Jan 17, 2018
@chemelnucfin chemelnucfin force-pushed the storage_predefined_acl branch 2 times, most recently from a3c3774 to 54bb0fc Compare January 17, 2018 22:30
@@ -688,6 +691,9 @@ def _do_multipart_upload(self, client, stream, content_type,

if self.user_project is not None:
name_value_pairs.append(('userProject', self.user_project))
if predefined_acl is not None:
self._acl.save_predefined(predefined_acl)
name_value_pairs.append(('predefinedAcl', predefined_acl))

This comment was marked as spam.

This comment was marked as spam.

@chemelnucfin
Copy link
Contributor Author

@tseaver PTAL, thanks. I set the acl after the blob was created as you had suggested.

@tseaver
Copy link
Contributor

tseaver commented Jan 26, 2018

@chemelnucfin Moving the save_predefined call after the actual upload still makes two API calls. The change I asked for was to avoid using save_predefined at all, and instead to get the appropriate query parameter added to the actual upload API request. This change will require factoring out the XML->JSON parameter name code (currently inside save_predefined), and tweaking _initiate_resumable_upload and _do_multipart_upload to inject the query parameter appropriately (like for userProject).

@chemelnucfin
Copy link
Contributor Author

Sorry, I must have misunderstood you. I will take a look in a bit. Thanks.

@chemelnucfin chemelnucfin force-pushed the storage_predefined_acl branch 2 times, most recently from b970be1 to 1d0aae7 Compare January 30, 2018 23:27
@chemelnucfin
Copy link
Contributor Author

@tseaver PTAL at your convenience. Thanks.

@@ -1009,9 +1013,11 @@ def _initiate_resumable_helper(
data = b'hello hallo halo hi-low'
stream = io.BytesIO(data)
content_type = u'text/plain'
predefined_acl = 'private'

This comment was marked as spam.

@@ -1180,8 +1187,9 @@ def _do_resumable_helper(self, use_size=False, num_retries=None):
client = mock.Mock(_http=transport, spec=['_http'])
stream = io.BytesIO(data)
content_type = u'text/html'
predefined_acl = 'private'

This comment was marked as spam.

@@ -1225,20 +1233,21 @@ def _do_upload_helper(self, chunk_size=None, num_retries=None):
stream = mock.sentinel.stream
content_type = u'video/mp4'
size = 12345654321

predefined_acl = 'private'

This comment was marked as spam.


blob = self._make_one('blob-name', bucket=None)

blob._acl = mock.create_autospec(ACL)

This comment was marked as spam.

@@ -1187,7 +1190,6 @@ def _do_resumable_helper(self, use_size=False, num_retries=None):
client = mock.Mock(_http=transport, spec=['_http'])
stream = io.BytesIO(data)
content_type = u'text/html'
predefined_acl = 'private'
response = blob._do_resumable_upload(
client, stream, content_type, size, num_retries, None)

This comment was marked as spam.

@chemelnucfin
Copy link
Contributor Author

@tseaver Hopefully this time is good. PTAL at your convenience.

@chemelnucfin chemelnucfin changed the title Storage: Implement predefined acl Implement predefined acl Feb 20, 2018
Copy link
Contributor

@tseaver tseaver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the other changes requested, please add explicit unit tests for ACL.valiate_predefined_acl, including cases for None, a valid XML acl, a valid JSON acl, and an invalid acl.

@@ -941,14 +965,18 @@ def upload_from_file(self, file_obj, rewind=False, size=None,
warnings.warn(_NUM_RETRIES_MESSAGE, DeprecationWarning)

_maybe_rewind(file_obj, rewind=rewind)
predefined_acl = ACL.validate_predefined(predefined_acl)

This comment was marked as spam.

This comment was marked as spam.

@@ -1109,7 +1145,7 @@ def create_resumable_upload_session(
# to the `ResumableUpload` constructor. The chunk size only
# matters when **sending** bytes to an upload.
upload, _ = self._initiate_resumable_upload(
client, dummy_stream, content_type, size, None,
client, dummy_stream, content_type, size, None, None,

This comment was marked as spam.

This comment was marked as spam.

@chemelnucfin
Copy link
Contributor Author

@tseaver added the unit test for validation.

@chemelnucfin
Copy link
Contributor Author

@tseaver I added the keyword arguments, PTAL and hopefully this is good!

@chemelnucfin chemelnucfin merged commit 34cedf3 into googleapis:master Feb 27, 2018
@chemelnucfin chemelnucfin deleted the storage_predefined_acl branch February 27, 2018 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. cla: yes This human has signed the Contributor License Agreement. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants