/
policy_schema.go
executable file
·433 lines (431 loc) · 20.6 KB
/
policy_schema.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
// Copyright 2024 Google LLC. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package orgpolicy
import (
"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl"
)
func DCLPolicySchema() *dcl.Schema {
return &dcl.Schema{
Info: &dcl.Info{
Title: "OrgPolicy/Policy",
Description: "An organization policy gives you programmatic control over your organization's cloud resources. Using Organization Policies, you will be able to configure constraints across your entire resource hierarchy.",
StructName: "Policy",
Reference: &dcl.Link{
Text: "REST API",
URL: "https://cloud.google.com/resource-manager/docs/reference/orgpolicy/rest/v2/organizations.policies",
},
Guides: []*dcl.Link{
&dcl.Link{
Text: "Understanding Org Policy concepts",
URL: "https://cloud.google.com/resource-manager/docs/organization-policy/overview",
},
&dcl.Link{
Text: "The resource hierarchy",
URL: "https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy",
},
&dcl.Link{
Text: "All valid constraints",
URL: "https://cloud.google.com/resource-manager/docs/organization-policy/org-policy-constraints",
},
},
},
Paths: &dcl.Paths{
Get: &dcl.Path{
Description: "The function used to get information about a Policy",
Parameters: []dcl.PathParameters{
dcl.PathParameters{
Name: "policy",
Required: true,
Description: "A full instance of a Policy",
},
},
},
Apply: &dcl.Path{
Description: "The function used to apply information about a Policy",
Parameters: []dcl.PathParameters{
dcl.PathParameters{
Name: "policy",
Required: true,
Description: "A full instance of a Policy",
},
},
},
Delete: &dcl.Path{
Description: "The function used to delete a Policy",
Parameters: []dcl.PathParameters{
dcl.PathParameters{
Name: "policy",
Required: true,
Description: "A full instance of a Policy",
},
},
},
DeleteAll: &dcl.Path{
Description: "The function used to delete all Policy",
Parameters: []dcl.PathParameters{
dcl.PathParameters{
Name: "parent",
Required: true,
Schema: &dcl.PathParametersSchema{
Type: "string",
},
},
},
},
List: &dcl.Path{
Description: "The function used to list information about many Policy",
Parameters: []dcl.PathParameters{
dcl.PathParameters{
Name: "parent",
Required: true,
Schema: &dcl.PathParametersSchema{
Type: "string",
},
},
},
},
},
Components: &dcl.Components{
Schemas: map[string]*dcl.Component{
"Policy": &dcl.Component{
Title: "Policy",
ID: "{{parent}}/policies/{{name}}",
HasCreate: true,
SchemaProperty: dcl.Property{
Type: "object",
Required: []string{
"name",
"parent",
},
Properties: map[string]*dcl.Property{
"dryRunSpec": &dcl.Property{
Type: "object",
GoName: "DryRunSpec",
GoType: "PolicyDryRunSpec",
Description: "Dry-run policy. Audit-only policy, can be used to monitor how the policy would have impacted the existing and future resources if it's enforced.",
Properties: map[string]*dcl.Property{
"etag": &dcl.Property{
Type: "string",
GoName: "Etag",
ReadOnly: true,
Description: "An opaque tag indicating the current version of the policy, used for concurrency control. This field is ignored if used in a `CreatePolicy` request. When the policy` is returned from either a `GetPolicy` or a `ListPolicies` request, this `etag` indicates the version of the current policy to use when executing a read-modify-write loop. When the policy is returned from a `GetEffectivePolicy` request, the `etag` will be unset.",
},
"inheritFromParent": &dcl.Property{
Type: "boolean",
GoName: "InheritFromParent",
Description: "Determines the inheritance behavior for this policy. If `inherit_from_parent` is true, policy rules set higher up in the hierarchy (up to the closest root) are inherited and present in the effective policy. If it is false, then no rules are inherited, and this policy becomes the new root for evaluation. This field can be set only for policies which configure list constraints.",
},
"reset": &dcl.Property{
Type: "boolean",
GoName: "Reset",
Description: "Ignores policies set above this resource and restores the `constraint_default` enforcement behavior of the specific constraint at this resource. This field can be set in policies for either list or boolean constraints. If set, `rules` must be empty and `inherit_from_parent` must be set to false.",
},
"rules": &dcl.Property{
Type: "array",
GoName: "Rules",
Description: "In policies for boolean constraints, the following requirements apply: - There must be one and only one policy rule where condition is unset. - Boolean policy rules with conditions must set `enforced` to the opposite of the policy rule without a condition. - During policy evaluation, policy rules with conditions that are true for a target resource take precedence.",
SendEmpty: true,
ListType: "list",
Items: &dcl.Property{
Type: "object",
GoType: "PolicyDryRunSpecRules",
Properties: map[string]*dcl.Property{
"allowAll": &dcl.Property{
Type: "boolean",
GoName: "AllowAll",
Description: "Setting this to `\"TRUE\"` means that all values are allowed. This field can be set only in policies for list constraints.",
Conflicts: []string{
"values",
"denyAll",
"enforce",
},
},
"condition": &dcl.Property{
Type: "object",
GoName: "Condition",
GoType: "PolicyDryRunSpecRulesCondition",
Description: "A condition which determines whether this rule is used in the evaluation of the policy. When set, the `expression` field in the `Expr' must include from 1 to 10 subexpressions, joined by the \"||\" or \"&&\" operators. Each subexpression must be of the form \"resource.matchTag('/tag_key_short_name, 'tag_value_short_name')\". or \"resource.matchTagId('tagKeys/key_id', 'tagValues/value_id')\". where key_name and value_name are the resource names for Label Keys and Values. These names are available from the Tag Manager Service. An example expression is: \"resource.matchTag('123456789/environment, 'prod')\". or \"resource.matchTagId('tagKeys/123', 'tagValues/456')\".",
Properties: map[string]*dcl.Property{
"description": &dcl.Property{
Type: "string",
GoName: "Description",
Description: "Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.",
},
"expression": &dcl.Property{
Type: "string",
GoName: "Expression",
Description: "Textual representation of an expression in Common Expression Language syntax.",
},
"location": &dcl.Property{
Type: "string",
GoName: "Location",
Description: "Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.",
},
"title": &dcl.Property{
Type: "string",
GoName: "Title",
Description: "Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.",
},
},
},
"denyAll": &dcl.Property{
Type: "boolean",
GoName: "DenyAll",
Description: "Setting this to `\"TRUE\"` means that all values are denied. This field can be set only in policies for list constraints.",
Conflicts: []string{
"values",
"allowAll",
"enforce",
},
},
"enforce": &dcl.Property{
Type: "boolean",
GoName: "Enforce",
Description: "If `\"TRUE\"`, then the policy is enforced. If `\"FALSE\"`, then any configuration is acceptable. This field can be set only in policies for boolean constraints.",
Conflicts: []string{
"values",
"allowAll",
"denyAll",
},
},
"values": &dcl.Property{
Type: "object",
GoName: "Values",
GoType: "PolicyDryRunSpecRulesValues",
Description: "List of values to be used for this policy rule. This field can be set only in policies for list constraints.",
Conflicts: []string{
"allowAll",
"denyAll",
"enforce",
},
Properties: map[string]*dcl.Property{
"allowedValues": &dcl.Property{
Type: "array",
GoName: "AllowedValues",
Description: "List of values allowed at this resource.",
SendEmpty: true,
ListType: "list",
Items: &dcl.Property{
Type: "string",
GoType: "string",
},
},
"deniedValues": &dcl.Property{
Type: "array",
GoName: "DeniedValues",
Description: "List of values denied at this resource.",
SendEmpty: true,
ListType: "list",
Items: &dcl.Property{
Type: "string",
GoType: "string",
},
},
},
},
},
},
},
"updateTime": &dcl.Property{
Type: "string",
Format: "date-time",
GoName: "UpdateTime",
ReadOnly: true,
Description: "Output only. The time stamp this was previously updated. This represents the last time a call to `CreatePolicy` or `UpdatePolicy` was made for that policy.",
},
},
},
"etag": &dcl.Property{
Type: "string",
GoName: "Etag",
ReadOnly: true,
Description: "Optional. An opaque tag indicating the current state of the policy, used for concurrency control. This 'etag' is computed by the server based on the value of other fields, and may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding.",
Immutable: true,
},
"name": &dcl.Property{
Type: "string",
GoName: "Name",
Description: "Immutable. The resource name of the Policy. Must be one of the following forms, where constraint_name is the name of the constraint which this Policy configures: * `projects/{project_number}/policies/{constraint_name}` * `folders/{folder_id}/policies/{constraint_name}` * `organizations/{organization_id}/policies/{constraint_name}` For example, \"projects/123/policies/compute.disableSerialPortAccess\". Note: `projects/{project_id}/policies/{constraint_name}` is also an acceptable name for API requests, but responses will return the name using the equivalent project number.",
Immutable: true,
HasLongForm: true,
},
"parent": &dcl.Property{
Type: "string",
GoName: "Parent",
Description: "The parent of the resource.",
Immutable: true,
ForwardSlashAllowed: true,
ResourceReferences: []*dcl.PropertyResourceReference{
&dcl.PropertyResourceReference{
Resource: "Cloudresourcemanager/Folder",
Field: "name",
Parent: true,
},
&dcl.PropertyResourceReference{
Resource: "Cloudresourcemanager/Organization",
Field: "name",
Parent: true,
},
&dcl.PropertyResourceReference{
Resource: "Cloudresourcemanager/Project",
Field: "name",
Parent: true,
},
},
Parameter: true,
},
"spec": &dcl.Property{
Type: "object",
GoName: "Spec",
GoType: "PolicySpec",
Description: "Basic information about the Organization Policy.",
Properties: map[string]*dcl.Property{
"etag": &dcl.Property{
Type: "string",
GoName: "Etag",
ReadOnly: true,
Description: "An opaque tag indicating the current version of the `Policy`, used for concurrency control. This field is ignored if used in a `CreatePolicy` request. When the `Policy` is returned from either a `GetPolicy` or a `ListPolicies` request, this `etag` indicates the version of the current `Policy` to use when executing a read-modify-write loop. When the `Policy` is returned from a `GetEffectivePolicy` request, the `etag` will be unset.",
},
"inheritFromParent": &dcl.Property{
Type: "boolean",
GoName: "InheritFromParent",
Description: "Determines the inheritance behavior for this `Policy`. If `inherit_from_parent` is true, PolicyRules set higher up in the hierarchy (up to the closest root) are inherited and present in the effective policy. If it is false, then no rules are inherited, and this Policy becomes the new root for evaluation. This field can be set only for Policies which configure list constraints.",
},
"reset": &dcl.Property{
Type: "boolean",
GoName: "Reset",
Description: "Ignores policies set above this resource and restores the `constraint_default` enforcement behavior of the specific `Constraint` at this resource. This field can be set in policies for either list or boolean constraints. If set, `rules` must be empty and `inherit_from_parent` must be set to false.",
},
"rules": &dcl.Property{
Type: "array",
GoName: "Rules",
Description: "Up to 10 PolicyRules are allowed. In Policies for boolean constraints, the following requirements apply: - There must be one and only one PolicyRule where condition is unset. - BooleanPolicyRules with conditions must set `enforced` to the opposite of the PolicyRule without a condition. - During policy evaluation, PolicyRules with conditions that are true for a target resource take precedence.",
SendEmpty: true,
ListType: "list",
Items: &dcl.Property{
Type: "object",
GoType: "PolicySpecRules",
Properties: map[string]*dcl.Property{
"allowAll": &dcl.Property{
Type: "boolean",
GoName: "AllowAll",
Description: "Setting this to `\"TRUE\"` means that all values are allowed. This field can be set only in Policies for list constraints.",
Conflicts: []string{
"values",
"denyAll",
"enforce",
},
},
"condition": &dcl.Property{
Type: "object",
GoName: "Condition",
GoType: "PolicySpecRulesCondition",
Description: "A condition which determines whether this rule is used in the evaluation of the policy. When set, the `expression` field in the `Expr' must include from 1 to 10 subexpressions, joined by the \"||\" or \"&&\" operators. Each subexpression must be of the form \"resource.matchTag('/tag_key_short_name, 'tag_value_short_name')\". or \"resource.matchTagId('tagKeys/key_id', 'tagValues/value_id')\". where key_name and value_name are the resource names for Label Keys and Values. These names are available from the Tag Manager Service. An example expression is: \"resource.matchTag('123456789/environment, 'prod')\". or \"resource.matchTagId('tagKeys/123', 'tagValues/456')\".",
Properties: map[string]*dcl.Property{
"description": &dcl.Property{
Type: "string",
GoName: "Description",
Description: "Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.",
},
"expression": &dcl.Property{
Type: "string",
GoName: "Expression",
Description: "Textual representation of an expression in Common Expression Language syntax.",
},
"location": &dcl.Property{
Type: "string",
GoName: "Location",
Description: "Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.",
},
"title": &dcl.Property{
Type: "string",
GoName: "Title",
Description: "Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.",
},
},
},
"denyAll": &dcl.Property{
Type: "boolean",
GoName: "DenyAll",
Description: "Setting this to `\"TRUE\"` means that all values are denied. This field can be set only in Policies for list constraints.",
Conflicts: []string{
"values",
"allowAll",
"enforce",
},
},
"enforce": &dcl.Property{
Type: "boolean",
GoName: "Enforce",
Description: "If `\"TRUE\"`, then the `Policy` is enforced. If `\"FALSE\"`, then any configuration is acceptable. This field can be set only in Policies for boolean constraints.",
Conflicts: []string{
"values",
"allowAll",
"denyAll",
},
},
"values": &dcl.Property{
Type: "object",
GoName: "Values",
GoType: "PolicySpecRulesValues",
Description: "List of values to be used for this PolicyRule. This field can be set only in Policies for list constraints.",
Conflicts: []string{
"allowAll",
"denyAll",
"enforce",
},
Properties: map[string]*dcl.Property{
"allowedValues": &dcl.Property{
Type: "array",
GoName: "AllowedValues",
Description: "List of values allowed at this resource.",
SendEmpty: true,
ListType: "list",
Items: &dcl.Property{
Type: "string",
GoType: "string",
},
},
"deniedValues": &dcl.Property{
Type: "array",
GoName: "DeniedValues",
Description: "List of values denied at this resource.",
SendEmpty: true,
ListType: "list",
Items: &dcl.Property{
Type: "string",
GoType: "string",
},
},
},
},
},
},
},
"updateTime": &dcl.Property{
Type: "string",
Format: "date-time",
GoName: "UpdateTime",
ReadOnly: true,
Description: "Output only. The time stamp this was previously updated. This represents the last time a call to `CreatePolicy` or `UpdatePolicy` was made for that `Policy`.",
},
},
},
},
},
},
},
},
}
}