Skip to content

Commit

Permalink
feat(update): introduce "path" variable
Browse files Browse the repository at this point in the history
In protobuf, the resource path is only an input parameter in the
context of update. This has resulted in increased complexity, such as
the introduction of an `IDENTIFIER` field behavior that must be
special-cased by linters and generators.

Normalizing update to the same pattern fixes this issue.

related to aep-dev#181
  • Loading branch information
toumorokoshi committed Aug 21, 2024
1 parent 4bff23e commit a33cb7e
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions aep/general/0134/aep.md.j2
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,22 @@ Update methods are specified using the following pattern:
```proto
rpc UpdateBook(UpdateBookRequest) returns (Book) {
option (google.api.http) = {
patch: "/v1/{book.path=publishers/*/books/*}"
patch: "/v1/{path=publishers/*/books/*}"
body: "book"
};
option (google.api.method_signature) = "book,update_mask";
}
```

- The resource's `path` field **should** map to the URI path.
- The `{resource}.path` field **should** be the only variable in the URI
- The request's `path` field **must** map to the URI path.
- The `path` field **must** be the only variable in the URI
path.
- There **must** be a `body` key in the `google.api.http` annotation, and it
**must** map to the resource field in the request message.
- All remaining fields **should** map to URI query parameters.
- There **should** be exactly one `google.api.method_signature` annotation,
with a value of `"{resource},update_mask"`.

**Note:** Unlike the other four standard methods, the URI path here references
a nested field (`book.path`) in the example. If the resource field has a word
separator, `snake_case` is used.

{% tab oas %}

**Note:** OAS example not yet written.
Expand All @@ -65,6 +61,8 @@ separator, `snake_case` is used.

Update methods implement a common request pattern:

- The request **must** contain a
- The name of this field **must** be the singular form of the resource's
- The request **must** contain a field for the resource.
- The name of this field **must** be the singular form of the resource's
name.
Expand All @@ -76,9 +74,14 @@ Update methods implement a common request pattern:

```proto
message UpdateBookRequest {
// The book to update.
//
// The book's `path` field is used to identify the book to update.
// The path of the book to update.
string path = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "library.googleapis.com/Book"
}];

// The value to update the book to.
// Format: publishers/{publisher}/books/{book}
Book book = 1 [(google.api.field_behavior) = REQUIRED];

Expand All @@ -87,6 +90,10 @@ message UpdateBookRequest {
}
```

- A `path` field **must** be included.
- The field **should** be [annotated as required](/field-behavior-documentation).
- The field **must** identify the [resource type](/resource-types) that it
references.
- The request message field for the resource **must** map to the `PATCH` body.
- The request message field for the resource **should** be [annotated as
required][aep-203].
Expand Down Expand Up @@ -194,14 +201,7 @@ will create the resource in the process):

```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.
Expand Down

0 comments on commit a33cb7e

Please sign in to comment.