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/field_mask.proto"; 22import "google/protobuf/timestamp.proto"; 23 24option csharp_namespace = "Google.Cloud.NetworkServices.V1"; 25option go_package = "cloud.google.com/go/networkservices/apiv1/networkservicespb;networkservicespb"; 26option java_multiple_files = true; 27option java_outer_classname = "TcpRouteProto"; 28option java_package = "com.google.cloud.networkservices.v1"; 29option php_namespace = "Google\\Cloud\\NetworkServices\\V1"; 30option ruby_package = "Google::Cloud::NetworkServices::V1"; 31option (google.api.resource_definition) = { 32 type: "compute.googleapis.com/BackendService" 33 pattern: "projects/{project}/locations/{location}/backendServices/{backend_service}" 34}; 35 36// TcpRoute is the resource defining how TCP traffic should be routed by a 37// Mesh/Gateway resource. 38message TcpRoute { 39 option (google.api.resource) = { 40 type: "networkservices.googleapis.com/TcpRoute" 41 pattern: "projects/{project}/locations/{location}/tcpRoutes/{tcp_route}" 42 }; 43 44 // Specifies how to match traffic and how to route traffic when traffic is 45 // matched. 46 message RouteRule { 47 // Optional. RouteMatch defines the predicate used to match requests to a 48 // given action. Multiple match types are "OR"ed for evaluation. If no 49 // routeMatch field is specified, this rule will unconditionally match 50 // traffic. 51 repeated RouteMatch matches = 1 [(google.api.field_behavior) = OPTIONAL]; 52 53 // Required. The detailed rule defining how to route matched traffic. 54 RouteAction action = 2 [(google.api.field_behavior) = REQUIRED]; 55 } 56 57 // RouteMatch defines the predicate used to match requests to a given action. 58 // Multiple match types are "OR"ed for evaluation. 59 // If no routeMatch field is specified, this rule will unconditionally match 60 // traffic. 61 message RouteMatch { 62 // Required. Must be specified in the CIDR range format. A CIDR range 63 // consists of an IP Address and a prefix length to construct the subnet 64 // mask. By default, the prefix length is 32 (i.e. matches a single IP 65 // address). Only IPV4 addresses are supported. 66 // Examples: 67 // "10.0.0.1" - matches against this exact IP address. 68 // "10.0.0.0/8" - matches against any IP address within the 10.0.0.0 subnet 69 // and 255.255.255.0 mask. 70 // "0.0.0.0/0" - matches against any IP address'. 71 string address = 1 [(google.api.field_behavior) = REQUIRED]; 72 73 // Required. Specifies the destination port to match against. 74 string port = 2 [(google.api.field_behavior) = REQUIRED]; 75 } 76 77 // The specifications for routing traffic and applying associated policies. 78 message RouteAction { 79 // Optional. The destination services to which traffic should be forwarded. 80 // At least one destination service is required. Only one of route 81 // destination or original destination can be set. 82 repeated RouteDestination destinations = 1 83 [(google.api.field_behavior) = OPTIONAL]; 84 85 // Optional. If true, Router will use the destination IP and port of the 86 // original connection as the destination of the request. Default is false. 87 // Only one of route destinations or original destination can be set. 88 bool original_destination = 3 [(google.api.field_behavior) = OPTIONAL]; 89 } 90 91 // Describe the destination for traffic to be routed to. 92 message RouteDestination { 93 // Required. The URL of a BackendService to route traffic to. 94 string service_name = 1 [ 95 (google.api.field_behavior) = REQUIRED, 96 (google.api.resource_reference) = { 97 type: "compute.googleapis.com/BackendService" 98 } 99 ]; 100 101 // Optional. Specifies the proportion of requests forwarded to the backend 102 // referenced by the serviceName field. This is computed as: 103 // - weight/Sum(weights in this destination list). 104 // For non-zero values, there may be some epsilon from the exact proportion 105 // defined here depending on the precision an implementation supports. 106 // 107 // If only one serviceName is specified and it has a weight greater than 0, 108 // 100% of the traffic is forwarded to that backend. 109 // 110 // If weights are specified for any one service name, they need to be 111 // specified for all of them. 112 // 113 // If weights are unspecified for all services, then, traffic is distributed 114 // in equal proportions to all of them. 115 int32 weight = 2 [(google.api.field_behavior) = OPTIONAL]; 116 } 117 118 // Required. Name of the TcpRoute resource. It matches pattern 119 // `projects/*/locations/global/tcpRoutes/tcp_route_name>`. 120 string name = 1 [(google.api.field_behavior) = REQUIRED]; 121 122 // Output only. Server-defined URL of this resource 123 string self_link = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; 124 125 // Output only. The timestamp when the resource was created. 126 google.protobuf.Timestamp create_time = 2 127 [(google.api.field_behavior) = OUTPUT_ONLY]; 128 129 // Output only. The timestamp when the resource was updated. 130 google.protobuf.Timestamp update_time = 3 131 [(google.api.field_behavior) = OUTPUT_ONLY]; 132 133 // Optional. A free-text description of the resource. Max length 1024 134 // characters. 135 string description = 4 [(google.api.field_behavior) = OPTIONAL]; 136 137 // Required. Rules that define how traffic is routed and handled. At least one 138 // RouteRule must be supplied. If there are multiple rules then the action 139 // taken will be the first rule to match. 140 repeated RouteRule rules = 5 [(google.api.field_behavior) = REQUIRED]; 141 142 // Optional. Meshes defines a list of meshes this TcpRoute is attached to, as 143 // one of the routing rules to route the requests served by the mesh. 144 // 145 // Each mesh reference should match the pattern: 146 // `projects/*/locations/global/meshes/<mesh_name>` 147 // 148 // The attached Mesh should be of a type SIDECAR 149 repeated string meshes = 8 [ 150 (google.api.field_behavior) = OPTIONAL, 151 (google.api.resource_reference) = { 152 type: "networkservices.googleapis.com/Mesh" 153 } 154 ]; 155 156 // Optional. Gateways defines a list of gateways this TcpRoute is attached to, 157 // as one of the routing rules to route the requests served by the gateway. 158 // 159 // Each gateway reference should match the pattern: 160 // `projects/*/locations/global/gateways/<gateway_name>` 161 repeated string gateways = 9 [ 162 (google.api.field_behavior) = OPTIONAL, 163 (google.api.resource_reference) = { 164 type: "networkservices.googleapis.com/Gateway" 165 } 166 ]; 167 168 // Optional. Set of label tags associated with the TcpRoute resource. 169 map<string, string> labels = 10 [(google.api.field_behavior) = OPTIONAL]; 170} 171 172// Request used with the ListTcpRoutes method. 173message ListTcpRoutesRequest { 174 // Required. The project and location from which the TcpRoutes should be 175 // listed, specified in the format `projects/*/locations/global`. 176 string parent = 1 [ 177 (google.api.field_behavior) = REQUIRED, 178 (google.api.resource_reference) = { 179 child_type: "networkservices.googleapis.com/TcpRoute" 180 } 181 ]; 182 183 // Maximum number of TcpRoutes to return per call. 184 int32 page_size = 2; 185 186 // The value returned by the last `ListTcpRoutesResponse` 187 // Indicates that this is a continuation of a prior `ListTcpRoutes` call, 188 // and that the system should return the next page of data. 189 string page_token = 3; 190} 191 192// Response returned by the ListTcpRoutes method. 193message ListTcpRoutesResponse { 194 // List of TcpRoute resources. 195 repeated TcpRoute tcp_routes = 1; 196 197 // If there might be more results than those appearing in this response, then 198 // `next_page_token` is included. To get the next set of results, call this 199 // method again using the value of `next_page_token` as `page_token`. 200 string next_page_token = 2; 201} 202 203// Request used by the GetTcpRoute method. 204message GetTcpRouteRequest { 205 // Required. A name of the TcpRoute to get. Must be in the format 206 // `projects/*/locations/global/tcpRoutes/*`. 207 string name = 1 [ 208 (google.api.field_behavior) = REQUIRED, 209 (google.api.resource_reference) = { 210 type: "networkservices.googleapis.com/TcpRoute" 211 } 212 ]; 213} 214 215// Request used by the TcpRoute method. 216message CreateTcpRouteRequest { 217 // Required. The parent resource of the TcpRoute. Must be in the 218 // format `projects/*/locations/global`. 219 string parent = 1 [ 220 (google.api.field_behavior) = REQUIRED, 221 (google.api.resource_reference) = { 222 child_type: "networkservices.googleapis.com/TcpRoute" 223 } 224 ]; 225 226 // Required. Short name of the TcpRoute resource to be created. 227 string tcp_route_id = 2 [(google.api.field_behavior) = REQUIRED]; 228 229 // Required. TcpRoute resource to be created. 230 TcpRoute tcp_route = 3 [(google.api.field_behavior) = REQUIRED]; 231} 232 233// Request used by the UpdateTcpRoute method. 234message UpdateTcpRouteRequest { 235 // Optional. Field mask is used to specify the fields to be overwritten in the 236 // TcpRoute resource by the update. 237 // The fields specified in the update_mask are relative to the resource, not 238 // the full request. A field will be overwritten if it is in the mask. If the 239 // user does not provide a mask then all fields will be overwritten. 240 google.protobuf.FieldMask update_mask = 1 241 [(google.api.field_behavior) = OPTIONAL]; 242 243 // Required. Updated TcpRoute resource. 244 TcpRoute tcp_route = 2 [(google.api.field_behavior) = REQUIRED]; 245} 246 247// Request used by the DeleteTcpRoute method. 248message DeleteTcpRouteRequest { 249 // Required. A name of the TcpRoute to delete. Must be in the format 250 // `projects/*/locations/global/tcpRoutes/*`. 251 string name = 1 [ 252 (google.api.field_behavior) = REQUIRED, 253 (google.api.resource_reference) = { 254 type: "networkservices.googleapis.com/TcpRoute" 255 } 256 ]; 257} 258