-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add '{Bucket,Blob}.user_project' properties. #3490
Add '{Bucket,Blob}.user_project' properties. #3490
Conversation
Save and expose via read-only 'user_project' property.
Rebased against master after the merge of #3488. |
There was a problem hiding this comment.
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
@@ -94,6 +99,8 @@ def reload(self, client=None): | |||
# 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
def user_project(self): | ||
"""Project ID used for API requests made via this blob. | ||
|
||
Derived from bucket's value. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
: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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
return Derived | ||
|
||
def test_path_is_abstract(self): | ||
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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
storage/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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
storage/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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
storage/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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
LGTM after your comment update |
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
Uses #3489 as a base.