os_policy_assignments.proto 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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 = "OsPolicyAssignmentsProto";
  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. // Filters to select target VMs for an assignment.
  62. //
  63. // If more than one filter criteria is specified below, a VM will be selected
  64. // if and only if it satisfies all of them.
  65. message InstanceFilter {
  66. // VM inventory details.
  67. message Inventory {
  68. // Required. The OS short name
  69. string os_short_name = 1 [(google.api.field_behavior) = REQUIRED];
  70. // The OS version
  71. //
  72. // Prefix matches are supported if asterisk(*) is provided as the
  73. // last character. For example, to match all versions with a major
  74. // version of `7`, specify the following value for this field `7.*`
  75. //
  76. // An empty string matches all OS versions.
  77. string os_version = 2;
  78. }
  79. // Target all VMs in the project. If true, no other criteria is
  80. // permitted.
  81. bool all = 1;
  82. // Deprecated. Use the `inventories` field instead.
  83. // A VM is selected if it's OS short name matches with any of the
  84. // values provided in this list.
  85. repeated string os_short_names = 2 [deprecated = true];
  86. // List of label sets used for VM inclusion.
  87. //
  88. // If the list has more than one `LabelSet`, the VM is included if any
  89. // of the label sets are applicable for the VM.
  90. repeated LabelSet inclusion_labels = 3;
  91. // List of label sets used for VM exclusion.
  92. //
  93. // If the list has more than one label set, the VM is excluded if any
  94. // of the label sets are applicable for the VM.
  95. repeated LabelSet exclusion_labels = 4;
  96. // List of inventories to select VMs.
  97. //
  98. // A VM is selected if its inventory data matches at least one of the
  99. // following inventories.
  100. repeated Inventory inventories = 5;
  101. }
  102. // Message to configure the rollout at the zonal level for the OS policy
  103. // assignment.
  104. message Rollout {
  105. // Required. The maximum number (or percentage) of VMs per zone to disrupt at
  106. // any given moment.
  107. FixedOrPercent disruption_budget = 1 [(google.api.field_behavior) = REQUIRED];
  108. // Required. This determines the minimum duration of time to wait after the
  109. // configuration changes are applied through the current rollout. A
  110. // VM continues to count towards the `disruption_budget` at least
  111. // until this duration of time has passed after configuration changes are
  112. // applied.
  113. google.protobuf.Duration min_wait_duration = 2 [(google.api.field_behavior) = REQUIRED];
  114. }
  115. // OS policy assignment rollout state
  116. enum RolloutState {
  117. // Invalid value
  118. ROLLOUT_STATE_UNSPECIFIED = 0;
  119. // The rollout is in progress.
  120. IN_PROGRESS = 1;
  121. // The rollout is being cancelled.
  122. CANCELLING = 2;
  123. // The rollout is cancelled.
  124. CANCELLED = 3;
  125. // The rollout has completed successfully.
  126. SUCCEEDED = 4;
  127. }
  128. // Resource name.
  129. //
  130. // Format:
  131. // `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id}`
  132. //
  133. // This field is ignored when you create an OS policy assignment.
  134. string name = 1;
  135. // OS policy assignment description.
  136. // Length of the description is limited to 1024 characters.
  137. string description = 2;
  138. // Required. List of OS policies to be applied to the VMs.
  139. repeated OSPolicy os_policies = 3 [(google.api.field_behavior) = REQUIRED];
  140. // Required. Filter to select VMs.
  141. InstanceFilter instance_filter = 4 [(google.api.field_behavior) = REQUIRED];
  142. // Required. Rollout to deploy the OS policy assignment.
  143. // A rollout is triggered in the following situations:
  144. // 1) OSPolicyAssignment is created.
  145. // 2) OSPolicyAssignment is updated and the update contains changes to one of
  146. // the following fields:
  147. // - instance_filter
  148. // - os_policies
  149. // 3) OSPolicyAssignment is deleted.
  150. Rollout rollout = 5 [(google.api.field_behavior) = REQUIRED];
  151. // Output only. The assignment revision ID
  152. // A new revision is committed whenever a rollout is triggered for a OS policy
  153. // assignment
  154. string revision_id = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
  155. // Output only. The timestamp that the revision was created.
  156. google.protobuf.Timestamp revision_create_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
  157. // The etag for this OS policy assignment.
  158. // If this is provided on update, it must match the server's etag.
  159. string etag = 8;
  160. // Output only. OS policy assignment rollout state
  161. RolloutState rollout_state = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
  162. // Output only. Indicates that this revision has been successfully rolled out in this zone
  163. // and new VMs will be assigned OS policies from this revision.
  164. //
  165. // For a given OS policy assignment, there is only one revision with a value
  166. // of `true` for this field.
  167. bool baseline = 10 [(google.api.field_behavior) = OUTPUT_ONLY];
  168. // Output only. Indicates that this revision deletes the OS policy assignment.
  169. bool deleted = 11 [(google.api.field_behavior) = OUTPUT_ONLY];
  170. // Output only. Indicates that reconciliation is in progress for the revision.
  171. // This value is `true` when the `rollout_state` is one of:
  172. // * IN_PROGRESS
  173. // * CANCELLING
  174. bool reconciling = 12 [(google.api.field_behavior) = OUTPUT_ONLY];
  175. // Output only. Server generated unique id for the OS policy assignment resource.
  176. string uid = 13 [(google.api.field_behavior) = OUTPUT_ONLY];
  177. }
  178. // OS policy assignment operation metadata provided by OS policy assignment API
  179. // methods that return long running operations.
  180. message OSPolicyAssignmentOperationMetadata {
  181. // The OS policy assignment API method.
  182. enum APIMethod {
  183. // Invalid value
  184. API_METHOD_UNSPECIFIED = 0;
  185. // Create OS policy assignment API method
  186. CREATE = 1;
  187. // Update OS policy assignment API method
  188. UPDATE = 2;
  189. // Delete OS policy assignment API method
  190. DELETE = 3;
  191. }
  192. // State of the rollout
  193. enum RolloutState {
  194. // Invalid value
  195. ROLLOUT_STATE_UNSPECIFIED = 0;
  196. // The rollout is in progress.
  197. IN_PROGRESS = 1;
  198. // The rollout is being cancelled.
  199. CANCELLING = 2;
  200. // The rollout is cancelled.
  201. CANCELLED = 3;
  202. // The rollout has completed successfully.
  203. SUCCEEDED = 4;
  204. }
  205. // Reference to the `OSPolicyAssignment` API resource.
  206. //
  207. // Format:
  208. // `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id@revision_id}`
  209. string os_policy_assignment = 1 [(google.api.resource_reference) = {
  210. type: "osconfig.googleapis.com/OSPolicyAssignment"
  211. }];
  212. // The OS policy assignment API method.
  213. APIMethod api_method = 2;
  214. // State of the rollout
  215. RolloutState rollout_state = 3;
  216. // Rollout start time
  217. google.protobuf.Timestamp rollout_start_time = 4;
  218. // Rollout update time
  219. google.protobuf.Timestamp rollout_update_time = 5;
  220. }
  221. // A request message to create an OS policy assignment
  222. message CreateOSPolicyAssignmentRequest {
  223. // Required. The parent resource name in the form:
  224. // projects/{project}/locations/{location}
  225. string parent = 1 [
  226. (google.api.field_behavior) = REQUIRED,
  227. (google.api.resource_reference) = {
  228. type: "locations.googleapis.com/Location"
  229. }
  230. ];
  231. // Required. The OS policy assignment to be created.
  232. OSPolicyAssignment os_policy_assignment = 2 [(google.api.field_behavior) = REQUIRED];
  233. // Required. The logical name of the OS policy assignment in the project
  234. // with the following restrictions:
  235. //
  236. // * Must contain only lowercase letters, numbers, and hyphens.
  237. // * Must start with a letter.
  238. // * Must be between 1-63 characters.
  239. // * Must end with a number or a letter.
  240. // * Must be unique within the project.
  241. string os_policy_assignment_id = 3 [(google.api.field_behavior) = REQUIRED];
  242. }
  243. // A request message to update an OS policy assignment
  244. message UpdateOSPolicyAssignmentRequest {
  245. // Required. The updated OS policy assignment.
  246. OSPolicyAssignment os_policy_assignment = 1 [(google.api.field_behavior) = REQUIRED];
  247. // Optional. Field mask that controls which fields of the assignment should be updated.
  248. google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL];
  249. }
  250. // A request message to get an OS policy assignment
  251. message GetOSPolicyAssignmentRequest {
  252. // Required. The resource name of OS policy assignment.
  253. //
  254. // Format:
  255. // `projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}@{revisionId}`
  256. string name = 1 [
  257. (google.api.field_behavior) = REQUIRED,
  258. (google.api.resource_reference) = {
  259. type: "osconfig.googleapis.com/OSPolicyAssignment"
  260. }
  261. ];
  262. }
  263. // A request message to list OS policy assignments for a parent resource
  264. message ListOSPolicyAssignmentsRequest {
  265. // Required. The parent resource name.
  266. string parent = 1 [
  267. (google.api.field_behavior) = REQUIRED,
  268. (google.api.resource_reference) = {
  269. type: "locations.googleapis.com/Location"
  270. }
  271. ];
  272. // The maximum number of assignments to return.
  273. int32 page_size = 2;
  274. // A pagination token returned from a previous call to
  275. // `ListOSPolicyAssignments` that indicates where this listing should continue
  276. // from.
  277. string page_token = 3;
  278. }
  279. // A response message for listing all assignments under given parent.
  280. message ListOSPolicyAssignmentsResponse {
  281. // The list of assignments
  282. repeated OSPolicyAssignment os_policy_assignments = 1;
  283. // The pagination token to retrieve the next page of OS policy assignments.
  284. string next_page_token = 2;
  285. }
  286. // A request message to list revisions for a OS policy assignment
  287. message ListOSPolicyAssignmentRevisionsRequest {
  288. // Required. The name of the OS policy assignment to list revisions for.
  289. string name = 1 [
  290. (google.api.field_behavior) = REQUIRED,
  291. (google.api.resource_reference) = {
  292. type: "osconfig.googleapis.com/OSPolicyAssignment"
  293. }
  294. ];
  295. // The maximum number of revisions to return.
  296. int32 page_size = 2;
  297. // A pagination token returned from a previous call to
  298. // `ListOSPolicyAssignmentRevisions` that indicates where this listing should
  299. // continue from.
  300. string page_token = 3;
  301. }
  302. // A response message for listing all revisions for a OS policy assignment.
  303. message ListOSPolicyAssignmentRevisionsResponse {
  304. // The OS policy assignment revisions
  305. repeated OSPolicyAssignment os_policy_assignments = 1;
  306. // The pagination token to retrieve the next page of OS policy assignment
  307. // revisions.
  308. string next_page_token = 2;
  309. }
  310. // A request message for deleting a OS policy assignment.
  311. message DeleteOSPolicyAssignmentRequest {
  312. // Required. The name of the OS policy assignment to be deleted
  313. string name = 1 [
  314. (google.api.field_behavior) = REQUIRED,
  315. (google.api.resource_reference) = {
  316. type: "osconfig.googleapis.com/OSPolicyAssignment"
  317. }
  318. ];
  319. }