orgpolicy.proto 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. // Copyright 2022 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. syntax = "proto3";
  15. package google.cloud.orgpolicy.v2;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/api/resource.proto";
  20. import "google/cloud/orgpolicy/v2/constraint.proto";
  21. import "google/protobuf/empty.proto";
  22. import "google/protobuf/timestamp.proto";
  23. import "google/type/expr.proto";
  24. option csharp_namespace = "Google.Cloud.OrgPolicy.V2";
  25. option go_package = "google.golang.org/genproto/googleapis/cloud/orgpolicy/v2;orgpolicy";
  26. option java_multiple_files = true;
  27. option java_outer_classname = "OrgPolicyProto";
  28. option java_package = "com.google.cloud.orgpolicy.v2";
  29. option php_namespace = "Google\\Cloud\\OrgPolicy\\V2";
  30. option ruby_package = "Google::Cloud::OrgPolicy::V2";
  31. // An interface for managing organization policies.
  32. //
  33. // The Cloud Org Policy service provides a simple mechanism for organizations to
  34. // restrict the allowed configurations across their entire Cloud Resource
  35. // hierarchy.
  36. //
  37. // You can use a `policy` to configure restrictions in Cloud resources. For
  38. // example, you can enforce a `policy` that restricts which Google
  39. // Cloud Platform APIs can be activated in a certain part of your resource
  40. // hierarchy, or prevents serial port access to VM instances in a particular
  41. // folder.
  42. //
  43. // `Policies` are inherited down through the resource hierarchy. A `policy`
  44. // applied to a parent resource automatically applies to all its child resources
  45. // unless overridden with a `policy` lower in the hierarchy.
  46. //
  47. // A `constraint` defines an aspect of a resource's configuration that can be
  48. // controlled by an organization's policy administrator. `Policies` are a
  49. // collection of `constraints` that defines their allowable configuration on a
  50. // particular resource and its child resources.
  51. service OrgPolicy {
  52. option (google.api.default_host) = "orgpolicy.googleapis.com";
  53. option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
  54. // Lists `Constraints` that could be applied on the specified resource.
  55. rpc ListConstraints(ListConstraintsRequest) returns (ListConstraintsResponse) {
  56. option (google.api.http) = {
  57. get: "/v2/{parent=projects/*}/constraints"
  58. additional_bindings {
  59. get: "/v2/{parent=folders/*}/constraints"
  60. }
  61. additional_bindings {
  62. get: "/v2/{parent=organizations/*}/constraints"
  63. }
  64. };
  65. option (google.api.method_signature) = "parent";
  66. }
  67. // Retrieves all of the `Policies` that exist on a particular resource.
  68. rpc ListPolicies(ListPoliciesRequest) returns (ListPoliciesResponse) {
  69. option (google.api.http) = {
  70. get: "/v2/{parent=projects/*}/policies"
  71. additional_bindings {
  72. get: "/v2/{parent=folders/*}/policies"
  73. }
  74. additional_bindings {
  75. get: "/v2/{parent=organizations/*}/policies"
  76. }
  77. };
  78. option (google.api.method_signature) = "parent";
  79. }
  80. // Gets a `Policy` on a resource.
  81. //
  82. // If no `Policy` is set on the resource, NOT_FOUND is returned. The
  83. // `etag` value can be used with `UpdatePolicy()` to update a
  84. // `Policy` during read-modify-write.
  85. rpc GetPolicy(GetPolicyRequest) returns (Policy) {
  86. option (google.api.http) = {
  87. get: "/v2/{name=projects/*/policies/*}"
  88. additional_bindings {
  89. get: "/v2/{name=folders/*/policies/*}"
  90. }
  91. additional_bindings {
  92. get: "/v2/{name=organizations/*/policies/*}"
  93. }
  94. };
  95. option (google.api.method_signature) = "name";
  96. }
  97. // Gets the effective `Policy` on a resource. This is the result of merging
  98. // `Policies` in the resource hierarchy and evaluating conditions. The
  99. // returned `Policy` will not have an `etag` or `condition` set because it is
  100. // a computed `Policy` across multiple resources.
  101. // Subtrees of Resource Manager resource hierarchy with 'under:' prefix will
  102. // not be expanded.
  103. rpc GetEffectivePolicy(GetEffectivePolicyRequest) returns (Policy) {
  104. option (google.api.http) = {
  105. get: "/v2/{name=projects/*/policies/*}:getEffectivePolicy"
  106. additional_bindings {
  107. get: "/v2/{name=folders/*/policies/*}:getEffectivePolicy"
  108. }
  109. additional_bindings {
  110. get: "/v2/{name=organizations/*/policies/*}:getEffectivePolicy"
  111. }
  112. };
  113. option (google.api.method_signature) = "name";
  114. }
  115. // Creates a Policy.
  116. //
  117. // Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
  118. // constraint does not exist.
  119. // Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the
  120. // policy already exists on the given Cloud resource.
  121. rpc CreatePolicy(CreatePolicyRequest) returns (Policy) {
  122. option (google.api.http) = {
  123. post: "/v2/{parent=projects/*}/policies"
  124. body: "policy"
  125. additional_bindings {
  126. post: "/v2/{parent=folders/*}/policies"
  127. body: "policy"
  128. }
  129. additional_bindings {
  130. post: "/v2/{parent=organizations/*}/policies"
  131. body: "policy"
  132. }
  133. };
  134. option (google.api.method_signature) = "parent,policy";
  135. }
  136. // Updates a Policy.
  137. //
  138. // Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
  139. // constraint or the policy do not exist.
  140. // Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag
  141. // supplied in the request does not match the persisted etag of the policy
  142. //
  143. // Note: the supplied policy will perform a full overwrite of all
  144. // fields.
  145. rpc UpdatePolicy(UpdatePolicyRequest) returns (Policy) {
  146. option (google.api.http) = {
  147. patch: "/v2/{policy.name=projects/*/policies/*}"
  148. body: "policy"
  149. additional_bindings {
  150. patch: "/v2/{policy.name=folders/*/policies/*}"
  151. body: "policy"
  152. }
  153. additional_bindings {
  154. patch: "/v2/{policy.name=organizations/*/policies/*}"
  155. body: "policy"
  156. }
  157. };
  158. option (google.api.method_signature) = "policy";
  159. }
  160. // Deletes a Policy.
  161. //
  162. // Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
  163. // constraint or Org Policy does not exist.
  164. rpc DeletePolicy(DeletePolicyRequest) returns (google.protobuf.Empty) {
  165. option (google.api.http) = {
  166. delete: "/v2/{name=projects/*/policies/*}"
  167. additional_bindings {
  168. delete: "/v2/{name=folders/*/policies/*}"
  169. }
  170. additional_bindings {
  171. delete: "/v2/{name=organizations/*/policies/*}"
  172. }
  173. };
  174. option (google.api.method_signature) = "name";
  175. }
  176. }
  177. // Defines a Cloud Organization `Policy` which is used to specify `Constraints`
  178. // for configurations of Cloud Platform resources.
  179. message Policy {
  180. option (google.api.resource) = {
  181. type: "orgpolicy.googleapis.com/Policy"
  182. pattern: "projects/{project}/policies/{policy}"
  183. pattern: "folders/{folder}/policies/{policy}"
  184. pattern: "organizations/{organization}/policies/{policy}"
  185. };
  186. // Immutable. The resource name of the Policy. Must be one of the following
  187. // forms, where constraint_name is the name of the constraint which this
  188. // Policy configures:
  189. // * `projects/{project_number}/policies/{constraint_name}`
  190. // * `folders/{folder_id}/policies/{constraint_name}`
  191. // * `organizations/{organization_id}/policies/{constraint_name}`
  192. //
  193. // For example, "projects/123/policies/compute.disableSerialPortAccess".
  194. //
  195. // Note: `projects/{project_id}/policies/{constraint_name}` is also an
  196. // acceptable name for API requests, but responses will return the name using
  197. // the equivalent project number.
  198. string name = 1 [(google.api.field_behavior) = IMMUTABLE];
  199. // Basic information about the Organization Policy.
  200. PolicySpec spec = 2;
  201. // Deprecated.
  202. AlternatePolicySpec alternate = 3 [deprecated = true];
  203. }
  204. // Similar to PolicySpec but with an extra 'launch' field for launch reference.
  205. // The PolicySpec here is specific for dry-run/darklaunch.
  206. message AlternatePolicySpec {
  207. // Reference to the launch that will be used while audit logging and to
  208. // control the launch.
  209. // Should be set only in the alternate policy.
  210. string launch = 1;
  211. // Specify `Constraint` for configurations of Cloud Platform resources.
  212. PolicySpec spec = 2;
  213. }
  214. // Defines a Cloud Organization `PolicySpec` which is used to specify
  215. // `Constraints` for configurations of Cloud Platform resources.
  216. message PolicySpec {
  217. // A rule used to express this policy.
  218. message PolicyRule {
  219. // A message that holds specific allowed and denied values.
  220. // This message can define specific values and subtrees of Cloud Resource
  221. // Manager resource hierarchy (`Organizations`, `Folders`, `Projects`) that
  222. // are allowed or denied. This is achieved by using the `under:` and
  223. // optional `is:` prefixes.
  224. // The `under:` prefix is used to denote resource subtree values.
  225. // The `is:` prefix is used to denote specific values, and is required only
  226. // if the value contains a ":". Values prefixed with "is:" are treated the
  227. // same as values with no prefix.
  228. // Ancestry subtrees must be in one of the following formats:
  229. // - "projects/<project-id>", e.g. "projects/tokyo-rain-123"
  230. // - "folders/<folder-id>", e.g. "folders/1234"
  231. // - "organizations/<organization-id>", e.g. "organizations/1234"
  232. // The `supports_under` field of the associated `Constraint` defines
  233. // whether ancestry prefixes can be used.
  234. message StringValues {
  235. // List of values allowed at this resource.
  236. repeated string allowed_values = 1;
  237. // List of values denied at this resource.
  238. repeated string denied_values = 2;
  239. }
  240. oneof kind {
  241. // List of values to be used for this PolicyRule. This field can be set
  242. // only in Policies for list constraints.
  243. StringValues values = 1;
  244. // Setting this to true means that all values are allowed. This field can
  245. // be set only in Policies for list constraints.
  246. bool allow_all = 2;
  247. // Setting this to true means that all values are denied. This field can
  248. // be set only in Policies for list constraints.
  249. bool deny_all = 3;
  250. // If `true`, then the `Policy` is enforced. If `false`, then any
  251. // configuration is acceptable.
  252. // This field can be set only in Policies for boolean constraints.
  253. bool enforce = 4;
  254. }
  255. // A condition which determines whether this rule is used
  256. // in the evaluation of the policy. When set, the `expression` field in
  257. // the `Expr' must include from 1 to 10 subexpressions, joined by the "||"
  258. // or "&&" operators. Each subexpression must be of the form
  259. // "resource.matchTag('<ORG_ID>/tag_key_short_name,
  260. // 'tag_value_short_name')". or "resource.matchTagId('tagKeys/key_id',
  261. // 'tagValues/value_id')". where key_name and value_name are the resource
  262. // names for Label Keys and Values. These names are available from the Tag
  263. // Manager Service. An example expression is:
  264. // "resource.matchTag('123456789/environment,
  265. // 'prod')". or "resource.matchTagId('tagKeys/123',
  266. // 'tagValues/456')".
  267. google.type.Expr condition = 5;
  268. }
  269. // An opaque tag indicating the current version of the `Policy`, used for
  270. // concurrency control.
  271. //
  272. // This field is ignored if used in a `CreatePolicy` request.
  273. //
  274. // When the `Policy` is returned from either a `GetPolicy` or a
  275. // `ListPolicies` request, this `etag` indicates the version of the
  276. // current `Policy` to use when executing a read-modify-write loop.
  277. //
  278. // When the `Policy` is returned from a `GetEffectivePolicy` request, the
  279. // `etag` will be unset.
  280. string etag = 1;
  281. // Output only. The time stamp this was previously updated. This
  282. // represents the last time a call to `CreatePolicy` or `UpdatePolicy` was
  283. // made for that `Policy`.
  284. google.protobuf.Timestamp update_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
  285. // Up to 10 PolicyRules are allowed.
  286. //
  287. // In Policies for boolean constraints, the following requirements apply:
  288. // - There must be one and only one PolicyRule where condition is unset.
  289. // - BooleanPolicyRules with conditions must set `enforced` to the opposite
  290. // of the PolicyRule without a condition.
  291. // - During policy evaluation, PolicyRules with conditions that are
  292. // true for a target resource take precedence.
  293. repeated PolicyRule rules = 3;
  294. // Determines the inheritance behavior for this `Policy`.
  295. //
  296. // If `inherit_from_parent` is true, PolicyRules set higher up in the
  297. // hierarchy (up to the closest root) are inherited and present in the
  298. // effective policy. If it is false, then no rules are inherited, and this
  299. // Policy becomes the new root for evaluation.
  300. // This field can be set only for Policies which configure list constraints.
  301. bool inherit_from_parent = 4;
  302. // Ignores policies set above this resource and restores the
  303. // `constraint_default` enforcement behavior of the specific `Constraint` at
  304. // this resource.
  305. // This field can be set in policies for either list or boolean
  306. // constraints. If set, `rules` must be empty and `inherit_from_parent`
  307. // must be set to false.
  308. bool reset = 5;
  309. }
  310. // The request sent to the [ListConstraints]
  311. // [google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints] method.
  312. message ListConstraintsRequest {
  313. // Required. The Cloud resource that parents the constraint. Must be in one of the
  314. // following forms:
  315. // * `projects/{project_number}`
  316. // * `projects/{project_id}`
  317. // * `folders/{folder_id}`
  318. // * `organizations/{organization_id}`
  319. string parent = 1 [
  320. (google.api.field_behavior) = REQUIRED,
  321. (google.api.resource_reference) = {
  322. child_type: "orgpolicy.googleapis.com/Constraint"
  323. }
  324. ];
  325. // Size of the pages to be returned. This is currently unsupported and will
  326. // be ignored. The server may at any point start using this field to limit
  327. // page size.
  328. int32 page_size = 2;
  329. // Page token used to retrieve the next page. This is currently unsupported
  330. // and will be ignored. The server may at any point start using this field.
  331. string page_token = 3;
  332. }
  333. // The response returned from the [ListConstraints]
  334. // [google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints] method.
  335. message ListConstraintsResponse {
  336. // The collection of constraints that are available on the targeted resource.
  337. repeated Constraint constraints = 1;
  338. // Page token used to retrieve the next page. This is currently not used.
  339. string next_page_token = 2;
  340. }
  341. // The request sent to the [ListPolicies]
  342. // [google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies] method.
  343. message ListPoliciesRequest {
  344. // Required. The target Cloud resource that parents the set of constraints and policies
  345. // that will be returned from this call. Must be in one of the following
  346. // forms:
  347. // * `projects/{project_number}`
  348. // * `projects/{project_id}`
  349. // * `folders/{folder_id}`
  350. // * `organizations/{organization_id}`
  351. string parent = 1 [
  352. (google.api.field_behavior) = REQUIRED,
  353. (google.api.resource_reference) = {
  354. child_type: "orgpolicy.googleapis.com/Policy"
  355. }
  356. ];
  357. // Size of the pages to be returned. This is currently unsupported and will
  358. // be ignored. The server may at any point start using this field to limit
  359. // page size.
  360. int32 page_size = 2;
  361. // Page token used to retrieve the next page. This is currently unsupported
  362. // and will be ignored. The server may at any point start using this field.
  363. string page_token = 3;
  364. }
  365. // The response returned from the [ListPolicies]
  366. // [google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies] method. It will be empty
  367. // if no `Policies` are set on the resource.
  368. message ListPoliciesResponse {
  369. // All `Policies` that exist on the resource. It will be empty if no
  370. // `Policies` are set.
  371. repeated Policy policies = 1;
  372. // Page token used to retrieve the next page. This is currently not used, but
  373. // the server may at any point start supplying a valid token.
  374. string next_page_token = 2;
  375. }
  376. // The request sent to the [GetPolicy]
  377. // [google.cloud.orgpolicy.v2.OrgPolicy.GetPolicy] method.
  378. message GetPolicyRequest {
  379. // Required. Resource name of the policy. See `Policy` for naming requirements.
  380. string name = 1 [
  381. (google.api.field_behavior) = REQUIRED,
  382. (google.api.resource_reference) = {
  383. type: "orgpolicy.googleapis.com/Policy"
  384. }
  385. ];
  386. }
  387. // The request sent to the [GetEffectivePolicy]
  388. // [google.cloud.orgpolicy.v2.OrgPolicy.GetEffectivePolicy] method.
  389. message GetEffectivePolicyRequest {
  390. // Required. The effective policy to compute. See `Policy` for naming rules.
  391. string name = 1 [
  392. (google.api.field_behavior) = REQUIRED,
  393. (google.api.resource_reference) = {
  394. type: "orgpolicy.googleapis.com/Policy"
  395. }
  396. ];
  397. }
  398. // The request sent to the [CreatePolicyRequest]
  399. // [google.cloud.orgpolicy.v2.OrgPolicy.CreatePolicy] method.
  400. message CreatePolicyRequest {
  401. // Required. The Cloud resource that will parent the new Policy. Must be in one of the
  402. // following forms:
  403. // * `projects/{project_number}`
  404. // * `projects/{project_id}`
  405. // * `folders/{folder_id}`
  406. // * `organizations/{organization_id}`
  407. string parent = 1 [
  408. (google.api.field_behavior) = REQUIRED,
  409. (google.api.resource_reference) = {
  410. child_type: "orgpolicy.googleapis.com/Policy"
  411. }
  412. ];
  413. // Required. `Policy` to create.
  414. Policy policy = 3 [(google.api.field_behavior) = REQUIRED];
  415. }
  416. // The request sent to the [UpdatePolicyRequest]
  417. // [google.cloud.orgpolicy.v2.OrgPolicy.UpdatePolicy] method.
  418. message UpdatePolicyRequest {
  419. // Required. `Policy` to update.
  420. Policy policy = 1 [(google.api.field_behavior) = REQUIRED];
  421. }
  422. // The request sent to the [DeletePolicy]
  423. // [google.cloud.orgpolicy.v2.OrgPolicy.DeletePolicy] method.
  424. message DeletePolicyRequest {
  425. // Required. Name of the policy to delete.
  426. // See `Policy` for naming rules.
  427. string name = 1 [
  428. (google.api.field_behavior) = REQUIRED,
  429. (google.api.resource_reference) = {
  430. type: "orgpolicy.googleapis.com/Policy"
  431. }
  432. ];
  433. }