spicedb_grpc/gen/google.api.rs
1// This file is @generated by prost-build.
2/// Defines the HTTP configuration for an API service. It contains a list of
3/// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method
4/// to one or more HTTP REST API methods.
5#[allow(clippy::derive_partial_eq_without_eq)]
6#[derive(Clone, PartialEq, ::prost::Message)]
7pub struct Http {
8 /// A list of HTTP configuration rules that apply to individual API methods.
9 ///
10 /// **NOTE:** All service configuration rules follow "last one wins" order.
11 #[prost(message, repeated, tag = "1")]
12 pub rules: ::prost::alloc::vec::Vec<HttpRule>,
13 /// When set to true, URL path parameters will be fully URI-decoded except in
14 /// cases of single segment matches in reserved expansion, where "%2F" will be
15 /// left encoded.
16 ///
17 /// The default behavior is to not decode RFC 6570 reserved characters in multi
18 /// segment matches.
19 #[prost(bool, tag = "2")]
20 pub fully_decode_reserved_expansion: bool,
21}
22/// # gRPC Transcoding
23///
24/// gRPC Transcoding is a feature for mapping between a gRPC method and one or
25/// more HTTP REST endpoints. It allows developers to build a single API service
26/// that supports both gRPC APIs and REST APIs. Many systems, including [Google
27/// APIs](<https://github.com/googleapis/googleapis>),
28/// [Cloud Endpoints](<https://cloud.google.com/endpoints>), [gRPC
29/// Gateway](<https://github.com/grpc-ecosystem/grpc-gateway>),
30/// and [Envoy](<https://github.com/envoyproxy/envoy>) proxy support this feature
31/// and use it for large scale production services.
32///
33/// `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies
34/// how different portions of the gRPC request message are mapped to the URL
35/// path, URL query parameters, and HTTP request body. It also controls how the
36/// gRPC response message is mapped to the HTTP response body. `HttpRule` is
37/// typically specified as an `google.api.http` annotation on the gRPC method.
38///
39/// Each mapping specifies a URL path template and an HTTP method. The path
40/// template may refer to one or more fields in the gRPC request message, as long
41/// as each field is a non-repeated field with a primitive (non-message) type.
42/// The path template controls how fields of the request message are mapped to
43/// the URL path.
44///
45/// Example:
46///
47/// service Messaging {
48/// rpc GetMessage(GetMessageRequest) returns (Message) {
49/// option (google.api.http) = {
50/// get: "/v1/{name=messages/*}"
51/// };
52/// }
53/// }
54/// message GetMessageRequest {
55/// string name = 1; // Mapped to URL path.
56/// }
57/// message Message {
58/// string text = 1; // The resource content.
59/// }
60///
61/// This enables an HTTP REST to gRPC mapping as below:
62///
63/// HTTP | gRPC
64/// -----|-----
65/// `GET /v1/messages/123456` | `GetMessage(name: "messages/123456")`
66///
67/// Any fields in the request message which are not bound by the path template
68/// automatically become HTTP query parameters if there is no HTTP request body.
69/// For example:
70///
71/// service Messaging {
72/// rpc GetMessage(GetMessageRequest) returns (Message) {
73/// option (google.api.http) = {
74/// get:"/v1/messages/{message_id}"
75/// };
76/// }
77/// }
78/// message GetMessageRequest {
79/// message SubMessage {
80/// string subfield = 1;
81/// }
82/// string message_id = 1; // Mapped to URL path.
83/// int64 revision = 2; // Mapped to URL query parameter `revision`.
84/// SubMessage sub = 3; // Mapped to URL query parameter `sub.subfield`.
85/// }
86///
87/// This enables a HTTP JSON to RPC mapping as below:
88///
89/// HTTP | gRPC
90/// -----|-----
91/// `GET /v1/messages/123456?revision=2&sub.subfield=foo` |
92/// `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield:
93/// "foo"))`
94///
95/// Note that fields which are mapped to URL query parameters must have a
96/// primitive type or a repeated primitive type or a non-repeated message type.
97/// In the case of a repeated type, the parameter can be repeated in the URL
98/// as `...?param=A¶m=B`. In the case of a message type, each field of the
99/// message is mapped to a separate parameter, such as
100/// `...?foo.a=A&foo.b=B&foo.c=C`.
101///
102/// For HTTP methods that allow a request body, the `body` field
103/// specifies the mapping. Consider a REST update method on the
104/// message resource collection:
105///
106/// service Messaging {
107/// rpc UpdateMessage(UpdateMessageRequest) returns (Message) {
108/// option (google.api.http) = {
109/// patch: "/v1/messages/{message_id}"
110/// body: "message"
111/// };
112/// }
113/// }
114/// message UpdateMessageRequest {
115/// string message_id = 1; // mapped to the URL
116/// Message message = 2; // mapped to the body
117/// }
118///
119/// The following HTTP JSON to RPC mapping is enabled, where the
120/// representation of the JSON in the request body is determined by
121/// protos JSON encoding:
122///
123/// HTTP | gRPC
124/// -----|-----
125/// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id:
126/// "123456" message { text: "Hi!" })`
127///
128/// The special name `*` can be used in the body mapping to define that
129/// every field not bound by the path template should be mapped to the
130/// request body. This enables the following alternative definition of
131/// the update method:
132///
133/// service Messaging {
134/// rpc UpdateMessage(Message) returns (Message) {
135/// option (google.api.http) = {
136/// patch: "/v1/messages/{message_id}"
137/// body: "*"
138/// };
139/// }
140/// }
141/// message Message {
142/// string message_id = 1;
143/// string text = 2;
144/// }
145///
146///
147/// The following HTTP JSON to RPC mapping is enabled:
148///
149/// HTTP | gRPC
150/// -----|-----
151/// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id:
152/// "123456" text: "Hi!")`
153///
154/// Note that when using `*` in the body mapping, it is not possible to
155/// have HTTP parameters, as all fields not bound by the path end in
156/// the body. This makes this option more rarely used in practice when
157/// defining REST APIs. The common usage of `*` is in custom methods
158/// which don't use the URL at all for transferring data.
159///
160/// It is possible to define multiple HTTP methods for one RPC by using
161/// the `additional_bindings` option. Example:
162///
163/// service Messaging {
164/// rpc GetMessage(GetMessageRequest) returns (Message) {
165/// option (google.api.http) = {
166/// get: "/v1/messages/{message_id}"
167/// additional_bindings {
168/// get: "/v1/users/{user_id}/messages/{message_id}"
169/// }
170/// };
171/// }
172/// }
173/// message GetMessageRequest {
174/// string message_id = 1;
175/// string user_id = 2;
176/// }
177///
178/// This enables the following two alternative HTTP JSON to RPC mappings:
179///
180/// HTTP | gRPC
181/// -----|-----
182/// `GET /v1/messages/123456` | `GetMessage(message_id: "123456")`
183/// `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id:
184/// "123456")`
185///
186/// ## Rules for HTTP mapping
187///
188/// 1. Leaf request fields (recursive expansion nested messages in the request
189/// message) are classified into three categories:
190/// - Fields referred by the path template. They are passed via the URL path.
191/// - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They are passed via the HTTP
192/// request body.
193/// - All other fields are passed via the URL query parameters, and the
194/// parameter name is the field path in the request message. A repeated
195/// field can be represented as multiple query parameters under the same
196/// name.
197/// 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL query parameter, all fields
198/// are passed via URL path and HTTP request body.
199/// 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP request body, all
200/// fields are passed via URL path and URL query parameters.
201///
202/// ### Path template syntax
203///
204/// Template = "/" Segments \[ Verb \] ;
205/// Segments = Segment { "/" Segment } ;
206/// Segment = "*" | "**" | LITERAL | Variable ;
207/// Variable = "{" FieldPath \[ "=" Segments \] "}" ;
208/// FieldPath = IDENT { "." IDENT } ;
209/// Verb = ":" LITERAL ;
210///
211/// The syntax `*` matches a single URL path segment. The syntax `**` matches
212/// zero or more URL path segments, which must be the last part of the URL path
213/// except the `Verb`.
214///
215/// The syntax `Variable` matches part of the URL path as specified by its
216/// template. A variable template must not contain other variables. If a variable
217/// matches a single path segment, its template may be omitted, e.g. `{var}`
218/// is equivalent to `{var=*}`.
219///
220/// The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL`
221/// contains any reserved character, such characters should be percent-encoded
222/// before the matching.
223///
224/// If a variable contains exactly one path segment, such as `"{var}"` or
225/// `"{var=*}"`, when such a variable is expanded into a URL path on the client
226/// side, all characters except `\[-_.~0-9a-zA-Z\]` are percent-encoded. The
227/// server side does the reverse decoding. Such variables show up in the
228/// [Discovery
229/// Document](<https://developers.google.com/discovery/v1/reference/apis>) as
230/// `{var}`.
231///
232/// If a variable contains multiple path segments, such as `"{var=foo/*}"`
233/// or `"{var=**}"`, when such a variable is expanded into a URL path on the
234/// client side, all characters except `\[-_.~/0-9a-zA-Z\]` are percent-encoded.
235/// The server side does the reverse decoding, except "%2F" and "%2f" are left
236/// unchanged. Such variables show up in the
237/// [Discovery
238/// Document](<https://developers.google.com/discovery/v1/reference/apis>) as
239/// `{+var}`.
240///
241/// ## Using gRPC API Service Configuration
242///
243/// gRPC API Service Configuration (service config) is a configuration language
244/// for configuring a gRPC service to become a user-facing product. The
245/// service config is simply the YAML representation of the `google.api.Service`
246/// proto message.
247///
248/// As an alternative to annotating your proto file, you can configure gRPC
249/// transcoding in your service config YAML files. You do this by specifying a
250/// `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same
251/// effect as the proto annotation. This can be particularly useful if you
252/// have a proto that is reused in multiple services. Note that any transcoding
253/// specified in the service config will override any matching transcoding
254/// configuration in the proto.
255///
256/// Example:
257///
258/// http:
259/// rules:
260/// # Selects a gRPC method and applies HttpRule to it.
261/// - selector: example.v1.Messaging.GetMessage
262/// get: /v1/messages/{message_id}/{sub.subfield}
263///
264/// ## Special notes
265///
266/// When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the
267/// proto to JSON conversion must follow the [proto3
268/// specification](<https://developers.google.com/protocol-buffers/docs/proto3#json>).
269///
270/// While the single segment variable follows the semantics of
271/// [RFC 6570](<https://tools.ietf.org/html/rfc6570>) Section 3.2.2 Simple String
272/// Expansion, the multi segment variable **does not** follow RFC 6570 Section
273/// 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion
274/// does not expand special characters like `?` and `#`, which would lead
275/// to invalid URLs. As the result, gRPC Transcoding uses a custom encoding
276/// for multi segment variables.
277///
278/// The path variables **must not** refer to any repeated or mapped field,
279/// because client libraries are not capable of handling such variable expansion.
280///
281/// The path variables **must not** capture the leading "/" character. The reason
282/// is that the most common use case "{var}" does not capture the leading "/"
283/// character. For consistency, all path variables must share the same behavior.
284///
285/// Repeated message fields must not be mapped to URL query parameters, because
286/// no client library can support such complicated mapping.
287///
288/// If an API needs to use a JSON array for request or response body, it can map
289/// the request or response body to a repeated field. However, some gRPC
290/// Transcoding implementations may not support this feature.
291#[allow(clippy::derive_partial_eq_without_eq)]
292#[derive(Clone, PartialEq, ::prost::Message)]
293pub struct HttpRule {
294 /// Selects a method to which this rule applies.
295 ///
296 /// Refer to [selector][google.api.DocumentationRule.selector] for syntax details.
297 #[prost(string, tag = "1")]
298 pub selector: ::prost::alloc::string::String,
299 /// The name of the request field whose value is mapped to the HTTP request
300 /// body, or `*` for mapping all request fields not captured by the path
301 /// pattern to the HTTP body, or omitted for not having any HTTP request body.
302 ///
303 /// NOTE: the referred field must be present at the top-level of the request
304 /// message type.
305 #[prost(string, tag = "7")]
306 pub body: ::prost::alloc::string::String,
307 /// Optional. The name of the response field whose value is mapped to the HTTP
308 /// response body. When omitted, the entire response message will be used
309 /// as the HTTP response body.
310 ///
311 /// NOTE: The referred field must be present at the top-level of the response
312 /// message type.
313 #[prost(string, tag = "12")]
314 pub response_body: ::prost::alloc::string::String,
315 /// Additional HTTP bindings for the selector. Nested bindings must
316 /// not contain an `additional_bindings` field themselves (that is,
317 /// the nesting may only be one level deep).
318 #[prost(message, repeated, tag = "11")]
319 pub additional_bindings: ::prost::alloc::vec::Vec<HttpRule>,
320 /// Determines the URL pattern is matched by this rules. This pattern can be
321 /// used with any of the {get|put|post|delete|patch} methods. A custom method
322 /// can be defined using the 'custom' field.
323 #[prost(oneof = "http_rule::Pattern", tags = "2, 3, 4, 5, 6, 8")]
324 pub pattern: ::core::option::Option<http_rule::Pattern>,
325}
326/// Nested message and enum types in `HttpRule`.
327pub mod http_rule {
328 /// Determines the URL pattern is matched by this rules. This pattern can be
329 /// used with any of the {get|put|post|delete|patch} methods. A custom method
330 /// can be defined using the 'custom' field.
331 #[allow(clippy::derive_partial_eq_without_eq)]
332 #[derive(Clone, PartialEq, ::prost::Oneof)]
333 pub enum Pattern {
334 /// Maps to HTTP GET. Used for listing and getting information about
335 /// resources.
336 #[prost(string, tag = "2")]
337 Get(::prost::alloc::string::String),
338 /// Maps to HTTP PUT. Used for replacing a resource.
339 #[prost(string, tag = "3")]
340 Put(::prost::alloc::string::String),
341 /// Maps to HTTP POST. Used for creating a resource or performing an action.
342 #[prost(string, tag = "4")]
343 Post(::prost::alloc::string::String),
344 /// Maps to HTTP DELETE. Used for deleting a resource.
345 #[prost(string, tag = "5")]
346 Delete(::prost::alloc::string::String),
347 /// Maps to HTTP PATCH. Used for updating a resource.
348 #[prost(string, tag = "6")]
349 Patch(::prost::alloc::string::String),
350 /// The custom pattern is used for specifying an HTTP method that is not
351 /// included in the `pattern` field, such as HEAD, or "*" to leave the
352 /// HTTP method unspecified for this rule. The wild-card rule is useful
353 /// for services that provide content to Web (HTML) clients.
354 #[prost(message, tag = "8")]
355 Custom(super::CustomHttpPattern),
356 }
357}
358/// A custom pattern is used for defining custom HTTP verb.
359#[allow(clippy::derive_partial_eq_without_eq)]
360#[derive(Clone, PartialEq, ::prost::Message)]
361pub struct CustomHttpPattern {
362 /// The name of this custom HTTP verb.
363 #[prost(string, tag = "1")]
364 pub kind: ::prost::alloc::string::String,
365 /// The path matched by this custom verb.
366 #[prost(string, tag = "2")]
367 pub path: ::prost::alloc::string::String,
368}