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