xref: /aosp_15_r20/external/googleapis/google/api/visibility.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
19import "google/protobuf/descriptor.proto";
20
21option cc_enable_arenas = true;
22option go_package = "google.golang.org/genproto/googleapis/api/visibility;visibility";
23option java_multiple_files = true;
24option java_outer_classname = "VisibilityProto";
25option java_package = "com.google.api";
26option objc_class_prefix = "GAPI";
27
28extend google.protobuf.EnumOptions {
29  // See `VisibilityRule`.
30  google.api.VisibilityRule enum_visibility = 72295727;
31}
32
33extend google.protobuf.EnumValueOptions {
34  // See `VisibilityRule`.
35  google.api.VisibilityRule value_visibility = 72295727;
36}
37
38extend google.protobuf.FieldOptions {
39  // See `VisibilityRule`.
40  google.api.VisibilityRule field_visibility = 72295727;
41}
42
43extend google.protobuf.MessageOptions {
44  // See `VisibilityRule`.
45  google.api.VisibilityRule message_visibility = 72295727;
46}
47
48extend google.protobuf.MethodOptions {
49  // See `VisibilityRule`.
50  google.api.VisibilityRule method_visibility = 72295727;
51}
52
53extend google.protobuf.ServiceOptions {
54  // See `VisibilityRule`.
55  google.api.VisibilityRule api_visibility = 72295727;
56}
57
58// `Visibility` restricts service consumer's access to service elements,
59// such as whether an application can call a visibility-restricted method.
60// The restriction is expressed by applying visibility labels on service
61// elements. The visibility labels are elsewhere linked to service consumers.
62//
63// A service can define multiple visibility labels, but a service consumer
64// should be granted at most one visibility label. Multiple visibility
65// labels for a single service consumer are not supported.
66//
67// If an element and all its parents have no visibility label, its visibility
68// is unconditionally granted.
69//
70// Example:
71//
72//     visibility:
73//       rules:
74//       - selector: google.calendar.Calendar.EnhancedSearch
75//         restriction: PREVIEW
76//       - selector: google.calendar.Calendar.Delegate
77//         restriction: INTERNAL
78//
79// Here, all methods are publicly visible except for the restricted methods
80// EnhancedSearch and Delegate.
81message Visibility {
82  // A list of visibility rules that apply to individual API elements.
83  //
84  // **NOTE:** All service configuration rules follow "last one wins" order.
85  repeated VisibilityRule rules = 1;
86}
87
88// A visibility rule provides visibility configuration for an individual API
89// element.
90message VisibilityRule {
91  // Selects methods, messages, fields, enums, etc. to which this rule applies.
92  //
93  // Refer to [selector][google.api.DocumentationRule.selector] for syntax
94  // details.
95  string selector = 1;
96
97  // A comma-separated list of visibility labels that apply to the `selector`.
98  // Any of the listed labels can be used to grant the visibility.
99  //
100  // If a rule has multiple labels, removing one of the labels but not all of
101  // them can break clients.
102  //
103  // Example:
104  //
105  //     visibility:
106  //       rules:
107  //       - selector: google.calendar.Calendar.EnhancedSearch
108  //         restriction: INTERNAL, PREVIEW
109  //
110  // Removing INTERNAL from this restriction will break clients that rely on
111  // this method and only had access to it through INTERNAL.
112  string restriction = 2;
113}
114