xref: /aosp_15_r20/external/googleapis/google/cloud/resourcesettings/v1/resource_settings.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2021 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.cloud.resourcesettings.v1;
18
19import "google/api/annotations.proto";
20import "google/api/client.proto";
21import "google/api/field_behavior.proto";
22import "google/api/resource.proto";
23
24option cc_enable_arenas = true;
25option go_package = "cloud.google.com/go/resourcesettings/apiv1/resourcesettingspb;resourcesettingspb";
26option java_multiple_files = true;
27option java_outer_classname = "ResourceSettingsProto";
28option java_package = "com.google.cloud.resourcesettings.v1";
29
30// Client library namespace
31option csharp_namespace = "Google.Cloud.ResourceSettings.V1";
32option php_namespace = "Google\\Cloud\\ResourceSettings\\V1";
33option ruby_package = "Google::Cloud::ResourceSettings::V1";
34
35// An interface to interact with resource settings and setting values throughout
36// the resource hierarchy.
37//
38// Services may surface a number of settings for users to control how their
39// resources behave. Values of settings applied on a given Cloud resource are
40// evaluated hierarchically and inherited by all descendants of that resource.
41//
42// For all requests, returns a `google.rpc.Status` with
43// `google.rpc.Code.PERMISSION_DENIED` if the IAM check fails or the `parent`
44// resource is not in a Cloud Organization.
45// For all requests, returns a `google.rpc.Status` with
46// `google.rpc.Code.INVALID_ARGUMENT` if the request is malformed.
47service ResourceSettingsService {
48  option (google.api.default_host) = "resourcesettings.googleapis.com";
49  option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
50
51  // Lists all the settings that are available on the Cloud resource `parent`.
52  rpc ListSettings(ListSettingsRequest) returns (ListSettingsResponse) {
53    option (google.api.http) = {
54      get: "/v1/{parent=organizations/*}/settings"
55      additional_bindings {
56        get: "/v1/{parent=folders/*}/settings"
57      }
58      additional_bindings {
59        get: "/v1/{parent=projects/*}/settings"
60      }
61    };
62    option (google.api.method_signature) = "parent";
63  }
64
65  // Gets a setting.
66  //
67  // Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
68  // setting does not exist.
69  rpc GetSetting(GetSettingRequest) returns (Setting) {
70    option (google.api.http) = {
71      get: "/v1/{name=organizations/*/settings/*}"
72      additional_bindings {
73        get: "/v1/{name=folders/*/settings/*}"
74      }
75      additional_bindings {
76        get: "/v1/{name=projects/*/settings/*}"
77      }
78    };
79    option (google.api.method_signature) = "name";
80  }
81
82  // Updates a setting.
83  //
84  // Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
85  // setting does not exist.
86  // Returns a `google.rpc.Status` with `google.rpc.Code.FAILED_PRECONDITION` if
87  // the setting is flagged as read only.
88  // Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag
89  // supplied in the request does not match the persisted etag of the setting
90  // value.
91  //
92  // On success, the response will contain only `name`, `local_value` and
93  // `etag`.  The `metadata` and `effective_value` cannot be updated through
94  // this API.
95  //
96  // Note: the supplied setting will perform a full overwrite of the
97  // `local_value` field.
98  rpc UpdateSetting(UpdateSettingRequest) returns (Setting) {
99    option (google.api.http) = {
100      patch: "/v1/{setting.name=organizations/*/settings/*}"
101      body: "setting"
102      additional_bindings {
103        patch: "/v1/{setting.name=folders/*/settings/*}"
104        body: "setting"
105      }
106      additional_bindings {
107        patch: "/v1/{setting.name=projects/*/settings/*}"
108        body: "setting"
109      }
110    };
111  }
112}
113
114// The schema for settings.
115message Setting {
116  option (google.api.resource) = {
117    type: "resourcesettings.googleapis.com/Setting"
118    pattern: "projects/{project_number}/settings/{setting_name}"
119    pattern: "folders/{folder}/settings/{setting_name}"
120    pattern: "organizations/{organization}/settings/{setting_name}"
121  };
122
123  // The resource name of the setting. Must be in one of the following forms:
124  //
125  // * `projects/{project_number}/settings/{setting_name}`
126  // * `folders/{folder_id}/settings/{setting_name}`
127  // * `organizations/{organization_id}/settings/{setting_name}`
128  //
129  // For example, "/projects/123/settings/gcp-enableMyFeature"
130  string name = 1;
131
132  // Output only. Metadata about a setting which is not editable by the end user.
133  SettingMetadata metadata = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
134
135  // The configured value of the setting at the given parent resource (ignoring
136  // the resource hierarchy). The data type of [Value][google.cloud.resourcesettings.v1.Value] must always be
137  // consistent with the data type defined in [Setting.metadata][google.cloud.resourcesettings.v1.Setting.metadata].
138  Value local_value = 8;
139
140  // Output only. The computed effective value of the setting at the given parent resource
141  // (based on the resource hierarchy).
142  //
143  // The effective value evaluates to one of the following options in the given
144  // order (the next option is used if the previous one does not exist):
145  //
146  // 1. the local setting value on the given resource: [Setting.local_value][google.cloud.resourcesettings.v1.Setting.local_value]
147  // 2. if one of the given resource's ancestors have a local setting value,
148  //    the local value at the nearest such ancestor
149  // 3. the setting's default value: [SettingMetadata.default_value][google.cloud.resourcesettings.v1.SettingMetadata.default_value]
150  // 4. an empty value (defined as a `Value` with all fields unset)
151  //
152  // The data type of [Value][google.cloud.resourcesettings.v1.Value] must always be
153  // consistent with the data type defined in [Setting.metadata][google.cloud.resourcesettings.v1.Setting.metadata].
154  Value effective_value = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
155
156  // A fingerprint used for optimistic concurrency. See
157  // [UpdateSetting][google.cloud.resourcesettings.v1.ResourceSettingsService.UpdateSetting] for more
158  // details.
159  string etag = 10;
160}
161
162// Metadata about a setting which is not editable by the end user.
163message SettingMetadata {
164  // The data type for setting values of this setting. See [Value][google.cloud.resourcesettings.v1.Value] for more
165  // details on the available data types.
166  enum DataType {
167    // Unspecified data type.
168    DATA_TYPE_UNSPECIFIED = 0;
169
170    // A boolean setting.
171    BOOLEAN = 1;
172
173    // A string setting.
174    STRING = 2;
175
176    // A string set setting.
177    STRING_SET = 3;
178
179    // A Enum setting
180    ENUM_VALUE = 4;
181  }
182
183  // The human readable name for this setting.
184  string display_name = 1;
185
186  // A detailed description of what this setting does.
187  string description = 2;
188
189  // A flag indicating that values of this setting cannot be modified (see
190  // documentation of the specific setting for updates and reasons).
191  bool read_only = 3;
192
193  // The data type for this setting.
194  DataType data_type = 4;
195
196  // The value provided by [Setting.effective_value][google.cloud.resourcesettings.v1.Setting.effective_value] if no setting value is
197  // explicitly set.
198  //
199  // Note: not all settings have a default value.
200  Value default_value = 5;
201}
202
203// The data in a setting value.
204message Value {
205  // A string set value that can hold a set of strings. The maximum length of
206  // each string is 200 characters and there can be a maximum of 50 strings in
207  // the string set.
208  message StringSet {
209    // The strings in the set
210    repeated string values = 1;
211  }
212
213  // A enum value that can hold any enum type setting values.
214  // Each enum type is represented by a number, this representation
215  // is stored in the definitions.
216  message EnumValue {
217    // The value of this enum
218    string value = 1;
219  }
220
221  // Selects the data type and associated value.
222  oneof value {
223    // Defines this value as being a boolean value.
224    bool boolean_value = 1;
225
226    // Defines this value as being a string value.
227    string string_value = 2;
228
229    // Defines this value as being a StringSet.
230    StringSet string_set_value = 3;
231
232    // Defines this value as being a Enum.
233    EnumValue enum_value = 4;
234  }
235}
236
237// The request for ListSettings.
238message ListSettingsRequest {
239  // Required. The Cloud resource that parents the setting. Must be in one of the
240  // following forms:
241  //
242  // * `projects/{project_number}`
243  // * `projects/{project_id}`
244  // * `folders/{folder_id}`
245  // * `organizations/{organization_id}`
246  string parent = 1 [
247    (google.api.field_behavior) = REQUIRED,
248    (google.api.resource_reference) = {
249      type: "*"
250    }
251  ];
252
253  // Unused. The size of the page to be returned.
254  int32 page_size = 2;
255
256  // Unused. A page token used to retrieve the next page.
257  string page_token = 3;
258
259  // The SettingView for this request.
260  SettingView view = 4;
261}
262
263// The response from ListSettings.
264message ListSettingsResponse {
265  // A list of settings that are available at the specified Cloud resource.
266  repeated Setting settings = 1;
267
268  // Unused. A page token used to retrieve the next page.
269  string next_page_token = 2;
270}
271
272// The request for GetSetting.
273message GetSettingRequest {
274  // Required. The name of the setting to get. See [Setting][google.cloud.resourcesettings.v1.Setting] for naming
275  // requirements.
276  string name = 1 [
277    (google.api.field_behavior) = REQUIRED,
278    (google.api.resource_reference) = {
279      type: "resourcesettings.googleapis.com/Setting"
280    }
281  ];
282
283  // The SettingView for this request.
284  SettingView view = 2;
285}
286
287// The request for UpdateSetting.
288message UpdateSettingRequest {
289  // Required. The setting to update. See [Setting][google.cloud.resourcesettings.v1.Setting] for field requirements.
290  Setting setting = 1 [(google.api.field_behavior) = REQUIRED];
291}
292
293// View options for Settings.
294enum SettingView {
295  // The default / unset value.
296  // The API will default to the SETTING_VIEW_BASIC view.
297  SETTING_VIEW_UNSPECIFIED = 0;
298
299  // Include [Setting.metadata][google.cloud.resourcesettings.v1.Setting.metadata], but nothing else.
300  // This is the default value (for both ListSettings and GetSetting).
301  SETTING_VIEW_BASIC = 1;
302
303  // Include [Setting.effective_value][google.cloud.resourcesettings.v1.Setting.effective_value], but nothing else.
304  SETTING_VIEW_EFFECTIVE_VALUE = 2;
305
306  // Include [Setting.local_value][google.cloud.resourcesettings.v1.Setting.local_value], but nothing else.
307  SETTING_VIEW_LOCAL_VALUE = 3;
308}
309