os_policy_assignments.proto 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. // Copyright 2021 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.osconfig.v1alpha;
  16. import "google/api/field_behavior.proto";
  17. import "google/api/resource.proto";
  18. import "google/cloud/osconfig/v1alpha/os_policy.proto";
  19. import "google/cloud/osconfig/v1alpha/osconfig_common.proto";
  20. import "google/protobuf/duration.proto";
  21. import "google/protobuf/field_mask.proto";
  22. import "google/protobuf/timestamp.proto";
  23. option csharp_namespace = "Google.Cloud.OsConfig.V1Alpha";
  24. option go_package = "google.golang.org/genproto/googleapis/cloud/osconfig/v1alpha;osconfig";
  25. option java_multiple_files = true;
  26. option java_outer_classname = "OSPolicyAssignments";
  27. option java_package = "com.google.cloud.osconfig.v1alpha";
  28. option php_namespace = "Google\\Cloud\\OsConfig\\V1alpha";
  29. option ruby_package = "Google::Cloud::OsConfig::V1alpha";
  30. // OS policy assignment is an API resource that is used to
  31. // apply a set of OS policies to a dynamically targeted group of Compute Engine
  32. // VM instances.
  33. //
  34. // An OS policy is used to define the desired state configuration for a
  35. // Compute Engine VM instance through a set of configuration resources that
  36. // provide capabilities such as installing or removing software packages, or
  37. // executing a script.
  38. //
  39. // For more information, see [OS policy and OS policy
  40. // assignment](https://cloud.google.com/compute/docs/os-configuration-management/working-with-os-policies).
  41. message OSPolicyAssignment {
  42. option (google.api.resource) = {
  43. type: "osconfig.googleapis.com/OSPolicyAssignment"
  44. pattern: "projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}"
  45. };
  46. // Message representing label set.
  47. // * A label is a key value pair set for a VM.
  48. // * A LabelSet is a set of labels.
  49. // * Labels within a LabelSet are ANDed. In other words, a LabelSet is
  50. // applicable for a VM only if it matches all the labels in the
  51. // LabelSet.
  52. // * Example: A LabelSet with 2 labels: `env=prod` and `type=webserver` will
  53. // only be applicable for those VMs with both labels
  54. // present.
  55. message LabelSet {
  56. // Labels are identified by key/value pairs in this map.
  57. // A VM should contain all the key/value pairs specified in this
  58. // map to be selected.
  59. map<string, string> labels = 1;
  60. }
  61. // Message to represent the filters to select VMs for an assignment
  62. message InstanceFilter {
  63. // Target all VMs in the project. If true, no other criteria is
  64. // permitted.
  65. bool all = 1;
  66. // A VM is included if it's OS short name matches with any of the
  67. // values provided in this list.
  68. repeated string os_short_names = 2;
  69. // List of label sets used for VM inclusion.
  70. //
  71. // If the list has more than one `LabelSet`, the VM is included if any
  72. // of the label sets are applicable for the VM.
  73. repeated LabelSet inclusion_labels = 3;
  74. // List of label sets used for VM exclusion.
  75. //
  76. // If the list has more than one label set, the VM is excluded if any
  77. // of the label sets are applicable for the VM.
  78. //
  79. // This filter is applied last in the filtering chain and therefore a
  80. // VM is guaranteed to be excluded if it satisfies one of the below
  81. // label sets.
  82. repeated LabelSet exclusion_labels = 4;
  83. }
  84. // Message to configure the rollout at the zonal level for the OS policy
  85. // assignment.
  86. message Rollout {
  87. // Required. The maximum number (or percentage) of VMs per zone to disrupt at
  88. // any given moment.
  89. FixedOrPercent disruption_budget = 1 [(google.api.field_behavior) = REQUIRED];
  90. // Required. This determines the minimum duration of time to wait after the
  91. // configuration changes are applied through the current rollout. A
  92. // VM continues to count towards the `disruption_budget` at least
  93. // until this duration of time has passed after configuration changes are
  94. // applied.
  95. google.protobuf.Duration min_wait_duration = 2 [(google.api.field_behavior) = REQUIRED];
  96. }
  97. // OS policy assignment rollout state
  98. enum RolloutState {
  99. // Invalid value
  100. ROLLOUT_STATE_UNSPECIFIED = 0;
  101. // The rollout is in progress.
  102. IN_PROGRESS = 1;
  103. // The rollout is being cancelled.
  104. CANCELLING = 2;
  105. // The rollout is cancelled.
  106. CANCELLED = 3;
  107. // The rollout has completed successfully.
  108. SUCCEEDED = 4;
  109. }
  110. // Resource name.
  111. //
  112. // Format:
  113. // `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id}`
  114. //
  115. // This field is ignored when you create an OS policy assignment.
  116. string name = 1;
  117. // OS policy assignment description.
  118. // Length of the description is limited to 1024 characters.
  119. string description = 2;
  120. // Required. List of OS policies to be applied to the VMs.
  121. repeated OSPolicy os_policies = 3 [(google.api.field_behavior) = REQUIRED];
  122. // Required. Filter to select VMs.
  123. InstanceFilter instance_filter = 4 [(google.api.field_behavior) = REQUIRED];
  124. // Required. Rollout to deploy the OS policy assignment.
  125. // A rollout is triggered in the following situations:
  126. // 1) OSPolicyAssignment is created.
  127. // 2) OSPolicyAssignment is updated and the update contains changes to one of
  128. // the following fields:
  129. // - instance_filter
  130. // - os_policies
  131. // 3) OSPolicyAssignment is deleted.
  132. Rollout rollout = 5 [(google.api.field_behavior) = REQUIRED];
  133. // Output only. The assignment revision ID
  134. // A new revision is committed whenever a rollout is triggered for a OS policy
  135. // assignment
  136. string revision_id = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
  137. // Output only. The timestamp that the revision was created.
  138. google.protobuf.Timestamp revision_create_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
  139. // Output only. OS policy assignment rollout state
  140. RolloutState rollout_state = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
  141. // Output only. Indicates that this revision has been successfully rolled out in this zone
  142. // and new VMs will be assigned OS policies from this revision.
  143. //
  144. // For a given OS policy assignment, there is only one revision with a value
  145. // of `true` for this field.
  146. bool baseline = 10 [(google.api.field_behavior) = OUTPUT_ONLY];
  147. // Output only. Indicates that this revision deletes the OS policy assignment.
  148. bool deleted = 11 [(google.api.field_behavior) = OUTPUT_ONLY];
  149. // Output only. Indicates that reconciliation is in progress for the revision.
  150. // This value is `true` when the `rollout_state` is one of:
  151. // * IN_PROGRESS
  152. // * CANCELLING
  153. bool reconciling = 12 [(google.api.field_behavior) = OUTPUT_ONLY];
  154. // Output only. Server generated unique id for the OS policy assignment resource.
  155. string uid = 13 [(google.api.field_behavior) = OUTPUT_ONLY];
  156. }
  157. // OS policy assignment operation metadata provided by OS policy assignment API
  158. // methods that return long running operations.
  159. message OSPolicyAssignmentOperationMetadata {
  160. // The OS policy assignment API method.
  161. enum APIMethod {
  162. // Invalid value
  163. API_METHOD_UNSPECIFIED = 0;
  164. // Create OS policy assignment API method
  165. CREATE = 1;
  166. // Update OS policy assignment API method
  167. UPDATE = 2;
  168. // Delete OS policy assignment API method
  169. DELETE = 3;
  170. }
  171. // State of the rollout
  172. enum RolloutState {
  173. // Invalid value
  174. ROLLOUT_STATE_UNSPECIFIED = 0;
  175. // The rollout is in progress.
  176. IN_PROGRESS = 1;
  177. // The rollout is being cancelled.
  178. CANCELLING = 2;
  179. // The rollout is cancelled.
  180. CANCELLED = 3;
  181. // The rollout has completed successfully.
  182. SUCCEEDED = 4;
  183. }
  184. // Reference to the `OSPolicyAssignment` API resource.
  185. //
  186. // Format:
  187. // `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id@revision_id}`
  188. string os_policy_assignment = 1 [(google.api.resource_reference) = {
  189. type: "osconfig.googleapis.com/OSPolicyAssignment"
  190. }];
  191. // The OS policy assignment API method.
  192. APIMethod api_method = 2;
  193. // State of the rollout
  194. RolloutState rollout_state = 3;
  195. // Rollout start time
  196. google.protobuf.Timestamp rollout_start_time = 4;
  197. // Rollout update time
  198. google.protobuf.Timestamp rollout_update_time = 5;
  199. }
  200. // A request message to create an OS policy assignment
  201. message CreateOSPolicyAssignmentRequest {
  202. // Required. The parent resource name in the form:
  203. // projects/{project}/locations/{location}
  204. string parent = 1 [
  205. (google.api.field_behavior) = REQUIRED,
  206. (google.api.resource_reference) = {
  207. type: "locations.googleapis.com/Location"
  208. }
  209. ];
  210. // Required. The OS policy assignment to be created.
  211. OSPolicyAssignment os_policy_assignment = 2 [(google.api.field_behavior) = REQUIRED];
  212. // Required. The logical name of the OS policy assignment in the project
  213. // with the following restrictions:
  214. //
  215. // * Must contain only lowercase letters, numbers, and hyphens.
  216. // * Must start with a letter.
  217. // * Must be between 1-63 characters.
  218. // * Must end with a number or a letter.
  219. // * Must be unique within the project.
  220. string os_policy_assignment_id = 3 [(google.api.field_behavior) = REQUIRED];
  221. }
  222. // A request message to update an OS policy assignment
  223. message UpdateOSPolicyAssignmentRequest {
  224. // Required. The updated OS policy assignment.
  225. OSPolicyAssignment os_policy_assignment = 1 [(google.api.field_behavior) = REQUIRED];
  226. // Optional. Field mask that controls which fields of the assignment should be updated.
  227. google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL];
  228. }
  229. // A request message to get an OS policy assignment
  230. message GetOSPolicyAssignmentRequest {
  231. // Required. The resource name of OS policy assignment.
  232. //
  233. // Format:
  234. // `projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}@{revisionId}`
  235. string name = 1 [
  236. (google.api.field_behavior) = REQUIRED,
  237. (google.api.resource_reference) = {
  238. type: "osconfig.googleapis.com/OSPolicyAssignment"
  239. }
  240. ];
  241. }
  242. // A request message to list OS policy assignments for a parent resource
  243. message ListOSPolicyAssignmentsRequest {
  244. // Required. The parent resource name.
  245. string parent = 1 [
  246. (google.api.field_behavior) = REQUIRED,
  247. (google.api.resource_reference) = {
  248. type: "locations.googleapis.com/Location"
  249. }
  250. ];
  251. // The maximum number of assignments to return.
  252. int32 page_size = 2;
  253. // A pagination token returned from a previous call to
  254. // `ListOSPolicyAssignments` that indicates where this listing should continue
  255. // from.
  256. string page_token = 3;
  257. }
  258. // A response message for listing all assignments under given parent.
  259. message ListOSPolicyAssignmentsResponse {
  260. // The list of assignments
  261. repeated OSPolicyAssignment os_policy_assignments = 1;
  262. // The pagination token to retrieve the next page of OS policy assignments.
  263. string next_page_token = 2;
  264. }
  265. // A request message to list revisions for a OS policy assignment
  266. message ListOSPolicyAssignmentRevisionsRequest {
  267. // Required. The name of the OS policy assignment to list revisions for.
  268. string name = 1 [
  269. (google.api.field_behavior) = REQUIRED,
  270. (google.api.resource_reference) = {
  271. type: "osconfig.googleapis.com/OSPolicyAssignment"
  272. }
  273. ];
  274. // The maximum number of revisions to return.
  275. int32 page_size = 2;
  276. // A pagination token returned from a previous call to
  277. // `ListOSPolicyAssignmentRevisions` that indicates where this listing should
  278. // continue from.
  279. string page_token = 3;
  280. }
  281. // A response message for listing all revisions for a OS policy assignment.
  282. message ListOSPolicyAssignmentRevisionsResponse {
  283. // The OS policy assignment revisions
  284. repeated OSPolicyAssignment os_policy_assignments = 1;
  285. // The pagination token to retrieve the next page of OS policy assignment
  286. // revisions.
  287. string next_page_token = 2;
  288. }
  289. // A request message for deleting a OS policy assignment.
  290. message DeleteOSPolicyAssignmentRequest {
  291. // Required. The name of the OS policy assignment to be deleted
  292. string name = 1 [
  293. (google.api.field_behavior) = REQUIRED,
  294. (google.api.resource_reference) = {
  295. type: "osconfig.googleapis.com/OSPolicyAssignment"
  296. }
  297. ];
  298. }