@@ -1518,6 +1518,301 @@ def sample_list():
1518
1518
# Done; return the response.
1519
1519
return response
1520
1520
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
+
1521
1816
def set_iam_policy (
1522
1817
self ,
1523
1818
request : Optional [
0 commit comments