Skip to content
Open
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
20 changes: 15 additions & 5 deletions aep/general/0231/aep.md.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ APIs **may** support batch get to retrieve a consistent set of resources.

- The method's name **must** begin with `BatchGet`. The remainder of the method
name **must** be the plural form of the resource being retrieved.
- The HTTP verb **must** be `GET`.
- The HTTP verb **must** be `GET` or `POST`.
- The HTTP URI **must** end with `:batch-get`.
- The URI path **must** represent the collection for the resource, matching the
collection used for simple CRUD operations. If the operation spans parents, a
[wilcard](./reading-across-collections) **may** be accepted.
- There **must not** be a request body.
- When the HTTP verb is `GET`, there **must not** be a request body.
- If a GET request contains a body, the body **must** be ignored, and **must
not** cause an error.
- When the HTTP verb is `POST`, there **must** be a request body.

### Request

Expand Down Expand Up @@ -45,7 +46,8 @@ pattern:
```proto
rpc BatchGetBooks(BatchGetBooksRequest) returns (BatchGetBooksResponse) {
option (google.api.http) = {
get: "/v1/{parent=publishers/*}/books:batch-get"
post: "/v1/{parent=publishers/*}/books:batch-get"
body: "*"
};
}

Expand All @@ -55,7 +57,7 @@ message BatchGetBooksRequest {
// If this is set, the parent of all of the books specified in `paths`
// must match this field.
string parent = 1 [
(aep.api.field_info) = { resource_reference: [ "library.com/book" ], field_behavior: [ FIELD_BEHAVIOR_OPTIONAL ] }
(aep.api.field_info) = { resource_reference: [ "library.com/publisher" ], field_behavior: [ FIELD_BEHAVIOR_OPTIONAL ] }
];

// The paths of the books to retrieve.
Expand All @@ -77,7 +79,8 @@ message BatchGetBooksRequest {
- The field **should** identify the [resource type][aep-122-parent] that it
references.
- The comment for the field **should** document the resource pattern.
- There **must not** be a body key in the `google.api.http` annotation.
- When the HTTP verb is `GET`, there **must not** be a body key in the `google.api.http` annotation.
- When the HTTP verb is `POST`, there **must** be a body key in the `google.api.http` annotation.

{% tab oas %}

Expand Down Expand Up @@ -159,6 +162,13 @@ get either succeeds for all requested resources or fails. When supported, the
method must define a boolean parameter `transactional` that the user must
specify with the value `true` to request a transactional operation.

## Rationale

### Why allowing both `POST` and `GET` HTTP verb?

- Allowing the `POST` HTTP verb address practical limitations such as URL length constraints (e.g., 2048 characters).
- Allowing the `GET` HTTP verb maintains backward compatibility and cacheability.

## Changelog

- **2024-04-22:** Adopt from Google AIP https://google.aip.dev/231 with the
Expand Down