xref: /aosp_15_r20/external/googleapis/google/cloud/osconfig/agentendpoint/v1/tasks.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2020 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
15syntax = "proto3";
16
17package google.cloud.osconfig.agentendpoint.v1;
18
19import "google/api/field_behavior.proto";
20import "google/api/resource.proto";
21import "google/cloud/osconfig/agentendpoint/v1/config_common.proto";
22import "google/cloud/osconfig/agentendpoint/v1/os_policy.proto";
23import "google/cloud/osconfig/agentendpoint/v1/patch_jobs.proto";
24
25option go_package = "cloud.google.com/go/osconfig/agentendpoint/apiv1/agentendpointpb;agentendpointpb";
26option java_multiple_files = true;
27option java_outer_classname = "Tasks";
28option java_package = "com.google.cloud.osconfig.agentendpoint.v1";
29option (google.api.resource_definition) = {
30  type: "osconfig.googleapis.com/OSPolicyAssignment"
31  pattern: "projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}"
32};
33
34// Specifies the current agent behavior.
35enum TaskDirective {
36  // Unspecified is invalid.
37  TASK_DIRECTIVE_UNSPECIFIED = 0;
38
39  // The task should continue to progress.
40  CONTINUE = 1;
41
42  // Task should not be started, or if already in progress, should stop
43  // at first safe stopping point.  Task should be considered done and will
44  // never repeat.
45  STOP = 2;
46}
47
48// Specifies the type of task to perform.
49enum TaskType {
50  // Unspecified is invalid.
51  TASK_TYPE_UNSPECIFIED = 0;
52
53  // The apply patches task.
54  APPLY_PATCHES = 1;
55
56  // The exec step task.
57  EXEC_STEP_TASK = 2;
58
59  // The apply config task
60  APPLY_CONFIG_TASK = 3;
61}
62
63// A unit of work to be performed by the agent.
64message Task {
65  // Unique task id.
66  string task_id = 1;
67
68  // The type of task to perform.
69  //
70  // Task details must include the appropriate message based on this enum as
71  // specified below:
72  // APPLY_PATCHES = ApplyPatchesTask
73  // EXEC_STEP = ExecStepTask
74  // APPLY_CONFIG_TASK = ApplyConfigTask
75  TaskType task_type = 2;
76
77  // Current directive to the agent.
78  TaskDirective task_directive = 3;
79
80  // Specific details about the current task to perform.
81  oneof task_details {
82    // Details about the apply patches task to perform.
83    ApplyPatchesTask apply_patches_task = 4;
84
85    // Details about the exec step task to perform.
86    ExecStepTask exec_step_task = 5;
87
88    // Details about the apply config step task to perform.
89    ApplyConfigTask apply_config_task = 7;
90  }
91
92  // Labels describing the task.  Used for logging by the agent.
93  map<string, string> service_labels = 6;
94}
95
96// Message which instructs agent to apply patches.
97message ApplyPatchesTask {
98  // Specific information about how patches should be applied.
99  PatchConfig patch_config = 1;
100
101  // If true, the agent will report its status as it goes through the motions
102  // but won't actually run any updates or perform any reboots.
103  bool dry_run = 3;
104}
105
106// Information reported from the agent about applying patches execution.
107message ApplyPatchesTaskProgress {
108  // The intermediate states of applying patches.
109  enum State {
110    // Unspecified is invalid.
111    STATE_UNSPECIFIED = 0;
112
113    // The agent has started the patch task.
114    STARTED = 4;
115
116    // The agent is currently downloading patches.
117    DOWNLOADING_PATCHES = 1;
118
119    // The agent is currently applying patches.
120    APPLYING_PATCHES = 2;
121
122    // The agent is currently rebooting the instance.
123    REBOOTING = 3;
124  }
125
126  // Required. The current state of this patch execution.
127  State state = 1 [(google.api.field_behavior) = REQUIRED];
128}
129
130// Information reported from the agent about applying patches execution.
131message ApplyPatchesTaskOutput {
132  // The final states of applying patches.
133  enum State {
134    // Unspecified is invalid.
135    STATE_UNSPECIFIED = 0;
136
137    // Applying patches completed successfully.
138    SUCCEEDED = 1;
139
140    // Applying patches completed successfully, but a reboot is required.
141    SUCCEEDED_REBOOT_REQUIRED = 2;
142
143    // Applying patches failed.
144    FAILED = 3;
145  }
146
147  // Required. The final state of this task.
148  State state = 1 [(google.api.field_behavior) = REQUIRED];
149}
150
151// Message which instructs agent to execute the following command.
152message ExecStepTask {
153  // Details of the exec step to run.
154  ExecStep exec_step = 1;
155}
156
157// Information reported from the agent about the exec step execution.
158message ExecStepTaskProgress {
159  // The intermediate states of exec steps.
160  enum State {
161    // Unspecified is invalid.
162    STATE_UNSPECIFIED = 0;
163
164    // The agent has started the exec step task.
165    STARTED = 1;
166  }
167
168  // Required. The current state of this exec step.
169  State state = 1 [(google.api.field_behavior) = REQUIRED];
170}
171
172// Information reported from the agent about the exec step execution.
173message ExecStepTaskOutput {
174  // The final states of exec steps.
175  enum State {
176    // Unspecified is invalid.
177    STATE_UNSPECIFIED = 0;
178
179    // The exec step completed normally.
180    COMPLETED = 1;
181
182    // The exec step was terminated because it took too long.
183    TIMED_OUT = 2;
184
185    // The exec step task was cancelled before it started.
186    CANCELLED = 3;
187  }
188
189  // Required. The final state of the exec step.
190  State state = 1 [(google.api.field_behavior) = REQUIRED];
191
192  // Required. The exit code received from the script which ran as part of the exec step.
193  int32 exit_code = 2 [(google.api.field_behavior) = REQUIRED];
194}
195
196// Message which instructs OS Config agent to apply the desired state
197// configuration.
198message ApplyConfigTask {
199  // Message representing an OS policy.
200  message OSPolicy {
201    // User provided policy id.
202    // Used for reporting and logging by the agent.
203    string id = 1;
204
205    // The policy mode
206    .google.cloud.osconfig.agentendpoint.v1.OSPolicy.Mode mode = 2;
207
208    // Reference to the `OSPolicyAssignment` API resource that this `OSPolicy`
209    // belongs to.
210    // Format:
211    // projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id@revision_id}
212    // Used for reporting and logging by the agent.
213    string os_policy_assignment = 3 [(google.api.resource_reference) = {
214                                       type: "osconfig.googleapis.com/OSPolicyAssignment"
215                                     }];
216
217    // List of resources associated with the policy to be set to their
218    // desired state.
219    repeated .google.cloud.osconfig.agentendpoint.v1.OSPolicy.Resource resources = 4;
220  }
221
222  // List of os policies to be applied for the instance.
223  repeated OSPolicy os_policies = 1;
224}
225
226// Information reported from the agent regarding the progress of the task of
227// applying desired state configuration.
228message ApplyConfigTaskProgress {
229  // The intermediate states of apply config task.
230  enum State {
231    // Invalid state
232    STATE_UNSPECIFIED = 0;
233
234    // The agent has started the task.
235    STARTED = 1;
236
237    // The agent is in the process of applying the configuration.
238    APPLYING_CONFIG = 2;
239  }
240
241  // The current state of this task.
242  State state = 1;
243}
244
245// Information reported from the agent regarding the output of the task of
246// applying desired state configuration.
247message ApplyConfigTaskOutput {
248  // Result of applying desired state config for an OS policy.
249  message OSPolicyResult {
250    // The OS policy id
251    string os_policy_id = 1;
252
253    // Reference to the `OSPolicyAssignment` API resource that this `OSPolicy`
254    // belongs to.
255    // Format:
256    // projects/{project_number}/locations/{location}/osPolicyAssignments/{os_policy_assignment_id@revision_id}
257    // Used for reporting and logging by the agent.
258    string os_policy_assignment = 2 [(google.api.resource_reference) = {
259                                       type: "osconfig.googleapis.com/OSPolicyAssignment"
260                                     }];
261
262    // Results of applying desired state config for the OS policy resources.
263    repeated OSPolicyResourceCompliance os_policy_resource_compliances = 3;
264  }
265
266  // The final state of this task.
267  enum State {
268    // Unspecified is invalid.
269    STATE_UNSPECIFIED = 0;
270
271    // The apply config task completed successfully.
272    SUCCEEDED = 1;
273
274    // The apply config task failed.
275    FAILED = 2;
276
277    // The apply config task was cancelled.
278    CANCELLED = 3;
279  }
280
281  // Required. The final state of this task.
282  State state = 1 [(google.api.field_behavior) = REQUIRED];
283
284  // Results of applying desired state config for the OS policies.
285  repeated OSPolicyResult os_policy_results = 2;
286}
287