xref: /aosp_15_r20/external/googleapis/google/api/context.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
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.api;
18
19option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig";
20option java_multiple_files = true;
21option java_outer_classname = "ContextProto";
22option java_package = "com.google.api";
23option objc_class_prefix = "GAPI";
24
25// `Context` defines which contexts an API requests.
26//
27// Example:
28//
29//     context:
30//       rules:
31//       - selector: "*"
32//         requested:
33//         - google.rpc.context.ProjectContext
34//         - google.rpc.context.OriginContext
35//
36// The above specifies that all methods in the API request
37// `google.rpc.context.ProjectContext` and
38// `google.rpc.context.OriginContext`.
39//
40// Available context types are defined in package
41// `google.rpc.context`.
42//
43// This also provides mechanism to allowlist any protobuf message extension that
44// can be sent in grpc metadata using “x-goog-ext-<extension_id>-bin” and
45// “x-goog-ext-<extension_id>-jspb” format. For example, list any service
46// specific protobuf types that can appear in grpc metadata as follows in your
47// yaml file:
48//
49// Example:
50//
51//     context:
52//       rules:
53//        - selector: "google.example.library.v1.LibraryService.CreateBook"
54//          allowed_request_extensions:
55//          - google.foo.v1.NewExtension
56//          allowed_response_extensions:
57//          - google.foo.v1.NewExtension
58//
59// You can also specify extension ID instead of fully qualified extension name
60// here.
61message Context {
62  // A list of RPC context rules that apply to individual API methods.
63  //
64  // **NOTE:** All service configuration rules follow "last one wins" order.
65  repeated ContextRule rules = 1;
66}
67
68// A context rule provides information about the context for an individual API
69// element.
70message ContextRule {
71  // Selects the methods to which this rule applies.
72  //
73  // Refer to [selector][google.api.DocumentationRule.selector] for syntax
74  // details.
75  string selector = 1;
76
77  // A list of full type names of requested contexts.
78  repeated string requested = 2;
79
80  // A list of full type names of provided contexts.
81  repeated string provided = 3;
82
83  // A list of full type names or extension IDs of extensions allowed in grpc
84  // side channel from client to backend.
85  repeated string allowed_request_extensions = 4;
86
87  // A list of full type names or extension IDs of extensions allowed in grpc
88  // side channel from backend to client.
89  repeated string allowed_response_extensions = 5;
90}
91