orgpolicy.proto 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. // Copyright 2019 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. package google.cloud.orgpolicy.v1;
  17. import "google/protobuf/timestamp.proto";
  18. option csharp_namespace = "Google.Cloud.OrgPolicy.V1";
  19. option go_package = "google.golang.org/genproto/googleapis/cloud/orgpolicy/v1;orgpolicy";
  20. option java_multiple_files = true;
  21. option java_outer_classname = "OrgPolicyProto";
  22. option java_package = "com.google.cloud.orgpolicy.v1";
  23. option php_namespace = "Google\\Cloud\\OrgPolicy\\V1";
  24. option ruby_package = "Google::Cloud::OrgPolicy::V1";
  25. // Defines a Cloud Organization `Policy` which is used to specify `Constraints`
  26. // for configurations of Cloud Platform resources.
  27. message Policy {
  28. // Used in `policy_type` to specify how `list_policy` behaves at this
  29. // resource.
  30. //
  31. // `ListPolicy` can define specific values and subtrees of Cloud Resource
  32. // Manager resource hierarchy (`Organizations`, `Folders`, `Projects`) that
  33. // are allowed or denied by setting the `allowed_values` and `denied_values`
  34. // fields. This is achieved by using the `under:` and optional `is:` prefixes.
  35. // The `under:` prefix is used to denote resource subtree values.
  36. // The `is:` prefix is used to denote specific values, and is required only
  37. // if the value contains a ":". Values prefixed with "is:" are treated the
  38. // same as values with no prefix.
  39. // Ancestry subtrees must be in one of the following formats:
  40. // - "projects/<project-id>", e.g. "projects/tokyo-rain-123"
  41. // - "folders/<folder-id>", e.g. "folders/1234"
  42. // - "organizations/<organization-id>", e.g. "organizations/1234"
  43. // The `supports_under` field of the associated `Constraint` defines whether
  44. // ancestry prefixes can be used. You can set `allowed_values` and
  45. // `denied_values` in the same `Policy` if `all_values` is
  46. // `ALL_VALUES_UNSPECIFIED`. `ALLOW` or `DENY` are used to allow or deny all
  47. // values. If `all_values` is set to either `ALLOW` or `DENY`,
  48. // `allowed_values` and `denied_values` must be unset.
  49. message ListPolicy {
  50. // This enum can be used to set `Policies` that apply to all possible
  51. // configuration values rather than specific values in `allowed_values` or
  52. // `denied_values`.
  53. //
  54. // Settting this to `ALLOW` will mean this `Policy` allows all values.
  55. // Similarly, setting it to `DENY` will mean no values are allowed. If
  56. // set to either `ALLOW` or `DENY, `allowed_values` and `denied_values`
  57. // must be unset. Setting this to `ALL_VALUES_UNSPECIFIED` allows for
  58. // setting `allowed_values` and `denied_values`.
  59. enum AllValues {
  60. // Indicates that allowed_values or denied_values must be set.
  61. ALL_VALUES_UNSPECIFIED = 0;
  62. // A policy with this set allows all values.
  63. ALLOW = 1;
  64. // A policy with this set denies all values.
  65. DENY = 2;
  66. }
  67. // List of values allowed at this resource. Can only be set if `all_values`
  68. // is set to `ALL_VALUES_UNSPECIFIED`.
  69. repeated string allowed_values = 1;
  70. // List of values denied at this resource. Can only be set if `all_values`
  71. // is set to `ALL_VALUES_UNSPECIFIED`.
  72. repeated string denied_values = 2;
  73. // The policy all_values state.
  74. AllValues all_values = 3;
  75. // Optional. The Google Cloud Console will try to default to a configuration
  76. // that matches the value specified in this `Policy`. If `suggested_value`
  77. // is not set, it will inherit the value specified higher in the hierarchy,
  78. // unless `inherit_from_parent` is `false`.
  79. string suggested_value = 4;
  80. // Determines the inheritance behavior for this `Policy`.
  81. //
  82. // By default, a `ListPolicy` set at a resource supercedes any `Policy` set
  83. // anywhere up the resource hierarchy. However, if `inherit_from_parent` is
  84. // set to `true`, then the values from the effective `Policy` of the parent
  85. // resource are inherited, meaning the values set in this `Policy` are
  86. // added to the values inherited up the hierarchy.
  87. //
  88. // Setting `Policy` hierarchies that inherit both allowed values and denied
  89. // values isn't recommended in most circumstances to keep the configuration
  90. // simple and understandable. However, it is possible to set a `Policy` with
  91. // `allowed_values` set that inherits a `Policy` with `denied_values` set.
  92. // In this case, the values that are allowed must be in `allowed_values` and
  93. // not present in `denied_values`.
  94. //
  95. // For example, suppose you have a `Constraint`
  96. // `constraints/serviceuser.services`, which has a `constraint_type` of
  97. // `list_constraint`, and with `constraint_default` set to `ALLOW`.
  98. // Suppose that at the Organization level, a `Policy` is applied that
  99. // restricts the allowed API activations to {`E1`, `E2`}. Then, if a
  100. // `Policy` is applied to a project below the Organization that has
  101. // `inherit_from_parent` set to `false` and field all_values set to DENY,
  102. // then an attempt to activate any API will be denied.
  103. //
  104. // The following examples demonstrate different possible layerings for
  105. // `projects/bar` parented by `organizations/foo`:
  106. //
  107. // Example 1 (no inherited values):
  108. // `organizations/foo` has a `Policy` with values:
  109. // {allowed_values: "E1" allowed_values:"E2"}
  110. // `projects/bar` has `inherit_from_parent` `false` and values:
  111. // {allowed_values: "E3" allowed_values: "E4"}
  112. // The accepted values at `organizations/foo` are `E1`, `E2`.
  113. // The accepted values at `projects/bar` are `E3`, and `E4`.
  114. //
  115. // Example 2 (inherited values):
  116. // `organizations/foo` has a `Policy` with values:
  117. // {allowed_values: "E1" allowed_values:"E2"}
  118. // `projects/bar` has a `Policy` with values:
  119. // {value: "E3" value: "E4" inherit_from_parent: true}
  120. // The accepted values at `organizations/foo` are `E1`, `E2`.
  121. // The accepted values at `projects/bar` are `E1`, `E2`, `E3`, and `E4`.
  122. //
  123. // Example 3 (inheriting both allowed and denied values):
  124. // `organizations/foo` has a `Policy` with values:
  125. // {allowed_values: "E1" allowed_values: "E2"}
  126. // `projects/bar` has a `Policy` with:
  127. // {denied_values: "E1"}
  128. // The accepted values at `organizations/foo` are `E1`, `E2`.
  129. // The value accepted at `projects/bar` is `E2`.
  130. //
  131. // Example 4 (RestoreDefault):
  132. // `organizations/foo` has a `Policy` with values:
  133. // {allowed_values: "E1" allowed_values:"E2"}
  134. // `projects/bar` has a `Policy` with values:
  135. // {RestoreDefault: {}}
  136. // The accepted values at `organizations/foo` are `E1`, `E2`.
  137. // The accepted values at `projects/bar` are either all or none depending on
  138. // the value of `constraint_default` (if `ALLOW`, all; if
  139. // `DENY`, none).
  140. //
  141. // Example 5 (no policy inherits parent policy):
  142. // `organizations/foo` has no `Policy` set.
  143. // `projects/bar` has no `Policy` set.
  144. // The accepted values at both levels are either all or none depending on
  145. // the value of `constraint_default` (if `ALLOW`, all; if
  146. // `DENY`, none).
  147. //
  148. // Example 6 (ListConstraint allowing all):
  149. // `organizations/foo` has a `Policy` with values:
  150. // {allowed_values: "E1" allowed_values: "E2"}
  151. // `projects/bar` has a `Policy` with:
  152. // {all: ALLOW}
  153. // The accepted values at `organizations/foo` are `E1`, E2`.
  154. // Any value is accepted at `projects/bar`.
  155. //
  156. // Example 7 (ListConstraint allowing none):
  157. // `organizations/foo` has a `Policy` with values:
  158. // {allowed_values: "E1" allowed_values: "E2"}
  159. // `projects/bar` has a `Policy` with:
  160. // {all: DENY}
  161. // The accepted values at `organizations/foo` are `E1`, E2`.
  162. // No value is accepted at `projects/bar`.
  163. //
  164. // Example 10 (allowed and denied subtrees of Resource Manager hierarchy):
  165. // Given the following resource hierarchy
  166. // O1->{F1, F2}; F1->{P1}; F2->{P2, P3},
  167. // `organizations/foo` has a `Policy` with values:
  168. // {allowed_values: "under:organizations/O1"}
  169. // `projects/bar` has a `Policy` with:
  170. // {allowed_values: "under:projects/P3"}
  171. // {denied_values: "under:folders/F2"}
  172. // The accepted values at `organizations/foo` are `organizations/O1`,
  173. // `folders/F1`, `folders/F2`, `projects/P1`, `projects/P2`,
  174. // `projects/P3`.
  175. // The accepted values at `projects/bar` are `organizations/O1`,
  176. // `folders/F1`, `projects/P1`.
  177. bool inherit_from_parent = 5;
  178. }
  179. // Used in `policy_type` to specify how `boolean_policy` will behave at this
  180. // resource.
  181. message BooleanPolicy {
  182. // If `true`, then the `Policy` is enforced. If `false`, then any
  183. // configuration is acceptable.
  184. //
  185. // Suppose you have a `Constraint`
  186. // `constraints/compute.disableSerialPortAccess` with `constraint_default`
  187. // set to `ALLOW`. A `Policy` for that `Constraint` exhibits the following
  188. // behavior:
  189. // - If the `Policy` at this resource has enforced set to `false`, serial
  190. // port connection attempts will be allowed.
  191. // - If the `Policy` at this resource has enforced set to `true`, serial
  192. // port connection attempts will be refused.
  193. // - If the `Policy` at this resource is `RestoreDefault`, serial port
  194. // connection attempts will be allowed.
  195. // - If no `Policy` is set at this resource or anywhere higher in the
  196. // resource hierarchy, serial port connection attempts will be allowed.
  197. // - If no `Policy` is set at this resource, but one exists higher in the
  198. // resource hierarchy, the behavior is as if the`Policy` were set at
  199. // this resource.
  200. //
  201. // The following examples demonstrate the different possible layerings:
  202. //
  203. // Example 1 (nearest `Constraint` wins):
  204. // `organizations/foo` has a `Policy` with:
  205. // {enforced: false}
  206. // `projects/bar` has no `Policy` set.
  207. // The constraint at `projects/bar` and `organizations/foo` will not be
  208. // enforced.
  209. //
  210. // Example 2 (enforcement gets replaced):
  211. // `organizations/foo` has a `Policy` with:
  212. // {enforced: false}
  213. // `projects/bar` has a `Policy` with:
  214. // {enforced: true}
  215. // The constraint at `organizations/foo` is not enforced.
  216. // The constraint at `projects/bar` is enforced.
  217. //
  218. // Example 3 (RestoreDefault):
  219. // `organizations/foo` has a `Policy` with:
  220. // {enforced: true}
  221. // `projects/bar` has a `Policy` with:
  222. // {RestoreDefault: {}}
  223. // The constraint at `organizations/foo` is enforced.
  224. // The constraint at `projects/bar` is not enforced, because
  225. // `constraint_default` for the `Constraint` is `ALLOW`.
  226. bool enforced = 1;
  227. }
  228. // Ignores policies set above this resource and restores the
  229. // `constraint_default` enforcement behavior of the specific `Constraint` at
  230. // this resource.
  231. //
  232. // Suppose that `constraint_default` is set to `ALLOW` for the
  233. // `Constraint` `constraints/serviceuser.services`. Suppose that organization
  234. // foo.com sets a `Policy` at their Organization resource node that restricts
  235. // the allowed service activations to deny all service activations. They
  236. // could then set a `Policy` with the `policy_type` `restore_default` on
  237. // several experimental projects, restoring the `constraint_default`
  238. // enforcement of the `Constraint` for only those projects, allowing those
  239. // projects to have all services activated.
  240. message RestoreDefault {
  241. }
  242. // Version of the `Policy`. Default version is 0;
  243. int32 version = 1;
  244. // The name of the `Constraint` the `Policy` is configuring, for example,
  245. // `constraints/serviceuser.services`.
  246. //
  247. // Immutable after creation.
  248. string constraint = 2;
  249. // An opaque tag indicating the current version of the `Policy`, used for
  250. // concurrency control.
  251. //
  252. // When the `Policy` is returned from either a `GetPolicy` or a
  253. // `ListOrgPolicy` request, this `etag` indicates the version of the current
  254. // `Policy` to use when executing a read-modify-write loop.
  255. //
  256. // When the `Policy` is returned from a `GetEffectivePolicy` request, the
  257. // `etag` will be unset.
  258. //
  259. // When the `Policy` is used in a `SetOrgPolicy` method, use the `etag` value
  260. // that was returned from a `GetOrgPolicy` request as part of a
  261. // read-modify-write loop for concurrency control. Not setting the `etag`in a
  262. // `SetOrgPolicy` request will result in an unconditional write of the
  263. // `Policy`.
  264. bytes etag = 3;
  265. // The time stamp the `Policy` was previously updated. This is set by the
  266. // server, not specified by the caller, and represents the last time a call to
  267. // `SetOrgPolicy` was made for that `Policy`. Any value set by the client will
  268. // be ignored.
  269. google.protobuf.Timestamp update_time = 4;
  270. // The field to populate is based on the `constraint_type` value in the
  271. // `Constraint`.
  272. // `list_constraint` => `list_policy`
  273. // `boolean_constraint` => `boolean_policy`
  274. //
  275. // A `restore_default` message may be used with any `Constraint` type.
  276. //
  277. // Providing a *_policy that is incompatible with the `constraint_type` will
  278. // result in an `invalid_argument` error.
  279. //
  280. // Attempting to set a `Policy` with a `policy_type` not set will result in an
  281. // `invalid_argument` error.
  282. oneof policy_type {
  283. // List of values either allowed or disallowed.
  284. ListPolicy list_policy = 5;
  285. // For boolean `Constraints`, whether to enforce the `Constraint` or not.
  286. BooleanPolicy boolean_policy = 6;
  287. // Restores the default behavior of the constraint; independent of
  288. // `Constraint` type.
  289. RestoreDefault restore_default = 7;
  290. }
  291. }