-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Policy on the basic CRUD operations #1722
Comments
FWIW, we already discussed this in #911. |
Added #911 to the related list. I think the discussion there got side-tracked (the main one was the debate about whether |
The main issue is really the disagreement about the Zen of Python:
In addition, we've never heard a request from a user for the extra methods. FWIW, I don't really have much fight in me on this one. I'm happy to acquiesce and implement whatever. |
Devil's advocate here:
I'm fine with leaving I'm personally in favor of @jgeewax's proposal for the API here. |
Still happy to acquiesce and implement whatever. |
Definitely want to hear @tseaver's view here. |
From a user's perspective, this is the natural way to fetch a thing:
Whether additionally offering a |
Is anyone Dutch? I'm not sure if these methods break the zen. Batteries included almost makes it sound like convince methods are welcome if logical and clear. I think the most important part is consistency so a user can find the rhythm of the library. I'm game like @dhermes for whatever as long as we're consistently consistent. :-D |
@rimey : What if we standardized on This would mean:
|
OK. I updated the body of this issue to summarize things, but the note above suggests ways we could avoid having (re Regardless of that, some key points are...
|
The
I would be wary of trying too hard to define a one-size-fits-all CRUD pattern. Different APIs are different:
|
@rimey, just tossing out ideas. Not sure if they're any good.
This is a guideline for the common case that we keep seeing. Cloud Storage, Pub/Sub, etc all have basic CRUD operations and static resource names. We do different things for these similar scenarios and I don't think we should. This isn't meant to be commandments stating that all APIs must look exactly like this. If they can look this way, they should. If we have a good reason to deviate, we should.
I'm fine with dropping the The API might require something by the time it arrives, however our client needs to accommodate people who don't have all of the information at init-time. Otherwise, we're just encouraging people to fill in dummy values until they have all the information they need. Sanjay G is a big proponent of "tell users quickly when they supply bad data", and even in Protobuf we don't deal with required fields this way. In other words, I don't think
If a field has to be a number and a user gives us "foo", we should tell them right away (protobuf does this). If they make a In other words, users say "I'm done!" by calling an API-contacting method ( As I mentioned above, this isn't a commandment. In Datastore, the ID field is "required" to be a persisted entity, but it's fine to omit the ID when saving a new one -- that's how you say "give me an auto-generated ID" -- so this certainly isn't a one-size-fits-all mandate. |
Another point of refrence for this: It's awkward in the bigquery API to have to do this: bigquery_client = bigquery.Client()
dataset = bigquery_client.dataset(dataset_name)
table = dataset.table(table_name)
# Reload the table to get the schema.
table.reload() Just to make sure the |
If the back-end already knows the schema (which it must, or else |
In this case I can't because of another bug. On Thu, Aug 18, 2016, 6:17 PM Tres Seaver notifications@github.com wrote:
|
I am going to close this because:
|
Seems that we're having some disagreements on what our surfaces should look like. Here's my opinion to start the discussion. I use a "thing API" that deals with "things". You can replace with "storage" and "bucket" if it that's easier.
/cc @daspecster @dhermes @tseaver @jonparrott
Client pattern
A client handles your credentials and acts as the pipe to the API.
Instantiate a thing
Create the thing object and eventually save it remotely.
It's important that the there are no required parameters:
If you want a one-liner to save a new thing remotely.
It's unusual, but perhaps you want to "load" a thing from the API by first creating the thing object with the right ID, and then reloading it.
Get a thing
Give me a thing from the API service.
What if the thing doesn't exist?
Update a thing
The same pattern as creating a thing, except I start with a loaded thing.
Reload a thing
I have a thing, but I suspect it's changed since I loaded it. I want to make sure what i have is fresh...
List a bunch of things
I have many things stored and I want to go through all of them.
I have lots of things, but I only want 100 of them. I don't care how many API calls there are.
I have lots of things, and I want to control specifically how many API calls I'm making -- I'm on a budget!
Delete a thing
I have a thing that I loaded, or paged through, and I want to delete it.
And to do this in a one-liner, with a single API request:
We may also want to support a single method, but I'm not 100% sure about this...
Related
The text was updated successfully, but these errors were encountered: