Skip to content

Commit

Permalink
feat: Update Compute Engine API to revision 20240421 (#899)
Browse files Browse the repository at this point in the history
Source-Link: googleapis/googleapis@55499b5

Source-Link: googleapis/googleapis-gen@cf5049b
Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWNvbXB1dGUvLk93bEJvdC55YW1sIiwiaCI6ImNmNTA0OWI3MDc5MjgyMDA2NWRiMzhlNzEyN2YzMmVhYjc3MDU5NDQifQ==
  • Loading branch information
gcf-owl-bot[bot] committed Apr 30, 2024
1 parent ac4ba7d commit 259b953
Show file tree
Hide file tree
Showing 16 changed files with 1,831 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,7 @@
from google.cloud.compute_v1.types.compute import NodeGroupsAddNodesRequest
from google.cloud.compute_v1.types.compute import NodeGroupsDeleteNodesRequest
from google.cloud.compute_v1.types.compute import NodeGroupsListNodes
from google.cloud.compute_v1.types.compute import NodeGroupsPerformMaintenanceRequest
from google.cloud.compute_v1.types.compute import NodeGroupsScopedList
from google.cloud.compute_v1.types.compute import NodeGroupsSetNodeTemplateRequest
from google.cloud.compute_v1.types.compute import NodeGroupsSimulateMaintenanceEventRequest
Expand Down Expand Up @@ -1107,6 +1108,7 @@
from google.cloud.compute_v1.types.compute import PathMatcher
from google.cloud.compute_v1.types.compute import PathRule
from google.cloud.compute_v1.types.compute import PerformMaintenanceInstanceRequest
from google.cloud.compute_v1.types.compute import PerformMaintenanceNodeGroupRequest
from google.cloud.compute_v1.types.compute import PerInstanceConfig
from google.cloud.compute_v1.types.compute import Policy
from google.cloud.compute_v1.types.compute import PreconfiguredWafSet
Expand Down Expand Up @@ -2616,6 +2618,7 @@
'NodeGroupsAddNodesRequest',
'NodeGroupsDeleteNodesRequest',
'NodeGroupsListNodes',
'NodeGroupsPerformMaintenanceRequest',
'NodeGroupsScopedList',
'NodeGroupsSetNodeTemplateRequest',
'NodeGroupsSimulateMaintenanceEventRequest',
Expand Down Expand Up @@ -2700,6 +2703,7 @@
'PathMatcher',
'PathRule',
'PerformMaintenanceInstanceRequest',
'PerformMaintenanceNodeGroupRequest',
'PerInstanceConfig',
'Policy',
'PreconfiguredWafSet',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,7 @@
from .types.compute import NodeGroupsAddNodesRequest
from .types.compute import NodeGroupsDeleteNodesRequest
from .types.compute import NodeGroupsListNodes
from .types.compute import NodeGroupsPerformMaintenanceRequest
from .types.compute import NodeGroupsScopedList
from .types.compute import NodeGroupsSetNodeTemplateRequest
from .types.compute import NodeGroupsSimulateMaintenanceEventRequest
Expand Down Expand Up @@ -1107,6 +1108,7 @@
from .types.compute import PathMatcher
from .types.compute import PathRule
from .types.compute import PerformMaintenanceInstanceRequest
from .types.compute import PerformMaintenanceNodeGroupRequest
from .types.compute import PerInstanceConfig
from .types.compute import Policy
from .types.compute import PreconfiguredWafSet
Expand Down Expand Up @@ -2560,6 +2562,7 @@
'NodeGroupsClient',
'NodeGroupsDeleteNodesRequest',
'NodeGroupsListNodes',
'NodeGroupsPerformMaintenanceRequest',
'NodeGroupsScopedList',
'NodeGroupsSetNodeTemplateRequest',
'NodeGroupsSimulateMaintenanceEventRequest',
Expand Down Expand Up @@ -2648,6 +2651,7 @@
'PathRule',
'PerInstanceConfig',
'PerformMaintenanceInstanceRequest',
'PerformMaintenanceNodeGroupRequest',
'Policy',
'PreconfiguredWafSet',
'PreservedState',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2145,6 +2145,11 @@
"patch"
]
},
"PerformMaintenance": {
"methods": [
"perform_maintenance"
]
},
"SetIamPolicy": {
"methods": [
"set_iam_policy"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2653,6 +2653,299 @@ def error_code(self):
# Done; return the response.
return response

def perform_maintenance_unary(self,
request: Optional[Union[compute.PerformMaintenanceNodeGroupRequest, dict]] = None,
*,
project: Optional[str] = None,
zone: Optional[str] = None,
node_group: Optional[str] = None,
node_groups_perform_maintenance_request_resource: Optional[compute.NodeGroupsPerformMaintenanceRequest] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Perform maintenance on a subset of nodes in the node
group.
.. code-block:: python
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import compute_v1
def sample_perform_maintenance():
# Create a client
client = compute_v1.NodeGroupsClient()
# Initialize request argument(s)
request = compute_v1.PerformMaintenanceNodeGroupRequest(
node_group="node_group_value",
project="project_value",
zone="zone_value",
)
# Make the request
response = client.perform_maintenance(request=request)
# Handle the response
print(response)
Args:
request (Union[google.cloud.compute_v1.types.PerformMaintenanceNodeGroupRequest, dict]):
The request object. A request message for
NodeGroups.PerformMaintenance. See the
method description for details.
project (str):
Project ID for this request.
This corresponds to the ``project`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
zone (str):
The name of the zone for this
request.
This corresponds to the ``zone`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
node_group (str):
Name of the node group scoping this
request.
This corresponds to the ``node_group`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
node_groups_perform_maintenance_request_resource (google.cloud.compute_v1.types.NodeGroupsPerformMaintenanceRequest):
The body resource for this request
This corresponds to the ``node_groups_perform_maintenance_request_resource`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
google.api_core.extended_operation.ExtendedOperation:
An object representing a extended
long-running operation.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([project, zone, node_group, node_groups_perform_maintenance_request_resource])
if request is not None and has_flattened_params:
raise ValueError('If the `request` argument is set, then none of '
'the individual field arguments should be set.')

# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, compute.PerformMaintenanceNodeGroupRequest):
request = compute.PerformMaintenanceNodeGroupRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if project is not None:
request.project = project
if zone is not None:
request.zone = zone
if node_group is not None:
request.node_group = node_group
if node_groups_perform_maintenance_request_resource is not None:
request.node_groups_perform_maintenance_request_resource = node_groups_perform_maintenance_request_resource

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.perform_maintenance]

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((
("project", request.project),
("zone", request.zone),
("node_group", request.node_group),
)),
)

# Validate the universe domain.
self._validate_universe_domain()

# Send the request.
response = rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

def perform_maintenance(self,
request: Optional[Union[compute.PerformMaintenanceNodeGroupRequest, dict]] = None,
*,
project: Optional[str] = None,
zone: Optional[str] = None,
node_group: Optional[str] = None,
node_groups_perform_maintenance_request_resource: Optional[compute.NodeGroupsPerformMaintenanceRequest] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> extended_operation.ExtendedOperation:
r"""Perform maintenance on a subset of nodes in the node
group.
.. code-block:: python
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import compute_v1
def sample_perform_maintenance():
# Create a client
client = compute_v1.NodeGroupsClient()
# Initialize request argument(s)
request = compute_v1.PerformMaintenanceNodeGroupRequest(
node_group="node_group_value",
project="project_value",
zone="zone_value",
)
# Make the request
response = client.perform_maintenance(request=request)
# Handle the response
print(response)
Args:
request (Union[google.cloud.compute_v1.types.PerformMaintenanceNodeGroupRequest, dict]):
The request object. A request message for
NodeGroups.PerformMaintenance. See the
method description for details.
project (str):
Project ID for this request.
This corresponds to the ``project`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
zone (str):
The name of the zone for this
request.
This corresponds to the ``zone`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
node_group (str):
Name of the node group scoping this
request.
This corresponds to the ``node_group`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
node_groups_perform_maintenance_request_resource (google.cloud.compute_v1.types.NodeGroupsPerformMaintenanceRequest):
The body resource for this request
This corresponds to the ``node_groups_perform_maintenance_request_resource`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
google.api_core.extended_operation.ExtendedOperation:
An object representing a extended
long-running operation.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([project, zone, node_group, node_groups_perform_maintenance_request_resource])
if request is not None and has_flattened_params:
raise ValueError('If the `request` argument is set, then none of '
'the individual field arguments should be set.')

# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, compute.PerformMaintenanceNodeGroupRequest):
request = compute.PerformMaintenanceNodeGroupRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if project is not None:
request.project = project
if zone is not None:
request.zone = zone
if node_group is not None:
request.node_group = node_group
if node_groups_perform_maintenance_request_resource is not None:
request.node_groups_perform_maintenance_request_resource = node_groups_perform_maintenance_request_resource

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.perform_maintenance]

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((
("project", request.project),
("zone", request.zone),
("node_group", request.node_group),
)),
)

# Validate the universe domain.
self._validate_universe_domain()

# Send the request.
response = rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

operation_service = self._transport._zone_operations_client
operation_request = compute.GetZoneOperationRequest()
operation_request.project = request.project
operation_request.zone = request.zone
operation_request.operation = response.name

get_operation = functools.partial(operation_service.get, operation_request)
# Cancel is not part of extended operations yet.
cancel_operation = lambda: None

# Note: this class is an implementation detail to provide a uniform
# set of names for certain fields in the extended operation proto message.
# See google.api_core.extended_operation.ExtendedOperation for details
# on these properties and the expected interface.
class _CustomOperation(extended_operation.ExtendedOperation):
@property
def error_message(self):
return self._extended_operation.http_error_message

@property
def error_code(self):
return self._extended_operation.http_error_status_code

response = _CustomOperation.make(get_operation, cancel_operation, response)

# Done; return the response.
return response

def set_iam_policy(self,
request: Optional[Union[compute.SetIamPolicyNodeGroupRequest, dict]] = None,
*,
Expand Down
Loading

0 comments on commit 259b953

Please sign in to comment.