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