Skip to content
This repository was archived by the owner on Oct 16, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 55 additions & 2 deletions google/cloud/iam_v2beta/services/policies/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

from google.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
from google.longrunning import operations_pb2
from google.protobuf import timestamp_pb2 # type: ignore

from google.cloud.iam_v2beta.services.policies import pagers
Expand All @@ -54,8 +55,6 @@ class PoliciesAsyncClient:
DEFAULT_ENDPOINT = PoliciesClient.DEFAULT_ENDPOINT
DEFAULT_MTLS_ENDPOINT = PoliciesClient.DEFAULT_MTLS_ENDPOINT

policy_path = staticmethod(PoliciesClient.policy_path)
parse_policy_path = staticmethod(PoliciesClient.parse_policy_path)
common_billing_account_path = staticmethod(
PoliciesClient.common_billing_account_path
)
Expand Down Expand Up @@ -831,6 +830,60 @@ async def sample_delete_policy():
# Done; return the response.
return response

async def get_operation(
self,
request: operations_pb2.GetOperationRequest = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operations_pb2.Operation:
r"""Gets the latest state of a long-running operation.

Args:
request (:class:`~.operations_pb2.GetOperationRequest`):
The request object. Request message for
`GetOperation` method.
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:
~.operations_pb2.Operation:
An ``Operation`` object.
"""
# Create or coerce a protobuf request object.
# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
if isinstance(request, dict):
request = operations_pb2.GetOperationRequest(**request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method.wrap_method(
self._client._transport.get_operation,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)

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

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

# Done; return the response.
return response

async def __aenter__(self):
return self

Expand Down
70 changes: 55 additions & 15 deletions google/cloud/iam_v2beta/services/policies/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

from google.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
from google.longrunning import operations_pb2
from google.protobuf import timestamp_pb2 # type: ignore

from google.cloud.iam_v2beta.services.policies import pagers
Expand Down Expand Up @@ -168,21 +169,6 @@ def transport(self) -> PoliciesTransport:
"""
return self._transport

@staticmethod
def policy_path(
policy: str,
) -> str:
"""Returns a fully-qualified policy string."""
return "policies/{policy}".format(
policy=policy,
)

@staticmethod
def parse_policy_path(path: str) -> Dict[str, str]:
"""Parses a policy path into its component segments."""
m = re.match(r"^policies/(?P<policy>.+?)$", path)
return m.groupdict() if m else {}

@staticmethod
def common_billing_account_path(
billing_account: str,
Expand Down Expand Up @@ -1024,6 +1010,60 @@ def __exit__(self, type, value, traceback):
"""
self.transport.close()

def get_operation(
self,
request: operations_pb2.GetOperationRequest = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operations_pb2.Operation:
r"""Gets the latest state of a long-running operation.

Args:
request (:class:`~.operations_pb2.GetOperationRequest`):
The request object. Request message for
`GetOperation` method.
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:
~.operations_pb2.Operation:
An ``Operation`` object.
"""
# Create or coerce a protobuf request object.
# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
if isinstance(request, dict):
request = operations_pb2.GetOperationRequest(**request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method.wrap_method(
self._transport.get_operation,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)

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

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

# Done; return the response.
return response


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
Expand Down
9 changes: 9 additions & 0 deletions google/cloud/iam_v2beta/services/policies/transports/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,15 @@ def delete_policy(
]:
raise NotImplementedError()

@property
def get_operation(
self,
) -> Callable[
[operations_pb2.GetOperationRequest],
Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
]:
raise NotImplementedError()

@property
def kind(self) -> str:
raise NotImplementedError()
Expand Down
17 changes: 17 additions & 0 deletions google/cloud/iam_v2beta/services/policies/transports/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,23 @@ def delete_policy(
def close(self):
self.grpc_channel.close()

@property
def get_operation(
self,
) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]:
r"""Return a callable for the get_operation method over gRPC."""
# Generate a "stub function" on-the-fly which will actually make
# the request.
# gRPC handles serialization and deserialization, so we just need
# to pass in the functions for each.
if "get_operation" not in self._stubs:
self._stubs["get_operation"] = self.grpc_channel.unary_unary(
"/google.longrunning.Operations/GetOperation",
request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
response_deserializer=operations_pb2.Operation.FromString,
)
return self._stubs["get_operation"]

@property
def kind(self) -> str:
return "grpc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,5 +400,22 @@ def delete_policy(
def close(self):
return self.grpc_channel.close()

@property
def get_operation(
self,
) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]:
r"""Return a callable for the get_operation method over gRPC."""
# Generate a "stub function" on-the-fly which will actually make
# the request.
# gRPC handles serialization and deserialization, so we just need
# to pass in the functions for each.
if "get_operation" not in self._stubs:
self._stubs["get_operation"] = self.grpc_channel.unary_unary(
"/google.longrunning.Operations/GetOperation",
request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
response_deserializer=operations_pb2.Operation.FromString,
)
return self._stubs["get_operation"]


__all__ = ("PoliciesGrpcAsyncIOTransport",)
5 changes: 3 additions & 2 deletions google/cloud/iam_v2beta/types/deny.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ class DenyRule(proto.Message):
contain the following values:

- ``principalSet://goog/public:all``: A special identifier
that represents any user who is on the internet, even if
they do not have a Google Account or are not logged in.
that represents any principal that is on the internet,
even if they do not have a Google Account or are not
logged in.

- ``principal://goog/subject/{email_id}``: A specific
Google Account. Includes Gmail, Cloud Identity, and
Expand Down
Loading