cuelang.org/go@v0.10.1/encoding/protobuf/testdata/istio.io/api/mixer/v1/config/client/api_spec.proto (about) 1 // Copyright 2017 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 package istio.mixer.v1.config.client; 18 19 option go_package="istio.io/api/mixer/v1/config/client"; 20 21 import "gogoproto/gogo.proto"; 22 23 import "mixer/v1/attributes.proto"; 24 import "mixer/v1/config/client/service.proto"; 25 26 option (gogoproto.goproto_getters_all) = false; 27 option (gogoproto.equal_all) = false; 28 option (gogoproto.gostring_all) = false; 29 option (gogoproto.stable_marshaler_all) = true; 30 31 // HTTPAPISpec defines the canonical configuration for generating 32 // API-related attributes from HTTP requests based on the method and 33 // uri templated path matches. It is sufficient for defining the API 34 // surface of a service for the purposes of API attribute 35 // generation. It is not intended to represent auth, quota, 36 // documentation, or other information commonly found in other API 37 // specifications, e.g. OpenAPI. 38 // 39 // Existing standards that define operations (or methods) in terms of 40 // HTTP methods and paths can be normalized to this format for use in 41 // Istio. For example, a simple petstore API described by OpenAPIv2 42 // [here](https://github.com/googleapis/gnostic/blob/master/examples/v2.0/yaml/petstore-simple.yaml) 43 // can be represented with the following HTTPAPISpec. 44 // 45 // ```yaml 46 // apiVersion: config.istio.io/v1alpha2 47 // kind: HTTPAPISpec 48 // metadata: 49 // name: petstore 50 // namespace: default 51 // spec: 52 // attributes: 53 // attributes: 54 // api.service: 55 // stringValue: petstore.swagger.io 56 // api.version: 57 // stringValue: 1.0.0 58 // patterns: 59 // - attributes: 60 // attributes: 61 // api.operation: 62 // stringValue: findPets 63 // httpMethod: GET 64 // uriTemplate: /api/pets 65 // - attributes: 66 // attributes: 67 // api.operation: 68 // stringValue: addPet 69 // httpMethod: POST 70 // uriTemplate: /api/pets 71 // - attributes: 72 // attributes: 73 // api.operation: 74 // stringValue: findPetById 75 // httpMethod: GET 76 // uriTemplate: /api/pets/{id} 77 // - attributes: 78 // attributes: 79 // api.operation: 80 // stringValue: deletePet 81 // httpMethod: DELETE 82 // uriTemplate: /api/pets/{id} 83 // api_keys: 84 // - query: api-key 85 // ``` 86 message HTTPAPISpec { 87 // List of attributes that are generated when *any* of the HTTP 88 // patterns match. This list typically includes the "api.service" 89 // and "api.version" attributes. 90 Attributes attributes = 1; 91 92 // List of HTTP patterns to match. 93 repeated HTTPAPISpecPattern patterns = 2; 94 95 // List of APIKey that describes how to extract an API-KEY from an 96 // HTTP request. The first API-Key match found in the list is used, 97 // i.e. 'OR' semantics. 98 // 99 // The following default policies are used to generate the 100 // `request.api_key` attribute if no explicit APIKey is defined. 101 // 102 // `query: key, `query: api_key`, and then `header: x-api-key` 103 // 104 repeated APIKey api_keys = 3; 105 } 106 107 // HTTPAPISpecPattern defines a single pattern to match against 108 // incoming HTTP requests. The per-pattern list of attributes is 109 // generated if both the http_method and uri_template match. In 110 // addition, the top-level list of attributes in the HTTPAPISpec is also 111 // generated. 112 // 113 // ```yaml 114 // pattern: 115 // - attributes 116 // api.operation: doFooBar 117 // httpMethod: GET 118 // uriTemplate: /foo/bar 119 // ``` 120 message HTTPAPISpecPattern { 121 // List of attributes that are generated if the HTTP request matches 122 // the specified http_method and uri_template. This typically 123 // includes the "api.operation" attribute. 124 Attributes attributes = 1; 125 126 // HTTP request method to match against as defined by 127 // [rfc7231](https://tools.ietf.org/html/rfc7231#page-21). For 128 // example: GET, HEAD, POST, PUT, DELETE. 129 string http_method = 2; 130 131 oneof pattern { 132 // URI template to match against as defined by 133 // [rfc6570](https://tools.ietf.org/html/rfc6570). For example, the 134 // following are valid URI templates: 135 // 136 // /pets 137 // /pets/{id} 138 // /dictionary/{term:1}/{term} 139 // /search{?q*,lang} 140 // 141 string uri_template = 3; 142 143 // EXPERIMENTAL: 144 // 145 // ecmascript style regex-based match as defined by 146 // [EDCA-262](http://en.cppreference.com/w/cpp/regex/ecmascript). For 147 // example, 148 // 149 // "^/pets/(.*?)?" 150 // 151 string regex = 4; 152 } 153 } 154 155 // APIKey defines the explicit configuration for generating the 156 // `request.api_key` attribute from HTTP requests. 157 // 158 // See [API Keys](https://swagger.io/docs/specification/authentication/api-keys) 159 // for a general overview of API keys as defined by OpenAPI. 160 message APIKey { 161 oneof key { 162 // API Key is sent as a query parameter. `query` represents the 163 // query string parameter name. 164 // 165 // For example, `query=api_key` should be used with the 166 // following request: 167 // 168 // GET /something?api_key=abcdef12345 169 // 170 string query = 1; 171 172 // API key is sent in a request header. `header` represents the 173 // header name. 174 // 175 // For example, `header=X-API-KEY` should be used with the 176 // following request: 177 // 178 // GET /something HTTP/1.1 179 // X-API-Key: abcdef12345 180 // 181 string header = 2; 182 183 // API key is sent in a 184 // [cookie](https://swagger.io/docs/specification/authentication/cookie-authentication), 185 // 186 // For example, `cookie=X-API-KEY` should be used for the 187 // following request: 188 // 189 // GET /something HTTP/1.1 190 // Cookie: X-API-KEY=abcdef12345 191 // 192 string cookie = 3; 193 } 194 } 195 196 // HTTPAPISpecReference defines a reference to an HTTPAPISpec. This is 197 // typically used for establishing bindings between an HTTPAPISpec and an 198 // IstioService. For example, the following defines an 199 // HTTPAPISpecReference for service `foo` in namespace `bar`. 200 // 201 // ```yaml 202 // - name: foo 203 // namespace: bar 204 // ``` 205 message HTTPAPISpecReference { 206 // REQUIRED. The short name of the HTTPAPISpec. This is the resource 207 // name defined by the metadata name field. 208 string name = 1; 209 210 // Optional namespace of the HTTPAPISpec. Defaults to the encompassing 211 // HTTPAPISpecBinding's metadata namespace field. 212 string namespace = 2; 213 } 214 215 // HTTPAPISpecBinding defines the binding between HTTPAPISpecs and one or more 216 // IstioService. For example, the following establishes a binding 217 // between the HTTPAPISpec `petstore` and service `foo` in namespace `bar`. 218 // 219 // ```yaml 220 // apiVersion: config.istio.io/v1alpha2 221 // kind: HTTPAPISpecBinding 222 // metadata: 223 // name: my-binding 224 // namespace: default 225 // spec: 226 // services: 227 // - name: foo 228 // namespace: bar 229 // api_specs: 230 // - name: petstore 231 // namespace: default 232 // ``` 233 message HTTPAPISpecBinding { 234 // REQUIRED. One or more services to map the listed HTTPAPISpec onto. 235 repeated IstioService services = 1; 236 237 // REQUIRED. One or more HTTPAPISpec references that should be mapped to 238 // the specified service(s). The aggregate collection of match 239 // conditions defined in the HTTPAPISpecs should not overlap. 240 repeated HTTPAPISpecReference api_specs = 2; 241 }