Skip to content
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

feat(update): remove create or update #220

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions aep/general/0134/aep.md.j2
Original file line number Diff line number Diff line change
Expand Up @@ -170,51 +170,6 @@ If a rating were set on a book and the existing `PUT` request were executed, it
would wipe out the book's rating. In essence, a `PUT` request unintentionally
would wipe out data because the previous version did not know about it.

### Create or Update

If the service uses client-assigned resource paths, `Update` methods **may**
expose a `bool allow_missing` field, which will cause the method to succeed in
the event that the user attempts to update a resource that is not present (and
will create the resource in the process).

{% tab proto %}

```proto
message UpdateBookRequest {
// The book to update.
//
// The book's `path` field is used to identify the book to be updated.
// Format: publishers/{publisher}/books/{book}
Book book = 1 [(google.api.field_behavior) = REQUIRED];

// The list of fields to be updated.
google.protobuf.FieldMask update_mask = 2;

// If set to true, and the book is not found, a new book will be created.
// In this situation, `update_mask` is ignored.
bool allow_missing = 3;
}
```

{% tab oas %}

**Note:** OAS example not yet written.

{% endtabs %}

More specifically, the `allow_missing` flag triggers the following behavior:

- If the method call is on a resource that does not exist, the resource is
created. All fields are applied regardless of any provided field mask.
- However, if any required fields are missing or fields have invalid values,
an `INVALID_ARGUMENT` error is returned.
- If the method call is on a resource that already exists, and all fields
match, the existing resource is returned unchanged.
- If the method call is on a resource that already exists, only fields declared
in the field mask are updated.

The user **must** have the update permissions to call `Update` even with
`allow_missing` set to `true`.

### Etags

Expand Down
Loading