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 = "GrpcRouteProto"; 29option java_package = "com.google.cloud.networkservices.v1"; 30option php_namespace = "Google\\Cloud\\NetworkServices\\V1"; 31option ruby_package = "Google::Cloud::NetworkServices::V1"; 32 33// GrpcRoute is the resource defining how gRPC traffic routed by a Mesh 34// or Gateway resource is routed. 35message GrpcRoute { 36 option (google.api.resource) = { 37 type: "networkservices.googleapis.com/GrpcRoute" 38 pattern: "projects/{project}/locations/{location}/grpcRoutes/{grpc_route}" 39 }; 40 41 // Specifies a match against a method. 42 message MethodMatch { 43 // The type of the match. 44 enum Type { 45 // Unspecified. 46 TYPE_UNSPECIFIED = 0; 47 48 // Will only match the exact name provided. 49 EXACT = 1; 50 51 // Will interpret grpc_method and grpc_service as regexes. RE2 syntax is 52 // supported. 53 REGULAR_EXPRESSION = 2; 54 } 55 56 // Optional. Specifies how to match against the name. If not specified, a 57 // default value of "EXACT" is used. 58 Type type = 1 [(google.api.field_behavior) = OPTIONAL]; 59 60 // Required. Name of the service to match against. If unspecified, will 61 // match all services. 62 string grpc_service = 2 [(google.api.field_behavior) = REQUIRED]; 63 64 // Required. Name of the method to match against. If unspecified, will match 65 // all methods. 66 string grpc_method = 3 [(google.api.field_behavior) = REQUIRED]; 67 68 // Optional. Specifies that matches are case sensitive. The default value 69 // is true. case_sensitive must not be used with a type of 70 // REGULAR_EXPRESSION. 71 optional bool case_sensitive = 4 [(google.api.field_behavior) = OPTIONAL]; 72 } 73 74 // A match against a collection of headers. 75 message HeaderMatch { 76 // The type of match. 77 enum Type { 78 // Unspecified. 79 TYPE_UNSPECIFIED = 0; 80 81 // Will only match the exact value provided. 82 EXACT = 1; 83 84 // Will match paths conforming to the prefix specified by value. RE2 85 // syntax is supported. 86 REGULAR_EXPRESSION = 2; 87 } 88 89 // Optional. Specifies how to match against the value of the header. If not 90 // specified, a default value of EXACT is used. 91 Type type = 1 [(google.api.field_behavior) = OPTIONAL]; 92 93 // Required. The key of the header. 94 string key = 2 [(google.api.field_behavior) = REQUIRED]; 95 96 // Required. The value of the header. 97 string value = 3 [(google.api.field_behavior) = REQUIRED]; 98 } 99 100 // Criteria for matching traffic. A RouteMatch will be considered to match 101 // when all supplied fields match. 102 message RouteMatch { 103 // Optional. A gRPC method to match against. If this field is empty or 104 // omitted, will match all methods. 105 optional MethodMatch method = 1 [(google.api.field_behavior) = OPTIONAL]; 106 107 // Optional. Specifies a collection of headers to match. 108 repeated HeaderMatch headers = 2 [(google.api.field_behavior) = OPTIONAL]; 109 } 110 111 // The destination to which traffic will be routed. 112 message Destination { 113 // Specifies the kind of destination to which traffic will be routed. 114 oneof destination_type { 115 // Required. The URL of a destination service to which to route traffic. 116 // Must refer to either a BackendService or ServiceDirectoryService. 117 string service_name = 1 [ 118 (google.api.field_behavior) = REQUIRED, 119 (google.api.resource_reference) = { 120 type: "compute.googleapis.com/BackendService" 121 } 122 ]; 123 } 124 125 // Optional. Specifies the proportion of requests forwarded to the backend 126 // referenced by the serviceName field. This is computed as: 127 // - weight/Sum(weights in this destination list). 128 // For non-zero values, there may be some epsilon from the exact proportion 129 // defined here depending on the precision an implementation supports. 130 // 131 // If only one serviceName is specified and it has a weight greater than 0, 132 // 100% of the traffic is forwarded to that backend. 133 // 134 // If weights are specified for any one service name, they need to be 135 // specified for all of them. 136 // 137 // If weights are unspecified for all services, then, traffic is distributed 138 // in equal proportions to all of them. 139 optional int32 weight = 2 [(google.api.field_behavior) = OPTIONAL]; 140 } 141 142 // The specification for fault injection introduced into traffic to test the 143 // resiliency of clients to destination service failure. As part of fault 144 // injection, when clients send requests to a destination, delays can be 145 // introduced on a percentage of requests before sending those requests to the 146 // destination service. Similarly requests from clients can be aborted by for 147 // a percentage of requests. 148 message FaultInjectionPolicy { 149 // Specification of how client requests are delayed as part of fault 150 // injection before being sent to a destination. 151 message Delay { 152 // Specify a fixed delay before forwarding the request. 153 optional google.protobuf.Duration fixed_delay = 1; 154 155 // The percentage of traffic on which delay will be injected. 156 // 157 // The value must be between [0, 100] 158 optional int32 percentage = 2; 159 } 160 161 // Specification of how client requests are aborted as part of fault 162 // injection before being sent to a destination. 163 message Abort { 164 // The HTTP status code used to abort the request. 165 // 166 // The value must be between 200 and 599 inclusive. 167 optional int32 http_status = 1; 168 169 // The percentage of traffic which will be aborted. 170 // 171 // The value must be between [0, 100] 172 optional int32 percentage = 2; 173 } 174 175 // The specification for injecting delay to client requests. 176 optional Delay delay = 1; 177 178 // The specification for aborting to client requests. 179 optional Abort abort = 2; 180 } 181 182 // The specifications for retries. 183 message RetryPolicy { 184 // - connect-failure: Router will retry on failures connecting to Backend 185 // Services, for example due to connection timeouts. 186 // - refused-stream: Router will retry if the backend service resets the 187 // stream 188 // with a REFUSED_STREAM error code. This reset type indicates that it is 189 // safe to retry. 190 // - cancelled: Router will retry if the gRPC status code in the response 191 // header 192 // is set to cancelled 193 // - deadline-exceeded: Router will retry if the gRPC status code in the 194 // response 195 // header is set to deadline-exceeded 196 // - resource-exhausted: Router will retry if the gRPC status code in the 197 // response header is set to resource-exhausted 198 // - unavailable: Router will retry if the gRPC status code in the response 199 // header is set to unavailable 200 repeated string retry_conditions = 1; 201 202 // Specifies the allowed number of retries. This number must be > 0. If not 203 // specified, default to 1. 204 uint32 num_retries = 2; 205 } 206 207 // Specifies how to route matched traffic. 208 message RouteAction { 209 // Optional. The destination services to which traffic should be forwarded. 210 // If multiple destinations are specified, traffic will be split between 211 // Backend Service(s) according to the weight field of these destinations. 212 repeated Destination destinations = 1 213 [(google.api.field_behavior) = OPTIONAL]; 214 215 // Optional. The specification for fault injection introduced into traffic to test the 216 // resiliency of clients to destination service failure. As part of fault 217 // injection, when clients send requests to a destination, delays can be 218 // introduced on a percentage of requests before sending those requests to 219 // the destination service. Similarly requests from clients can be aborted 220 // by for a percentage of requests. 221 // 222 // timeout and retry_policy will be ignored by clients that are configured 223 // with a fault_injection_policy 224 FaultInjectionPolicy fault_injection_policy = 3 225 [(google.api.field_behavior) = OPTIONAL]; 226 227 // Optional. Specifies the timeout for selected route. Timeout is computed 228 // from the time the request has been fully processed (i.e. end of stream) 229 // up until the response has been completely processed. Timeout includes all 230 // retries. 231 google.protobuf.Duration timeout = 7 232 [(google.api.field_behavior) = OPTIONAL]; 233 234 // Optional. Specifies the retry policy associated with this route. 235 RetryPolicy retry_policy = 8 [(google.api.field_behavior) = OPTIONAL]; 236 } 237 238 // Describes how to route traffic. 239 message RouteRule { 240 // Optional. Matches define conditions used for matching the rule against 241 // incoming gRPC requests. Each match is independent, i.e. this rule will be 242 // matched if ANY one of the matches is satisfied. If no matches field is 243 // specified, this rule will unconditionally match traffic. 244 repeated RouteMatch matches = 1 [(google.api.field_behavior) = OPTIONAL]; 245 246 // Required. A detailed rule defining how to route traffic. This field is 247 // required. 248 RouteAction action = 2 [(google.api.field_behavior) = REQUIRED]; 249 } 250 251 // Required. Name of the GrpcRoute resource. It matches pattern 252 // `projects/*/locations/global/grpcRoutes/<grpc_route_name>` 253 string name = 1 [(google.api.field_behavior) = REQUIRED]; 254 255 // Output only. Server-defined URL of this resource 256 string self_link = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; 257 258 // Output only. The timestamp when the resource was created. 259 google.protobuf.Timestamp create_time = 2 260 [(google.api.field_behavior) = OUTPUT_ONLY]; 261 262 // Output only. The timestamp when the resource was updated. 263 google.protobuf.Timestamp update_time = 3 264 [(google.api.field_behavior) = OUTPUT_ONLY]; 265 266 // Optional. Set of label tags associated with the GrpcRoute resource. 267 map<string, string> labels = 4 [(google.api.field_behavior) = OPTIONAL]; 268 269 // Optional. A free-text description of the resource. Max length 1024 270 // characters. 271 string description = 5 [(google.api.field_behavior) = OPTIONAL]; 272 273 // Required. Service hostnames with an optional port for which this route 274 // describes traffic. 275 // 276 // Format: <hostname>[:<port>] 277 // 278 // Hostname is the fully qualified domain name of a network host. This matches 279 // the RFC 1123 definition of a hostname with 2 notable exceptions: 280 // - IPs are not allowed. 281 // - A hostname may be prefixed with a wildcard label (`*.`). The wildcard 282 // label must appear by itself as the first label. 283 // 284 // Hostname can be "precise" which is a domain name without the terminating 285 // dot of a network host (e.g. `foo.example.com`) or "wildcard", which is a 286 // domain name prefixed with a single wildcard label (e.g. `*.example.com`). 287 // 288 // Note that as per RFC1035 and RFC1123, a label must consist of lower case 289 // alphanumeric characters or '-', and must start and end with an alphanumeric 290 // character. No other punctuation is allowed. 291 // 292 // The routes associated with a Mesh or Gateway must have unique hostnames. If 293 // you attempt to attach multiple routes with conflicting hostnames, the 294 // configuration will be rejected. 295 // 296 // For example, while it is acceptable for routes for the hostnames 297 // `*.foo.bar.com` and `*.bar.com` to be associated with the same route, it is 298 // not possible to associate two routes both with `*.bar.com` or both with 299 // `bar.com`. 300 // 301 // If a port is specified, then gRPC clients must use the channel URI with the 302 // port to match this rule (i.e. "xds:///service:123"), otherwise they must 303 // supply the URI without a port (i.e. "xds:///service"). 304 repeated string hostnames = 6 [(google.api.field_behavior) = REQUIRED]; 305 306 // Optional. Meshes defines a list of meshes this GrpcRoute is attached to, as 307 // one of the routing rules to route the requests served by the mesh. 308 // 309 // Each mesh reference should match the pattern: 310 // `projects/*/locations/global/meshes/<mesh_name>` 311 repeated string meshes = 9 [ 312 (google.api.field_behavior) = OPTIONAL, 313 (google.api.resource_reference) = { 314 type: "networkservices.googleapis.com/Mesh" 315 } 316 ]; 317 318 // Optional. Gateways defines a list of gateways this GrpcRoute is attached 319 // to, as one of the routing rules to route the requests served by the 320 // gateway. 321 // 322 // Each gateway reference should match the pattern: 323 // `projects/*/locations/global/gateways/<gateway_name>` 324 repeated string gateways = 10 [ 325 (google.api.field_behavior) = OPTIONAL, 326 (google.api.resource_reference) = { 327 type: "networkservices.googleapis.com/Gateway" 328 } 329 ]; 330 331 // Required. A list of detailed rules defining how to route traffic. 332 // 333 // Within a single GrpcRoute, the GrpcRoute.RouteAction associated with the 334 // first matching GrpcRoute.RouteRule will be executed. At least one rule 335 // must be supplied. 336 repeated RouteRule rules = 7 [(google.api.field_behavior) = REQUIRED]; 337} 338 339// Request used with the ListGrpcRoutes method. 340message ListGrpcRoutesRequest { 341 // Required. The project and location from which the GrpcRoutes should be 342 // listed, specified in the format `projects/*/locations/global`. 343 string parent = 1 [ 344 (google.api.field_behavior) = REQUIRED, 345 (google.api.resource_reference) = { 346 child_type: "networkservices.googleapis.com/GrpcRoute" 347 } 348 ]; 349 350 // Maximum number of GrpcRoutes to return per call. 351 int32 page_size = 2; 352 353 // The value returned by the last `ListGrpcRoutesResponse` 354 // Indicates that this is a continuation of a prior `ListGrpcRoutes` call, 355 // and that the system should return the next page of data. 356 string page_token = 3; 357} 358 359// Response returned by the ListGrpcRoutes method. 360message ListGrpcRoutesResponse { 361 // List of GrpcRoute resources. 362 repeated GrpcRoute grpc_routes = 1; 363 364 // If there might be more results than those appearing in this response, then 365 // `next_page_token` is included. To get the next set of results, call this 366 // method again using the value of `next_page_token` as `page_token`. 367 string next_page_token = 2; 368} 369 370// Request used by the GetGrpcRoute method. 371message GetGrpcRouteRequest { 372 // Required. A name of the GrpcRoute to get. Must be in the format 373 // `projects/*/locations/global/grpcRoutes/*`. 374 string name = 1 [ 375 (google.api.field_behavior) = REQUIRED, 376 (google.api.resource_reference) = { 377 type: "networkservices.googleapis.com/GrpcRoute" 378 } 379 ]; 380} 381 382// Request used by the CreateGrpcRoute method. 383message CreateGrpcRouteRequest { 384 // Required. The parent resource of the GrpcRoute. Must be in the 385 // format `projects/*/locations/global`. 386 string parent = 1 [ 387 (google.api.field_behavior) = REQUIRED, 388 (google.api.resource_reference) = { 389 child_type: "networkservices.googleapis.com/GrpcRoute" 390 } 391 ]; 392 393 // Required. Short name of the GrpcRoute resource to be created. 394 string grpc_route_id = 2 [(google.api.field_behavior) = REQUIRED]; 395 396 // Required. GrpcRoute resource to be created. 397 GrpcRoute grpc_route = 3 [(google.api.field_behavior) = REQUIRED]; 398} 399 400// Request used by the UpdateGrpcRoute method. 401message UpdateGrpcRouteRequest { 402 // Optional. Field mask is used to specify the fields to be overwritten in the 403 // GrpcRoute resource by the update. 404 // The fields specified in the update_mask are relative to the resource, not 405 // the full request. A field will be overwritten if it is in the mask. If the 406 // user does not provide a mask then all fields will be overwritten. 407 google.protobuf.FieldMask update_mask = 1 408 [(google.api.field_behavior) = OPTIONAL]; 409 410 // Required. Updated GrpcRoute resource. 411 GrpcRoute grpc_route = 2 [(google.api.field_behavior) = REQUIRED]; 412} 413 414// Request used by the DeleteGrpcRoute method. 415message DeleteGrpcRouteRequest { 416 // Required. A name of the GrpcRoute to delete. Must be in the format 417 // `projects/*/locations/global/grpcRoutes/*`. 418 string name = 1 [ 419 (google.api.field_behavior) = REQUIRED, 420 (google.api.resource_reference) = { 421 type: "networkservices.googleapis.com/GrpcRoute" 422 } 423 ]; 424} 425