Skip to content

Add '{Bucket,Blob}.user_project' properties. - #3490

Merged
tseaver merged 9 commits into
googleapis:masterfrom
tseaver:3474-storage-bucket-requester_pays-user_project-property
Jun 13, 2017
Merged

Add '{Bucket,Blob}.user_project' properties.#3490
tseaver merged 9 commits into
googleapis:masterfrom
tseaver:3474-storage-bucket-requester_pays-user_project-property

Conversation

@tseaver

@tseavertseaver commented Jun 8, 2017

Copy link
Copy Markdown
Contributor

Uses #3489 as a base.

@tseavertseaver added api: storage Issues related to the Cloud Storage API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Jun 8, 2017
@googlebotgooglebot added the cla: yes This human has signed the Contributor License Agreement. label Jun 8, 2017
@tseaver

Copy link
Copy Markdown
ContributorAuthor

Rebased against master after the merge of #3488.

@dhermesdhermes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pretty straightforward, mostly (totally?) just nits

# Pass only '?projection=noAcl' here because 'acl' and related
# are handled via custom endpoints.
query_params = {'projection': 'noAcl'}
if self.user_project is not None:

This comment was marked as spam.

This comment was marked as spam.

@property
def user_project(self):
"""Project ID used for API requests made via this blob.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.


:type user_project: str
:param user_project: (Optional) the project ID to be billed for API
requests made via this instance.

This comment was marked as spam.

This comment was marked as spam.

def user_project(self):
"""Project ID to be billed for API requests made via this bucket.

If unset, API requests are billed to the bucket owner.

This comment was marked as spam.

This comment was marked as spam.

mixin = self._make_one()
self.assertRaises(NotImplementedError, lambda: mixin.path)
with self.assertRaises(NotImplementedError):
mixin.path

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

Comment threadstorage/tests/unit/test__helpers.py Outdated
connection = _Connection({'foo': 'Foo'})
client = _Client(connection)
derived = self._derivedClass('/path', user_project)()
# Make sure changes is not a set, so we can observe a change.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

Comment threadstorage/tests/unit/test__helpers.py Outdated
self.assertEqual(kw[0]['path'], '/path')
self.assertEqual(
kw[0]['query_params'],
{'projection': 'noAcl', 'userProject': user_project})

This comment was marked as spam.

This comment was marked as spam.

bucket = klass(client, name=NAME, user_project=USER_PROJECT)
self.assertEqual(bucket.name, NAME)
self.assertEqual(bucket._properties, {})
self.assertEqual(bucket.user_project, USER_PROJECT)

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

Comment threadstorage/tests/unit/test__helpers.py Outdated
kw[0]['query_params'],
{'projection': 'full', 'userProject': user_project})
# Since changes does not include `baz`, we don't see it sent.
self.assertEqual(kw[0]['data'], {'bar': BAR})

This comment was marked as spam.

This comment was marked as spam.

@dhermes

Copy link
Copy Markdown
Contributor

LGTM after your comment update

@tseaver
tseaver merged commit 60832b8 into googleapis:masterJun 13, 2017
@tseaver
tseaver deleted the 3474-storage-bucket-requester_pays-user_project-property branch June 13, 2017 13:55
landrito pushed a commit to landrito/google-cloud-python that referenced this pull request Aug 21, 2017
* Add abstract '_PropertyMixin.user_project' property.
* Support 'user_project' in '_PropertyMixin.{reload,patch}'.
* Add 'user_project' param to 'Bucket.__init__'.
* Save and expose via read-only 'user_project' property.
* Implement 'Blob.user_property' via bucket's value.
landrito pushed a commit to landrito/google-cloud-python that referenced this pull request Aug 22, 2017
* Add abstract '_PropertyMixin.user_project' property.
* Support 'user_project' in '_PropertyMixin.{reload,patch}'.
* Add 'user_project' param to 'Bucket.__init__'.
* Save and expose via read-only 'user_project' property.
* Implement 'Blob.user_property' via bucket's value.
landrito pushed a commit to landrito/google-cloud-python that referenced this pull request Aug 22, 2017
* Add abstract '_PropertyMixin.user_project' property.
* Support 'user_project' in '_PropertyMixin.{reload,patch}'.
* Add 'user_project' param to 'Bucket.__init__'.
* Save and expose via read-only 'user_project' property.
* Implement 'Blob.user_property' via bucket's value.
tseaver added a commit that referenced this pull request Sep 22, 2017
* Add abstract '_PropertyMixin.user_project' property.
* Support 'user_project' in '_PropertyMixin.{reload,patch}'.
* Add 'user_project' param to 'Bucket.__init__'.
* Save and expose via read-only 'user_project' property.
* Implement 'Blob.user_property' via bucket's value.
tseaver added a commit that referenced this pull request Oct 2, 2017
* Add abstract '_PropertyMixin.user_project' property.
* Support 'user_project' in '_PropertyMixin.{reload,patch}'.
* Add 'user_project' param to 'Bucket.__init__'.
* Save and expose via read-only 'user_project' property.
* Implement 'Blob.user_property' via bucket's value.
tseaver added a commit that referenced this pull request Oct 5, 2017
* Add abstract '_PropertyMixin.user_project' property.
* Support 'user_project' in '_PropertyMixin.{reload,patch}'.
* Add 'user_project' param to 'Bucket.__init__'.
* Save and expose via read-only 'user_project' property.
* Implement 'Blob.user_property' via bucket's value.
tseaver added a commit that referenced this pull request Oct 10, 2017
* Add abstract '_PropertyMixin.user_project' property.
* Support 'user_project' in '_PropertyMixin.{reload,patch}'.
* Add 'user_project' param to 'Bucket.__init__'.
* Save and expose via read-only 'user_project' property.
* Implement 'Blob.user_property' via bucket's value.
tseaver added a commit that referenced this pull request Oct 10, 2017
* Add abstract '_PropertyMixin.user_project' property.
* Support 'user_project' in '_PropertyMixin.{reload,patch}'.
* Add 'user_project' param to 'Bucket.__init__'.
* Save and expose via read-only 'user_project' property.
* Implement 'Blob.user_property' via bucket's value.
parthea pushed a commit that referenced this pull request Mar 9, 2026
* Add abstract '_PropertyMixin.user_project' property.
* Support 'user_project' in '_PropertyMixin.{reload,patch}'.
* Add 'user_project' param to 'Bucket.__init__'.
* Save and expose via read-only 'user_project' property.
* Implement 'Blob.user_property' via bucket's value.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storageIssues related to the Cloud Storage API.cla: yesThis 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

@tseaver@dhermes@googlebot