attribute_context.proto 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. // Copyright 2024 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. syntax = "proto3";
  15. package google.rpc.context;
  16. import "google/protobuf/any.proto";
  17. import "google/protobuf/duration.proto";
  18. import "google/protobuf/struct.proto";
  19. import "google/protobuf/timestamp.proto";
  20. option cc_enable_arenas = true;
  21. option go_package = "google.golang.org/genproto/googleapis/rpc/context/attribute_context;attribute_context";
  22. option java_multiple_files = true;
  23. option java_outer_classname = "AttributeContextProto";
  24. option java_package = "com.google.rpc.context";
  25. // This message defines the standard attribute vocabulary for Google APIs.
  26. //
  27. // An attribute is a piece of metadata that describes an activity on a network
  28. // service. For example, the size of an HTTP request, or the status code of
  29. // an HTTP response.
  30. //
  31. // Each attribute has a type and a name, which is logically defined as
  32. // a proto message field in `AttributeContext`. The field type becomes the
  33. // attribute type, and the field path becomes the attribute name. For example,
  34. // the attribute `source.ip` maps to field `AttributeContext.source.ip`.
  35. //
  36. // This message definition is guaranteed not to have any wire breaking change.
  37. // So you can use it directly for passing attributes across different systems.
  38. //
  39. // NOTE: Different system may generate different subset of attributes. Please
  40. // verify the system specification before relying on an attribute generated
  41. // a system.
  42. message AttributeContext {
  43. // This message defines attributes for a node that handles a network request.
  44. // The node can be either a service or an application that sends, forwards,
  45. // or receives the request. Service peers should fill in
  46. // `principal` and `labels` as appropriate.
  47. message Peer {
  48. // The IP address of the peer.
  49. string ip = 1;
  50. // The network port of the peer.
  51. int64 port = 2;
  52. // The labels associated with the peer.
  53. map<string, string> labels = 6;
  54. // The identity of this peer. Similar to `Request.auth.principal`, but
  55. // relative to the peer instead of the request. For example, the
  56. // identity associated with a load balancer that forwarded the request.
  57. string principal = 7;
  58. // The CLDR country/region code associated with the above IP address.
  59. // If the IP address is private, the `region_code` should reflect the
  60. // physical location where this peer is running.
  61. string region_code = 8;
  62. }
  63. // This message defines attributes associated with API operations, such as
  64. // a network API request. The terminology is based on the conventions used
  65. // by Google APIs, Istio, and OpenAPI.
  66. message Api {
  67. // The API service name. It is a logical identifier for a networked API,
  68. // such as "pubsub.googleapis.com". The naming syntax depends on the
  69. // API management system being used for handling the request.
  70. string service = 1;
  71. // The API operation name. For gRPC requests, it is the fully qualified API
  72. // method name, such as "google.pubsub.v1.Publisher.Publish". For OpenAPI
  73. // requests, it is the `operationId`, such as "getPet".
  74. string operation = 2;
  75. // The API protocol used for sending the request, such as "http", "https",
  76. // "grpc", or "internal".
  77. string protocol = 3;
  78. // The API version associated with the API operation above, such as "v1" or
  79. // "v1alpha1".
  80. string version = 4;
  81. }
  82. // This message defines request authentication attributes. Terminology is
  83. // based on the JSON Web Token (JWT) standard, but the terms also
  84. // correlate to concepts in other standards.
  85. message Auth {
  86. // The authenticated principal. Reflects the issuer (`iss`) and subject
  87. // (`sub`) claims within a JWT. The issuer and subject should be `/`
  88. // delimited, with `/` percent-encoded within the subject fragment. For
  89. // Google accounts, the principal format is:
  90. // "https://accounts.google.com/{id}"
  91. string principal = 1;
  92. // The intended audience(s) for this authentication information. Reflects
  93. // the audience (`aud`) claim within a JWT. The audience
  94. // value(s) depends on the `issuer`, but typically include one or more of
  95. // the following pieces of information:
  96. //
  97. // * The services intended to receive the credential. For example,
  98. // ["https://pubsub.googleapis.com/", "https://storage.googleapis.com/"].
  99. // * A set of service-based scopes. For example,
  100. // ["https://www.googleapis.com/auth/cloud-platform"].
  101. // * The client id of an app, such as the Firebase project id for JWTs
  102. // from Firebase Auth.
  103. //
  104. // Consult the documentation for the credential issuer to determine the
  105. // information provided.
  106. repeated string audiences = 2;
  107. // The authorized presenter of the credential. Reflects the optional
  108. // Authorized Presenter (`azp`) claim within a JWT or the
  109. // OAuth client id. For example, a Google Cloud Platform client id looks
  110. // as follows: "123456789012.apps.googleusercontent.com".
  111. string presenter = 3;
  112. // Structured claims presented with the credential. JWTs include
  113. // `{key: value}` pairs for standard and private claims. The following
  114. // is a subset of the standard required and optional claims that would
  115. // typically be presented for a Google-based JWT:
  116. //
  117. // {'iss': 'accounts.google.com',
  118. // 'sub': '113289723416554971153',
  119. // 'aud': ['123456789012', 'pubsub.googleapis.com'],
  120. // 'azp': '123456789012.apps.googleusercontent.com',
  121. // 'email': 'jsmith@example.com',
  122. // 'iat': 1353601026,
  123. // 'exp': 1353604926}
  124. //
  125. // SAML assertions are similarly specified, but with an identity provider
  126. // dependent structure.
  127. google.protobuf.Struct claims = 4;
  128. // A list of access level resource names that allow resources to be
  129. // accessed by authenticated requester. It is part of Secure GCP processing
  130. // for the incoming request. An access level string has the format:
  131. // "//{api_service_name}/accessPolicies/{policy_id}/accessLevels/{short_name}"
  132. //
  133. // Example:
  134. // "//accesscontextmanager.googleapis.com/accessPolicies/MY_POLICY_ID/accessLevels/MY_LEVEL"
  135. repeated string access_levels = 5;
  136. }
  137. // This message defines attributes for an HTTP request. If the actual
  138. // request is not an HTTP request, the runtime system should try to map
  139. // the actual request to an equivalent HTTP request.
  140. message Request {
  141. // The unique ID for a request, which can be propagated to downstream
  142. // systems. The ID should have low probability of collision
  143. // within a single day for a specific service.
  144. string id = 1;
  145. // The HTTP request method, such as `GET`, `POST`.
  146. string method = 2;
  147. // The HTTP request headers. If multiple headers share the same key, they
  148. // must be merged according to the HTTP spec. All header keys must be
  149. // lowercased, because HTTP header keys are case-insensitive.
  150. map<string, string> headers = 3;
  151. // The HTTP URL path, excluding the query parameters.
  152. string path = 4;
  153. // The HTTP request `Host` header value.
  154. string host = 5;
  155. // The HTTP URL scheme, such as `http` and `https`.
  156. string scheme = 6;
  157. // The HTTP URL query in the format of `name1=value1&name2=value2`, as it
  158. // appears in the first line of the HTTP request. No decoding is performed.
  159. string query = 7;
  160. // The timestamp when the `destination` service receives the last byte of
  161. // the request.
  162. google.protobuf.Timestamp time = 9;
  163. // The HTTP request size in bytes. If unknown, it must be -1.
  164. int64 size = 10;
  165. // The network protocol used with the request, such as "http/1.1",
  166. // "spdy/3", "h2", "h2c", "webrtc", "tcp", "udp", "quic". See
  167. // https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids
  168. // for details.
  169. string protocol = 11;
  170. // A special parameter for request reason. It is used by security systems
  171. // to associate auditing information with a request.
  172. string reason = 12;
  173. // The request authentication. May be absent for unauthenticated requests.
  174. // Derived from the HTTP request `Authorization` header or equivalent.
  175. Auth auth = 13;
  176. }
  177. // This message defines attributes for a typical network response. It
  178. // generally models semantics of an HTTP response.
  179. message Response {
  180. // The HTTP response status code, such as `200` and `404`.
  181. int64 code = 1;
  182. // The HTTP response size in bytes. If unknown, it must be -1.
  183. int64 size = 2;
  184. // The HTTP response headers. If multiple headers share the same key, they
  185. // must be merged according to HTTP spec. All header keys must be
  186. // lowercased, because HTTP header keys are case-insensitive.
  187. map<string, string> headers = 3;
  188. // The timestamp when the `destination` service sends the last byte of
  189. // the response.
  190. google.protobuf.Timestamp time = 4;
  191. // The amount of time it takes the backend service to fully respond to a
  192. // request. Measured from when the destination service starts to send the
  193. // request to the backend until when the destination service receives the
  194. // complete response from the backend.
  195. google.protobuf.Duration backend_latency = 5;
  196. }
  197. // This message defines core attributes for a resource. A resource is an
  198. // addressable (named) entity provided by the destination service. For
  199. // example, a file stored on a network storage service.
  200. message Resource {
  201. // The name of the service that this resource belongs to, such as
  202. // `pubsub.googleapis.com`. The service may be different from the DNS
  203. // hostname that actually serves the request.
  204. string service = 1;
  205. // The stable identifier (name) of a resource on the `service`. A resource
  206. // can be logically identified as "//{resource.service}/{resource.name}".
  207. // The differences between a resource name and a URI are:
  208. //
  209. // * Resource name is a logical identifier, independent of network
  210. // protocol and API version. For example,
  211. // `//pubsub.googleapis.com/projects/123/topics/news-feed`.
  212. // * URI often includes protocol and version information, so it can
  213. // be used directly by applications. For example,
  214. // `https://pubsub.googleapis.com/v1/projects/123/topics/news-feed`.
  215. //
  216. // See https://cloud.google.com/apis/design/resource_names for details.
  217. string name = 2;
  218. // The type of the resource. The syntax is platform-specific because
  219. // different platforms define their resources differently.
  220. //
  221. // For Google APIs, the type format must be "{service}/{kind}", such as
  222. // "pubsub.googleapis.com/Topic".
  223. string type = 3;
  224. // The labels or tags on the resource, such as AWS resource tags and
  225. // Kubernetes resource labels.
  226. map<string, string> labels = 4;
  227. // The unique identifier of the resource. UID is unique in the time
  228. // and space for this resource within the scope of the service. It is
  229. // typically generated by the server on successful creation of a resource
  230. // and must not be changed. UID is used to uniquely identify resources
  231. // with resource name reuses. This should be a UUID4.
  232. string uid = 5;
  233. // Annotations is an unstructured key-value map stored with a resource that
  234. // may be set by external tools to store and retrieve arbitrary metadata.
  235. // They are not queryable and should be preserved when modifying objects.
  236. //
  237. // More info: https://kubernetes.io/docs/user-guide/annotations
  238. map<string, string> annotations = 6;
  239. // Mutable. The display name set by clients. Must be <= 63 characters.
  240. string display_name = 7;
  241. // Output only. The timestamp when the resource was created. This may
  242. // be either the time creation was initiated or when it was completed.
  243. google.protobuf.Timestamp create_time = 8;
  244. // Output only. The timestamp when the resource was last updated. Any
  245. // change to the resource made by users must refresh this value.
  246. // Changes to a resource made by the service should refresh this value.
  247. google.protobuf.Timestamp update_time = 9;
  248. // Output only. The timestamp when the resource was deleted.
  249. // If the resource is not deleted, this must be empty.
  250. google.protobuf.Timestamp delete_time = 10;
  251. // Output only. An opaque value that uniquely identifies a version or
  252. // generation of a resource. It can be used to confirm that the client
  253. // and server agree on the ordering of a resource being written.
  254. string etag = 11;
  255. // Immutable. The location of the resource. The location encoding is
  256. // specific to the service provider, and new encoding may be introduced
  257. // as the service evolves.
  258. //
  259. // For Google Cloud products, the encoding is what is used by Google Cloud
  260. // APIs, such as `us-east1`, `aws-us-east-1`, and `azure-eastus2`. The
  261. // semantics of `location` is identical to the
  262. // `cloud.googleapis.com/location` label used by some Google Cloud APIs.
  263. string location = 12;
  264. }
  265. // The origin of a network activity. In a multi hop network activity,
  266. // the origin represents the sender of the first hop. For the first hop,
  267. // the `source` and the `origin` must have the same content.
  268. Peer origin = 7;
  269. // The source of a network activity, such as starting a TCP connection.
  270. // In a multi hop network activity, the source represents the sender of the
  271. // last hop.
  272. Peer source = 1;
  273. // The destination of a network activity, such as accepting a TCP connection.
  274. // In a multi hop network activity, the destination represents the receiver of
  275. // the last hop.
  276. Peer destination = 2;
  277. // Represents a network request, such as an HTTP request.
  278. Request request = 3;
  279. // Represents a network response, such as an HTTP response.
  280. Response response = 4;
  281. // Represents a target resource that is involved with a network activity.
  282. // If multiple resources are involved with an activity, this must be the
  283. // primary one.
  284. Resource resource = 5;
  285. // Represents an API operation that is involved to a network activity.
  286. Api api = 6;
  287. // Supports extensions for advanced use cases, such as logs and metrics.
  288. repeated google.protobuf.Any extensions = 8;
  289. }