Skip to content

Commit 3dd43d6

Browse files
authored
Fix: Port proto changes (#871)
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
1 parent fbc7f9e commit 3dd43d6

File tree

12 files changed

+694
-127
lines changed

12 files changed

+694
-127
lines changed

google/pubsub_v1/services/publisher/async_client.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
from google.iam.v1 import iam_policy_pb2 # type: ignore
4747
from google.iam.v1 import policy_pb2 # type: ignore
4848
from google.protobuf import duration_pb2 # type: ignore
49+
from google.protobuf import field_mask_pb2 # type: ignore
4950
from google.pubsub_v1.services.publisher import pagers
5051
from google.pubsub_v1.types import pubsub
5152
from google.pubsub_v1.types import TimeoutType
@@ -339,6 +340,8 @@ async def update_topic(
339340
self,
340341
request: Optional[Union[pubsub.UpdateTopicRequest, dict]] = None,
341342
*,
343+
topic: Optional[pubsub.Topic] = None,
344+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
342345
retry: OptionalRetry = gapic_v1.method.DEFAULT,
343346
timeout: TimeoutType = gapic_v1.method.DEFAULT,
344347
metadata: Sequence[Tuple[str, str]] = (),
@@ -378,6 +381,23 @@ async def sample_update_topic():
378381
Args:
379382
request (Optional[Union[google.pubsub_v1.types.UpdateTopicRequest, dict]]):
380383
The request object. Request for the UpdateTopic method.
384+
topic (:class:`google.pubsub_v1.types.Topic`):
385+
Required. The updated topic object.
386+
This corresponds to the ``topic`` field
387+
on the ``request`` instance; if ``request`` is provided, this
388+
should not be set.
389+
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
390+
Required. Indicates which fields in the provided topic
391+
to update. Must be specified and non-empty. Note that if
392+
``update_mask`` contains "message_storage_policy" but
393+
the ``message_storage_policy`` is not set in the
394+
``topic`` provided above, then the updated value is
395+
determined by the policy configured at the project or
396+
organization level.
397+
398+
This corresponds to the ``update_mask`` field
399+
on the ``request`` instance; if ``request`` is provided, this
400+
should not be set.
381401
retry (google.api_core.retry.Retry): Designation of what errors, if any,
382402
should be retried.
383403
timeout (TimeoutType):
@@ -390,8 +410,24 @@ async def sample_update_topic():
390410
A topic resource.
391411
"""
392412
# Create or coerce a protobuf request object.
413+
# Quick check: If we got a request object, we should *not* have
414+
# gotten any keyword arguments that map to the request.
415+
has_flattened_params = any([topic, update_mask])
416+
if request is not None and has_flattened_params:
417+
raise ValueError(
418+
"If the `request` argument is set, then none of "
419+
"the individual field arguments should be set."
420+
)
421+
393422
request = pubsub.UpdateTopicRequest(request)
394423

424+
# If we have keyword arguments corresponding to fields on the
425+
# request, apply these.
426+
if topic is not None:
427+
request.topic = topic
428+
if update_mask is not None:
429+
request.update_mask = update_mask
430+
395431
# Wrap the RPC method; this adds retry and timeout information,
396432
# and friendly error handling.
397433
rpc = gapic_v1.method_async.wrap_method(

google/pubsub_v1/services/publisher/client.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
from google.iam.v1 import iam_policy_pb2 # type: ignore
5252
from google.iam.v1 import policy_pb2 # type: ignore
5353
from google.protobuf import duration_pb2 # type: ignore
54+
from google.protobuf import field_mask_pb2 # type: ignore
5455
from google.pubsub_v1.services.publisher import pagers
5556
from google.pubsub_v1.types import pubsub
5657
from google.pubsub_v1.types import TimeoutType
@@ -610,6 +611,8 @@ def update_topic(
610611
self,
611612
request: Optional[Union[pubsub.UpdateTopicRequest, dict]] = None,
612613
*,
614+
topic: Optional[pubsub.Topic] = None,
615+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
613616
retry: OptionalRetry = gapic_v1.method.DEFAULT,
614617
timeout: TimeoutType = gapic_v1.method.DEFAULT,
615618
metadata: Sequence[Tuple[str, str]] = (),
@@ -649,6 +652,23 @@ def sample_update_topic():
649652
Args:
650653
request (Union[google.pubsub_v1.types.UpdateTopicRequest, dict]):
651654
The request object. Request for the UpdateTopic method.
655+
topic (google.pubsub_v1.types.Topic):
656+
Required. The updated topic object.
657+
This corresponds to the ``topic`` field
658+
on the ``request`` instance; if ``request`` is provided, this
659+
should not be set.
660+
update_mask (google.protobuf.field_mask_pb2.FieldMask):
661+
Required. Indicates which fields in the provided topic
662+
to update. Must be specified and non-empty. Note that if
663+
``update_mask`` contains "message_storage_policy" but
664+
the ``message_storage_policy`` is not set in the
665+
``topic`` provided above, then the updated value is
666+
determined by the policy configured at the project or
667+
organization level.
668+
669+
This corresponds to the ``update_mask`` field
670+
on the ``request`` instance; if ``request`` is provided, this
671+
should not be set.
652672
retry (google.api_core.retry.Retry): Designation of what errors, if any,
653673
should be retried.
654674
timeout (TimeoutType):
@@ -661,12 +681,27 @@ def sample_update_topic():
661681
A topic resource.
662682
"""
663683
# Create or coerce a protobuf request object.
684+
# Quick check: If we got a request object, we should *not* have
685+
# gotten any keyword arguments that map to the request.
686+
has_flattened_params = any([topic, update_mask])
687+
if request is not None and has_flattened_params:
688+
raise ValueError(
689+
"If the `request` argument is set, then none of "
690+
"the individual field arguments should be set."
691+
)
692+
664693
# Minor optimization to avoid making a copy if the user passes
665694
# in a pubsub.UpdateTopicRequest.
666695
# There's no risk of modifying the input as we've already verified
667696
# there are no flattened fields.
668697
if not isinstance(request, pubsub.UpdateTopicRequest):
669698
request = pubsub.UpdateTopicRequest(request)
699+
# If we have keyword arguments corresponding to fields on the
700+
# request, apply these.
701+
if topic is not None:
702+
request.topic = topic
703+
if update_mask is not None:
704+
request.update_mask = update_mask
670705

671706
# Wrap the RPC method; this adds retry and timeout information,
672707
# and friendly error handling.

google/pubsub_v1/services/subscriber/async_client.py

Lines changed: 106 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
from google.iam.v1 import iam_policy_pb2 # type: ignore
5050
from google.iam.v1 import policy_pb2 # type: ignore
5151
from google.protobuf import duration_pb2 # type: ignore
52+
from google.protobuf import field_mask_pb2 # type: ignore
5253
from google.protobuf import timestamp_pb2 # type: ignore
5354
from google.pubsub_v1.services.subscriber import pagers
5455
from google.pubsub_v1.types import pubsub
@@ -278,7 +279,10 @@ async def sample_create_subscription():
278279
279280
Args:
280281
request (Optional[Union[google.pubsub_v1.types.Subscription, dict]]):
281-
The request object. A subscription resource.
282+
The request object. A subscription resource. If none of
283+
`push_config` or `bigquery_config` is set, then the
284+
subscriber will pull and ack messages using API methods.
285+
At most one of these fields may be set.
282286
name (:class:`str`):
283287
Required. The name of the subscription. It must have the
284288
format
@@ -304,11 +308,9 @@ async def sample_create_subscription():
304308
on the ``request`` instance; if ``request`` is provided, this
305309
should not be set.
306310
push_config (:class:`google.pubsub_v1.types.PushConfig`):
307-
If push delivery is used with this subscription, this
308-
field is used to configure it. Either ``pushConfig`` or
309-
``bigQueryConfig`` can be set, but not both. If both are
310-
empty, then the subscriber will pull and ack messages
311-
using API methods.
311+
If push delivery is used with this
312+
subscription, this field is used to
313+
configure it.
312314
313315
This corresponds to the ``push_config`` field
314316
on the ``request`` instance; if ``request`` is provided, this
@@ -318,7 +320,7 @@ async def sample_create_subscription():
318320
Pub/Sub waits for the subscriber to acknowledge receipt
319321
before resending the message. In the interval after the
320322
message is delivered and before it is acknowledged, it
321-
is considered to be outstanding. During that time
323+
is considered to be *outstanding*. During that time
322324
period, the message will not be redelivered (on a
323325
best-effort basis).
324326
@@ -350,7 +352,11 @@ async def sample_create_subscription():
350352
351353
Returns:
352354
google.pubsub_v1.types.Subscription:
353-
A subscription resource.
355+
A subscription resource. If none of push_config or bigquery_config is
356+
set, then the subscriber will pull and ack messages
357+
using API methods. At most one of these fields may be
358+
set.
359+
354360
"""
355361
# Create or coerce a protobuf request object.
356362
# Quick check: If we got a request object, we should *not* have
@@ -467,7 +473,11 @@ async def sample_get_subscription():
467473
468474
Returns:
469475
google.pubsub_v1.types.Subscription:
470-
A subscription resource.
476+
A subscription resource. If none of push_config or bigquery_config is
477+
set, then the subscriber will pull and ack messages
478+
using API methods. At most one of these fields may be
479+
set.
480+
471481
"""
472482
# Create or coerce a protobuf request object.
473483
# Quick check: If we got a request object, we should *not* have
@@ -528,6 +538,8 @@ async def update_subscription(
528538
self,
529539
request: Optional[Union[pubsub.UpdateSubscriptionRequest, dict]] = None,
530540
*,
541+
subscription: Optional[pubsub.Subscription] = None,
542+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
531543
retry: OptionalRetry = gapic_v1.method.DEFAULT,
532544
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
533545
metadata: Sequence[Tuple[str, str]] = (),
@@ -570,6 +582,21 @@ async def sample_update_subscription():
570582
request (Optional[Union[google.pubsub_v1.types.UpdateSubscriptionRequest, dict]]):
571583
The request object. Request for the UpdateSubscription
572584
method.
585+
subscription (:class:`google.pubsub_v1.types.Subscription`):
586+
Required. The updated subscription
587+
object.
588+
589+
This corresponds to the ``subscription`` field
590+
on the ``request`` instance; if ``request`` is provided, this
591+
should not be set.
592+
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
593+
Required. Indicates which fields in
594+
the provided subscription to update.
595+
Must be specified and non-empty.
596+
597+
This corresponds to the ``update_mask`` field
598+
on the ``request`` instance; if ``request`` is provided, this
599+
should not be set.
573600
retry (google.api_core.retry.Retry): Designation of what errors, if any,
574601
should be retried.
575602
timeout (float): The timeout for this request.
@@ -578,11 +605,31 @@ async def sample_update_subscription():
578605
579606
Returns:
580607
google.pubsub_v1.types.Subscription:
581-
A subscription resource.
608+
A subscription resource. If none of push_config or bigquery_config is
609+
set, then the subscriber will pull and ack messages
610+
using API methods. At most one of these fields may be
611+
set.
612+
582613
"""
583614
# Create or coerce a protobuf request object.
615+
# Quick check: If we got a request object, we should *not* have
616+
# gotten any keyword arguments that map to the request.
617+
has_flattened_params = any([subscription, update_mask])
618+
if request is not None and has_flattened_params:
619+
raise ValueError(
620+
"If the `request` argument is set, then none of "
621+
"the individual field arguments should be set."
622+
)
623+
584624
request = pubsub.UpdateSubscriptionRequest(request)
585625

626+
# If we have keyword arguments corresponding to fields on the
627+
# request, apply these.
628+
if subscription is not None:
629+
request.subscription = subscription
630+
if update_mask is not None:
631+
request.update_mask = update_mask
632+
586633
# Wrap the RPC method; this adds retry and timeout information,
587634
# and friendly error handling.
588635
rpc = gapic_v1.method_async.wrap_method(
@@ -1116,9 +1163,7 @@ async def pull(
11161163
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
11171164
metadata: Sequence[Tuple[str, str]] = (),
11181165
) -> pubsub.PullResponse:
1119-
r"""Pulls messages from the server. The server may return
1120-
``UNAVAILABLE`` if there are too many concurrent pull requests
1121-
pending for the given subscription.
1166+
r"""Pulls messages from the server.
11221167
11231168
.. code-block:: python
11241169
@@ -1229,6 +1274,7 @@ async def sample_pull():
12291274
multiplier=1.3,
12301275
predicate=retries.if_exception_type(
12311276
core_exceptions.Aborted,
1277+
core_exceptions.InternalServerError,
12321278
core_exceptions.ServiceUnavailable,
12331279
core_exceptions.Unknown,
12341280
),
@@ -1495,13 +1541,12 @@ async def get_snapshot(
14951541
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
14961542
metadata: Sequence[Tuple[str, str]] = (),
14971543
) -> pubsub.Snapshot:
1498-
r"""Gets the configuration details of a snapshot.
1499-
Snapshots are used in <a
1500-
href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
1501-
operations, which allow you to manage message
1502-
acknowledgments in bulk. That is, you can set the
1503-
acknowledgment state of messages in an existing
1504-
subscription to the state captured by a snapshot.
1544+
r"""Gets the configuration details of a snapshot. Snapshots are used
1545+
in
1546+
`Seek <https://cloud.google.com/pubsub/docs/replay-overview>`__
1547+
operations, which allow you to manage message acknowledgments in
1548+
bulk. That is, you can set the acknowledgment state of messages
1549+
in an existing subscription to the state captured by a snapshot.
15051550
15061551
.. code-block:: python
15071552
@@ -1803,9 +1848,10 @@ async def sample_create_snapshot():
18031848
name is not provided in the request, the server will
18041849
assign a random name for this snapshot on the same
18051850
project as the subscription. Note that for REST API
1806-
requests, you must specify a name. See the resource name
1807-
rules. Format is
1808-
``projects/{project}/snapshots/{snap}``.
1851+
requests, you must specify a name. See the `resource
1852+
name
1853+
rules <https://cloud.google.com/pubsub/docs/admin#resource_names>`__.
1854+
Format is ``projects/{project}/snapshots/{snap}``.
18091855
18101856
This corresponds to the ``name`` field
18111857
on the ``request`` instance; if ``request`` is provided, this
@@ -1898,18 +1944,17 @@ async def update_snapshot(
18981944
self,
18991945
request: Optional[Union[pubsub.UpdateSnapshotRequest, dict]] = None,
19001946
*,
1947+
snapshot: Optional[pubsub.Snapshot] = None,
1948+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
19011949
retry: OptionalRetry = gapic_v1.method.DEFAULT,
19021950
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
19031951
metadata: Sequence[Tuple[str, str]] = (),
19041952
) -> pubsub.Snapshot:
19051953
r"""Updates an existing snapshot. Snapshots are used in
1906-
<a
1907-
href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
1908-
operations, which allow
1909-
you to manage message acknowledgments in bulk. That is,
1910-
you can set the acknowledgment state of messages in an
1911-
existing subscription to the state captured by a
1912-
snapshot.
1954+
`Seek <https://cloud.google.com/pubsub/docs/replay-overview>`__
1955+
operations, which allow you to manage message acknowledgments in
1956+
bulk. That is, you can set the acknowledgment state of messages
1957+
in an existing subscription to the state captured by a snapshot.
19131958
19141959
.. code-block:: python
19151960
@@ -1940,6 +1985,21 @@ async def sample_update_snapshot():
19401985
request (Optional[Union[google.pubsub_v1.types.UpdateSnapshotRequest, dict]]):
19411986
The request object. Request for the UpdateSnapshot
19421987
method.
1988+
snapshot (:class:`google.pubsub_v1.types.Snapshot`):
1989+
Required. The updated snapshot
1990+
object.
1991+
1992+
This corresponds to the ``snapshot`` field
1993+
on the ``request`` instance; if ``request`` is provided, this
1994+
should not be set.
1995+
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
1996+
Required. Indicates which fields in
1997+
the provided snapshot to update. Must be
1998+
specified and non-empty.
1999+
2000+
This corresponds to the ``update_mask`` field
2001+
on the ``request`` instance; if ``request`` is provided, this
2002+
should not be set.
19432003
retry (google.api_core.retry.Retry): Designation of what errors, if any,
19442004
should be retried.
19452005
timeout (float): The timeout for this request.
@@ -1957,8 +2017,24 @@ async def sample_update_snapshot():
19572017
19582018
"""
19592019
# Create or coerce a protobuf request object.
2020+
# Quick check: If we got a request object, we should *not* have
2021+
# gotten any keyword arguments that map to the request.
2022+
has_flattened_params = any([snapshot, update_mask])
2023+
if request is not None and has_flattened_params:
2024+
raise ValueError(
2025+
"If the `request` argument is set, then none of "
2026+
"the individual field arguments should be set."
2027+
)
2028+
19602029
request = pubsub.UpdateSnapshotRequest(request)
19612030

2031+
# If we have keyword arguments corresponding to fields on the
2032+
# request, apply these.
2033+
if snapshot is not None:
2034+
request.snapshot = snapshot
2035+
if update_mask is not None:
2036+
request.update_mask = update_mask
2037+
19622038
# Wrap the RPC method; this adds retry and timeout information,
19632039
# and friendly error handling.
19642040
rpc = gapic_v1.method_async.wrap_method(

0 commit comments

Comments
 (0)