1// Copyright 2023 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15syntax = "proto3"; 16 17package google.cloud.networkservices.v1; 18 19import "google/api/field_behavior.proto"; 20import "google/api/resource.proto"; 21import "google/protobuf/duration.proto"; 22import "google/protobuf/field_mask.proto"; 23import "google/protobuf/timestamp.proto"; 24 25option csharp_namespace = "Google.Cloud.NetworkServices.V1"; 26option go_package = "cloud.google.com/go/networkservices/apiv1/networkservicespb;networkservicespb"; 27option java_multiple_files = true; 28option java_outer_classname = "HttpRouteProto"; 29option java_package = "com.google.cloud.networkservices.v1"; 30option php_namespace = "Google\\Cloud\\NetworkServices\\V1"; 31option ruby_package = "Google::Cloud::NetworkServices::V1"; 32 33// HttpRoute is the resource defining how HTTP traffic should be routed by a 34// Mesh or Gateway resource. 35message HttpRoute { 36 option (google.api.resource) = { 37 type: "networkservices.googleapis.com/HttpRoute" 38 pattern: "projects/{project}/locations/{location}/httpRoutes/{http_route}" 39 }; 40 41 // Specifies how to select a route rule based on HTTP request headers. 42 message HeaderMatch { 43 // Represents an integer value range. 44 message IntegerRange { 45 // Start of the range (inclusive) 46 int32 start = 1; 47 48 // End of the range (exclusive) 49 int32 end = 2; 50 } 51 52 oneof MatchType { 53 // The value of the header should match exactly the content of 54 // exact_match. 55 string exact_match = 2; 56 57 // The value of the header must match the regular expression specified in 58 // regex_match. For regular expression grammar, please see: 59 // https://github.com/google/re2/wiki/Syntax 60 string regex_match = 3; 61 62 // The value of the header must start with the contents of prefix_match. 63 string prefix_match = 4; 64 65 // A header with header_name must exist. The match takes place whether or 66 // not the header has a value. 67 bool present_match = 5; 68 69 // The value of the header must end with the contents of suffix_match. 70 string suffix_match = 6; 71 72 // If specified, the rule will match if the request header value is within 73 // the range. 74 IntegerRange range_match = 7; 75 } 76 77 // The name of the HTTP header to match against. 78 string header = 1; 79 80 // If specified, the match result will be inverted before checking. Default 81 // value is set to false. 82 bool invert_match = 8; 83 } 84 85 // Specifications to match a query parameter in the request. 86 message QueryParameterMatch { 87 oneof MatchType { 88 // The value of the query parameter must exactly match the contents of 89 // exact_match. 90 // 91 // Only one of exact_match, regex_match, or present_match must be set. 92 string exact_match = 2; 93 94 // The value of the query parameter must match the regular expression 95 // specified by regex_match. For regular expression grammar, please see 96 // https://github.com/google/re2/wiki/Syntax 97 // 98 // Only one of exact_match, regex_match, or present_match must be set. 99 string regex_match = 3; 100 101 // Specifies that the QueryParameterMatcher matches if request contains 102 // query parameter, irrespective of whether the parameter has a value or 103 // not. 104 // 105 // Only one of exact_match, regex_match, or present_match must be set. 106 bool present_match = 4; 107 } 108 109 // The name of the query parameter to match. 110 string query_parameter = 1; 111 } 112 113 // RouteMatch defines specifications used to match requests. If multiple match 114 // types are set, this RouteMatch will match if ALL type of matches are 115 // matched. 116 message RouteMatch { 117 oneof PathMatch { 118 // The HTTP request path value should exactly match this value. 119 // 120 // Only one of full_path_match, prefix_match, or regex_match should be 121 // used. 122 string full_path_match = 1; 123 124 // The HTTP request path value must begin with specified prefix_match. 125 // prefix_match must begin with a /. 126 // 127 // Only one of full_path_match, prefix_match, or regex_match should be 128 // used. 129 string prefix_match = 2; 130 131 // The HTTP request path value must satisfy the regular expression 132 // specified by regex_match after removing any query parameters and anchor 133 // supplied with the original URL. For regular expression grammar, please 134 // see https://github.com/google/re2/wiki/Syntax 135 // 136 // Only one of full_path_match, prefix_match, or regex_match should be 137 // used. 138 string regex_match = 3; 139 } 140 141 // Specifies if prefix_match and full_path_match matches are case sensitive. 142 // The default value is false. 143 bool ignore_case = 4; 144 145 // Specifies a list of HTTP request headers to match against. ALL of the 146 // supplied headers must be matched. 147 repeated HeaderMatch headers = 5; 148 149 // Specifies a list of query parameters to match against. ALL of the query 150 // parameters must be matched. 151 repeated QueryParameterMatch query_parameters = 6; 152 } 153 154 // Specifications of a destination to which the request should be routed to. 155 message Destination { 156 // The URL of a BackendService to route traffic to. 157 string service_name = 1 [(google.api.resource_reference) = { 158 type: "compute.googleapis.com/BackendService" 159 }]; 160 161 // Specifies the proportion of requests forwarded to the backend referenced 162 // by the serviceName field. This is computed as: 163 // - weight/Sum(weights in this destination list). 164 // For non-zero values, there may be some epsilon from the exact proportion 165 // defined here depending on the precision an implementation supports. 166 // 167 // If only one serviceName is specified and it has a weight greater than 0, 168 // 100% of the traffic is forwarded to that backend. 169 // 170 // If weights are specified for any one service name, they need to be 171 // specified for all of them. 172 // 173 // If weights are unspecified for all services, then, traffic is distributed 174 // in equal proportions to all of them. 175 int32 weight = 2; 176 } 177 178 // The specification for redirecting traffic. 179 message Redirect { 180 // Supported HTTP response code. 181 enum ResponseCode { 182 // Default value 183 RESPONSE_CODE_UNSPECIFIED = 0; 184 185 // Corresponds to 301. 186 MOVED_PERMANENTLY_DEFAULT = 1; 187 188 // Corresponds to 302. 189 FOUND = 2; 190 191 // Corresponds to 303. 192 SEE_OTHER = 3; 193 194 // Corresponds to 307. In this case, the request method will be retained. 195 TEMPORARY_REDIRECT = 4; 196 197 // Corresponds to 308. In this case, the request method will be retained. 198 PERMANENT_REDIRECT = 5; 199 } 200 201 // The host that will be used in the redirect response instead of the one 202 // that was supplied in the request. 203 string host_redirect = 1; 204 205 // The path that will be used in the redirect response instead of the one 206 // that was supplied in the request. 207 // path_redirect can not be supplied together with prefix_redirect. Supply 208 // one alone or neither. If neither is supplied, the path of the original 209 // request will be used for the redirect. 210 string path_redirect = 2; 211 212 // Indicates that during redirection, the matched prefix (or path) should be 213 // swapped with this value. This option allows URLs be dynamically created 214 // based on the request. 215 string prefix_rewrite = 3; 216 217 // The HTTP Status code to use for the redirect. 218 ResponseCode response_code = 4; 219 220 // If set to true, the URL scheme in the redirected request is set to https. 221 // If set to false, the URL scheme of the redirected request will remain the 222 // same as that of the request. 223 // 224 // The default is set to false. 225 bool https_redirect = 5; 226 227 // if set to true, any accompanying query portion of the original URL is 228 // removed prior to redirecting the request. If set to false, the query 229 // portion of the original URL is retained. 230 // 231 // The default is set to false. 232 bool strip_query = 6; 233 234 // The port that will be used in the redirected request instead of the one 235 // that was supplied in the request. 236 int32 port_redirect = 7; 237 } 238 239 // The specification for fault injection introduced into traffic to test the 240 // resiliency of clients to destination service failure. As part of fault 241 // injection, when clients send requests to a destination, delays can be 242 // introduced by client proxy on a percentage of requests before sending those 243 // requests to the destination service. Similarly requests can be aborted by 244 // client proxy for a percentage of requests. 245 message FaultInjectionPolicy { 246 // Specification of how client requests are delayed as part of fault 247 // injection before being sent to a destination. 248 message Delay { 249 // Specify a fixed delay before forwarding the request. 250 google.protobuf.Duration fixed_delay = 1; 251 252 // The percentage of traffic on which delay will be injected. 253 // 254 // The value must be between [0, 100] 255 int32 percentage = 2; 256 } 257 258 // Specification of how client requests are aborted as part of fault 259 // injection before being sent to a destination. 260 message Abort { 261 // The HTTP status code used to abort the request. 262 // 263 // The value must be between 200 and 599 inclusive. 264 int32 http_status = 1; 265 266 // The percentage of traffic which will be aborted. 267 // 268 // The value must be between [0, 100] 269 int32 percentage = 2; 270 } 271 272 // The specification for injecting delay to client requests. 273 Delay delay = 1; 274 275 // The specification for aborting to client requests. 276 Abort abort = 2; 277 } 278 279 // The specification for modifying HTTP header in HTTP request and HTTP 280 // response. 281 message HeaderModifier { 282 // Completely overwrite/replace the headers with given map where key is the 283 // name of the header, value is the value of the header. 284 map<string, string> set = 1; 285 286 // Add the headers with given map where key is the name of the header, value 287 // is the value of the header. 288 map<string, string> add = 2; 289 290 // Remove headers (matching by header names) specified in the list. 291 repeated string remove = 3; 292 } 293 294 // The specification for modifying the URL of the request, prior to forwarding 295 // the request to the destination. 296 message URLRewrite { 297 // Prior to forwarding the request to the selected destination, the matching 298 // portion of the requests path is replaced by this value. 299 string path_prefix_rewrite = 1; 300 301 // Prior to forwarding the request to the selected destination, the requests 302 // host header is replaced by this value. 303 string host_rewrite = 2; 304 } 305 306 // The specifications for retries. 307 message RetryPolicy { 308 // Specifies one or more conditions when this retry policy applies. Valid 309 // values are: 310 // 5xx: Proxy will attempt a retry if the destination service responds 311 // with any 5xx response code, of if the destination service does not 312 // respond at all, example: disconnect, reset, read timeout, connection 313 // failure and refused streams. 314 // 315 // gateway-error: Similar to 5xx, but only applies to response codes 502, 316 // 503, 504. 317 // 318 // reset: Proxy will attempt a retry if the destination service does not 319 // respond at all (disconnect/reset/read timeout) 320 // 321 // connect-failure: Proxy will retry on failures connecting to destination 322 // for example due to connection timeouts. 323 // 324 // retriable-4xx: Proxy will retry fro retriable 4xx response codes. 325 // Currently the only retriable error supported is 409. 326 // 327 // refused-stream: Proxy will retry if the destination resets the stream 328 // with a REFUSED_STREAM error code. This reset type indicates that it 329 // is safe to retry. 330 repeated string retry_conditions = 1; 331 332 // Specifies the allowed number of retries. This number must be > 0. If not 333 // specified, default to 1. 334 int32 num_retries = 2; 335 336 // Specifies a non-zero timeout per retry attempt. 337 google.protobuf.Duration per_try_timeout = 3; 338 } 339 340 // Specifies the policy on how requests are shadowed to a separate mirrored 341 // destination service. The proxy does not wait for responses from the 342 // shadow service. Prior to sending traffic to the shadow service, the 343 // host/authority header is suffixed with -shadow. 344 message RequestMirrorPolicy { 345 // The destination the requests will be mirrored to. The weight of the 346 // destination will be ignored. 347 Destination destination = 1; 348 } 349 350 // The Specification for allowing client side cross-origin requests. 351 message CorsPolicy { 352 // Specifies the list of origins that will be allowed to do CORS requests. 353 // An origin is allowed if it matches either an item in allow_origins or 354 // an item in allow_origin_regexes. 355 repeated string allow_origins = 1; 356 357 // Specifies the regular expression patterns that match allowed origins. For 358 // regular expression grammar, please see 359 // https://github.com/google/re2/wiki/Syntax. 360 repeated string allow_origin_regexes = 2; 361 362 // Specifies the content for Access-Control-Allow-Methods header. 363 repeated string allow_methods = 3; 364 365 // Specifies the content for Access-Control-Allow-Headers header. 366 repeated string allow_headers = 4; 367 368 // Specifies the content for Access-Control-Expose-Headers header. 369 repeated string expose_headers = 5; 370 371 // Specifies how long result of a preflight request can be cached in 372 // seconds. This translates to the Access-Control-Max-Age header. 373 string max_age = 6; 374 375 // In response to a preflight request, setting this to true indicates that 376 // the actual request can include user credentials. This translates to the 377 // Access-Control-Allow-Credentials header. 378 // 379 // Default value is false. 380 bool allow_credentials = 7; 381 382 // If true, the CORS policy is disabled. The default value is false, which 383 // indicates that the CORS policy is in effect. 384 bool disabled = 8; 385 } 386 387 // The specifications for routing traffic and applying associated policies. 388 message RouteAction { 389 // The destination to which traffic should be forwarded. 390 repeated Destination destinations = 1; 391 392 // If set, the request is directed as configured by this field. 393 Redirect redirect = 2; 394 395 // The specification for fault injection introduced into traffic to test the 396 // resiliency of clients to backend service failure. As part of fault 397 // injection, when clients send requests to a backend service, delays can be 398 // introduced on a percentage of requests before sending those requests to 399 // the backend service. Similarly requests from clients can be aborted for a 400 // percentage of requests. 401 // 402 // timeout and retry_policy will be ignored by clients that are configured 403 // with a fault_injection_policy 404 FaultInjectionPolicy fault_injection_policy = 4; 405 406 // The specification for modifying the headers of a matching request prior 407 // to delivery of the request to the destination. If HeaderModifiers are set 408 // on both the Destination and the RouteAction, they will be merged. 409 // Conflicts between the two will not be resolved on the configuration. 410 HeaderModifier request_header_modifier = 5; 411 412 // The specification for modifying the headers of a response prior to 413 // sending the response back to the client. If HeaderModifiers are set 414 // on both the Destination and the RouteAction, they will be merged. 415 // Conflicts between the two will not be resolved on the configuration. 416 HeaderModifier response_header_modifier = 6; 417 418 // The specification for rewrite URL before forwarding requests to the 419 // destination. 420 URLRewrite url_rewrite = 7; 421 422 // Specifies the timeout for selected route. Timeout is computed from the 423 // time the request has been fully processed (i.e. end of stream) up until 424 // the response has been completely processed. Timeout includes all retries. 425 google.protobuf.Duration timeout = 8; 426 427 // Specifies the retry policy associated with this route. 428 RetryPolicy retry_policy = 9; 429 430 // Specifies the policy on how requests intended for the routes destination 431 // are shadowed to a separate mirrored destination. Proxy will not wait for 432 // the shadow destination to respond before returning the response. Prior to 433 // sending traffic to the shadow service, the host/authority header is 434 // suffixed with -shadow. 435 RequestMirrorPolicy request_mirror_policy = 10; 436 437 // The specification for allowing client side cross-origin requests. 438 CorsPolicy cors_policy = 11; 439 } 440 441 // Specifies how to match traffic and how to route traffic when traffic is 442 // matched. 443 message RouteRule { 444 // A list of matches define conditions used for matching the rule against 445 // incoming HTTP requests. Each match is independent, i.e. this rule will be 446 // matched if ANY one of the matches is satisfied. 447 // 448 // If no matches field is specified, this rule will unconditionally match 449 // traffic. 450 // 451 // If a default rule is desired to be configured, add a rule with no matches 452 // specified to the end of the rules list. 453 repeated RouteMatch matches = 1; 454 455 // The detailed rule defining how to route matched traffic. 456 RouteAction action = 2; 457 } 458 459 // Required. Name of the HttpRoute resource. It matches pattern 460 // `projects/*/locations/global/httpRoutes/http_route_name>`. 461 string name = 1 [(google.api.field_behavior) = REQUIRED]; 462 463 // Output only. Server-defined URL of this resource 464 string self_link = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; 465 466 // Optional. A free-text description of the resource. Max length 1024 467 // characters. 468 string description = 2 [(google.api.field_behavior) = OPTIONAL]; 469 470 // Output only. The timestamp when the resource was created. 471 google.protobuf.Timestamp create_time = 3 472 [(google.api.field_behavior) = OUTPUT_ONLY]; 473 474 // Output only. The timestamp when the resource was updated. 475 google.protobuf.Timestamp update_time = 4 476 [(google.api.field_behavior) = OUTPUT_ONLY]; 477 478 // Required. Hostnames define a set of hosts that should match against the 479 // HTTP host header to select a HttpRoute to process the request. Hostname is 480 // the fully qualified domain name of a network host, as defined by RFC 1123 481 // with the exception that: 482 // - IPs are not allowed. 483 // - A hostname may be prefixed with a wildcard label (`*.`). The wildcard 484 // label must appear by itself as the first label. 485 // 486 // Hostname can be "precise" which is a domain name without the terminating 487 // dot of a network host (e.g. `foo.example.com`) or "wildcard", which is a 488 // domain name prefixed with a single wildcard label (e.g. `*.example.com`). 489 // 490 // Note that as per RFC1035 and RFC1123, a label must consist of lower case 491 // alphanumeric characters or '-', and must start and end with an alphanumeric 492 // character. No other punctuation is allowed. 493 // 494 // The routes associated with a Mesh or Gateways must have unique hostnames. 495 // If you attempt to attach multiple routes with conflicting hostnames, 496 // the configuration will be rejected. 497 // 498 // For example, while it is acceptable for routes for the hostnames 499 // `*.foo.bar.com` and `*.bar.com` to be associated with the same Mesh (or 500 // Gateways under the same scope), it is not possible to associate two routes 501 // both with `*.bar.com` or both with `bar.com`. 502 repeated string hostnames = 5 [(google.api.field_behavior) = REQUIRED]; 503 504 // Optional. Meshes defines a list of meshes this HttpRoute is attached to, as 505 // one of the routing rules to route the requests served by the mesh. 506 // 507 // Each mesh reference should match the pattern: 508 // `projects/*/locations/global/meshes/<mesh_name>` 509 // 510 // The attached Mesh should be of a type SIDECAR 511 repeated string meshes = 8 [ 512 (google.api.field_behavior) = OPTIONAL, 513 (google.api.resource_reference) = { 514 type: "networkservices.googleapis.com/Mesh" 515 } 516 ]; 517 518 // Optional. Gateways defines a list of gateways this HttpRoute is attached 519 // to, as one of the routing rules to route the requests served by the 520 // gateway. 521 // 522 // Each gateway reference should match the pattern: 523 // `projects/*/locations/global/gateways/<gateway_name>` 524 repeated string gateways = 9 [ 525 (google.api.field_behavior) = OPTIONAL, 526 (google.api.resource_reference) = { 527 type: "networkservices.googleapis.com/Gateway" 528 } 529 ]; 530 531 // Optional. Set of label tags associated with the HttpRoute resource. 532 map<string, string> labels = 10 [(google.api.field_behavior) = OPTIONAL]; 533 534 // Required. Rules that define how traffic is routed and handled. 535 // Rules will be matched sequentially based on the RouteMatch specified for 536 // the rule. 537 repeated RouteRule rules = 6 [(google.api.field_behavior) = REQUIRED]; 538} 539 540// Request used with the ListHttpRoutes method. 541message ListHttpRoutesRequest { 542 // Required. The project and location from which the HttpRoutes should be 543 // listed, specified in the format `projects/*/locations/global`. 544 string parent = 1 [ 545 (google.api.field_behavior) = REQUIRED, 546 (google.api.resource_reference) = { 547 child_type: "networkservices.googleapis.com/HttpRoute" 548 } 549 ]; 550 551 // Maximum number of HttpRoutes to return per call. 552 int32 page_size = 2; 553 554 // The value returned by the last `ListHttpRoutesResponse` 555 // Indicates that this is a continuation of a prior `ListHttpRoutes` call, 556 // and that the system should return the next page of data. 557 string page_token = 3; 558} 559 560// Response returned by the ListHttpRoutes method. 561message ListHttpRoutesResponse { 562 // List of HttpRoute resources. 563 repeated HttpRoute http_routes = 1; 564 565 // If there might be more results than those appearing in this response, then 566 // `next_page_token` is included. To get the next set of results, call this 567 // method again using the value of `next_page_token` as `page_token`. 568 string next_page_token = 2; 569} 570 571// Request used by the GetHttpRoute method. 572message GetHttpRouteRequest { 573 // Required. A name of the HttpRoute to get. Must be in the format 574 // `projects/*/locations/global/httpRoutes/*`. 575 string name = 1 [ 576 (google.api.field_behavior) = REQUIRED, 577 (google.api.resource_reference) = { 578 type: "networkservices.googleapis.com/HttpRoute" 579 } 580 ]; 581} 582 583// Request used by the HttpRoute method. 584message CreateHttpRouteRequest { 585 // Required. The parent resource of the HttpRoute. Must be in the 586 // format `projects/*/locations/global`. 587 string parent = 1 [ 588 (google.api.field_behavior) = REQUIRED, 589 (google.api.resource_reference) = { 590 child_type: "networkservices.googleapis.com/HttpRoute" 591 } 592 ]; 593 594 // Required. Short name of the HttpRoute resource to be created. 595 string http_route_id = 2 [(google.api.field_behavior) = REQUIRED]; 596 597 // Required. HttpRoute resource to be created. 598 HttpRoute http_route = 3 [(google.api.field_behavior) = REQUIRED]; 599} 600 601// Request used by the UpdateHttpRoute method. 602message UpdateHttpRouteRequest { 603 // Optional. Field mask is used to specify the fields to be overwritten in the 604 // HttpRoute resource by the update. 605 // The fields specified in the update_mask are relative to the resource, not 606 // the full request. A field will be overwritten if it is in the mask. If the 607 // user does not provide a mask then all fields will be overwritten. 608 google.protobuf.FieldMask update_mask = 1 609 [(google.api.field_behavior) = OPTIONAL]; 610 611 // Required. Updated HttpRoute resource. 612 HttpRoute http_route = 2 [(google.api.field_behavior) = REQUIRED]; 613} 614 615// Request used by the DeleteHttpRoute method. 616message DeleteHttpRouteRequest { 617 // Required. A name of the HttpRoute to delete. Must be in the format 618 // `projects/*/locations/global/httpRoutes/*`. 619 string name = 1 [ 620 (google.api.field_behavior) = REQUIRED, 621 (google.api.resource_reference) = { 622 type: "networkservices.googleapis.com/HttpRoute" 623 } 624 ]; 625} 626