From 68771d01b44ec16e1d1383ae507298bce1edb904 Mon Sep 17 00:00:00 2001 From: Yusuke Tsutsumi Date: Fri, 13 Sep 2024 19:33:11 -0700 Subject: [PATCH] feat(update): remove create or update create or update introduces a new pattern in addition to the existing flow of: 1. getting a resource. 2. if NOT_FOUND, send a create. 3. if found, send an update. In the future, this could be re-added as an Apply method, which would map to the appropriate REST method of PUT. --- aep/general/0134/aep.md.j2 | 45 -------------------------------------- 1 file changed, 45 deletions(-) diff --git a/aep/general/0134/aep.md.j2 b/aep/general/0134/aep.md.j2 index 7fb5b101..6683f454 100644 --- a/aep/general/0134/aep.md.j2 +++ b/aep/general/0134/aep.md.j2 @@ -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