Skip to content

Commit

Permalink
fix(diregapic): s/bazel/bazelisk/ in DIREGAPIC build GitHub action (#…
Browse files Browse the repository at this point in the history
…1064)

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: mukund-ananthu <83691193+mukund-ananthu@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
4 people committed Feb 9, 2024
1 parent aa40c4b commit d56ad12
Show file tree
Hide file tree
Showing 31 changed files with 3,112 additions and 608 deletions.
2 changes: 1 addition & 1 deletion google/cloud/pubsub_v1/publisher/client.py
Expand Up @@ -399,7 +399,7 @@ def on_publish_done(future):
transport = self._transport
base_retry = transport._wrapped_methods[transport.publish]._retry
retry = base_retry.with_deadline(2.0**32)
else:
elif retry is not None:
retry = retry.with_deadline(2.0**32)

# Delegate the publishing to the sequencer.
Expand Down
2 changes: 2 additions & 0 deletions google/pubsub/__init__.py
Expand Up @@ -41,6 +41,7 @@
from google.pubsub_v1.types.pubsub import GetSnapshotRequest
from google.pubsub_v1.types.pubsub import GetSubscriptionRequest
from google.pubsub_v1.types.pubsub import GetTopicRequest
from google.pubsub_v1.types.pubsub import IngestionDataSourceSettings
from google.pubsub_v1.types.pubsub import ListSnapshotsRequest
from google.pubsub_v1.types.pubsub import ListSnapshotsResponse
from google.pubsub_v1.types.pubsub import ListSubscriptionsRequest
Expand Down Expand Up @@ -112,6 +113,7 @@
"GetSnapshotRequest",
"GetSubscriptionRequest",
"GetTopicRequest",
"IngestionDataSourceSettings",
"ListSnapshotsRequest",
"ListSnapshotsResponse",
"ListSubscriptionsRequest",
Expand Down
2 changes: 2 additions & 0 deletions google/pubsub_v1/__init__.py
Expand Up @@ -39,6 +39,7 @@
from .types.pubsub import GetSnapshotRequest
from .types.pubsub import GetSubscriptionRequest
from .types.pubsub import GetTopicRequest
from .types.pubsub import IngestionDataSourceSettings
from .types.pubsub import ListSnapshotsRequest
from .types.pubsub import ListSnapshotsResponse
from .types.pubsub import ListSubscriptionsRequest
Expand Down Expand Up @@ -113,6 +114,7 @@
"GetSnapshotRequest",
"GetSubscriptionRequest",
"GetTopicRequest",
"IngestionDataSourceSettings",
"ListSchemaRevisionsRequest",
"ListSchemaRevisionsResponse",
"ListSchemasRequest",
Expand Down
107 changes: 91 additions & 16 deletions google/pubsub_v1/services/publisher/async_client.py
Expand Up @@ -38,9 +38,9 @@
from google.oauth2 import service_account # type: ignore

try:
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault]
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None]
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.AsyncRetry, object] # type: ignore
OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore

from google.iam.v1 import iam_policy_pb2 # type: ignore
from google.iam.v1 import policy_pb2 # type: ignore
Expand All @@ -61,8 +61,12 @@ class PublisherAsyncClient:

_client: PublisherClient

# Copy defaults from the synchronous client for use here.
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
DEFAULT_ENDPOINT = PublisherClient.DEFAULT_ENDPOINT
DEFAULT_MTLS_ENDPOINT = PublisherClient.DEFAULT_MTLS_ENDPOINT
_DEFAULT_ENDPOINT_TEMPLATE = PublisherClient._DEFAULT_ENDPOINT_TEMPLATE
_DEFAULT_UNIVERSE = PublisherClient._DEFAULT_UNIVERSE

schema_path = staticmethod(PublisherClient.schema_path)
parse_schema_path = staticmethod(PublisherClient.parse_schema_path)
Expand Down Expand Up @@ -167,6 +171,25 @@ def transport(self) -> PublisherTransport:
"""
return self._client.transport

@property
def api_endpoint(self):
"""Return the API endpoint used by the client instance.
Returns:
str: The API endpoint used by the client instance.
"""
return self._client._api_endpoint

@property
def universe_domain(self) -> str:
"""Return the universe domain used by the client instance.
Returns:
str: The universe domain used
by the client instance.
"""
return self._client._universe_domain

get_transport_class = functools.partial(
type(PublisherClient).get_transport_class, type(PublisherClient)
)
Expand All @@ -179,7 +202,7 @@ def __init__(
client_options: Optional[ClientOptions] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
"""Instantiates the publisher client.
"""Instantiates the publisher async client.
Args:
credentials (Optional[google.auth.credentials.Credentials]): The
Expand All @@ -190,23 +213,38 @@ def __init__(
transport (Union[str, ~.PublisherTransport]): The
transport to use. If set to None, a transport is chosen
automatically.
client_options (ClientOptions): Custom options for the client. It
won't take effect if a ``transport`` instance is provided.
(1) The ``api_endpoint`` property can be used to override the
default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
environment variable can also be used to override the endpoint:
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
Custom options for the client.
1. The ``api_endpoint`` property can be used to override the
default endpoint provided by the client when ``transport`` is
not explicitly provided. Only if this property is not set and
``transport`` was not explicitly provided, the endpoint is
determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
variable, which have one of the following values:
"always" (always use the default mTLS endpoint), "never" (always
use the default regular endpoint) and "auto" (auto switch to the
default mTLS endpoint if client certificate is present, this is
the default value). However, the ``api_endpoint`` property takes
precedence if provided.
(2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
use the default regular endpoint) and "auto" (auto-switch to the
default mTLS endpoint if client certificate is present; this is
the default value).
2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
is "true", then the ``client_cert_source`` property can be used
to provide client certificate for mutual TLS transport. If
to provide a client certificate for mTLS transport. If
not provided, the default SSL client certificate will be used if
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
set, no client certificate will be used.
3. The ``universe_domain`` property can be used to override the
default "googleapis.com" universe. Note that ``api_endpoint``
property still takes precedence; and ``universe_domain`` is
currently not supported for mTLS.
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
The client info used to send a user-agent string along with
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
creation failed for any reason.
Expand Down Expand Up @@ -324,6 +362,9 @@ async def sample_create_topic():
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)

# Validate the universe domain.
self._client._validate_universe_domain()

# Send the request.
response = await rpc(
request,
Expand All @@ -345,7 +386,8 @@ async def update_topic(
timeout: TimeoutType = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pubsub.Topic:
r"""Updates an existing topic. Note that certain
r"""Updates an existing topic by updating the fields
specified in the update mask. Note that certain
properties of a topic are not modifiable.
.. code-block:: python
Expand Down Expand Up @@ -452,6 +494,9 @@ async def sample_update_topic():
),
)

# Validate the universe domain.
self._client._validate_universe_domain()

# Send the request.
response = await rpc(
request,
Expand Down Expand Up @@ -555,7 +600,7 @@ async def sample_publish():
default_retry=retries.AsyncRetry(
initial=0.1,
maximum=60.0,
multiplier=4.0,
multiplier=4,
predicate=retries.if_exception_type(
core_exceptions.Aborted,
core_exceptions.Cancelled,
Expand All @@ -577,6 +622,9 @@ async def sample_publish():
gapic_v1.routing_header.to_grpc_metadata((("topic", request.topic),)),
)

# Validate the universe domain.
self._client._validate_universe_domain()

# Send the request.
response = await rpc(
request,
Expand Down Expand Up @@ -688,6 +736,9 @@ async def sample_get_topic():
gapic_v1.routing_header.to_grpc_metadata((("topic", request.topic),)),
)

# Validate the universe domain.
self._client._validate_universe_domain()

# Send the request.
response = await rpc(
request,
Expand Down Expand Up @@ -804,6 +855,9 @@ async def sample_list_topics():
gapic_v1.routing_header.to_grpc_metadata((("project", request.project),)),
)

# Validate the universe domain.
self._client._validate_universe_domain()

# Send the request.
response = await rpc(
request,
Expand Down Expand Up @@ -931,6 +985,9 @@ async def sample_list_topic_subscriptions():
gapic_v1.routing_header.to_grpc_metadata((("topic", request.topic),)),
)

# Validate the universe domain.
self._client._validate_universe_domain()

# Send the request.
response = await rpc(
request,
Expand Down Expand Up @@ -1062,6 +1119,9 @@ async def sample_list_topic_snapshots():
gapic_v1.routing_header.to_grpc_metadata((("topic", request.topic),)),
)

# Validate the universe domain.
self._client._validate_universe_domain()

# Send the request.
response = await rpc(
request,
Expand Down Expand Up @@ -1178,6 +1238,9 @@ async def sample_delete_topic():
gapic_v1.routing_header.to_grpc_metadata((("topic", request.topic),)),
)

# Validate the universe domain.
self._client._validate_universe_domain()

# Send the request.
await rpc(
request,
Expand Down Expand Up @@ -1271,6 +1334,9 @@ async def sample_detach_subscription():
),
)

# Validate the universe domain.
self._client._validate_universe_domain()

# Send the request.
response = await rpc(
request,
Expand Down Expand Up @@ -1391,6 +1457,9 @@ async def set_iam_policy(
gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
)

# Validate the universe domain.
self._client._validate_universe_domain()

# Send the request.
response = await rpc(
request,
Expand Down Expand Up @@ -1513,6 +1582,9 @@ async def get_iam_policy(
gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
)

# Validate the universe domain.
self._client._validate_universe_domain()

# Send the request.
response = await rpc(
request,
Expand Down Expand Up @@ -1573,6 +1645,9 @@ async def test_iam_permissions(
gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
)

# Validate the universe domain.
self._client._validate_universe_domain()

# Send the request.
response = await rpc(
request,
Expand Down

0 comments on commit d56ad12

Please sign in to comment.