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.v1;
18
19import "google/api/field_behavior.proto";
20import "google/api/resource.proto";
21import "google/cloud/osconfig/v1/patch_jobs.proto";
22import "google/protobuf/duration.proto";
23import "google/protobuf/field_mask.proto";
24import "google/protobuf/timestamp.proto";
25import "google/type/datetime.proto";
26import "google/type/dayofweek.proto";
27import "google/type/timeofday.proto";
28
29option csharp_namespace = "Google.Cloud.OsConfig.V1";
30option go_package = "cloud.google.com/go/osconfig/apiv1/osconfigpb;osconfigpb";
31option java_outer_classname = "PatchDeployments";
32option java_package = "com.google.cloud.osconfig.v1";
33option php_namespace = "Google\\Cloud\\OsConfig\\V1";
34option ruby_package = "Google::Cloud::OsConfig::V1";
35
36// Patch deployments are configurations that individual patch jobs use to
37// complete a patch. These configurations include instance filter, package
38// repository settings, and a schedule. For more information about creating and
39// managing patch deployments, see [Scheduling patch
40// jobs](https://cloud.google.com/compute/docs/os-patch-management/schedule-patch-jobs).
41message PatchDeployment {
42  option (google.api.resource) = {
43    type: "osconfig.googleapis.com/PatchDeployment"
44    pattern: "projects/{project}/patchDeployments/{patch_deployment}"
45  };
46
47  // Represents state of patch peployment.
48  enum State {
49    // The default value. This value is used if the state is omitted.
50    STATE_UNSPECIFIED = 0;
51
52    // Active value means that patch deployment generates Patch Jobs.
53    ACTIVE = 1;
54
55    // Paused value means that patch deployment does not generate
56    // Patch jobs. Requires user action to move in and out from this state.
57    PAUSED = 2;
58  }
59
60  // Unique name for the patch deployment resource in a project. The patch
61  // deployment name is in the form:
62  // `projects/{project_id}/patchDeployments/{patch_deployment_id}`.
63  // This field is ignored when you create a new patch deployment.
64  string name = 1;
65
66  // Optional. Description of the patch deployment. Length of the description is
67  // limited to 1024 characters.
68  string description = 2 [(google.api.field_behavior) = OPTIONAL];
69
70  // Required. VM instances to patch.
71  PatchInstanceFilter instance_filter = 3
72      [(google.api.field_behavior) = REQUIRED];
73
74  // Optional. Patch configuration that is applied.
75  PatchConfig patch_config = 4 [(google.api.field_behavior) = OPTIONAL];
76
77  // Optional. Duration of the patch. After the duration ends, the patch times
78  // out.
79  google.protobuf.Duration duration = 5
80      [(google.api.field_behavior) = OPTIONAL];
81
82  // Schedule for the patch.
83  oneof schedule {
84    // Required. Schedule a one-time execution.
85    OneTimeSchedule one_time_schedule = 6
86        [(google.api.field_behavior) = REQUIRED];
87
88    // Required. Schedule recurring executions.
89    RecurringSchedule recurring_schedule = 7
90        [(google.api.field_behavior) = REQUIRED];
91  }
92
93  // Output only. Time the patch deployment was created. Timestamp is in
94  // [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text format.
95  google.protobuf.Timestamp create_time = 8
96      [(google.api.field_behavior) = OUTPUT_ONLY];
97
98  // Output only. Time the patch deployment was last updated. Timestamp is in
99  // [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text format.
100  google.protobuf.Timestamp update_time = 9
101      [(google.api.field_behavior) = OUTPUT_ONLY];
102
103  // Output only. The last time a patch job was started by this deployment.
104  // Timestamp is in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text
105  // format.
106  google.protobuf.Timestamp last_execute_time = 10
107      [(google.api.field_behavior) = OUTPUT_ONLY];
108
109  // Optional. Rollout strategy of the patch job.
110  PatchRollout rollout = 11 [(google.api.field_behavior) = OPTIONAL];
111
112  // Output only. Current state of the patch deployment.
113  State state = 12 [(google.api.field_behavior) = OUTPUT_ONLY];
114}
115
116// Sets the time for a one time patch deployment. Timestamp is in
117// [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text format.
118message OneTimeSchedule {
119  // Required. The desired patch job execution time.
120  google.protobuf.Timestamp execute_time = 1
121      [(google.api.field_behavior) = REQUIRED];
122}
123
124// Sets the time for recurring patch deployments.
125message RecurringSchedule {
126  // Specifies the frequency of the recurring patch deployments.
127  enum Frequency {
128    // Invalid. A frequency must be specified.
129    FREQUENCY_UNSPECIFIED = 0;
130
131    // Indicates that the frequency of recurrence should be expressed in terms
132    // of weeks.
133    WEEKLY = 1;
134
135    // Indicates that the frequency of recurrence should be expressed in terms
136    // of months.
137    MONTHLY = 2;
138
139    // Indicates that the frequency of recurrence should be expressed in terms
140    // of days.
141    DAILY = 3;
142  }
143
144  // Required. Defines the time zone that `time_of_day` is relative to.
145  // The rules for daylight saving time are determined by the chosen time zone.
146  google.type.TimeZone time_zone = 1 [(google.api.field_behavior) = REQUIRED];
147
148  // Optional. The time that the recurring schedule becomes effective.
149  // Defaults to `create_time` of the patch deployment.
150  google.protobuf.Timestamp start_time = 2
151      [(google.api.field_behavior) = OPTIONAL];
152
153  // Optional. The end time at which a recurring patch deployment schedule is no
154  // longer active.
155  google.protobuf.Timestamp end_time = 3
156      [(google.api.field_behavior) = OPTIONAL];
157
158  // Required. Time of the day to run a recurring deployment.
159  google.type.TimeOfDay time_of_day = 4
160      [(google.api.field_behavior) = REQUIRED];
161
162  // Required. The frequency unit of this recurring schedule.
163  Frequency frequency = 5 [(google.api.field_behavior) = REQUIRED];
164
165  // Configurations for this recurring schedule.
166  // Configurations must match frequency.
167  oneof schedule_config {
168    // Required. Schedule with weekly executions.
169    WeeklySchedule weekly = 6 [(google.api.field_behavior) = REQUIRED];
170
171    // Required. Schedule with monthly executions.
172    MonthlySchedule monthly = 7 [(google.api.field_behavior) = REQUIRED];
173  }
174
175  // Output only. The time the last patch job ran successfully.
176  google.protobuf.Timestamp last_execute_time = 9
177      [(google.api.field_behavior) = OUTPUT_ONLY];
178
179  // Output only. The time the next patch job is scheduled to run.
180  google.protobuf.Timestamp next_execute_time = 10
181      [(google.api.field_behavior) = OUTPUT_ONLY];
182}
183
184// Represents a weekly schedule.
185message WeeklySchedule {
186  // Required. Day of the week.
187  google.type.DayOfWeek day_of_week = 1
188      [(google.api.field_behavior) = REQUIRED];
189}
190
191// Represents a monthly schedule. An example of a valid monthly schedule is
192// "on the third Tuesday of the month" or "on the 15th of the month".
193message MonthlySchedule {
194  // One day in a month.
195  oneof day_of_month {
196    // Required. Week day in a month.
197    WeekDayOfMonth week_day_of_month = 1
198        [(google.api.field_behavior) = REQUIRED];
199
200    // Required. One day of the month. 1-31 indicates the 1st to the 31st day.
201    // -1 indicates the last day of the month. Months without the target day
202    // will be skipped. For example, a schedule to run "every month on the 31st"
203    // will not run in February, April, June, etc.
204    int32 month_day = 2 [(google.api.field_behavior) = REQUIRED];
205  }
206}
207
208// Represents one week day in a month. An example is "the 4th Sunday".
209message WeekDayOfMonth {
210  // Required. Week number in a month. 1-4 indicates the 1st to 4th week of the
211  // month. -1 indicates the last week of the month.
212  int32 week_ordinal = 1 [(google.api.field_behavior) = REQUIRED];
213
214  // Required. A day of the week.
215  google.type.DayOfWeek day_of_week = 2
216      [(google.api.field_behavior) = REQUIRED];
217
218  // Optional. Represents the number of days before or after the given week day
219  // of month that the patch deployment is scheduled for. For example if
220  // `week_ordinal` and `day_of_week` values point to the second day of the
221  // month and this `day_offset` value is set to `3`, the patch deployment takes
222  // place three days after the second Tuesday of the month. If this value is
223  // negative, for example -5, the patches are deployed five days before before
224  // the second Tuesday of the month. Allowed values are in range [-30, 30].
225  int32 day_offset = 3 [(google.api.field_behavior) = OPTIONAL];
226}
227
228// A request message for creating a patch deployment.
229message CreatePatchDeploymentRequest {
230  // Required. The project to apply this patch deployment to in the form
231  // `projects/*`.
232  string parent = 1 [
233    (google.api.field_behavior) = REQUIRED,
234    (google.api.resource_reference) = {
235      type: "cloudresourcemanager.googleapis.com/Project"
236    }
237  ];
238
239  // Required. A name for the patch deployment in the project. When creating a
240  // name the following rules apply:
241  // * Must contain only lowercase letters, numbers, and hyphens.
242  // * Must start with a letter.
243  // * Must be between 1-63 characters.
244  // * Must end with a number or a letter.
245  // * Must be unique within the project.
246  string patch_deployment_id = 2 [(google.api.field_behavior) = REQUIRED];
247
248  // Required. The patch deployment to create.
249  PatchDeployment patch_deployment = 3 [(google.api.field_behavior) = REQUIRED];
250}
251
252// A request message for retrieving a patch deployment.
253message GetPatchDeploymentRequest {
254  // Required. The resource name of the patch deployment in the form
255  // `projects/*/patchDeployments/*`.
256  string name = 1 [
257    (google.api.field_behavior) = REQUIRED,
258    (google.api.resource_reference) = {
259      type: "osconfig.googleapis.com/PatchDeployment"
260    }
261  ];
262}
263
264// A request message for listing patch deployments.
265message ListPatchDeploymentsRequest {
266  // Required. The resource name of the parent in the form `projects/*`.
267  string parent = 1 [
268    (google.api.field_behavior) = REQUIRED,
269    (google.api.resource_reference) = {
270      type: "cloudresourcemanager.googleapis.com/Project"
271    }
272  ];
273
274  // Optional. The maximum number of patch deployments to return. Default is
275  // 100.
276  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
277
278  // Optional. A pagination token returned from a previous call to
279  // ListPatchDeployments that indicates where this listing should continue
280  // from.
281  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
282}
283
284// A response message for listing patch deployments.
285message ListPatchDeploymentsResponse {
286  // The list of patch deployments.
287  repeated PatchDeployment patch_deployments = 1;
288
289  // A pagination token that can be used to get the next page of patch
290  // deployments.
291  string next_page_token = 2;
292}
293
294// A request message for deleting a patch deployment.
295message DeletePatchDeploymentRequest {
296  // Required. The resource name of the patch deployment in the form
297  // `projects/*/patchDeployments/*`.
298  string name = 1 [
299    (google.api.field_behavior) = REQUIRED,
300    (google.api.resource_reference) = {
301      type: "osconfig.googleapis.com/PatchDeployment"
302    }
303  ];
304}
305
306// A request message for updating a patch deployment.
307message UpdatePatchDeploymentRequest {
308  // Required. The patch deployment to Update.
309  PatchDeployment patch_deployment = 1 [(google.api.field_behavior) = REQUIRED];
310
311  // Optional. Field mask that controls which fields of the patch deployment
312  // should be updated.
313  google.protobuf.FieldMask update_mask = 2
314      [(google.api.field_behavior) = OPTIONAL];
315}
316
317// A request message for pausing a patch deployment.
318message PausePatchDeploymentRequest {
319  // Required. The resource name of the patch deployment in the form
320  // `projects/*/patchDeployments/*`.
321  string name = 1 [
322    (google.api.field_behavior) = REQUIRED,
323    (google.api.resource_reference) = {
324      type: "osconfig.googleapis.com/PatchDeployment"
325    }
326  ];
327}
328
329// A request message for resuming a patch deployment.
330message ResumePatchDeploymentRequest {
331  // Required. The resource name of the patch deployment in the form
332  // `projects/*/patchDeployments/*`.
333  string name = 1 [
334    (google.api.field_behavior) = REQUIRED,
335    (google.api.resource_reference) = {
336      type: "osconfig.googleapis.com/PatchDeployment"
337    }
338  ];
339}
340