Debian Codegraph @

google/api/policy.proto

raw
1 // Copyright 2026 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
15 syntax = "proto3";
16
17 package google.api;
18
19 import "google/protobuf/descriptor.proto";
20
21 option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig";
22 option java_multiple_files = true;
23 option java_outer_classname = "PolicyProto";
24 option java_package = "com.google.api";
25 option objc_class_prefix = "GAPI";
26
27 extend google.protobuf.FieldOptions {
28 // See [FieldPolicy][].
29 google.api.FieldPolicy field_policy = 158361448;
30 }
31
32 extend google.protobuf.MethodOptions {
33 // See [MethodPolicy][].
34 google.api.MethodPolicy method_policy = 161893301;
35 }
36
37 // Google API Policy Annotation
38 //
39 // This message defines a simple API policy annotation that can be used to
40 // annotate API request and response message fields with applicable policies.
41 // One field may have multiple applicable policies that must all be satisfied
42 // before a request can be processed. This policy annotation is used to
43 // generate the overall policy that will be used for automatic runtime
44 // policy enforcement and documentation generation.
45 message FieldPolicy {
46 // Selects one or more request or response message fields to apply this
47 // `FieldPolicy`.
48 //
49 // When a `FieldPolicy` is used in proto annotation, the selector must
50 // be left as empty. The service config generator will automatically fill
51 // the correct value.
52 //
53 // When a `FieldPolicy` is used in service config, the selector must be a
54 // comma-separated string with valid request or response field paths,
55 // such as "foo.bar" or "foo.bar,foo.baz".
56 string selector = 1;
57
58 // Specifies the required permission(s) for the resource referred to by the
59 // field. It requires the field contains a valid resource reference, and
60 // the request must pass the permission checks to proceed. For example,
61 // "resourcemanager.projects.get".
62 string resource_permission = 2;
63
64 // Specifies the resource type for the resource referred to by the field.
65 string resource_type = 3;
66 }
67
68 // Defines policies applying to an RPC method.
69 message MethodPolicy {
70 // Selects a method to which these policies should be enforced, for example,
71 // "google.pubsub.v1.Subscriber.CreateSubscription".
72 //
73 // Refer to [selector][google.api.DocumentationRule.selector] for syntax
74 // details.
75 //
76 // NOTE: This field must not be set in the proto annotation. It will be
77 // automatically filled by the service config compiler .
78 string selector = 9;
79
80 // Policies that are applicable to the request message.
81 repeated FieldPolicy request_policies = 2;
82 }