Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Commit

Permalink
feat: Update Compute Engine API to revision 20230711 (#836) (#426)
Browse files Browse the repository at this point in the history
* feat: Update Compute Engine API to revision 20230711 (#836)

Source-Link: googleapis/googleapis@e8c26cc

Source-Link: googleapis/googleapis-gen@81d1ed1
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODFkMWVkMTE3ZjY4NDRmZWZiMjM5ZTBjZDA4NGJhMTAxODQ2ZWYwMSJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] committed Jul 25, 2023
1 parent 8798b73 commit 40f2de8
Show file tree
Hide file tree
Showing 19 changed files with 1,789 additions and 36 deletions.
2 changes: 2 additions & 0 deletions google/cloud/compute/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@
PatchRegionSslPolicyRequest,
PatchRegionTargetHttpsProxyRequest,
PatchRegionUrlMapRequest,
PatchResourcePolicyRequest,
PatchRouterRequest,
PatchRuleFirewallPolicyRequest,
PatchRuleNetworkFirewallPolicyRequest,
Expand Down Expand Up @@ -2571,6 +2572,7 @@
"PatchRegionSslPolicyRequest",
"PatchRegionTargetHttpsProxyRequest",
"PatchRegionUrlMapRequest",
"PatchResourcePolicyRequest",
"PatchRouterRequest",
"PatchRuleFirewallPolicyRequest",
"PatchRuleNetworkFirewallPolicyRequest",
Expand Down
2 changes: 2 additions & 0 deletions google/cloud/compute_v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,7 @@
PatchRegionSslPolicyRequest,
PatchRegionTargetHttpsProxyRequest,
PatchRegionUrlMapRequest,
PatchResourcePolicyRequest,
PatchRouterRequest,
PatchRuleFirewallPolicyRequest,
PatchRuleNetworkFirewallPolicyRequest,
Expand Down Expand Up @@ -2416,6 +2417,7 @@
"PatchRegionSslPolicyRequest",
"PatchRegionTargetHttpsProxyRequest",
"PatchRegionUrlMapRequest",
"PatchResourcePolicyRequest",
"PatchRouterRequest",
"PatchRuleFirewallPolicyRequest",
"PatchRuleNetworkFirewallPolicyRequest",
Expand Down
5 changes: 5 additions & 0 deletions google/cloud/compute_v1/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3317,6 +3317,11 @@
"list"
]
},
"Patch": {
"methods": [
"patch"
]
},
"SetIamPolicy": {
"methods": [
"set_iam_policy"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ def patch_unary(
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Patches the specified policy with the data included
in the request. To clear fields in the rule, leave the
in the request. To clear fields in the policy, leave the
fields empty and specify them in the updateMask. This
cannot be used to be update the rules in the policy.
Please use the per rule methods like addRule, patchRule,
Expand Down Expand Up @@ -1411,7 +1411,7 @@ def patch(
metadata: Sequence[Tuple[str, str]] = (),
) -> extended_operation.ExtendedOperation:
r"""Patches the specified policy with the data included
in the request. To clear fields in the rule, leave the
in the request. To clear fields in the policy, leave the
fields empty and specify them in the updateMask. This
cannot be used to be update the rules in the policy.
Please use the per rule methods like addRule, patchRule,
Expand Down
295 changes: 295 additions & 0 deletions google/cloud/compute_v1/services/resource_policies/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,301 @@ def sample_list():
# Done; return the response.
return response

def patch_unary(
self,
request: Optional[Union[compute.PatchResourcePolicyRequest, dict]] = None,
*,
project: Optional[str] = None,
region: Optional[str] = None,
resource_policy: Optional[str] = None,
resource_policy_resource: Optional[compute.ResourcePolicy] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> compute.Operation:
r"""Modify the specified resource policy.
.. 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_patch():
# Create a client
client = compute_v1.ResourcePoliciesClient()
# Initialize request argument(s)
request = compute_v1.PatchResourcePolicyRequest(
project="project_value",
region="region_value",
resource_policy="resource_policy_value",
)
# Make the request
response = client.patch(request=request)
# Handle the response
print(response)
Args:
request (Union[google.cloud.compute_v1.types.PatchResourcePolicyRequest, dict]):
The request object. A request message for
ResourcePolicies.Patch. 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.
region (str):
Name of the region for this request.
This corresponds to the ``region`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
resource_policy (str):
Id of the resource policy to patch.
This corresponds to the ``resource_policy`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
resource_policy_resource (google.cloud.compute_v1.types.ResourcePolicy):
The body resource for this request
This corresponds to the ``resource_policy_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, region, resource_policy, resource_policy_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."
)

# Minor optimization to avoid making a copy if the user passes
# in a compute.PatchResourcePolicyRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
if not isinstance(request, compute.PatchResourcePolicyRequest):
request = compute.PatchResourcePolicyRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if project is not None:
request.project = project
if region is not None:
request.region = region
if resource_policy is not None:
request.resource_policy = resource_policy
if resource_policy_resource is not None:
request.resource_policy_resource = resource_policy_resource

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

# 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),
("region", request.region),
("resource_policy", request.resource_policy),
)
),
)

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

# Done; return the response.
return response

def patch(
self,
request: Optional[Union[compute.PatchResourcePolicyRequest, dict]] = None,
*,
project: Optional[str] = None,
region: Optional[str] = None,
resource_policy: Optional[str] = None,
resource_policy_resource: Optional[compute.ResourcePolicy] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> extended_operation.ExtendedOperation:
r"""Modify the specified resource policy.
.. 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_patch():
# Create a client
client = compute_v1.ResourcePoliciesClient()
# Initialize request argument(s)
request = compute_v1.PatchResourcePolicyRequest(
project="project_value",
region="region_value",
resource_policy="resource_policy_value",
)
# Make the request
response = client.patch(request=request)
# Handle the response
print(response)
Args:
request (Union[google.cloud.compute_v1.types.PatchResourcePolicyRequest, dict]):
The request object. A request message for
ResourcePolicies.Patch. 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.
region (str):
Name of the region for this request.
This corresponds to the ``region`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
resource_policy (str):
Id of the resource policy to patch.
This corresponds to the ``resource_policy`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
resource_policy_resource (google.cloud.compute_v1.types.ResourcePolicy):
The body resource for this request
This corresponds to the ``resource_policy_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, region, resource_policy, resource_policy_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."
)

# Minor optimization to avoid making a copy if the user passes
# in a compute.PatchResourcePolicyRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
if not isinstance(request, compute.PatchResourcePolicyRequest):
request = compute.PatchResourcePolicyRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if project is not None:
request.project = project
if region is not None:
request.region = region
if resource_policy is not None:
request.resource_policy = resource_policy
if resource_policy_resource is not None:
request.resource_policy_resource = resource_policy_resource

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

# 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),
("region", request.region),
("resource_policy", request.resource_policy),
)
),
)

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

operation_service = self._transport._region_operations_client
operation_request = compute.GetRegionOperationRequest()
operation_request.project = request.project
operation_request.region = request.region
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[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ def _prep_wrapped_messages(self, client_info):
default_timeout=None,
client_info=client_info,
),
self.patch: gapic_v1.method.wrap_method(
self.patch,
default_timeout=None,
client_info=client_info,
),
self.set_iam_policy: gapic_v1.method.wrap_method(
self.set_iam_policy,
default_timeout=None,
Expand Down Expand Up @@ -235,6 +240,15 @@ def list(
]:
raise NotImplementedError()

@property
def patch(
self,
) -> Callable[
[compute.PatchResourcePolicyRequest],
Union[compute.Operation, Awaitable[compute.Operation]],
]:
raise NotImplementedError()

@property
def set_iam_policy(
self,
Expand Down
Loading

0 comments on commit 40f2de8

Please sign in to comment.