Title: PROPOSAL: Storage API consistency fix · Issue #632 · googleapis/google-cloud-python · GitHub
Open Graph Title: PROPOSAL: Storage API consistency fix · Issue #632 · googleapis/google-cloud-python
X Title: PROPOSAL: Storage API consistency fix · Issue #632 · googleapis/google-cloud-python
Description: Guiding principles: Getters and setters should never make HTTP requests. Lazy loading is OK, but only when it involves instance creation / other local (non-network bound) behavior. For example, in Bucket.acl this already happens: @proper...
Open Graph Description: Guiding principles: Getters and setters should never make HTTP requests. Lazy loading is OK, but only when it involves instance creation / other local (non-network bound) behavior. For example, in ...
X Description: Guiding principles: Getters and setters should never make HTTP requests. Lazy loading is OK, but only when it involves instance creation / other local (non-network bound) behavior. For example, in ...
Opengraph URL: https://github.com/googleapis/google-cloud-python/issues/632
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PROPOSAL: Storage API consistency fix","articleBody":"Guiding principles:\n- [x] Getters and setters should **never** make HTTP requests. Lazy loading is OK,\n but only when it involves instance creation / other local (non-network bound) behavior. For [example](https://github.com/GoogleCloudPlatform/gcloud-python/blob/f73ad7e8fc877e14e2f9c0b4ec42430f2396f770/gcloud/storage/bucket.py#L139-L144), in `Bucket.acl` this already happens:\n \n ``` python\n @property\n def acl(self):\n \"\"\"Create our ACL on demand.\"\"\"\n if self._acl is None:\n self._acl = BucketACL(self)\n return self._acl\n ```\n- [ ] More generally HTTP requests should be limited to explicit method calls. This also rules out constructors loading data.\n- [ ] `Blob`, `Bucket`, and `*ACL` (the only nouns) instances should have `load()`, `exists()`, `create()`, `delete()`, and `update()` methods. This design gives rise to code like\n \n ``` python\n blob = Blob('/remote/path.txt', bucket=bucket, properties=properties)\n try:\n blob.load() # Just metadata\n except NotFound:\n blob.upload_from_file(filename) # Sends metadata from properties\n ```\n \n (this maybe screams for `get_or_create()`, we'll feel it out as we develop). It's unclear if it's worth making a distinction between `storage.NOUN.update \u003c--\u003e PUT` and `storage.NOUN.patch \u003c--\u003e PATCH`. (As of right now, we don't implement `PUT` / `update` anywhere.)\n- [x] `exists()` should use `fields` in the requests to minimize the payload.\n- [ ] A `Connection` should not be required to be bound to any object (one of the nouns `Bucket`, `ACL`, or `Blob`) but should be an optional argument to methods which actually talk to the API.\n- [ ] We should **strongly** consider adding a `last_updated` field to classes to indicate the last time the values were updated (from the server).\n- [ ] For list methods: List all buckets top-level, e.g.\n \n ``` python\n storage.get_all_buckets(connection=optional_connection)\n ```\n \n and then `bucket.get_all_objects()`. It's unclear how the other 3 nouns (`objectAccessControls`, `bucketAccessControls` and `defaultObjectAccessControls`) will handle this. Right now they are handled via `ObjectACL.reload()` and `BucketACL.reload()` (a superclass of `DefaultObjectACL`).\n- [x] Implicit behavior (default project, default bucket and/or default connection) should be used wherever possible (and documented)\n\n@tseaver Please weigh in. This was inspired by our [discussion](https://github.com/GoogleCloudPlatform/gcloud-python/pull/604#issuecomment-73929760) at the end of #604.\n\n/cc @thobrla I'd like to close #545 and focus on this (possibly broken down into sub-bugs). Does that sound OK?\n","author":{"url":"https://github.com/dhermes","@type":"Person","name":"dhermes"},"datePublished":"2015-02-13T07:57:26.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/632/google-cloud-python/issues/632"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:175ee791-cb37-28bd-1d19-b91fd8e2f4dd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B5BC:29330:A0CC3D:A4641A:6A4DB34D |
| html-safe-nonce | 8ca726b22989f95ae5bf8405e08c34473bb16da36ca349d25eb9add86b5f28a0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNUJDOjI5MzMwOkEwQ0MzRDpBNDY0MUE6NkE0REIzNEQiLCJ2aXNpdG9yX2lkIjoiODQxMjUxNDk5NjYzODgyMzI0NiIsInJlZ2lvbl9lZGdlIjoic2VhIiwicmVnaW9uX3JlbmRlciI6InNlYSJ9 |
| visitor-hmac | 7302040e21521a384adc807508aef478044e9c85a788b50585c045ee705f9d58 |
| hovercard-subject-tag | issue:57569934 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/google-cloud-python/632/issue_layout |
| twitter:image | https://opengraph.githubassets.com/711a70626f1218c0703033be7c0031e5fcfb15923e0314c311ebbf4e094a9d31/googleapis/google-cloud-python/issues/632 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/711a70626f1218c0703033be7c0031e5fcfb15923e0314c311ebbf4e094a9d31/googleapis/google-cloud-python/issues/632 |
| og:image:alt | Guiding principles: Getters and setters should never make HTTP requests. Lazy loading is OK, but only when it involves instance creation / other local (non-network bound) behavior. For example, in ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dhermes |
| hostname | github.com |
| expected-hostname | github.com |
| None | 06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33 |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/google-cloud-python git https://github.com/googleapis/google-cloud-python.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 16316451 |
| octolytics-dimension-repository_nwo | googleapis/google-cloud-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 16316451 |
| octolytics-dimension-repository_network_root_nwo | googleapis/google-cloud-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 32f7b614aca06e6bbd89842b1370df1328264f68 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width