Phase 1 Update create_bucket to take Bucket object within Storage Client#7820
Phase 1 Update create_bucket to take Bucket object within Storage Client#7820tswast merged 8 commits intogoogleapis:masterfrom
Conversation
storage/tests/unit/test_client.py
Outdated
| from google.cloud.exceptions import Conflict | ||
| from google.cloud.storage.bucket import Bucket | ||
|
|
||
| PROJECT = "PROJECT" |
There was a problem hiding this comment.
nit: since these are just local variables, use lower-case letters.
There was a problem hiding this comment.
Changed variable names to lower-case on all tests I'm working on.
storage/tests/unit/test_client.py
Outdated
| ] | ||
| ) | ||
| data = {"error": {"message": "Conflict"}} | ||
| sent = {"name": BUCKET_NAME} |
There was a problem hiding this comment.
nit: I recommend moving this down near the assertion and calling it json_expected to align with json_sent.
There was a problem hiding this comment.
Renamed sent to json_expected on all relevant tests for consistency and moved down as directed.
storage/tests/unit/test_client.py
Outdated
| "b?project=%s" % (PROJECT,), | ||
| ] | ||
| ) | ||
| sent = {"name": BUCKET_NAME, "billing": {"requesterPays": True}} |
There was a problem hiding this comment.
In addition to requesterPays, let's set some properties on the bucket object in this test. The properties I most want to see are
location - Which region is this bucket belonging to?(actually, that's not settable yet. Let's add that to the list in the redesign doc if it's not there yet)storage_class- What kind of bucket is this?requester_pays- Leave the argument tocreate_bucketunset and set it on the Bucket, instead. (We should deprecaterequester_paysoncreate_bucket. Add that to the redesign list, too.)
There was a problem hiding this comment.
Added storage_class property and adjusted requester_pays as directed. Included requester_pays and location comment in the redesign doc.
| """ | ||
|
|
||
| def __init__(self, client, name=None, user_project=None): | ||
| def __init__(self, client=None, name=None, user_project=None): |
There was a problem hiding this comment.
Let's make this update as a separate PR, as I think we'll want to show better error messages in the existing Bucket methods when client isn't supplied (for example, say what method to call instead on Client).
There was a problem hiding this comment.
Took this file out of review - please disregard, thanks!
| return Batch(client=self) | ||
|
|
||
| def get_bucket(self, bucket_name): | ||
| def get_bucket(self, bucket_or_name): |
There was a problem hiding this comment.
I'd prefer this to be a separate PR, too, but it's okay this once. In general a PR should correspond to 1 easily-described change (new feature / bug fix). Now this PR has 2 new features (but they are related, at least).
There was a problem hiding this comment.
Took this file out of review - please disregard, thanks!
|
|
||
| :type bucket_name: str | ||
| :param bucket_name: The bucket name to create. | ||
| :type bucket_or_name: str or resource |
There was a problem hiding this comment.
Could you make the docstring for create_bucket follow the same pattern as we use in BigQuery. These :type: and :param: are Sphinx/RST-style, but we are migrating to Google-style.
Docs on Google-style are at https://sphinxcontrib-napoleon.readthedocs.io/en/latest/ with an example file at https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html#example-google
We had to do this for BigQuery too. Basically, as we update each method we migrate it to the Google-style.
There was a problem hiding this comment.
Updated docstring to reflect Google-style.
|
Python 2.7 test failure is due to #7841 |
|
@tswast Hmm, I wasn't aware that this redesign had actually been approved: in fact I asked about that in yesterdays storage sync call, and got a "no, still under consideration." |
…ent (#7820) * Update create_bucket to take Bucket object * Updated changes based on feedback * Updated test with changes per feedback * Adjusted variable names for consistency and updated test based on feedback. * Made client argument be optional in Bucket constructor. * Removed changes for future PR * Updating docstring to reflect new google style * Updating docstring to match Google style guide for create_bucket
Part of issue: #7762
@tswast
@engelke