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