Skip to content

Commit

Permalink
Fix: Port proto changes (#871)
Browse files Browse the repository at this point in the history
feat: Add temporary_failed_ack_ids to ModifyAckDeadlineConfirmation
fix: Add service_yaml_parameters to py_gapic_library BUILD.bazel targets
docs: Clarify BigQueryConfig PERMISSION_DENIED state
docs: Clarify subscription description
docs: Replacing HTML code with Markdown
docs: Fix PullResponse description
docs: Fix Pull description
feat: Add google.api.method.signature to update methods
docs: Update Pub/Sub topic retention limit from 7 days to 31 days
  • Loading branch information
acocuzzo committed Feb 22, 2023
1 parent fbc7f9e commit 3dd43d6
Show file tree
Hide file tree
Showing 12 changed files with 694 additions and 127 deletions.
36 changes: 36 additions & 0 deletions google/pubsub_v1/services/publisher/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
from google.iam.v1 import iam_policy_pb2 # type: ignore
from google.iam.v1 import policy_pb2 # type: ignore
from google.protobuf import duration_pb2 # type: ignore
from google.protobuf import field_mask_pb2 # type: ignore
from google.pubsub_v1.services.publisher import pagers
from google.pubsub_v1.types import pubsub
from google.pubsub_v1.types import TimeoutType
Expand Down Expand Up @@ -339,6 +340,8 @@ async def update_topic(
self,
request: Optional[Union[pubsub.UpdateTopicRequest, dict]] = None,
*,
topic: Optional[pubsub.Topic] = None,
update_mask: Optional[field_mask_pb2.FieldMask] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: TimeoutType = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
Expand Down Expand Up @@ -378,6 +381,23 @@ async def sample_update_topic():
Args:
request (Optional[Union[google.pubsub_v1.types.UpdateTopicRequest, dict]]):
The request object. Request for the UpdateTopic method.
topic (:class:`google.pubsub_v1.types.Topic`):
Required. The updated topic object.
This corresponds to the ``topic`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
Required. Indicates which fields in the provided topic
to update. Must be specified and non-empty. Note that if
``update_mask`` contains "message_storage_policy" but
the ``message_storage_policy`` is not set in the
``topic`` provided above, then the updated value is
determined by the policy configured at the project or
organization level.
This corresponds to the ``update_mask`` 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 (TimeoutType):
Expand All @@ -390,8 +410,24 @@ async def sample_update_topic():
A topic resource.
"""
# 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([topic, update_mask])
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."
)

request = pubsub.UpdateTopicRequest(request)

# If we have keyword arguments corresponding to fields on the
# request, apply these.
if topic is not None:
request.topic = topic
if update_mask is not None:
request.update_mask = update_mask

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
Expand Down
35 changes: 35 additions & 0 deletions google/pubsub_v1/services/publisher/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from google.iam.v1 import iam_policy_pb2 # type: ignore
from google.iam.v1 import policy_pb2 # type: ignore
from google.protobuf import duration_pb2 # type: ignore
from google.protobuf import field_mask_pb2 # type: ignore
from google.pubsub_v1.services.publisher import pagers
from google.pubsub_v1.types import pubsub
from google.pubsub_v1.types import TimeoutType
Expand Down Expand Up @@ -610,6 +611,8 @@ def update_topic(
self,
request: Optional[Union[pubsub.UpdateTopicRequest, dict]] = None,
*,
topic: Optional[pubsub.Topic] = None,
update_mask: Optional[field_mask_pb2.FieldMask] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: TimeoutType = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
Expand Down Expand Up @@ -649,6 +652,23 @@ def sample_update_topic():
Args:
request (Union[google.pubsub_v1.types.UpdateTopicRequest, dict]):
The request object. Request for the UpdateTopic method.
topic (google.pubsub_v1.types.Topic):
Required. The updated topic object.
This corresponds to the ``topic`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
update_mask (google.protobuf.field_mask_pb2.FieldMask):
Required. Indicates which fields in the provided topic
to update. Must be specified and non-empty. Note that if
``update_mask`` contains "message_storage_policy" but
the ``message_storage_policy`` is not set in the
``topic`` provided above, then the updated value is
determined by the policy configured at the project or
organization level.
This corresponds to the ``update_mask`` 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 (TimeoutType):
Expand All @@ -661,12 +681,27 @@ def sample_update_topic():
A topic resource.
"""
# 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([topic, update_mask])
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 pubsub.UpdateTopicRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
if not isinstance(request, pubsub.UpdateTopicRequest):
request = pubsub.UpdateTopicRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if topic is not None:
request.topic = topic
if update_mask is not None:
request.update_mask = update_mask

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
Expand Down
136 changes: 106 additions & 30 deletions google/pubsub_v1/services/subscriber/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
from google.iam.v1 import iam_policy_pb2 # type: ignore
from google.iam.v1 import policy_pb2 # type: ignore
from google.protobuf import duration_pb2 # type: ignore
from google.protobuf import field_mask_pb2 # type: ignore
from google.protobuf import timestamp_pb2 # type: ignore
from google.pubsub_v1.services.subscriber import pagers
from google.pubsub_v1.types import pubsub
Expand Down Expand Up @@ -278,7 +279,10 @@ async def sample_create_subscription():
Args:
request (Optional[Union[google.pubsub_v1.types.Subscription, dict]]):
The request object. A subscription resource.
The request object. A subscription resource. If none of
`push_config` or `bigquery_config` is set, then the
subscriber will pull and ack messages using API methods.
At most one of these fields may be set.
name (:class:`str`):
Required. The name of the subscription. It must have the
format
Expand All @@ -304,11 +308,9 @@ async def sample_create_subscription():
on the ``request`` instance; if ``request`` is provided, this
should not be set.
push_config (:class:`google.pubsub_v1.types.PushConfig`):
If push delivery is used with this subscription, this
field is used to configure it. Either ``pushConfig`` or
``bigQueryConfig`` can be set, but not both. If both are
empty, then the subscriber will pull and ack messages
using API methods.
If push delivery is used with this
subscription, this field is used to
configure it.
This corresponds to the ``push_config`` field
on the ``request`` instance; if ``request`` is provided, this
Expand All @@ -318,7 +320,7 @@ async def sample_create_subscription():
Pub/Sub waits for the subscriber to acknowledge receipt
before resending the message. In the interval after the
message is delivered and before it is acknowledged, it
is considered to be outstanding. During that time
is considered to be *outstanding*. During that time
period, the message will not be redelivered (on a
best-effort basis).
Expand Down Expand Up @@ -350,7 +352,11 @@ async def sample_create_subscription():
Returns:
google.pubsub_v1.types.Subscription:
A subscription resource.
A subscription resource. If none of push_config or bigquery_config is
set, then the subscriber will pull and ack messages
using API methods. At most one of these fields may be
set.
"""
# Create or coerce a protobuf request object.
# Quick check: If we got a request object, we should *not* have
Expand Down Expand Up @@ -467,7 +473,11 @@ async def sample_get_subscription():
Returns:
google.pubsub_v1.types.Subscription:
A subscription resource.
A subscription resource. If none of push_config or bigquery_config is
set, then the subscriber will pull and ack messages
using API methods. At most one of these fields may be
set.
"""
# Create or coerce a protobuf request object.
# Quick check: If we got a request object, we should *not* have
Expand Down Expand Up @@ -528,6 +538,8 @@ async def update_subscription(
self,
request: Optional[Union[pubsub.UpdateSubscriptionRequest, dict]] = None,
*,
subscription: Optional[pubsub.Subscription] = None,
update_mask: Optional[field_mask_pb2.FieldMask] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
Expand Down Expand Up @@ -570,6 +582,21 @@ async def sample_update_subscription():
request (Optional[Union[google.pubsub_v1.types.UpdateSubscriptionRequest, dict]]):
The request object. Request for the UpdateSubscription
method.
subscription (:class:`google.pubsub_v1.types.Subscription`):
Required. The updated subscription
object.
This corresponds to the ``subscription`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
Required. Indicates which fields in
the provided subscription to update.
Must be specified and non-empty.
This corresponds to the ``update_mask`` 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.
Expand All @@ -578,11 +605,31 @@ async def sample_update_subscription():
Returns:
google.pubsub_v1.types.Subscription:
A subscription resource.
A subscription resource. If none of push_config or bigquery_config is
set, then the subscriber will pull and ack messages
using API methods. At most one of these fields may be
set.
"""
# 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([subscription, update_mask])
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."
)

request = pubsub.UpdateSubscriptionRequest(request)

# If we have keyword arguments corresponding to fields on the
# request, apply these.
if subscription is not None:
request.subscription = subscription
if update_mask is not None:
request.update_mask = update_mask

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
Expand Down Expand Up @@ -1116,9 +1163,7 @@ async def pull(
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pubsub.PullResponse:
r"""Pulls messages from the server. The server may return
``UNAVAILABLE`` if there are too many concurrent pull requests
pending for the given subscription.
r"""Pulls messages from the server.
.. code-block:: python
Expand Down Expand Up @@ -1229,6 +1274,7 @@ async def sample_pull():
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.Aborted,
core_exceptions.InternalServerError,
core_exceptions.ServiceUnavailable,
core_exceptions.Unknown,
),
Expand Down Expand Up @@ -1495,13 +1541,12 @@ async def get_snapshot(
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pubsub.Snapshot:
r"""Gets the configuration details of a snapshot.
Snapshots are used in <a
href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
operations, which allow you to manage message
acknowledgments in bulk. That is, you can set the
acknowledgment state of messages in an existing
subscription to the state captured by a snapshot.
r"""Gets the configuration details of a snapshot. Snapshots are used
in
`Seek <https://cloud.google.com/pubsub/docs/replay-overview>`__
operations, which allow you to manage message acknowledgments in
bulk. That is, you can set the acknowledgment state of messages
in an existing subscription to the state captured by a snapshot.
.. code-block:: python
Expand Down Expand Up @@ -1803,9 +1848,10 @@ async def sample_create_snapshot():
name is not provided in the request, the server will
assign a random name for this snapshot on the same
project as the subscription. Note that for REST API
requests, you must specify a name. See the resource name
rules. Format is
``projects/{project}/snapshots/{snap}``.
requests, you must specify a name. See the `resource
name
rules <https://cloud.google.com/pubsub/docs/admin#resource_names>`__.
Format is ``projects/{project}/snapshots/{snap}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
Expand Down Expand Up @@ -1898,18 +1944,17 @@ async def update_snapshot(
self,
request: Optional[Union[pubsub.UpdateSnapshotRequest, dict]] = None,
*,
snapshot: Optional[pubsub.Snapshot] = None,
update_mask: Optional[field_mask_pb2.FieldMask] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pubsub.Snapshot:
r"""Updates an existing snapshot. Snapshots are used in
<a
href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
operations, which allow
you to manage message acknowledgments in bulk. That is,
you can set the acknowledgment state of messages in an
existing subscription to the state captured by a
snapshot.
`Seek <https://cloud.google.com/pubsub/docs/replay-overview>`__
operations, which allow you to manage message acknowledgments in
bulk. That is, you can set the acknowledgment state of messages
in an existing subscription to the state captured by a snapshot.
.. code-block:: python
Expand Down Expand Up @@ -1940,6 +1985,21 @@ async def sample_update_snapshot():
request (Optional[Union[google.pubsub_v1.types.UpdateSnapshotRequest, dict]]):
The request object. Request for the UpdateSnapshot
method.
snapshot (:class:`google.pubsub_v1.types.Snapshot`):
Required. The updated snapshot
object.
This corresponds to the ``snapshot`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
Required. Indicates which fields in
the provided snapshot to update. Must be
specified and non-empty.
This corresponds to the ``update_mask`` 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.
Expand All @@ -1957,8 +2017,24 @@ async def sample_update_snapshot():
"""
# 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([snapshot, update_mask])
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."
)

request = pubsub.UpdateSnapshotRequest(request)

# If we have keyword arguments corresponding to fields on the
# request, apply these.
if snapshot is not None:
request.snapshot = snapshot
if update_mask is not None:
request.update_mask = update_mask

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
Expand Down

0 comments on commit 3dd43d6

Please sign in to comment.