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

Commit 40f2de8

Browse files
feat: Update Compute Engine API to revision 20230711 (#836) (#426)
* feat: Update Compute Engine API to revision 20230711 (#836) Source-Link: googleapis/googleapis@e8c26cc Source-Link: https://github.com/googleapis/googleapis-gen/commit/81d1ed117f6844fefb239e0cd084ba101846ef01 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>
1 parent 8798b73 commit 40f2de8

File tree

19 files changed

+1789
-36
lines changed

19 files changed

+1789
-36
lines changed

google/cloud/compute/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,7 @@
11151115
PatchRegionSslPolicyRequest,
11161116
PatchRegionTargetHttpsProxyRequest,
11171117
PatchRegionUrlMapRequest,
1118+
PatchResourcePolicyRequest,
11181119
PatchRouterRequest,
11191120
PatchRuleFirewallPolicyRequest,
11201121
PatchRuleNetworkFirewallPolicyRequest,
@@ -2571,6 +2572,7 @@
25712572
"PatchRegionSslPolicyRequest",
25722573
"PatchRegionTargetHttpsProxyRequest",
25732574
"PatchRegionUrlMapRequest",
2575+
"PatchResourcePolicyRequest",
25742576
"PatchRouterRequest",
25752577
"PatchRuleFirewallPolicyRequest",
25762578
"PatchRuleNetworkFirewallPolicyRequest",

google/cloud/compute_v1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,7 @@
10091009
PatchRegionSslPolicyRequest,
10101010
PatchRegionTargetHttpsProxyRequest,
10111011
PatchRegionUrlMapRequest,
1012+
PatchResourcePolicyRequest,
10121013
PatchRouterRequest,
10131014
PatchRuleFirewallPolicyRequest,
10141015
PatchRuleNetworkFirewallPolicyRequest,
@@ -2416,6 +2417,7 @@
24162417
"PatchRegionSslPolicyRequest",
24172418
"PatchRegionTargetHttpsProxyRequest",
24182419
"PatchRegionUrlMapRequest",
2420+
"PatchResourcePolicyRequest",
24192421
"PatchRouterRequest",
24202422
"PatchRuleFirewallPolicyRequest",
24212423
"PatchRuleNetworkFirewallPolicyRequest",

google/cloud/compute_v1/gapic_metadata.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3317,6 +3317,11 @@
33173317
"list"
33183318
]
33193319
},
3320+
"Patch": {
3321+
"methods": [
3322+
"patch"
3323+
]
3324+
},
33203325
"SetIamPolicy": {
33213326
"methods": [
33223327
"set_iam_policy"

google/cloud/compute_v1/services/region_security_policies/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,7 @@ def patch_unary(
12671267
metadata: Sequence[Tuple[str, str]] = (),
12681268
) -> compute.Operation:
12691269
r"""Patches the specified policy with the data included
1270-
in the request. To clear fields in the rule, leave the
1270+
in the request. To clear fields in the policy, leave the
12711271
fields empty and specify them in the updateMask. This
12721272
cannot be used to be update the rules in the policy.
12731273
Please use the per rule methods like addRule, patchRule,
@@ -1411,7 +1411,7 @@ def patch(
14111411
metadata: Sequence[Tuple[str, str]] = (),
14121412
) -> extended_operation.ExtendedOperation:
14131413
r"""Patches the specified policy with the data included
1414-
in the request. To clear fields in the rule, leave the
1414+
in the request. To clear fields in the policy, leave the
14151415
fields empty and specify them in the updateMask. This
14161416
cannot be used to be update the rules in the policy.
14171417
Please use the per rule methods like addRule, patchRule,

google/cloud/compute_v1/services/resource_policies/client.py

Lines changed: 295 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,301 @@ def sample_list():
15181518
# Done; return the response.
15191519
return response
15201520

1521+
def patch_unary(
1522+
self,
1523+
request: Optional[Union[compute.PatchResourcePolicyRequest, dict]] = None,
1524+
*,
1525+
project: Optional[str] = None,
1526+
region: Optional[str] = None,
1527+
resource_policy: Optional[str] = None,
1528+
resource_policy_resource: Optional[compute.ResourcePolicy] = None,
1529+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1530+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1531+
metadata: Sequence[Tuple[str, str]] = (),
1532+
) -> compute.Operation:
1533+
r"""Modify the specified resource policy.
1534+
1535+
.. code-block:: python
1536+
1537+
# This snippet has been automatically generated and should be regarded as a
1538+
# code template only.
1539+
# It will require modifications to work:
1540+
# - It may require correct/in-range values for request initialization.
1541+
# - It may require specifying regional endpoints when creating the service
1542+
# client as shown in:
1543+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
1544+
from google.cloud import compute_v1
1545+
1546+
def sample_patch():
1547+
# Create a client
1548+
client = compute_v1.ResourcePoliciesClient()
1549+
1550+
# Initialize request argument(s)
1551+
request = compute_v1.PatchResourcePolicyRequest(
1552+
project="project_value",
1553+
region="region_value",
1554+
resource_policy="resource_policy_value",
1555+
)
1556+
1557+
# Make the request
1558+
response = client.patch(request=request)
1559+
1560+
# Handle the response
1561+
print(response)
1562+
1563+
Args:
1564+
request (Union[google.cloud.compute_v1.types.PatchResourcePolicyRequest, dict]):
1565+
The request object. A request message for
1566+
ResourcePolicies.Patch. See the method
1567+
description for details.
1568+
project (str):
1569+
Project ID for this request.
1570+
This corresponds to the ``project`` field
1571+
on the ``request`` instance; if ``request`` is provided, this
1572+
should not be set.
1573+
region (str):
1574+
Name of the region for this request.
1575+
This corresponds to the ``region`` field
1576+
on the ``request`` instance; if ``request`` is provided, this
1577+
should not be set.
1578+
resource_policy (str):
1579+
Id of the resource policy to patch.
1580+
This corresponds to the ``resource_policy`` field
1581+
on the ``request`` instance; if ``request`` is provided, this
1582+
should not be set.
1583+
resource_policy_resource (google.cloud.compute_v1.types.ResourcePolicy):
1584+
The body resource for this request
1585+
This corresponds to the ``resource_policy_resource`` field
1586+
on the ``request`` instance; if ``request`` is provided, this
1587+
should not be set.
1588+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
1589+
should be retried.
1590+
timeout (float): The timeout for this request.
1591+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1592+
sent along with the request as metadata.
1593+
1594+
Returns:
1595+
google.api_core.extended_operation.ExtendedOperation:
1596+
An object representing a extended
1597+
long-running operation.
1598+
1599+
"""
1600+
# Create or coerce a protobuf request object.
1601+
# Quick check: If we got a request object, we should *not* have
1602+
# gotten any keyword arguments that map to the request.
1603+
has_flattened_params = any(
1604+
[project, region, resource_policy, resource_policy_resource]
1605+
)
1606+
if request is not None and has_flattened_params:
1607+
raise ValueError(
1608+
"If the `request` argument is set, then none of "
1609+
"the individual field arguments should be set."
1610+
)
1611+
1612+
# Minor optimization to avoid making a copy if the user passes
1613+
# in a compute.PatchResourcePolicyRequest.
1614+
# There's no risk of modifying the input as we've already verified
1615+
# there are no flattened fields.
1616+
if not isinstance(request, compute.PatchResourcePolicyRequest):
1617+
request = compute.PatchResourcePolicyRequest(request)
1618+
# If we have keyword arguments corresponding to fields on the
1619+
# request, apply these.
1620+
if project is not None:
1621+
request.project = project
1622+
if region is not None:
1623+
request.region = region
1624+
if resource_policy is not None:
1625+
request.resource_policy = resource_policy
1626+
if resource_policy_resource is not None:
1627+
request.resource_policy_resource = resource_policy_resource
1628+
1629+
# Wrap the RPC method; this adds retry and timeout information,
1630+
# and friendly error handling.
1631+
rpc = self._transport._wrapped_methods[self._transport.patch]
1632+
1633+
# Certain fields should be provided within the metadata header;
1634+
# add these here.
1635+
metadata = tuple(metadata) + (
1636+
gapic_v1.routing_header.to_grpc_metadata(
1637+
(
1638+
("project", request.project),
1639+
("region", request.region),
1640+
("resource_policy", request.resource_policy),
1641+
)
1642+
),
1643+
)
1644+
1645+
# Send the request.
1646+
response = rpc(
1647+
request,
1648+
retry=retry,
1649+
timeout=timeout,
1650+
metadata=metadata,
1651+
)
1652+
1653+
# Done; return the response.
1654+
return response
1655+
1656+
def patch(
1657+
self,
1658+
request: Optional[Union[compute.PatchResourcePolicyRequest, dict]] = None,
1659+
*,
1660+
project: Optional[str] = None,
1661+
region: Optional[str] = None,
1662+
resource_policy: Optional[str] = None,
1663+
resource_policy_resource: Optional[compute.ResourcePolicy] = None,
1664+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1665+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1666+
metadata: Sequence[Tuple[str, str]] = (),
1667+
) -> extended_operation.ExtendedOperation:
1668+
r"""Modify the specified resource policy.
1669+
1670+
.. code-block:: python
1671+
1672+
# This snippet has been automatically generated and should be regarded as a
1673+
# code template only.
1674+
# It will require modifications to work:
1675+
# - It may require correct/in-range values for request initialization.
1676+
# - It may require specifying regional endpoints when creating the service
1677+
# client as shown in:
1678+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
1679+
from google.cloud import compute_v1
1680+
1681+
def sample_patch():
1682+
# Create a client
1683+
client = compute_v1.ResourcePoliciesClient()
1684+
1685+
# Initialize request argument(s)
1686+
request = compute_v1.PatchResourcePolicyRequest(
1687+
project="project_value",
1688+
region="region_value",
1689+
resource_policy="resource_policy_value",
1690+
)
1691+
1692+
# Make the request
1693+
response = client.patch(request=request)
1694+
1695+
# Handle the response
1696+
print(response)
1697+
1698+
Args:
1699+
request (Union[google.cloud.compute_v1.types.PatchResourcePolicyRequest, dict]):
1700+
The request object. A request message for
1701+
ResourcePolicies.Patch. See the method
1702+
description for details.
1703+
project (str):
1704+
Project ID for this request.
1705+
This corresponds to the ``project`` field
1706+
on the ``request`` instance; if ``request`` is provided, this
1707+
should not be set.
1708+
region (str):
1709+
Name of the region for this request.
1710+
This corresponds to the ``region`` field
1711+
on the ``request`` instance; if ``request`` is provided, this
1712+
should not be set.
1713+
resource_policy (str):
1714+
Id of the resource policy to patch.
1715+
This corresponds to the ``resource_policy`` field
1716+
on the ``request`` instance; if ``request`` is provided, this
1717+
should not be set.
1718+
resource_policy_resource (google.cloud.compute_v1.types.ResourcePolicy):
1719+
The body resource for this request
1720+
This corresponds to the ``resource_policy_resource`` field
1721+
on the ``request`` instance; if ``request`` is provided, this
1722+
should not be set.
1723+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
1724+
should be retried.
1725+
timeout (float): The timeout for this request.
1726+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1727+
sent along with the request as metadata.
1728+
1729+
Returns:
1730+
google.api_core.extended_operation.ExtendedOperation:
1731+
An object representing a extended
1732+
long-running operation.
1733+
1734+
"""
1735+
# Create or coerce a protobuf request object.
1736+
# Quick check: If we got a request object, we should *not* have
1737+
# gotten any keyword arguments that map to the request.
1738+
has_flattened_params = any(
1739+
[project, region, resource_policy, resource_policy_resource]
1740+
)
1741+
if request is not None and has_flattened_params:
1742+
raise ValueError(
1743+
"If the `request` argument is set, then none of "
1744+
"the individual field arguments should be set."
1745+
)
1746+
1747+
# Minor optimization to avoid making a copy if the user passes
1748+
# in a compute.PatchResourcePolicyRequest.
1749+
# There's no risk of modifying the input as we've already verified
1750+
# there are no flattened fields.
1751+
if not isinstance(request, compute.PatchResourcePolicyRequest):
1752+
request = compute.PatchResourcePolicyRequest(request)
1753+
# If we have keyword arguments corresponding to fields on the
1754+
# request, apply these.
1755+
if project is not None:
1756+
request.project = project
1757+
if region is not None:
1758+
request.region = region
1759+
if resource_policy is not None:
1760+
request.resource_policy = resource_policy
1761+
if resource_policy_resource is not None:
1762+
request.resource_policy_resource = resource_policy_resource
1763+
1764+
# Wrap the RPC method; this adds retry and timeout information,
1765+
# and friendly error handling.
1766+
rpc = self._transport._wrapped_methods[self._transport.patch]
1767+
1768+
# Certain fields should be provided within the metadata header;
1769+
# add these here.
1770+
metadata = tuple(metadata) + (
1771+
gapic_v1.routing_header.to_grpc_metadata(
1772+
(
1773+
("project", request.project),
1774+
("region", request.region),
1775+
("resource_policy", request.resource_policy),
1776+
)
1777+
),
1778+
)
1779+
1780+
# Send the request.
1781+
response = rpc(
1782+
request,
1783+
retry=retry,
1784+
timeout=timeout,
1785+
metadata=metadata,
1786+
)
1787+
1788+
operation_service = self._transport._region_operations_client
1789+
operation_request = compute.GetRegionOperationRequest()
1790+
operation_request.project = request.project
1791+
operation_request.region = request.region
1792+
operation_request.operation = response.name
1793+
1794+
get_operation = functools.partial(operation_service.get, operation_request)
1795+
# Cancel is not part of extended operations yet.
1796+
cancel_operation = lambda: None
1797+
1798+
# Note: this class is an implementation detail to provide a uniform
1799+
# set of names for certain fields in the extended operation proto message.
1800+
# See google.api_core.extended_operation.ExtendedOperation for details
1801+
# on these properties and the expected interface.
1802+
class _CustomOperation(extended_operation.ExtendedOperation):
1803+
@property
1804+
def error_message(self):
1805+
return self._extended_operation.http_error_message
1806+
1807+
@property
1808+
def error_code(self):
1809+
return self._extended_operation.http_error_status_code
1810+
1811+
response = _CustomOperation.make(get_operation, cancel_operation, response)
1812+
1813+
# Done; return the response.
1814+
return response
1815+
15211816
def set_iam_policy(
15221817
self,
15231818
request: Optional[

google/cloud/compute_v1/services/resource_policies/transports/base.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ def _prep_wrapped_messages(self, client_info):
157157
default_timeout=None,
158158
client_info=client_info,
159159
),
160+
self.patch: gapic_v1.method.wrap_method(
161+
self.patch,
162+
default_timeout=None,
163+
client_info=client_info,
164+
),
160165
self.set_iam_policy: gapic_v1.method.wrap_method(
161166
self.set_iam_policy,
162167
default_timeout=None,
@@ -235,6 +240,15 @@ def list(
235240
]:
236241
raise NotImplementedError()
237242

243+
@property
244+
def patch(
245+
self,
246+
) -> Callable[
247+
[compute.PatchResourcePolicyRequest],
248+
Union[compute.Operation, Awaitable[compute.Operation]],
249+
]:
250+
raise NotImplementedError()
251+
238252
@property
239253
def set_iam_policy(
240254
self,

0 commit comments

Comments
 (0)