os_policy_assignments.proto 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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.v1;
  16. import "google/api/field_behavior.proto";
  17. import "google/api/resource.proto";
  18. import "google/cloud/osconfig/v1/os_policy.proto";
  19. import "google/cloud/osconfig/v1/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.V1";
  24. option go_package = "google.golang.org/genproto/googleapis/cloud/osconfig/v1;osconfig";
  25. option java_multiple_files = true;
  26. option java_outer_classname = "OsPolicyAssignmentsProto";
  27. option java_package = "com.google.cloud.osconfig.v1";
  28. option php_namespace = "Google\\Cloud\\OsConfig\\V1";
  29. option ruby_package = "Google::Cloud::OsConfig::V1";
  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. // List of label sets used for VM inclusion.
  83. //
  84. // If the list has more than one `LabelSet`, the VM is included if any
  85. // of the label sets are applicable for the VM.
  86. repeated LabelSet inclusion_labels = 2;
  87. // List of label sets used for VM exclusion.
  88. //
  89. // If the list has more than one label set, the VM is excluded if any
  90. // of the label sets are applicable for the VM.
  91. repeated LabelSet exclusion_labels = 3;
  92. // List of inventories to select VMs.
  93. //
  94. // A VM is selected if its inventory data matches at least one of the
  95. // following inventories.
  96. repeated Inventory inventories = 4;
  97. }
  98. // Message to configure the rollout at the zonal level for the OS policy
  99. // assignment.
  100. message Rollout {
  101. // Required. The maximum number (or percentage) of VMs per zone to disrupt
  102. // at any given moment.
  103. FixedOrPercent disruption_budget = 1
  104. [(google.api.field_behavior) = REQUIRED];
  105. // Required. This determines the minimum duration of time to wait after the
  106. // configuration changes are applied through the current rollout. A
  107. // VM continues to count towards the `disruption_budget` at least
  108. // until this duration of time has passed after configuration changes are
  109. // applied.
  110. google.protobuf.Duration min_wait_duration = 2
  111. [(google.api.field_behavior) = REQUIRED];
  112. }
  113. // OS policy assignment rollout state
  114. enum RolloutState {
  115. // Invalid value
  116. ROLLOUT_STATE_UNSPECIFIED = 0;
  117. // The rollout is in progress.
  118. IN_PROGRESS = 1;
  119. // The rollout is being cancelled.
  120. CANCELLING = 2;
  121. // The rollout is cancelled.
  122. CANCELLED = 3;
  123. // The rollout has completed successfully.
  124. SUCCEEDED = 4;
  125. }
  126. // Resource name.
  127. //
  128. // Format:
  129. // `projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id}`
  130. //
  131. // This field is ignored when you create an OS policy assignment.
  132. string name = 1;
  133. // OS policy assignment description.
  134. // Length of the description is limited to 1024 characters.
  135. string description = 2;
  136. // Required. List of OS policies to be applied to the VMs.
  137. repeated OSPolicy os_policies = 3 [(google.api.field_behavior) = REQUIRED];
  138. // Required. Filter to select VMs.
  139. InstanceFilter instance_filter = 4 [(google.api.field_behavior) = REQUIRED];
  140. // Required. Rollout to deploy the OS policy assignment.
  141. // A rollout is triggered in the following situations:
  142. // 1) OSPolicyAssignment is created.
  143. // 2) OSPolicyAssignment is updated and the update contains changes to one of
  144. // the following fields:
  145. // - instance_filter
  146. // - os_policies
  147. // 3) OSPolicyAssignment is deleted.
  148. Rollout rollout = 5 [(google.api.field_behavior) = REQUIRED];
  149. // Output only. The assignment revision ID
  150. // A new revision is committed whenever a rollout is triggered for a OS policy
  151. // assignment
  152. string revision_id = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
  153. // Output only. The timestamp that the revision was created.
  154. google.protobuf.Timestamp revision_create_time = 7
  155. [(google.api.field_behavior) = OUTPUT_ONLY];
  156. // The etag for this OS policy assignment.
  157. // If this is provided on update, it must match the server's etag.
  158. string etag = 8;
  159. // Output only. OS policy assignment rollout state
  160. RolloutState rollout_state = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
  161. // Output only. Indicates that this revision has been successfully rolled out
  162. // in this zone and new VMs will be assigned OS policies from this revision.
  163. //
  164. // For a given OS policy assignment, there is only one revision with a value
  165. // of `true` for this field.
  166. bool baseline = 10 [(google.api.field_behavior) = OUTPUT_ONLY];
  167. // Output only. Indicates that this revision deletes the OS policy assignment.
  168. bool deleted = 11 [(google.api.field_behavior) = OUTPUT_ONLY];
  169. // Output only. Indicates that reconciliation is in progress for the revision.
  170. // This value is `true` when the `rollout_state` is one of:
  171. // * IN_PROGRESS
  172. // * CANCELLING
  173. bool reconciling = 12 [(google.api.field_behavior) = OUTPUT_ONLY];
  174. // Output only. Server generated unique id for the OS policy assignment
  175. // 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
  233. [(google.api.field_behavior) = REQUIRED];
  234. // Required. The logical name of the OS policy assignment in the project
  235. // with the following restrictions:
  236. //
  237. // * Must contain only lowercase letters, numbers, and hyphens.
  238. // * Must start with a letter.
  239. // * Must be between 1-63 characters.
  240. // * Must end with a number or a letter.
  241. // * Must be unique within the project.
  242. string os_policy_assignment_id = 3 [(google.api.field_behavior) = REQUIRED];
  243. }
  244. // A request message to update an OS policy assignment
  245. message UpdateOSPolicyAssignmentRequest {
  246. // Required. The updated OS policy assignment.
  247. OSPolicyAssignment os_policy_assignment = 1
  248. [(google.api.field_behavior) = REQUIRED];
  249. // Optional. Field mask that controls which fields of the assignment should be
  250. // updated.
  251. google.protobuf.FieldMask update_mask = 2
  252. [(google.api.field_behavior) = OPTIONAL];
  253. }
  254. // A request message to get an OS policy assignment
  255. message GetOSPolicyAssignmentRequest {
  256. // Required. The resource name of OS policy assignment.
  257. //
  258. // Format:
  259. // `projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}@{revisionId}`
  260. string name = 1 [
  261. (google.api.field_behavior) = REQUIRED,
  262. (google.api.resource_reference) = {
  263. type: "osconfig.googleapis.com/OSPolicyAssignment"
  264. }
  265. ];
  266. }
  267. // A request message to list OS policy assignments for a parent resource
  268. message ListOSPolicyAssignmentsRequest {
  269. // Required. The parent resource name.
  270. string parent = 1 [
  271. (google.api.field_behavior) = REQUIRED,
  272. (google.api.resource_reference) = {
  273. type: "locations.googleapis.com/Location"
  274. }
  275. ];
  276. // The maximum number of assignments to return.
  277. int32 page_size = 2;
  278. // A pagination token returned from a previous call to
  279. // `ListOSPolicyAssignments` that indicates where this listing should continue
  280. // from.
  281. string page_token = 3;
  282. }
  283. // A response message for listing all assignments under given parent.
  284. message ListOSPolicyAssignmentsResponse {
  285. // The list of assignments
  286. repeated OSPolicyAssignment os_policy_assignments = 1;
  287. // The pagination token to retrieve the next page of OS policy assignments.
  288. string next_page_token = 2;
  289. }
  290. // A request message to list revisions for a OS policy assignment
  291. message ListOSPolicyAssignmentRevisionsRequest {
  292. // Required. The name of the OS policy assignment to list revisions for.
  293. string name = 1 [
  294. (google.api.field_behavior) = REQUIRED,
  295. (google.api.resource_reference) = {
  296. type: "osconfig.googleapis.com/OSPolicyAssignment"
  297. }
  298. ];
  299. // The maximum number of revisions to return.
  300. int32 page_size = 2;
  301. // A pagination token returned from a previous call to
  302. // `ListOSPolicyAssignmentRevisions` that indicates where this listing should
  303. // continue from.
  304. string page_token = 3;
  305. }
  306. // A response message for listing all revisions for a OS policy assignment.
  307. message ListOSPolicyAssignmentRevisionsResponse {
  308. // The OS policy assignment revisions
  309. repeated OSPolicyAssignment os_policy_assignments = 1;
  310. // The pagination token to retrieve the next page of OS policy assignment
  311. // revisions.
  312. string next_page_token = 2;
  313. }
  314. // A request message for deleting a OS policy assignment.
  315. message DeleteOSPolicyAssignmentRequest {
  316. // Required. The name of the OS policy assignment to be deleted
  317. string name = 1 [
  318. (google.api.field_behavior) = REQUIRED,
  319. (google.api.resource_reference) = {
  320. type: "osconfig.googleapis.com/OSPolicyAssignment"
  321. }
  322. ];
  323. }