4949from google .iam .v1 import iam_policy_pb2 # type: ignore
5050from google .iam .v1 import policy_pb2 # type: ignore
5151from google .protobuf import duration_pb2 # type: ignore
52+ from google .protobuf import field_mask_pb2 # type: ignore
5253from google .protobuf import timestamp_pb2 # type: ignore
5354from google .pubsub_v1 .services .subscriber import pagers
5455from 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