49
49
from google .iam .v1 import iam_policy_pb2 # type: ignore
50
50
from google .iam .v1 import policy_pb2 # type: ignore
51
51
from google .protobuf import duration_pb2 # type: ignore
52
+ from google .protobuf import field_mask_pb2 # type: ignore
52
53
from google .protobuf import timestamp_pb2 # type: ignore
53
54
from google .pubsub_v1 .services .subscriber import pagers
54
55
from google .pubsub_v1 .types import pubsub
@@ -278,7 +279,10 @@ async def sample_create_subscription():
278
279
279
280
Args:
280
281
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.
282
286
name (:class:`str`):
283
287
Required. The name of the subscription. It must have the
284
288
format
@@ -304,11 +308,9 @@ async def sample_create_subscription():
304
308
on the ``request`` instance; if ``request`` is provided, this
305
309
should not be set.
306
310
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.
312
314
313
315
This corresponds to the ``push_config`` field
314
316
on the ``request`` instance; if ``request`` is provided, this
@@ -318,7 +320,7 @@ async def sample_create_subscription():
318
320
Pub/Sub waits for the subscriber to acknowledge receipt
319
321
before resending the message. In the interval after the
320
322
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
322
324
period, the message will not be redelivered (on a
323
325
best-effort basis).
324
326
@@ -350,7 +352,11 @@ async def sample_create_subscription():
350
352
351
353
Returns:
352
354
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
+
354
360
"""
355
361
# Create or coerce a protobuf request object.
356
362
# Quick check: If we got a request object, we should *not* have
@@ -467,7 +473,11 @@ async def sample_get_subscription():
467
473
468
474
Returns:
469
475
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
+
471
481
"""
472
482
# Create or coerce a protobuf request object.
473
483
# Quick check: If we got a request object, we should *not* have
@@ -528,6 +538,8 @@ async def update_subscription(
528
538
self ,
529
539
request : Optional [Union [pubsub .UpdateSubscriptionRequest , dict ]] = None ,
530
540
* ,
541
+ subscription : Optional [pubsub .Subscription ] = None ,
542
+ update_mask : Optional [field_mask_pb2 .FieldMask ] = None ,
531
543
retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
532
544
timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
533
545
metadata : Sequence [Tuple [str , str ]] = (),
@@ -570,6 +582,21 @@ async def sample_update_subscription():
570
582
request (Optional[Union[google.pubsub_v1.types.UpdateSubscriptionRequest, dict]]):
571
583
The request object. Request for the UpdateSubscription
572
584
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.
573
600
retry (google.api_core.retry.Retry): Designation of what errors, if any,
574
601
should be retried.
575
602
timeout (float): The timeout for this request.
@@ -578,11 +605,31 @@ async def sample_update_subscription():
578
605
579
606
Returns:
580
607
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
+
582
613
"""
583
614
# 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
+
584
624
request = pubsub .UpdateSubscriptionRequest (request )
585
625
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
+
586
633
# Wrap the RPC method; this adds retry and timeout information,
587
634
# and friendly error handling.
588
635
rpc = gapic_v1 .method_async .wrap_method (
@@ -1116,9 +1163,7 @@ async def pull(
1116
1163
timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
1117
1164
metadata : Sequence [Tuple [str , str ]] = (),
1118
1165
) -> 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.
1122
1167
1123
1168
.. code-block:: python
1124
1169
@@ -1229,6 +1274,7 @@ async def sample_pull():
1229
1274
multiplier = 1.3 ,
1230
1275
predicate = retries .if_exception_type (
1231
1276
core_exceptions .Aborted ,
1277
+ core_exceptions .InternalServerError ,
1232
1278
core_exceptions .ServiceUnavailable ,
1233
1279
core_exceptions .Unknown ,
1234
1280
),
@@ -1495,13 +1541,12 @@ async def get_snapshot(
1495
1541
timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
1496
1542
metadata : Sequence [Tuple [str , str ]] = (),
1497
1543
) -> 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.
1505
1550
1506
1551
.. code-block:: python
1507
1552
@@ -1803,9 +1848,10 @@ async def sample_create_snapshot():
1803
1848
name is not provided in the request, the server will
1804
1849
assign a random name for this snapshot on the same
1805
1850
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}``.
1809
1855
1810
1856
This corresponds to the ``name`` field
1811
1857
on the ``request`` instance; if ``request`` is provided, this
@@ -1898,18 +1944,17 @@ async def update_snapshot(
1898
1944
self ,
1899
1945
request : Optional [Union [pubsub .UpdateSnapshotRequest , dict ]] = None ,
1900
1946
* ,
1947
+ snapshot : Optional [pubsub .Snapshot ] = None ,
1948
+ update_mask : Optional [field_mask_pb2 .FieldMask ] = None ,
1901
1949
retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
1902
1950
timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
1903
1951
metadata : Sequence [Tuple [str , str ]] = (),
1904
1952
) -> pubsub .Snapshot :
1905
1953
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.
1913
1958
1914
1959
.. code-block:: python
1915
1960
@@ -1940,6 +1985,21 @@ async def sample_update_snapshot():
1940
1985
request (Optional[Union[google.pubsub_v1.types.UpdateSnapshotRequest, dict]]):
1941
1986
The request object. Request for the UpdateSnapshot
1942
1987
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.
1943
2003
retry (google.api_core.retry.Retry): Designation of what errors, if any,
1944
2004
should be retried.
1945
2005
timeout (float): The timeout for this request.
@@ -1957,8 +2017,24 @@ async def sample_update_snapshot():
1957
2017
1958
2018
"""
1959
2019
# 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
+
1960
2029
request = pubsub .UpdateSnapshotRequest (request )
1961
2030
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
+
1962
2038
# Wrap the RPC method; this adds retry and timeout information,
1963
2039
# and friendly error handling.
1964
2040
rpc = gapic_v1 .method_async .wrap_method (
0 commit comments