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