cuelang.org/go@v0.10.1/encoding/protobuf/testdata/istio.io/api/mixer/v1/mixer.proto (about) 1 // Copyright 2016 Istio Authors 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 15 syntax = "proto3"; 16 17 // This package defines the Mixer API that the sidecar proxy uses to perform 18 // precondition checks, manage quotas, and report telemetry. 19 package istio.mixer.v1; 20 21 option go_package = "istio.io/api/mixer/v1"; 22 option cc_generic_services = true; 23 24 import "gogoproto/gogo.proto"; 25 import "google/protobuf/duration.proto"; 26 import "google/rpc/status.proto"; 27 import "mixer/v1/attributes.proto"; 28 29 option (gogoproto.goproto_getters_all) = false; 30 option (gogoproto.equal_all) = false; 31 option (gogoproto.gostring_all) = false; 32 option cc_enable_arenas = true; 33 34 // Mixer provides three core features: 35 // 36 // - *Precondition Checking*. Enables callers to verify a number of preconditions 37 // before responding to an incoming request from a service consumer. 38 // Preconditions can include whether the service consumer is properly 39 // authenticated, is on the service’s whitelist, passes ACL checks, and more. 40 // 41 // - *Quota Management*. Enables services to allocate and free quota on a number 42 // of dimensions, Quotas are used as a relatively simple resource management tool 43 // to provide some fairness between service consumers when contending for limited 44 // resources. Rate limits are examples of quotas. 45 // 46 // - *Telemetry Reporting*. Enables services to report logging and monitoring. 47 // In the future, it will also enable tracing and billing streams intended for 48 // both the service operator as well as for service consumers. 49 service Mixer { 50 // Checks preconditions and allocate quota before performing an operation. 51 // The preconditions enforced depend on the set of supplied attributes and 52 // the active configuration. 53 rpc Check(CheckRequest) returns (CheckResponse) {} 54 55 // Reports telemetry, such as logs and metrics. 56 // The reported information depends on the set of supplied attributes and the 57 // active configuration. 58 rpc Report(ReportRequest) returns (ReportResponse) {} 59 } 60 61 // Used to get a thumbs-up/thumbs-down before performing an action. 62 message CheckRequest { 63 // parameters for a quota allocation 64 message QuotaParams { 65 // Amount of quota to allocate 66 int64 amount = 1; 67 68 // When true, supports returning less quota than what was requested. 69 bool best_effort = 2; 70 } 71 72 // The attributes to use for this request. 73 // 74 // Mixer's configuration determines how these attributes are used to 75 // establish the result returned in the response. 76 CompressedAttributes attributes = 1 [(gogoproto.nullable) = false]; 77 78 // The number of words in the global dictionary, used with to populate the attributes. 79 // This value is used as a quick way to determine whether the client is using a dictionary that 80 // the server understands. 81 uint32 global_word_count = 2; 82 83 // Used for deduplicating `Check` calls in the case of failed RPCs and retries. This should be a UUID 84 // per call, where the same UUID is used for retries of the same call. 85 string deduplication_id = 3; 86 87 // The individual quotas to allocate 88 map<string, QuotaParams> quotas = 4 [(gogoproto.nullable) = false]; 89 } 90 91 // The response generated by the Check method. 92 message CheckResponse { 93 94 // Expresses the result of a precondition check. 95 message PreconditionResult { 96 reserved 4; 97 98 // A status code of OK indicates all preconditions were satisfied. Any other code indicates not 99 // all preconditions were satisfied and details describe why. 100 google.rpc.Status status = 1 [(gogoproto.nullable) = false]; 101 102 // The amount of time for which this result can be considered valid. 103 google.protobuf.Duration valid_duration = 2 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; 104 105 // The number of uses for which this result can be considered valid. 106 int32 valid_use_count = 3; 107 108 // The total set of attributes that were used in producing the result 109 // along with matching conditions. 110 ReferencedAttributes referenced_attributes = 5; 111 112 // An optional routing directive, used to manipulate the traffic metadata 113 // whenever all preconditions are satisfied. 114 RouteDirective route_directive = 6; 115 } 116 117 // Expresses the result of a quota allocation. 118 message QuotaResult { 119 // The amount of time for which this result can be considered valid. 120 google.protobuf.Duration valid_duration = 1 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; 121 122 // The amount of granted quota. When `QuotaParams.best_effort` is true, this will be >= 0. 123 // If `QuotaParams.best_effort` is false, this will be either 0 or >= `QuotaParams.amount`. 124 int64 granted_amount = 2; 125 126 // The total set of attributes that were used in producing the result 127 // along with matching conditions. 128 ReferencedAttributes referenced_attributes = 5 [(gogoproto.nullable) = false]; 129 } 130 131 // The precondition check results. 132 PreconditionResult precondition = 2 [(gogoproto.nullable) = false]; 133 134 // The resulting quota, one entry per requested quota. 135 map<string, QuotaResult> quotas = 3 [(gogoproto.nullable) = false]; 136 } 137 138 // Describes the attributes that were used to determine the response. 139 // This can be used to construct a response cache. 140 message ReferencedAttributes { 141 // How an attribute's value was matched 142 enum Condition { 143 CONDITION_UNSPECIFIED = 0; // should not occur 144 ABSENCE = 1; // match when attribute doesn't exist 145 EXACT = 2; // match when attribute value is an exact byte-for-byte match 146 REGEX = 3; // match when attribute value matches the included regex 147 } 148 149 // Describes a single attribute match. 150 message AttributeMatch { 151 // The name of the attribute. This is a dictionary index encoded in a manner identical 152 // to all strings in the [CompressedAttributes][istio.mixer.v1.CompressedAttributes] message. 153 sint32 name = 1; 154 155 // The kind of match against the attribute value. 156 Condition condition = 2; 157 158 // If a REGEX condition is provided for a STRING_MAP attribute, 159 // clients should use the regex value to match against map keys. 160 string regex = 3; 161 162 // A key in a STRING_MAP. When multiple keys from a STRING_MAP 163 // attribute were referenced, there will be multiple AttributeMatch 164 // messages with different map_key values. Values for map_key SHOULD 165 // be ignored for attributes that are not STRING_MAP. 166 // 167 // Indices for the keys are used (taken either from the 168 // message dictionary from the `words` field or the global dictionary). 169 // 170 // If no map_key value is provided for a STRING_MAP attribute, the 171 // entire STRING_MAP will be used. 172 sint32 map_key = 4; 173 } 174 175 // The message-level dictionary. Refer to [CompressedAttributes][istio.mixer.v1.CompressedAttributes] for information 176 // on using dictionaries. 177 repeated string words = 1; 178 179 // Describes a set of attributes. 180 repeated AttributeMatch attribute_matches = 2 [(gogoproto.nullable) = false]; 181 } 182 183 // Operation on HTTP headers to replace, append, or remove a header. Header 184 // names are normalized to lower-case with dashes, e.g. "x-request-id". 185 // Pseudo-headers ":path", ":authority", and ":method" are supported to modify 186 // the request headers. 187 message HeaderOperation { 188 // Operation type. 189 enum Operation { 190 REPLACE = 0; // replaces the header with the given name 191 REMOVE = 1; // removes the header with the given name (the value is ignored) 192 APPEND = 2; // appends the value to the header value, or sets it if not present 193 } 194 // Header name. 195 string name = 1; 196 197 // Header value. 198 string value = 2; 199 200 // Header operation. 201 Operation operation = 3; 202 } 203 204 // Expresses the routing manipulation actions to be performed on behalf of 205 // Mixer in response to a precondition check. 206 message RouteDirective { 207 // Operations on the request headers. 208 repeated HeaderOperation request_header_operations = 1 [(gogoproto.nullable) = false]; 209 210 // Operations on the response headers. 211 repeated HeaderOperation response_header_operations = 2 [(gogoproto.nullable) = false]; 212 213 // If set, enables a direct response without proxying the request to the routing 214 // destination. Required to be a value in the 2xx or 3xx range. 215 uint32 direct_response_code = 3; 216 217 // Supplies the response body for the direct response. 218 // If this setting is omitted, no body is included in the generated response. 219 string direct_response_body = 4; 220 } 221 222 // Used to report telemetry after performing one or more actions. 223 message ReportRequest { 224 // next value: 5 225 226 // Used to signal how the sets of compressed attributes should be reconstitued server-side. 227 enum RepeatedAttributesSemantics { 228 // Use delta encoding between sets of compressed attributes to reduce the overall on-wire 229 // request size. Each individual set of attributes is used to modify the previous set. 230 // NOTE: There is no way with this encoding to specify attribute value deletion. This 231 // option should be used with extreme caution. 232 DELTA_ENCODING = 0; 233 234 // Treat each set of compressed attributes as complete - independent from other sets 235 // in this request. This will result in on-wire duplication of attributes and values, but 236 // will allow for proper accounting of absent values in overall encoding. 237 INDEPENDENT_ENCODING = 1; 238 } 239 240 // The attributes to use for this request. 241 // 242 // Each `Attributes` element represents the state of a single action. Multiple actions 243 // can be provided in a single message in order to improve communication efficiency. The 244 // client can accumulate a set of actions and send them all in one single message. 245 repeated CompressedAttributes attributes = 1 [(gogoproto.nullable) = false]; 246 247 // Indicates how to decode the attributes sets in this request. 248 RepeatedAttributesSemantics repeated_attributes_semantics = 4; 249 250 // The default message-level dictionary for all the attributes. 251 // Individual attribute messages can have their own dictionaries, but if they don't 252 // then this set of words, if it is provided, is used instead. 253 // 254 // This makes it possible to share the same dictionary for all attributes in this 255 // request, which can substantially reduce the overall request size. 256 repeated string default_words = 2; 257 258 // The number of words in the global dictionary. 259 // To detect global dictionary out of sync between client and server. 260 uint32 global_word_count = 3; 261 } 262 263 // Used to carry responses to telemetry reports 264 message ReportResponse { 265 }