This repository was archived by the owner on Dec 31, 2023. It is now read-only.

File tree

9 files changed

+1232
-4
lines changed

9 files changed

+1232
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,7 @@
10291029
NodeGroupsListNodes,
10301030
NodeGroupsScopedList,
10311031
NodeGroupsSetNodeTemplateRequest,
1032+
NodeGroupsSimulateMaintenanceEventRequest,
10321033
NodeTemplate,
10331034
NodeTemplateAggregatedList,
10341035
NodeTemplateList,
@@ -1365,6 +1366,7 @@
13651366
ShieldedInstanceIntegrityPolicy,
13661367
SignedUrlKey,
13671368
SimulateMaintenanceEventInstanceRequest,
1369+
SimulateMaintenanceEventNodeGroupRequest,
13681370
Snapshot,
13691371
SnapshotList,
13701372
SourceDiskEncryptionKey,
@@ -2449,6 +2451,7 @@
24492451
"NodeGroupsListNodes",
24502452
"NodeGroupsScopedList",
24512453
"NodeGroupsSetNodeTemplateRequest",
2454+
"NodeGroupsSimulateMaintenanceEventRequest",
24522455
"NodeTemplate",
24532456
"NodeTemplateAggregatedList",
24542457
"NodeTemplateList",
@@ -2785,6 +2788,7 @@
27852788
"ShieldedInstanceIntegrityPolicy",
27862789
"SignedUrlKey",
27872790
"SimulateMaintenanceEventInstanceRequest",
2791+
"SimulateMaintenanceEventNodeGroupRequest",
27882792
"Snapshot",
27892793
"SnapshotList",
27902794
"SourceDiskEncryptionKey",
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,7 @@
925925
NodeGroupsListNodes,
926926
NodeGroupsScopedList,
927927
NodeGroupsSetNodeTemplateRequest,
928+
NodeGroupsSimulateMaintenanceEventRequest,
928929
NodeTemplate,
929930
NodeTemplateAggregatedList,
930931
NodeTemplateList,
@@ -1261,6 +1262,7 @@
12611262
ShieldedInstanceIntegrityPolicy,
12621263
SignedUrlKey,
12631264
SimulateMaintenanceEventInstanceRequest,
1265+
SimulateMaintenanceEventNodeGroupRequest,
12641266
Snapshot,
12651267
SnapshotList,
12661268
SourceDiskEncryptionKey,
@@ -2293,6 +2295,7 @@
22932295
"NodeGroupsListNodes",
22942296
"NodeGroupsScopedList",
22952297
"NodeGroupsSetNodeTemplateRequest",
2298+
"NodeGroupsSimulateMaintenanceEventRequest",
22962299
"NodeTemplate",
22972300
"NodeTemplateAggregatedList",
22982301
"NodeTemplateList",
@@ -2665,6 +2668,7 @@
26652668
"ShieldedInstanceIntegrityPolicy",
26662669
"SignedUrlKey",
26672670
"SimulateMaintenanceEventInstanceRequest",
2671+
"SimulateMaintenanceEventNodeGroupRequest",
26682672
"Snapshot",
26692673
"SnapshotList",
26702674
"SnapshotsClient",
Original file line numberDiff line numberDiff line change
@@ -1954,6 +1954,11 @@
19541954
"set_node_template"
19551955
]
19561956
},
1957+
"SimulateMaintenanceEvent": {
1958+
"methods": [
1959+
"simulate_maintenance_event"
1960+
]
1961+
},
19571962
"TestIamPermissions": {
19581963
"methods": [
19591964
"test_iam_permissions"
Original file line numberDiff line numberDiff line change
@@ -2601,6 +2601,283 @@ def error_code(self):
26012601
# Done; return the response.
26022602
return response
26032603

2604+
def simulate_maintenance_event_unary(
2605+
self,
2606+
request: Optional[
2607+
Union[compute.SimulateMaintenanceEventNodeGroupRequest, dict]
2608+
] = None,
2609+
*,
2610+
project: Optional[str] = None,
2611+
zone: Optional[str] = None,
2612+
node_group: Optional[str] = None,
2613+
node_groups_simulate_maintenance_event_request_resource: Optional[
2614+
compute.NodeGroupsSimulateMaintenanceEventRequest
2615+
] = None,
2616+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
2617+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2618+
metadata: Sequence[Tuple[str, str]] = (),
2619+
) -> compute.Operation:
2620+
r"""Simulates maintenance event on specified nodes from
2621+
the node group.
2622+
2623+
Args:
2624+
request (Union[google.cloud.compute_v1.types.SimulateMaintenanceEventNodeGroupRequest, dict]):
2625+
The request object. A request message for
2626+
NodeGroups.SimulateMaintenanceEvent. See the method
2627+
description for details.
2628+
project (str):
2629+
Project ID for this request.
2630+
This corresponds to the ``project`` field
2631+
on the ``request`` instance; if ``request`` is provided, this
2632+
should not be set.
2633+
zone (str):
2634+
The name of the zone for this
2635+
request.
2636+
2637+
This corresponds to the ``zone`` field
2638+
on the ``request`` instance; if ``request`` is provided, this
2639+
should not be set.
2640+
node_group (str):
2641+
Name of the NodeGroup resource whose
2642+
nodes will go under maintenance
2643+
simulation.
2644+
2645+
This corresponds to the ``node_group`` field
2646+
on the ``request`` instance; if ``request`` is provided, this
2647+
should not be set.
2648+
node_groups_simulate_maintenance_event_request_resource (google.cloud.compute_v1.types.NodeGroupsSimulateMaintenanceEventRequest):
2649+
The body resource for this request
2650+
This corresponds to the ``node_groups_simulate_maintenance_event_request_resource`` field
2651+
on the ``request`` instance; if ``request`` is provided, this
2652+
should not be set.
2653+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
2654+
should be retried.
2655+
timeout (float): The timeout for this request.
2656+
metadata (Sequence[Tuple[str, str]]): Strings which should be
2657+
sent along with the request as metadata.
2658+
2659+
Returns:
2660+
google.api_core.extended_operation.ExtendedOperation:
2661+
An object representing a extended
2662+
long-running operation.
2663+
2664+
"""
2665+
# Create or coerce a protobuf request object.
2666+
# Quick check: If we got a request object, we should *not* have
2667+
# gotten any keyword arguments that map to the request.
2668+
has_flattened_params = any(
2669+
[
2670+
project,
2671+
zone,
2672+
node_group,
2673+
node_groups_simulate_maintenance_event_request_resource,
2674+
]
2675+
)
2676+
if request is not None and has_flattened_params:
2677+
raise ValueError(
2678+
"If the `request` argument is set, then none of "
2679+
"the individual field arguments should be set."
2680+
)
2681+
2682+
# Minor optimization to avoid making a copy if the user passes
2683+
# in a compute.SimulateMaintenanceEventNodeGroupRequest.
2684+
# There's no risk of modifying the input as we've already verified
2685+
# there are no flattened fields.
2686+
if not isinstance(request, compute.SimulateMaintenanceEventNodeGroupRequest):
2687+
request = compute.SimulateMaintenanceEventNodeGroupRequest(request)
2688+
# If we have keyword arguments corresponding to fields on the
2689+
# request, apply these.
2690+
if project is not None:
2691+
request.project = project
2692+
if zone is not None:
2693+
request.zone = zone
2694+
if node_group is not None:
2695+
request.node_group = node_group
2696+
if node_groups_simulate_maintenance_event_request_resource is not None:
2697+
request.node_groups_simulate_maintenance_event_request_resource = (
2698+
node_groups_simulate_maintenance_event_request_resource
2699+
)
2700+
2701+
# Wrap the RPC method; this adds retry and timeout information,
2702+
# and friendly error handling.
2703+
rpc = self._transport._wrapped_methods[
2704+
self._transport.simulate_maintenance_event
2705+
]
2706+
2707+
# Certain fields should be provided within the metadata header;
2708+
# add these here.
2709+
metadata = tuple(metadata) + (
2710+
gapic_v1.routing_header.to_grpc_metadata(
2711+
(
2712+
("project", request.project),
2713+
("zone", request.zone),
2714+
("node_group", request.node_group),
2715+
)
2716+
),
2717+
)
2718+
2719+
# Send the request.
2720+
response = rpc(
2721+
request,
2722+
retry=retry,
2723+
timeout=timeout,
2724+
metadata=metadata,
2725+
)
2726+
2727+
# Done; return the response.
2728+
return response
2729+
2730+
def simulate_maintenance_event(
2731+
self,
2732+
request: Optional[
2733+
Union[compute.SimulateMaintenanceEventNodeGroupRequest, dict]
2734+
] = None,
2735+
*,
2736+
project: Optional[str] = None,
2737+
zone: Optional[str] = None,
2738+
node_group: Optional[str] = None,
2739+
node_groups_simulate_maintenance_event_request_resource: Optional[
2740+
compute.NodeGroupsSimulateMaintenanceEventRequest
2741+
] = None,
2742+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
2743+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
2744+
metadata: Sequence[Tuple[str, str]] = (),
2745+
) -> extended_operation.ExtendedOperation:
2746+
r"""Simulates maintenance event on specified nodes from
2747+
the node group.
2748+
2749+
Args:
2750+
request (Union[google.cloud.compute_v1.types.SimulateMaintenanceEventNodeGroupRequest, dict]):
2751+
The request object. A request message for
2752+
NodeGroups.SimulateMaintenanceEvent. See the method
2753+
description for details.
2754+
project (str):
2755+
Project ID for this request.
2756+
This corresponds to the ``project`` field
2757+
on the ``request`` instance; if ``request`` is provided, this
2758+
should not be set.
2759+
zone (str):
2760+
The name of the zone for this
2761+
request.
2762+
2763+
This corresponds to the ``zone`` field
2764+
on the ``request`` instance; if ``request`` is provided, this
2765+
should not be set.
2766+
node_group (str):
2767+
Name of the NodeGroup resource whose
2768+
nodes will go under maintenance
2769+
simulation.
2770+
2771+
This corresponds to the ``node_group`` field
2772+
on the ``request`` instance; if ``request`` is provided, this
2773+
should not be set.
2774+
node_groups_simulate_maintenance_event_request_resource (google.cloud.compute_v1.types.NodeGroupsSimulateMaintenanceEventRequest):
2775+
The body resource for this request
2776+
This corresponds to the ``node_groups_simulate_maintenance_event_request_resource`` field
2777+
on the ``request`` instance; if ``request`` is provided, this
2778+
should not be set.
2779+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
2780+
should be retried.
2781+
timeout (float): The timeout for this request.
2782+
metadata (Sequence[Tuple[str, str]]): Strings which should be
2783+
sent along with the request as metadata.
2784+
2785+
Returns:
2786+
google.api_core.extended_operation.ExtendedOperation:
2787+
An object representing a extended
2788+
long-running operation.
2789+
2790+
"""
2791+
# Create or coerce a protobuf request object.
2792+
# Quick check: If we got a request object, we should *not* have
2793+
# gotten any keyword arguments that map to the request.
2794+
has_flattened_params = any(
2795+
[
2796+
project,
2797+
zone,
2798+
node_group,
2799+
node_groups_simulate_maintenance_event_request_resource,
2800+
]
2801+
)
2802+
if request is not None and has_flattened_params:
2803+
raise ValueError(
2804+
"If the `request` argument is set, then none of "
2805+
"the individual field arguments should be set."
2806+
)
2807+
2808+
# Minor optimization to avoid making a copy if the user passes
2809+
# in a compute.SimulateMaintenanceEventNodeGroupRequest.
2810+
# There's no risk of modifying the input as we've already verified
2811+
# there are no flattened fields.
2812+
if not isinstance(request, compute.SimulateMaintenanceEventNodeGroupRequest):
2813+
request = compute.SimulateMaintenanceEventNodeGroupRequest(request)
2814+
# If we have keyword arguments corresponding to fields on the
2815+
# request, apply these.
2816+
if project is not None:
2817+
request.project = project
2818+
if zone is not None:
2819+
request.zone = zone
2820+
if node_group is not None:
2821+
request.node_group = node_group
2822+
if node_groups_simulate_maintenance_event_request_resource is not None:
2823+
request.node_groups_simulate_maintenance_event_request_resource = (
2824+
node_groups_simulate_maintenance_event_request_resource
2825+
)
2826+
2827+
# Wrap the RPC method; this adds retry and timeout information,
2828+
# and friendly error handling.
2829+
rpc = self._transport._wrapped_methods[
2830+
self._transport.simulate_maintenance_event
2831+
]
2832+
2833+
# Certain fields should be provided within the metadata header;
2834+
# add these here.
2835+
metadata = tuple(metadata) + (
2836+
gapic_v1.routing_header.to_grpc_metadata(
2837+
(
2838+
("project", request.project),
2839+
("zone", request.zone),
2840+
("node_group", request.node_group),
2841+
)
2842+
),
2843+
)
2844+
2845+
# Send the request.
2846+
response = rpc(
2847+
request,
2848+
retry=retry,
2849+
timeout=timeout,
2850+
metadata=metadata,
2851+
)
2852+
2853+
operation_service = self._transport._zone_operations_client
2854+
operation_request = compute.GetZoneOperationRequest()
2855+
operation_request.project = request.project
2856+
operation_request.zone = request.zone
2857+
operation_request.operation = response.name
2858+
2859+
get_operation = functools.partial(operation_service.get, operation_request)
2860+
# Cancel is not part of extended operations yet.
2861+
cancel_operation = lambda: None
2862+
2863+
# Note: this class is an implementation detail to provide a uniform
2864+
# set of names for certain fields in the extended operation proto message.
2865+
# See google.api_core.extended_operation.ExtendedOperation for details
2866+
# on these properties and the expected interface.
2867+
class _CustomOperation(extended_operation.ExtendedOperation):
2868+
@property
2869+
def error_message(self):
2870+
return self._extended_operation.http_error_message
2871+
2872+
@property
2873+
def error_code(self):
2874+
return self._extended_operation.http_error_status_code
2875+
2876+
response = _CustomOperation.make(get_operation, cancel_operation, response)
2877+
2878+
# Done; return the response.
2879+
return response
2880+
26042881
def test_iam_permissions(
26052882
self,
26062883
request: Optional[
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ def _prep_wrapped_messages(self, client_info):
187187
default_timeout=None,
188188
client_info=client_info,
189189
),
190+
self.simulate_maintenance_event: gapic_v1.method.wrap_method(
191+
self.simulate_maintenance_event,
192+
default_timeout=None,
193+
client_info=client_info,
194+
),
190195
self.test_iam_permissions: gapic_v1.method.wrap_method(
191196
self.test_iam_permissions,
192197
default_timeout=None,
@@ -313,6 +318,15 @@ def set_node_template(
313318
]:
314319
raise NotImplementedError()
315320

321+
@property
322+
def simulate_maintenance_event(
323+
self,
324+
) -> Callable[
325+
[compute.SimulateMaintenanceEventNodeGroupRequest],
326+
Union[compute.Operation, Awaitable[compute.Operation]],
327+
]:
328+
raise NotImplementedError()
329+
316330
@property
317331
def test_iam_permissions(
318332
self,

0 commit comments

Comments
 (0)