yandex_cloud/google.api.rs
1/// Defines the HTTP configuration for a service. It contains a list of
2/// \[HttpRule][google.api.HttpRule\], each specifying the mapping of an RPC method
3/// to one or more HTTP REST API methods.
4#[allow(clippy::derive_partial_eq_without_eq)]
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}
13/// `HttpRule` defines the mapping of an RPC method to one or more HTTP
14/// REST APIs. The mapping determines what portions of the request
15/// message are populated from the path, query parameters, or body of
16/// the HTTP request. The mapping is typically specified as an
17/// `google.api.http` annotation, see "google/api/annotations.proto"
18/// for details.
19///
20/// The mapping consists of a field specifying the path template and
21/// method kind. The path template can refer to fields in the request
22/// message, as in the example below which describes a REST GET
23/// operation on a resource collection of messages:
24///
25///
26/// service Messaging {
27/// rpc GetMessage(GetMessageRequest) returns (Message) {
28/// option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}";
29/// }
30/// }
31/// message GetMessageRequest {
32/// message SubMessage {
33/// string subfield = 1;
34/// }
35/// string message_id = 1; // mapped to the URL
36/// SubMessage sub = 2; // `sub.subfield` is url-mapped
37/// }
38/// message Message {
39/// string text = 1; // content of the resource
40/// }
41///
42/// The same http annotation can alternatively be expressed inside the
43/// `GRPC API Configuration` YAML file.
44///
45/// http:
46/// rules:
47/// - selector: <proto_package_name>.Messaging.GetMessage
48/// get: /v1/messages/{message_id}/{sub.subfield}
49///
50/// This definition enables an automatic, bidrectional mapping of HTTP
51/// JSON to RPC. Example:
52///
53/// HTTP | RPC
54/// -----|-----
55/// `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))`
56///
57/// In general, not only fields but also field paths can be referenced
58/// from a path pattern. Fields mapped to the path pattern cannot be
59/// repeated and must have a primitive (non-message) type.
60///
61/// Any fields in the request message which are not bound by the path
62/// pattern automatically become (optional) HTTP query
63/// parameters. Assume the following definition of the request message:
64///
65///
66/// message GetMessageRequest {
67/// message SubMessage {
68/// string subfield = 1;
69/// }
70/// string message_id = 1; // mapped to the URL
71/// int64 revision = 2; // becomes a parameter
72/// SubMessage sub = 3; // `sub.subfield` becomes a parameter
73/// }
74///
75///
76/// This enables a HTTP JSON to RPC mapping as below:
77///
78/// HTTP | RPC
79/// -----|-----
80/// `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))`
81///
82/// Note that fields which are mapped to HTTP parameters must have a
83/// primitive type or a repeated primitive type. Message types are not
84/// allowed. In the case of a repeated type, the parameter can be
85/// repeated in the URL, as in `...?param=A¶m=B`.
86///
87/// For HTTP method kinds which allow a request body, the `body` field
88/// specifies the mapping. Consider a REST update method on the
89/// message resource collection:
90///
91///
92/// service Messaging {
93/// rpc UpdateMessage(UpdateMessageRequest) returns (Message) {
94/// option (google.api.http) = {
95/// put: "/v1/messages/{message_id}"
96/// body: "message"
97/// };
98/// }
99/// }
100/// message UpdateMessageRequest {
101/// string message_id = 1; // mapped to the URL
102/// Message message = 2; // mapped to the body
103/// }
104///
105///
106/// The following HTTP JSON to RPC mapping is enabled, where the
107/// representation of the JSON in the request body is determined by
108/// protos JSON encoding:
109///
110/// HTTP | RPC
111/// -----|-----
112/// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })`
113///
114/// The special name `*` can be used in the body mapping to define that
115/// every field not bound by the path template should be mapped to the
116/// request body. This enables the following alternative definition of
117/// the update method:
118///
119/// service Messaging {
120/// rpc UpdateMessage(Message) returns (Message) {
121/// option (google.api.http) = {
122/// put: "/v1/messages/{message_id}"
123/// body: "*"
124/// };
125/// }
126/// }
127/// message Message {
128/// string message_id = 1;
129/// string text = 2;
130/// }
131///
132///
133/// The following HTTP JSON to RPC mapping is enabled:
134///
135/// HTTP | RPC
136/// -----|-----
137/// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")`
138///
139/// Note that when using `*` in the body mapping, it is not possible to
140/// have HTTP parameters, as all fields not bound by the path end in
141/// the body. This makes this option more rarely used in practice of
142/// defining REST APIs. The common usage of `*` is in custom methods
143/// which don't use the URL at all for transferring data.
144///
145/// It is possible to define multiple HTTP methods for one RPC by using
146/// the `additional_bindings` option. Example:
147///
148/// service Messaging {
149/// rpc GetMessage(GetMessageRequest) returns (Message) {
150/// option (google.api.http) = {
151/// get: "/v1/messages/{message_id}"
152/// additional_bindings {
153/// get: "/v1/users/{user_id}/messages/{message_id}"
154/// }
155/// };
156/// }
157/// }
158/// message GetMessageRequest {
159/// string message_id = 1;
160/// string user_id = 2;
161/// }
162///
163///
164/// This enables the following two alternative HTTP JSON to RPC
165/// mappings:
166///
167/// HTTP | RPC
168/// -----|-----
169/// `GET /v1/messages/123456` | `GetMessage(message_id: "123456")`
170/// `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")`
171///
172/// # Rules for HTTP mapping
173///
174/// The rules for mapping HTTP path, query parameters, and body fields
175/// to the request message are as follows:
176///
177/// 1. The `body` field specifies either `*` or a field path, or is
178/// omitted. If omitted, it assumes there is no HTTP body.
179/// 2. Leaf fields (recursive expansion of nested messages in the
180/// request) can be classified into three types:
181/// (a) Matched in the URL template.
182/// (b) Covered by body (if body is `*`, everything except (a) fields;
183/// else everything under the body field)
184/// (c) All other fields.
185/// 3. URL query parameters found in the HTTP request are mapped to (c) fields.
186/// 4. Any body sent with an HTTP request can contain only (b) fields.
187///
188/// The syntax of the path template is as follows:
189///
190/// Template = "/" Segments [ Verb ] ;
191/// Segments = Segment { "/" Segment } ;
192/// Segment = "*" | "**" | LITERAL | Variable ;
193/// Variable = "{" FieldPath [ "=" Segments ] "}" ;
194/// FieldPath = IDENT { "." IDENT } ;
195/// Verb = ":" LITERAL ;
196///
197/// The syntax `*` matches a single path segment. It follows the semantics of
198/// [RFC 6570](<https://tools.ietf.org/html/rfc6570>) Section 3.2.2 Simple String
199/// Expansion.
200///
201/// The syntax `**` matches zero or more path segments. It follows the semantics
202/// of [RFC 6570](<https://tools.ietf.org/html/rfc6570>) Section 3.2.3 Reserved
203/// Expansion. NOTE: it must be the last segment in the path except the Verb.
204///
205/// The syntax `LITERAL` matches literal text in the URL path.
206///
207/// The syntax `Variable` matches the entire path as specified by its template;
208/// this nested template must not contain further variables. If a variable
209/// matches a single path segment, its template may be omitted, e.g. `{var}`
210/// is equivalent to `{var=*}`.
211///
212/// NOTE: the field paths in variables and in the `body` must not refer to
213/// repeated fields or map fields.
214///
215/// Use CustomHttpPattern to specify any HTTP method that is not included in the
216/// `pattern` field, such as HEAD, or "*" to leave the HTTP method unspecified for
217/// a given URL path rule. The wild-card rule is useful for services that provide
218/// content to Web (HTML) clients.
219#[allow(clippy::derive_partial_eq_without_eq)]
220#[derive(Clone, PartialEq, ::prost::Message)]
221pub struct HttpRule {
222 /// Selects methods to which this rule applies.
223 ///
224 /// Refer to \[selector][google.api.DocumentationRule.selector\] for syntax details.
225 #[prost(string, tag = "1")]
226 pub selector: ::prost::alloc::string::String,
227 /// The name of the request field whose value is mapped to the HTTP body, or
228 /// `*` for mapping all fields not captured by the path pattern to the HTTP
229 /// body. NOTE: the referred field must not be a repeated field and must be
230 /// present at the top-level of request message type.
231 #[prost(string, tag = "7")]
232 pub body: ::prost::alloc::string::String,
233 /// Additional HTTP bindings for the selector. Nested bindings must
234 /// not contain an `additional_bindings` field themselves (that is,
235 /// the nesting may only be one level deep).
236 #[prost(message, repeated, tag = "11")]
237 pub additional_bindings: ::prost::alloc::vec::Vec<HttpRule>,
238 /// Determines the URL pattern is matched by this rules. This pattern can be
239 /// used with any of the {get|put|post|delete|patch} methods. A custom method
240 /// can be defined using the 'custom' field.
241 #[prost(oneof = "http_rule::Pattern", tags = "2, 3, 4, 5, 6, 8")]
242 pub pattern: ::core::option::Option<http_rule::Pattern>,
243}
244/// Nested message and enum types in `HttpRule`.
245pub mod http_rule {
246 /// Determines the URL pattern is matched by this rules. This pattern can be
247 /// used with any of the {get|put|post|delete|patch} methods. A custom method
248 /// can be defined using the 'custom' field.
249 #[allow(clippy::derive_partial_eq_without_eq)]
250 #[derive(Clone, PartialEq, ::prost::Oneof)]
251 pub enum Pattern {
252 /// Used for listing and getting information about resources.
253 #[prost(string, tag = "2")]
254 Get(::prost::alloc::string::String),
255 /// Used for updating a resource.
256 #[prost(string, tag = "3")]
257 Put(::prost::alloc::string::String),
258 /// Used for creating a resource.
259 #[prost(string, tag = "4")]
260 Post(::prost::alloc::string::String),
261 /// Used for deleting a resource.
262 #[prost(string, tag = "5")]
263 Delete(::prost::alloc::string::String),
264 /// Used for updating a resource.
265 #[prost(string, tag = "6")]
266 Patch(::prost::alloc::string::String),
267 /// Custom pattern is used for defining custom verbs.
268 #[prost(message, tag = "8")]
269 Custom(super::CustomHttpPattern),
270 }
271}
272/// A custom pattern is used for defining custom HTTP verb.
273#[allow(clippy::derive_partial_eq_without_eq)]
274#[derive(Clone, PartialEq, ::prost::Message)]
275pub struct CustomHttpPattern {
276 /// The name of this custom HTTP verb.
277 #[prost(string, tag = "1")]
278 pub kind: ::prost::alloc::string::String,
279 /// The path matched by this custom verb.
280 #[prost(string, tag = "2")]
281 pub path: ::prost::alloc::string::String,
282}