Title:
Open Graph Title:
X Title:
Description: Moved over from #910 per @dhermes Goal of this issue is to decide: Is it reasonable to provide one-liners to do things like create_topic() which is just a wrapper: python def create_topic(self, name): topic = self.topic(name) topic.creat...
Open Graph Description: Moved over from #910 per @dhermes Goal of this issue is to decide: Is it reasonable to provide one-liners to do things like create_topic() which is just a wrapper: python def create_topic(self, nam...
X Description: Moved over from #910 per @dhermes Goal of this issue is to decide: Is it reasonable to provide one-liners to do things like create_topic() which is just a wrapper: python def create_topic(self, nam...
Opengraph URL: https://github.com/googleapis/google-cloud-python/issues/911
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"\u003cnoun\u003e() vs get_\u003cnoun\u003e() vs \u003cverb\u003e_\u003cnoun\u003e()","articleBody":"Moved over from #910 per @dhermes \n\nGoal of this issue is to decide:\n1. Is it reasonable to provide one-liners to do things like `create_topic()` which is just a wrapper:\n `python\n def create_topic(self, name):\n topic = self.topic(name)\n topic.create()\n return topic\n `\n2. Can we agree on the naming convention of what does and does not require an API request\n\n---\n\nComment from the pull request was...\n\n\u003e The name create_topic is ambiguous to new users. Does it mean create a Topic instance or actual insert one?\n\nThat's a good point. I think we should adopt the attitude that `client.\u003cverb\u003e_\u003cnoun\u003e()` is an API request. So `create_topic` would hit the API trying to 'insert' the topic (using Google's API lingo). `client.\u003cnoun\u003e` is nothing more than a factory for the noun which won't fire an API request but gives you back an instance of the \u003cnoun\u003e.\n\n\u003e We'd need to offer Client.topic and Client.create_topic side-by-side since users would need to construct pre-existing topics without sending insert.\n\nTotally agree -- I think we had this debate already and I'm totally sold on the need for `.topic()` as the sole way to get a hold of a topic object, without hitting the API (as the topic literally has _zero_ extra metadata).\n\nFor other APIs, where the object itself holds lots of (potentially important) metadata, I think it might be worthwhile to provide a `get_\u003cnoun\u003e()` to pull down that metadata, in addition to the `\u003cnoun\u003e()` method which just gives you an object which may not be tied to the remote (authoritative) representation.\n\nAn example here might be `bucket`.\n- `.bucket()` gives me a bucket object, sans remote data (no API request).\n- `create_bucket()` explicitly creates the bucket in the remote service, throwing an error if I was unable to do so.\n- `get_bucket()` would be an API request that gives me all the metadata about a bucket.\n\nNote that the `\u003cverb\u003e_bucket()` methods are really just shortcuts so that I can have one-liners for the common things I want to do with a bucket. (ie, `create` == `bucket = client.bucket('name'); bucket.create(); return bucket;`)\n\nIn boto for S3, they have this `verify` or `check` parameter on the bucket constructor, so the comparisons look like:\n\n| Action | boto | gcloud (suggestion) |\n| --- | --- | --- |\n| Get a bucket, no API request | `connection.get_bucket(validate=False)` | `client.bucket()` |\n| Get a bucket + metadata | `connection.get_bucket()` | `client.get_bucket()` |\n\nI personally don't love the boto method, and would much rather the \"gcloud (suggestion)\" option.\n","author":{"url":"https://github.com/jgeewax","@type":"Person","name":"jgeewax"},"datePublished":"2015-06-06T16:57:35.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":20},"url":"https://github.com/911/google-cloud-python/issues/911"}
| 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:6545e6e7-6e6e-820f-208f-e0550b93717b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 92BC:1A1859:1100DA1:16B813C:6A4D8D9F |
| html-safe-nonce | d59f9d576b373858dd40a28870c28b85d2b18c7bda92e25dff78dbc41fe3094c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MkJDOjFBMTg1OToxMTAwREExOjE2QjgxM0M6NkE0RDhEOUYiLCJ2aXNpdG9yX2lkIjoiNDEzNDg2NDU3NDk4NDU4ODcwMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 48310f78009117b971a4e80017ebd10e1c4f303d3146e1475e312366e35d6a67 |
| hovercard-subject-tag | issue:85781210 |
| 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/911/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d336830bc3d23b5633c10d501a6b89aaadfab00ccc2511ae400cd268c194ba68/googleapis/google-cloud-python/issues/911 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d336830bc3d23b5633c10d501a6b89aaadfab00ccc2511ae400cd268c194ba68/googleapis/google-cloud-python/issues/911 |
| og:image:alt | Moved over from #910 per @dhermes Goal of this issue is to decide: Is it reasonable to provide one-liners to do things like create_topic() which is just a wrapper: python def create_topic(self, nam... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jgeewax |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9f8758a3953dfe943439713a6fa4f90d542a3431f10e861ca03dd7f39009f320 |
| 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 | bffd5484f01713a661b03469b77678f72b6574ed |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width