In REST APIs, it is customary to make a GET
request to a resource's URI (for example, /v1/publishers/{publisher}/books/{book}
) in order to retrieve that resource.
Resource-oriented design (AIP-121) honors this pattern through the Get
method. These RPCs accept the URI representing that resource and return the resource.
APIs must provide a get method for resources. The purpose of the get method is to return data from a single resource.
Get methods are specified using the following pattern:
rpc GetBook(GetBookRequest) returns (Book) {
option (google.api.http) = {
get: "/v1/{name=publishers/*/books/*}"
};
option (google.api.method_signature) = "name";
}
Get
. The remainder of the RPC name should be the singular form of the resource's message name.Request
suffix.GetBookResponse
.)
GET
.name
.name
field should be the only variable in the URI path. All remaining parameters should map to URI query parameters.body
key in the google.api.http
annotation.google.api.method_signature
annotation, with a value of "name"
.Get methods implement a common request message pattern:
message GetBookRequest {
// The name of the book to retrieve.
// Format: publishers/{publisher}/books/{book}
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "library.googleapis.com/Book"
}];
}
name
.
name
field should document the resource pattern.Note: The name
field in the request object corresponds to the name
variable in the google.api.http
annotation on the RPC. This causes the name
field in the request to be populated based on the value in the URL when the REST/JSON interface is used.
See errors, in particular when to use PERMISSION_DENIED and NOT_FOUND errors.
ChangelogRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.5