policy.proto 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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.iam.v2;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/iam/v2/deny.proto";
  20. import "google/longrunning/operations.proto";
  21. import "google/protobuf/timestamp.proto";
  22. option csharp_namespace = "Google.Cloud.Iam.V2";
  23. option go_package = "google.golang.org/genproto/googleapis/iam/v2;iam";
  24. option java_multiple_files = true;
  25. option java_outer_classname = "PolicyProto";
  26. option java_package = "com.google.iam.v2";
  27. option php_namespace = "Google\\Cloud\\Iam\\V2";
  28. // An interface for managing Identity and Access Management (IAM) policies.
  29. service Policies {
  30. option (google.api.default_host) = "iam.googleapis.com";
  31. option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
  32. // Retrieves the policies of the specified kind that are attached to a
  33. // resource.
  34. //
  35. // The response lists only policy metadata. In particular, policy rules are
  36. // omitted.
  37. rpc ListPolicies(ListPoliciesRequest) returns (ListPoliciesResponse) {
  38. option (google.api.http) = {
  39. get: "/v2/{parent=policies/*/*}"
  40. };
  41. option (google.api.method_signature) = "parent";
  42. }
  43. // Gets a policy.
  44. rpc GetPolicy(GetPolicyRequest) returns (Policy) {
  45. option (google.api.http) = {
  46. get: "/v2/{name=policies/*/*/*}"
  47. };
  48. option (google.api.method_signature) = "name";
  49. }
  50. // Creates a policy.
  51. rpc CreatePolicy(CreatePolicyRequest) returns (google.longrunning.Operation) {
  52. option (google.api.http) = {
  53. post: "/v2/{parent=policies/*/*}"
  54. body: "policy"
  55. };
  56. option (google.api.method_signature) = "parent,policy,policy_id";
  57. option (google.longrunning.operation_info) = {
  58. response_type: "Policy"
  59. metadata_type: "PolicyOperationMetadata"
  60. };
  61. }
  62. // Updates the specified policy.
  63. //
  64. // You can update only the rules and the display name for the policy.
  65. //
  66. // To update a policy, you should use a read-modify-write loop:
  67. //
  68. // 1. Use [GetPolicy][google.iam.v2.Policies.GetPolicy] to read the current version of the policy.
  69. // 2. Modify the policy as needed.
  70. // 3. Use `UpdatePolicy` to write the updated policy.
  71. //
  72. // This pattern helps prevent conflicts between concurrent updates.
  73. rpc UpdatePolicy(UpdatePolicyRequest) returns (google.longrunning.Operation) {
  74. option (google.api.http) = {
  75. put: "/v2/{policy.name=policies/*/*/*}"
  76. body: "policy"
  77. };
  78. option (google.longrunning.operation_info) = {
  79. response_type: "Policy"
  80. metadata_type: "PolicyOperationMetadata"
  81. };
  82. }
  83. // Deletes a policy. This action is permanent.
  84. rpc DeletePolicy(DeletePolicyRequest) returns (google.longrunning.Operation) {
  85. option (google.api.http) = {
  86. delete: "/v2/{name=policies/*/*/*}"
  87. };
  88. option (google.api.method_signature) = "name";
  89. option (google.longrunning.operation_info) = {
  90. response_type: "Policy"
  91. metadata_type: "PolicyOperationMetadata"
  92. };
  93. }
  94. }
  95. // Data for an IAM policy.
  96. message Policy {
  97. // Immutable. The resource name of the `Policy`, which must be unique. Format:
  98. // `policies/{attachment_point}/denypolicies/{policy_id}`
  99. //
  100. //
  101. // The attachment point is identified by its URL-encoded full resource name,
  102. // which means that the forward-slash character, `/`, must be written as
  103. // `%2F`. For example,
  104. // `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-deny-policy`.
  105. //
  106. // For organizations and folders, use the numeric ID in the full resource
  107. // name. For projects, requests can use the alphanumeric or the numeric ID.
  108. // Responses always contain the numeric ID.
  109. string name = 1 [(google.api.field_behavior) = IMMUTABLE];
  110. // Immutable. The globally unique ID of the `Policy`. Assigned automatically when the
  111. // `Policy` is created.
  112. string uid = 2 [(google.api.field_behavior) = IMMUTABLE];
  113. // Output only. The kind of the `Policy`. Always contains the value `DenyPolicy`.
  114. string kind = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
  115. // A user-specified description of the `Policy`. This value can be up to 63
  116. // characters.
  117. string display_name = 4;
  118. // A key-value map to store arbitrary metadata for the `Policy`. Keys
  119. // can be up to 63 characters. Values can be up to 255 characters.
  120. map<string, string> annotations = 5;
  121. // An opaque tag that identifies the current version of the `Policy`. IAM uses
  122. // this value to help manage concurrent updates, so they do not cause one
  123. // update to be overwritten by another.
  124. //
  125. // If this field is present in a [CreatePolicy][] request, the value is
  126. // ignored.
  127. string etag = 6;
  128. // Output only. The time when the `Policy` was created.
  129. google.protobuf.Timestamp create_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
  130. // Output only. The time when the `Policy` was last updated.
  131. google.protobuf.Timestamp update_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY];
  132. // Output only. The time when the `Policy` was deleted. Empty if the policy is not deleted.
  133. google.protobuf.Timestamp delete_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
  134. // A list of rules that specify the behavior of the `Policy`. All of the rules
  135. // should be of the `kind` specified in the `Policy`.
  136. repeated PolicyRule rules = 10;
  137. // Immutable. Specifies that this policy is managed by an authority and can only be
  138. // modified by that authority. Usage is restricted.
  139. string managing_authority = 11 [(google.api.field_behavior) = IMMUTABLE];
  140. }
  141. // A single rule in a `Policy`.
  142. message PolicyRule {
  143. oneof kind {
  144. // A rule for a deny policy.
  145. DenyRule deny_rule = 2;
  146. }
  147. // A user-specified description of the rule. This value can be up to 256
  148. // characters.
  149. string description = 1;
  150. }
  151. // Request message for `ListPolicies`.
  152. message ListPoliciesRequest {
  153. // Required. The resource that the policy is attached to, along with the kind of policy
  154. // to list. Format:
  155. // `policies/{attachment_point}/denypolicies`
  156. //
  157. //
  158. // The attachment point is identified by its URL-encoded full resource name,
  159. // which means that the forward-slash character, `/`, must be written as
  160. // `%2F`. For example,
  161. // `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies`.
  162. //
  163. // For organizations and folders, use the numeric ID in the full resource
  164. // name. For projects, you can use the alphanumeric or the numeric ID.
  165. string parent = 1 [(google.api.field_behavior) = REQUIRED];
  166. // The maximum number of policies to return. IAM ignores this value and uses
  167. // the value 1000.
  168. int32 page_size = 2;
  169. // A page token received in a [ListPoliciesResponse][google.iam.v2.ListPoliciesResponse]. Provide this token to
  170. // retrieve the next page.
  171. string page_token = 3;
  172. }
  173. // Response message for `ListPolicies`.
  174. message ListPoliciesResponse {
  175. // Metadata for the policies that are attached to the resource.
  176. repeated Policy policies = 1;
  177. // A page token that you can use in a [ListPoliciesRequest][google.iam.v2.ListPoliciesRequest] to retrieve the
  178. // next page. If this field is omitted, there are no additional pages.
  179. string next_page_token = 2;
  180. }
  181. // Request message for `GetPolicy`.
  182. message GetPolicyRequest {
  183. // Required. The resource name of the policy to retrieve. Format:
  184. // `policies/{attachment_point}/denypolicies/{policy_id}`
  185. //
  186. //
  187. // Use the URL-encoded full resource name, which means that the forward-slash
  188. // character, `/`, must be written as `%2F`. For example,
  189. // `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy`.
  190. //
  191. // For organizations and folders, use the numeric ID in the full resource
  192. // name. For projects, you can use the alphanumeric or the numeric ID.
  193. string name = 1 [(google.api.field_behavior) = REQUIRED];
  194. }
  195. // Request message for `CreatePolicy`.
  196. message CreatePolicyRequest {
  197. // Required. The resource that the policy is attached to, along with the kind of policy
  198. // to create. Format: `policies/{attachment_point}/denypolicies`
  199. //
  200. //
  201. // The attachment point is identified by its URL-encoded full resource name,
  202. // which means that the forward-slash character, `/`, must be written as
  203. // `%2F`. For example,
  204. // `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies`.
  205. //
  206. // For organizations and folders, use the numeric ID in the full resource
  207. // name. For projects, you can use the alphanumeric or the numeric ID.
  208. string parent = 1 [(google.api.field_behavior) = REQUIRED];
  209. // Required. The policy to create.
  210. Policy policy = 2 [(google.api.field_behavior) = REQUIRED];
  211. // The ID to use for this policy, which will become the final component of
  212. // the policy's resource name. The ID must contain 3 to 63 characters. It can
  213. // contain lowercase letters and numbers, as well as dashes (`-`) and periods
  214. // (`.`). The first character must be a lowercase letter.
  215. string policy_id = 3;
  216. }
  217. // Request message for `UpdatePolicy`.
  218. message UpdatePolicyRequest {
  219. // Required. The policy to update.
  220. //
  221. // To prevent conflicting updates, the `etag` value must match the value that
  222. // is stored in IAM. If the `etag` values do not match, the request fails with
  223. // a `409` error code and `ABORTED` status.
  224. Policy policy = 1 [(google.api.field_behavior) = REQUIRED];
  225. }
  226. // Request message for `DeletePolicy`.
  227. message DeletePolicyRequest {
  228. // Required. The resource name of the policy to delete. Format:
  229. // `policies/{attachment_point}/denypolicies/{policy_id}`
  230. //
  231. //
  232. // Use the URL-encoded full resource name, which means that the forward-slash
  233. // character, `/`, must be written as `%2F`. For example,
  234. // `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy`.
  235. //
  236. // For organizations and folders, use the numeric ID in the full resource
  237. // name. For projects, you can use the alphanumeric or the numeric ID.
  238. string name = 1 [(google.api.field_behavior) = REQUIRED];
  239. // Optional. The expected `etag` of the policy to delete. If the value does not match
  240. // the value that is stored in IAM, the request fails with a `409` error code
  241. // and `ABORTED` status.
  242. //
  243. // If you omit this field, the policy is deleted regardless of its current
  244. // `etag`.
  245. string etag = 2 [(google.api.field_behavior) = OPTIONAL];
  246. }
  247. // Metadata for long-running `Policy` operations.
  248. message PolicyOperationMetadata {
  249. // Timestamp when the `google.longrunning.Operation` was created.
  250. google.protobuf.Timestamp create_time = 1;
  251. }