constraint.proto 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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/field_behavior.proto";
  17. import "google/api/resource.proto";
  18. option csharp_namespace = "Google.Cloud.OrgPolicy.V2";
  19. option go_package = "google.golang.org/genproto/googleapis/cloud/orgpolicy/v2;orgpolicy";
  20. option java_multiple_files = true;
  21. option java_outer_classname = "ConstraintProto";
  22. option java_package = "com.google.cloud.orgpolicy.v2";
  23. option php_namespace = "Google\\Cloud\\OrgPolicy\\V2";
  24. option ruby_package = "Google::Cloud::OrgPolicy::V2";
  25. // A `constraint` describes a way to restrict resource's configuration. For
  26. // example, you could enforce a constraint that controls which cloud services
  27. // can be activated across an organization, or whether a Compute Engine instance
  28. // can have serial port connections established. `Constraints` can be configured
  29. // by the organization's policy administrator to fit the needs of the
  30. // organization by setting a `policy` that includes `constraints` at different
  31. // locations in the organization's resource hierarchy. Policies are inherited
  32. // down the resource hierarchy from higher levels, but can also be overridden.
  33. // For details about the inheritance rules please read about
  34. // [`policies`][google.cloud.OrgPolicy.v2.Policy].
  35. //
  36. // `Constraints` have a default behavior determined by the `constraint_default`
  37. // field, which is the enforcement behavior that is used in the absence of a
  38. // `policy` being defined or inherited for the resource in question.
  39. message Constraint {
  40. option (google.api.resource) = {
  41. type: "orgpolicy.googleapis.com/Constraint"
  42. pattern: "projects/{project}/constraints/{constraint}"
  43. pattern: "folders/{folder}/constraints/{constraint}"
  44. pattern: "organizations/{organization}/constraints/{constraint}"
  45. };
  46. // Specifies the default behavior in the absence of any `Policy` for the
  47. // `Constraint`. This must not be `CONSTRAINT_DEFAULT_UNSPECIFIED`.
  48. //
  49. // Immutable after creation.
  50. enum ConstraintDefault {
  51. // This is only used for distinguishing unset values and should never be
  52. // used.
  53. CONSTRAINT_DEFAULT_UNSPECIFIED = 0;
  54. // Indicate that all values are allowed for list constraints.
  55. // Indicate that enforcement is off for boolean constraints.
  56. ALLOW = 1;
  57. // Indicate that all values are denied for list constraints.
  58. // Indicate that enforcement is on for boolean constraints.
  59. DENY = 2;
  60. }
  61. // A `Constraint` that allows or disallows a list of string values, which are
  62. // configured by an Organization's policy administrator with a `Policy`.
  63. message ListConstraint {
  64. // Indicates whether values grouped into categories can be used in
  65. // `Policy.allowed_values` and `Policy.denied_values`. For example,
  66. // `"in:Python"` would match any value in the 'Python' group.
  67. bool supports_in = 1;
  68. // Indicates whether subtrees of Cloud Resource Manager resource hierarchy
  69. // can be used in `Policy.allowed_values` and `Policy.denied_values`. For
  70. // example, `"under:folders/123"` would match any resource under the
  71. // 'folders/123' folder.
  72. bool supports_under = 2;
  73. }
  74. // A `Constraint` that is either enforced or not.
  75. //
  76. // For example a constraint `constraints/compute.disableSerialPortAccess`.
  77. // If it is enforced on a VM instance, serial port connections will not be
  78. // opened to that instance.
  79. message BooleanConstraint {
  80. }
  81. // Immutable. The resource name of the Constraint. Must be in one of
  82. // the following forms:
  83. // * `projects/{project_number}/constraints/{constraint_name}`
  84. // * `folders/{folder_id}/constraints/{constraint_name}`
  85. // * `organizations/{organization_id}/constraints/{constraint_name}`
  86. //
  87. // For example, "/projects/123/constraints/compute.disableSerialPortAccess".
  88. string name = 1 [(google.api.field_behavior) = IMMUTABLE];
  89. // The human readable name.
  90. //
  91. // Mutable.
  92. string display_name = 2;
  93. // Detailed description of what this `Constraint` controls as well as how and
  94. // where it is enforced.
  95. //
  96. // Mutable.
  97. string description = 3;
  98. // The evaluation behavior of this constraint in the absence of 'Policy'.
  99. ConstraintDefault constraint_default = 4;
  100. // The type of restrictions for this `Constraint`.
  101. //
  102. // Immutable after creation.
  103. oneof constraint_type {
  104. // Defines this constraint as being a ListConstraint.
  105. ListConstraint list_constraint = 5;
  106. // Defines this constraint as being a BooleanConstraint.
  107. BooleanConstraint boolean_constraint = 6;
  108. }
  109. }