This repository has been archived by the owner on Nov 29, 2023. It is now read-only.
/
patch_deployments.py
332 lines (280 loc) · 12.6 KB
/
patch_deployments.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# -*- coding: utf-8 -*-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import proto # type: ignore
from google.cloud.osconfig_v1.types import patch_jobs
from google.protobuf import duration_pb2 # type: ignore
from google.protobuf import timestamp_pb2 # type: ignore
from google.type import datetime_pb2 # type: ignore
from google.type import dayofweek_pb2 # type: ignore
from google.type import timeofday_pb2 # type: ignore
__protobuf__ = proto.module(
package="google.cloud.osconfig.v1",
manifest={
"PatchDeployment",
"OneTimeSchedule",
"RecurringSchedule",
"WeeklySchedule",
"MonthlySchedule",
"WeekDayOfMonth",
"CreatePatchDeploymentRequest",
"GetPatchDeploymentRequest",
"ListPatchDeploymentsRequest",
"ListPatchDeploymentsResponse",
"DeletePatchDeploymentRequest",
},
)
class PatchDeployment(proto.Message):
r"""Patch deployments are configurations that individual patch jobs use
to complete a patch. These configurations include instance filter,
package repository settings, and a schedule. For more information
about creating and managing patch deployments, see `Scheduling patch
jobs <https://cloud.google.com/compute/docs/os-patch-management/schedule-patch-jobs>`__.
Attributes:
name (str):
Unique name for the patch deployment resource in a project.
The patch deployment name is in the form:
``projects/{project_id}/patchDeployments/{patch_deployment_id}``.
This field is ignored when you create a new patch
deployment.
description (str):
Optional. Description of the patch
deployment. Length of the description is limited
to 1024 characters.
instance_filter (google.cloud.osconfig_v1.types.PatchInstanceFilter):
Required. VM instances to patch.
patch_config (google.cloud.osconfig_v1.types.PatchConfig):
Optional. Patch configuration that is
applied.
duration (google.protobuf.duration_pb2.Duration):
Optional. Duration of the patch. After the
duration ends, the patch times out.
one_time_schedule (google.cloud.osconfig_v1.types.OneTimeSchedule):
Required. Schedule a one-time execution.
recurring_schedule (google.cloud.osconfig_v1.types.RecurringSchedule):
Required. Schedule recurring executions.
create_time (google.protobuf.timestamp_pb2.Timestamp):
Output only. Time the patch deployment was created.
Timestamp is in
`RFC3339 <https://www.ietf.org/rfc/rfc3339.txt>`__ text
format.
update_time (google.protobuf.timestamp_pb2.Timestamp):
Output only. Time the patch deployment was last updated.
Timestamp is in
`RFC3339 <https://www.ietf.org/rfc/rfc3339.txt>`__ text
format.
last_execute_time (google.protobuf.timestamp_pb2.Timestamp):
Output only. The last time a patch job was started by this
deployment. Timestamp is in
`RFC3339 <https://www.ietf.org/rfc/rfc3339.txt>`__ text
format.
rollout (google.cloud.osconfig_v1.types.PatchRollout):
Optional. Rollout strategy of the patch job.
"""
name = proto.Field(proto.STRING, number=1,)
description = proto.Field(proto.STRING, number=2,)
instance_filter = proto.Field(
proto.MESSAGE, number=3, message=patch_jobs.PatchInstanceFilter,
)
patch_config = proto.Field(proto.MESSAGE, number=4, message=patch_jobs.PatchConfig,)
duration = proto.Field(proto.MESSAGE, number=5, message=duration_pb2.Duration,)
one_time_schedule = proto.Field(
proto.MESSAGE, number=6, oneof="schedule", message="OneTimeSchedule",
)
recurring_schedule = proto.Field(
proto.MESSAGE, number=7, oneof="schedule", message="RecurringSchedule",
)
create_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,)
update_time = proto.Field(proto.MESSAGE, number=9, message=timestamp_pb2.Timestamp,)
last_execute_time = proto.Field(
proto.MESSAGE, number=10, message=timestamp_pb2.Timestamp,
)
rollout = proto.Field(proto.MESSAGE, number=11, message=patch_jobs.PatchRollout,)
class OneTimeSchedule(proto.Message):
r"""Sets the time for a one time patch deployment. Timestamp is in
`RFC3339 <https://www.ietf.org/rfc/rfc3339.txt>`__ text format.
Attributes:
execute_time (google.protobuf.timestamp_pb2.Timestamp):
Required. The desired patch job execution
time.
"""
execute_time = proto.Field(
proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,
)
class RecurringSchedule(proto.Message):
r"""Sets the time for recurring patch deployments.
Attributes:
time_zone (google.type.datetime_pb2.TimeZone):
Required. Defines the time zone that ``time_of_day`` is
relative to. The rules for daylight saving time are
determined by the chosen time zone.
start_time (google.protobuf.timestamp_pb2.Timestamp):
Optional. The time that the recurring schedule becomes
effective. Defaults to ``create_time`` of the patch
deployment.
end_time (google.protobuf.timestamp_pb2.Timestamp):
Optional. The end time at which a recurring
patch deployment schedule is no longer active.
time_of_day (google.type.timeofday_pb2.TimeOfDay):
Required. Time of the day to run a recurring
deployment.
frequency (google.cloud.osconfig_v1.types.RecurringSchedule.Frequency):
Required. The frequency unit of this
recurring schedule.
weekly (google.cloud.osconfig_v1.types.WeeklySchedule):
Required. Schedule with weekly executions.
monthly (google.cloud.osconfig_v1.types.MonthlySchedule):
Required. Schedule with monthly executions.
last_execute_time (google.protobuf.timestamp_pb2.Timestamp):
Output only. The time the last patch job ran
successfully.
next_execute_time (google.protobuf.timestamp_pb2.Timestamp):
Output only. The time the next patch job is
scheduled to run.
"""
class Frequency(proto.Enum):
r"""Specifies the frequency of the recurring patch deployments."""
FREQUENCY_UNSPECIFIED = 0
WEEKLY = 1
MONTHLY = 2
DAILY = 3
time_zone = proto.Field(proto.MESSAGE, number=1, message=datetime_pb2.TimeZone,)
start_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,)
end_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,)
time_of_day = proto.Field(proto.MESSAGE, number=4, message=timeofday_pb2.TimeOfDay,)
frequency = proto.Field(proto.ENUM, number=5, enum=Frequency,)
weekly = proto.Field(
proto.MESSAGE, number=6, oneof="schedule_config", message="WeeklySchedule",
)
monthly = proto.Field(
proto.MESSAGE, number=7, oneof="schedule_config", message="MonthlySchedule",
)
last_execute_time = proto.Field(
proto.MESSAGE, number=9, message=timestamp_pb2.Timestamp,
)
next_execute_time = proto.Field(
proto.MESSAGE, number=10, message=timestamp_pb2.Timestamp,
)
class WeeklySchedule(proto.Message):
r"""Represents a weekly schedule.
Attributes:
day_of_week (google.type.dayofweek_pb2.DayOfWeek):
Required. Day of the week.
"""
day_of_week = proto.Field(proto.ENUM, number=1, enum=dayofweek_pb2.DayOfWeek,)
class MonthlySchedule(proto.Message):
r"""Represents a monthly schedule. An example of a valid monthly
schedule is "on the third Tuesday of the month" or "on the 15th
of the month".
Attributes:
week_day_of_month (google.cloud.osconfig_v1.types.WeekDayOfMonth):
Required. Week day in a month.
month_day (int):
Required. One day of the month. 1-31
indicates the 1st to the 31st day. -1 indicates
the last day of the month. Months without the
target day will be skipped. For example, a
schedule to run "every month on the 31st" will
not run in February, April, June, etc.
"""
week_day_of_month = proto.Field(
proto.MESSAGE, number=1, oneof="day_of_month", message="WeekDayOfMonth",
)
month_day = proto.Field(proto.INT32, number=2, oneof="day_of_month",)
class WeekDayOfMonth(proto.Message):
r"""Represents one week day in a month. An example is "the 4th
Sunday".
Attributes:
week_ordinal (int):
Required. Week number in a month. 1-4
indicates the 1st to 4th week of the month. -1
indicates the last week of the month.
day_of_week (google.type.dayofweek_pb2.DayOfWeek):
Required. A day of the week.
"""
week_ordinal = proto.Field(proto.INT32, number=1,)
day_of_week = proto.Field(proto.ENUM, number=2, enum=dayofweek_pb2.DayOfWeek,)
class CreatePatchDeploymentRequest(proto.Message):
r"""A request message for creating a patch deployment.
Attributes:
parent (str):
Required. The project to apply this patch deployment to in
the form ``projects/*``.
patch_deployment_id (str):
Required. A name for the patch deployment in the project.
When creating a name the following rules apply:
- Must contain only lowercase letters, numbers, and
hyphens.
- Must start with a letter.
- Must be between 1-63 characters.
- Must end with a number or a letter.
- Must be unique within the project.
patch_deployment (google.cloud.osconfig_v1.types.PatchDeployment):
Required. The patch deployment to create.
"""
parent = proto.Field(proto.STRING, number=1,)
patch_deployment_id = proto.Field(proto.STRING, number=2,)
patch_deployment = proto.Field(proto.MESSAGE, number=3, message="PatchDeployment",)
class GetPatchDeploymentRequest(proto.Message):
r"""A request message for retrieving a patch deployment.
Attributes:
name (str):
Required. The resource name of the patch deployment in the
form ``projects/*/patchDeployments/*``.
"""
name = proto.Field(proto.STRING, number=1,)
class ListPatchDeploymentsRequest(proto.Message):
r"""A request message for listing patch deployments.
Attributes:
parent (str):
Required. The resource name of the parent in the form
``projects/*``.
page_size (int):
Optional. The maximum number of patch
deployments to return. Default is 100.
page_token (str):
Optional. A pagination token returned from a
previous call to ListPatchDeployments that
indicates where this listing should continue
from.
"""
parent = proto.Field(proto.STRING, number=1,)
page_size = proto.Field(proto.INT32, number=2,)
page_token = proto.Field(proto.STRING, number=3,)
class ListPatchDeploymentsResponse(proto.Message):
r"""A response message for listing patch deployments.
Attributes:
patch_deployments (Sequence[google.cloud.osconfig_v1.types.PatchDeployment]):
The list of patch deployments.
next_page_token (str):
A pagination token that can be used to get
the next page of patch deployments.
"""
@property
def raw_page(self):
return self
patch_deployments = proto.RepeatedField(
proto.MESSAGE, number=1, message="PatchDeployment",
)
next_page_token = proto.Field(proto.STRING, number=2,)
class DeletePatchDeploymentRequest(proto.Message):
r"""A request message for deleting a patch deployment.
Attributes:
name (str):
Required. The resource name of the patch deployment in the
form ``projects/*/patchDeployments/*``.
"""
name = proto.Field(proto.STRING, number=1,)
__all__ = tuple(sorted(__protobuf__.manifest))