`__.
enable_message_ordering (bool):
If true, messages published with the same ``ordering_key``
in ``PubsubMessage`` will be delivered to the subscribers in
@@ -977,11 +974,7 @@ class PushConfig(proto.Message):
- ``v1`` or ``v1beta2``: uses the push format defined in
the v1 Pub/Sub API.
- For example:
-
- .. raw:: html
-
- attributes { "x-goog-version": "v1" }
+ For example: ``attributes { "x-goog-version": "v1" }``
oidc_token (google.pubsub_v1.types.PushConfig.OidcToken):
If specified, Pub/Sub will generate and attach an OIDC JWT
token as an ``Authorization`` header in the HTTP request for
@@ -1047,7 +1040,7 @@ class BigQueryConfig(proto.Message):
Attributes:
table (str):
The name of the table to which to write data,
- of the form {projectId}:{datasetId}.{tableId}
+ of the form {projectId}.{datasetId}.{tableId}
use_topic_schema (bool):
When true, use the topic's schema as the
columns to write to in BigQuery, if it exists.
@@ -1081,8 +1074,15 @@ class State(proto.Enum):
The subscription can actively send messages
to BigQuery
PERMISSION_DENIED (2):
- Cannot write to the BigQuery table because of
- permission denied errors.
+ Cannot write to the BigQuery table because of permission
+ denied errors. This can happen if
+
+ - Pub/Sub SA has not been granted the `appropriate BigQuery
+ IAM
+ permissions `__
+ - bigquery.googleapis.com API is not enabled for the
+ project
+ (`instructions `__)
NOT_FOUND (3):
Cannot write to the BigQuery table because it
does not exist.
@@ -1347,9 +1347,10 @@ class PullResponse(proto.Message):
Attributes:
received_messages (MutableSequence[google.pubsub_v1.types.ReceivedMessage]):
Received Pub/Sub messages. The list will be empty if there
- are no more messages available in the backlog. For JSON, the
- response can be entirely empty. The Pub/Sub system may
- return fewer than the ``maxMessages`` requested even if
+ are no more messages available in the backlog, or if no
+ messages could be returned before the request timeout. For
+ JSON, the response can be entirely empty. The Pub/Sub system
+ may return fewer than the ``maxMessages`` requested even if
there are more messages available in the backlog.
"""
@@ -1570,6 +1571,9 @@ class AcknowledgeConfirmation(proto.Message):
unordered_ack_ids (MutableSequence[str]):
List of acknowledgement IDs that were out of
order.
+ temporary_failed_ack_ids (MutableSequence[str]):
+ List of acknowledgement IDs that failed
+ processing with temporary issues.
"""
ack_ids: MutableSequence[str] = proto.RepeatedField(
@@ -1584,6 +1588,10 @@ class AcknowledgeConfirmation(proto.Message):
proto.STRING,
number=3,
)
+ temporary_failed_ack_ids: MutableSequence[str] = proto.RepeatedField(
+ proto.STRING,
+ number=4,
+ )
class ModifyAckDeadlineConfirmation(proto.Message):
r"""Acknowledgement IDs sent in one or more previous requests to
@@ -1596,6 +1604,9 @@ class ModifyAckDeadlineConfirmation(proto.Message):
List of acknowledgement IDs that were
malformed or whose acknowledgement deadline has
expired.
+ temporary_failed_ack_ids (MutableSequence[str]):
+ List of acknowledgement IDs that failed
+ processing with temporary issues.
"""
ack_ids: MutableSequence[str] = proto.RepeatedField(
@@ -1606,6 +1617,10 @@ class ModifyAckDeadlineConfirmation(proto.Message):
proto.STRING,
number=2,
)
+ temporary_failed_ack_ids: MutableSequence[str] = proto.RepeatedField(
+ proto.STRING,
+ number=3,
+ )
class SubscriptionProperties(proto.Message):
r"""Subscription properties sent as part of the response.
@@ -1659,8 +1674,9 @@ class CreateSnapshotRequest(proto.Message):
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}``.
+ specify a name. See the `resource name
+ rules `__.
+ Format is ``projects/{project}/snapshots/{snap}``.
subscription (str):
Required. The subscription whose backlog the snapshot
retains. Specifically, the created snapshot is guaranteed to
@@ -1673,9 +1689,8 @@ class CreateSnapshotRequest(proto.Message):
CreateSnapshot request. Format is
``projects/{project}/subscriptions/{sub}``.
labels (MutableMapping[str, str]):
- See
- Creating and managing labels.
+ See `Creating and managing
+ labels `__.
"""
name: str = proto.Field(
diff --git a/samples/generated_samples/snippet_metadata_google.pubsub.v1.json b/samples/generated_samples/snippet_metadata_google.pubsub.v1.json
index e0f3623a9..d66015ac4 100644
--- a/samples/generated_samples/snippet_metadata_google.pubsub.v1.json
+++ b/samples/generated_samples/snippet_metadata_google.pubsub.v1.json
@@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-pubsub",
- "version": "2.14.1"
+ "version": "0.1.0"
},
"snippets": [
{
@@ -1315,6 +1315,14 @@
"name": "request",
"type": "google.pubsub_v1.types.UpdateTopicRequest"
},
+ {
+ "name": "topic",
+ "type": "google.pubsub_v1.types.Topic"
+ },
+ {
+ "name": "update_mask",
+ "type": "google.protobuf.field_mask_pb2.FieldMask"
+ },
{
"name": "retry",
"type": "google.api_core.retry.Retry"
@@ -1391,6 +1399,14 @@
"name": "request",
"type": "google.pubsub_v1.types.UpdateTopicRequest"
},
+ {
+ "name": "topic",
+ "type": "google.pubsub_v1.types.Topic"
+ },
+ {
+ "name": "update_mask",
+ "type": "google.protobuf.field_mask_pb2.FieldMask"
+ },
{
"name": "retry",
"type": "google.api_core.retry.Retry"
@@ -5400,6 +5416,14 @@
"name": "request",
"type": "google.pubsub_v1.types.UpdateSnapshotRequest"
},
+ {
+ "name": "snapshot",
+ "type": "google.pubsub_v1.types.Snapshot"
+ },
+ {
+ "name": "update_mask",
+ "type": "google.protobuf.field_mask_pb2.FieldMask"
+ },
{
"name": "retry",
"type": "google.api_core.retry.Retry"
@@ -5476,6 +5500,14 @@
"name": "request",
"type": "google.pubsub_v1.types.UpdateSnapshotRequest"
},
+ {
+ "name": "snapshot",
+ "type": "google.pubsub_v1.types.Snapshot"
+ },
+ {
+ "name": "update_mask",
+ "type": "google.protobuf.field_mask_pb2.FieldMask"
+ },
{
"name": "retry",
"type": "google.api_core.retry.Retry"
@@ -5553,6 +5585,14 @@
"name": "request",
"type": "google.pubsub_v1.types.UpdateSubscriptionRequest"
},
+ {
+ "name": "subscription",
+ "type": "google.pubsub_v1.types.Subscription"
+ },
+ {
+ "name": "update_mask",
+ "type": "google.protobuf.field_mask_pb2.FieldMask"
+ },
{
"name": "retry",
"type": "google.api_core.retry.Retry"
@@ -5629,6 +5669,14 @@
"name": "request",
"type": "google.pubsub_v1.types.UpdateSubscriptionRequest"
},
+ {
+ "name": "subscription",
+ "type": "google.pubsub_v1.types.Subscription"
+ },
+ {
+ "name": "update_mask",
+ "type": "google.protobuf.field_mask_pb2.FieldMask"
+ },
{
"name": "retry",
"type": "google.api_core.retry.Retry"
diff --git a/tests/unit/gapic/pubsub_v1/test_publisher.py b/tests/unit/gapic/pubsub_v1/test_publisher.py
index 1b86bb735..6badf82d6 100644
--- a/tests/unit/gapic/pubsub_v1/test_publisher.py
+++ b/tests/unit/gapic/pubsub_v1/test_publisher.py
@@ -24,10 +24,17 @@
import grpc
from grpc.experimental import aio
+from collections.abc import Iterable
+from google.protobuf import json_format
+import json
import math
import pytest
from proto.marshal.rules.dates import DurationRule, TimestampRule
from proto.marshal.rules import wrappers
+from requests import Response
+from requests import Request, PreparedRequest
+from requests.sessions import Session
+from google.protobuf import json_format
from google.api_core import client_options
from google.api_core import exceptions as core_exceptions
@@ -1057,6 +1064,96 @@ async def test_update_topic_field_headers_async():
) in kw["metadata"]
+def test_update_topic_flattened():
+ client = PublisherClient(
+ credentials=ga_credentials.AnonymousCredentials(),
+ )
+
+ # Mock the actual call within the gRPC stub, and fake the request.
+ with mock.patch.object(type(client.transport.update_topic), "__call__") as call:
+ # Designate an appropriate return value for the call.
+ call.return_value = pubsub.Topic()
+ # Call the method with a truthy value for each flattened field,
+ # using the keyword arguments to the method.
+ client.update_topic(
+ topic=pubsub.Topic(name="name_value"),
+ update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]),
+ )
+
+ # Establish that the underlying call was made with the expected
+ # request object values.
+ assert len(call.mock_calls) == 1
+ _, args, _ = call.mock_calls[0]
+ arg = args[0].topic
+ mock_val = pubsub.Topic(name="name_value")
+ assert arg == mock_val
+ arg = args[0].update_mask
+ mock_val = field_mask_pb2.FieldMask(paths=["paths_value"])
+ assert arg == mock_val
+
+
+def test_update_topic_flattened_error():
+ client = PublisherClient(
+ credentials=ga_credentials.AnonymousCredentials(),
+ )
+
+ # Attempting to call a method with both a request object and flattened
+ # fields is an error.
+ with pytest.raises(ValueError):
+ client.update_topic(
+ pubsub.UpdateTopicRequest(),
+ topic=pubsub.Topic(name="name_value"),
+ update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]),
+ )
+
+
+@pytest.mark.asyncio
+async def test_update_topic_flattened_async():
+ client = PublisherAsyncClient(
+ credentials=ga_credentials.AnonymousCredentials(),
+ )
+
+ # Mock the actual call within the gRPC stub, and fake the request.
+ with mock.patch.object(type(client.transport.update_topic), "__call__") as call:
+ # Designate an appropriate return value for the call.
+ call.return_value = pubsub.Topic()
+
+ call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(pubsub.Topic())
+ # Call the method with a truthy value for each flattened field,
+ # using the keyword arguments to the method.
+ response = await client.update_topic(
+ topic=pubsub.Topic(name="name_value"),
+ update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]),
+ )
+
+ # Establish that the underlying call was made with the expected
+ # request object values.
+ assert len(call.mock_calls)
+ _, args, _ = call.mock_calls[0]
+ arg = args[0].topic
+ mock_val = pubsub.Topic(name="name_value")
+ assert arg == mock_val
+ arg = args[0].update_mask
+ mock_val = field_mask_pb2.FieldMask(paths=["paths_value"])
+ assert arg == mock_val
+
+
+@pytest.mark.asyncio
+async def test_update_topic_flattened_error_async():
+ client = PublisherAsyncClient(
+ credentials=ga_credentials.AnonymousCredentials(),
+ )
+
+ # Attempting to call a method with both a request object and flattened
+ # fields is an error.
+ with pytest.raises(ValueError):
+ await client.update_topic(
+ pubsub.UpdateTopicRequest(),
+ topic=pubsub.Topic(name="name_value"),
+ update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]),
+ )
+
+
@pytest.mark.parametrize(
"request_type",
[
diff --git a/tests/unit/gapic/pubsub_v1/test_schema_service.py b/tests/unit/gapic/pubsub_v1/test_schema_service.py
index 4c7ffd5ed..54b8d8ac3 100644
--- a/tests/unit/gapic/pubsub_v1/test_schema_service.py
+++ b/tests/unit/gapic/pubsub_v1/test_schema_service.py
@@ -24,10 +24,17 @@
import grpc
from grpc.experimental import aio
+from collections.abc import Iterable
+from google.protobuf import json_format
+import json
import math
import pytest
from proto.marshal.rules.dates import DurationRule, TimestampRule
from proto.marshal.rules import wrappers
+from requests import Response
+from requests import Request, PreparedRequest
+from requests.sessions import Session
+from google.protobuf import json_format
from google.api_core import client_options
from google.api_core import exceptions as core_exceptions
diff --git a/tests/unit/gapic/pubsub_v1/test_subscriber.py b/tests/unit/gapic/pubsub_v1/test_subscriber.py
index 79fd1bdbe..3be5857f3 100644
--- a/tests/unit/gapic/pubsub_v1/test_subscriber.py
+++ b/tests/unit/gapic/pubsub_v1/test_subscriber.py
@@ -25,10 +25,17 @@
import grpc
from grpc.experimental import aio
+from collections.abc import Iterable
+from google.protobuf import json_format
+import json
import math
import pytest
from proto.marshal.rules.dates import DurationRule, TimestampRule
from proto.marshal.rules import wrappers
+from requests import Response
+from requests import Request, PreparedRequest
+from requests.sessions import Session
+from google.protobuf import json_format
from google.api_core import client_options
from google.api_core import exceptions as core_exceptions
@@ -1423,6 +1430,100 @@ async def test_update_subscription_field_headers_async():
) in kw["metadata"]
+def test_update_subscription_flattened():
+ client = SubscriberClient(
+ credentials=ga_credentials.AnonymousCredentials(),
+ )
+
+ # Mock the actual call within the gRPC stub, and fake the request.
+ with mock.patch.object(
+ type(client.transport.update_subscription), "__call__"
+ ) as call:
+ # Designate an appropriate return value for the call.
+ call.return_value = pubsub.Subscription()
+ # Call the method with a truthy value for each flattened field,
+ # using the keyword arguments to the method.
+ client.update_subscription(
+ subscription=pubsub.Subscription(name="name_value"),
+ update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]),
+ )
+
+ # Establish that the underlying call was made with the expected
+ # request object values.
+ assert len(call.mock_calls) == 1
+ _, args, _ = call.mock_calls[0]
+ arg = args[0].subscription
+ mock_val = pubsub.Subscription(name="name_value")
+ assert arg == mock_val
+ arg = args[0].update_mask
+ mock_val = field_mask_pb2.FieldMask(paths=["paths_value"])
+ assert arg == mock_val
+
+
+def test_update_subscription_flattened_error():
+ client = SubscriberClient(
+ credentials=ga_credentials.AnonymousCredentials(),
+ )
+
+ # Attempting to call a method with both a request object and flattened
+ # fields is an error.
+ with pytest.raises(ValueError):
+ client.update_subscription(
+ pubsub.UpdateSubscriptionRequest(),
+ subscription=pubsub.Subscription(name="name_value"),
+ update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]),
+ )
+
+
+@pytest.mark.asyncio
+async def test_update_subscription_flattened_async():
+ client = SubscriberAsyncClient(
+ credentials=ga_credentials.AnonymousCredentials(),
+ )
+
+ # Mock the actual call within the gRPC stub, and fake the request.
+ with mock.patch.object(
+ type(client.transport.update_subscription), "__call__"
+ ) as call:
+ # Designate an appropriate return value for the call.
+ call.return_value = pubsub.Subscription()
+
+ call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(pubsub.Subscription())
+ # Call the method with a truthy value for each flattened field,
+ # using the keyword arguments to the method.
+ response = await client.update_subscription(
+ subscription=pubsub.Subscription(name="name_value"),
+ update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]),
+ )
+
+ # Establish that the underlying call was made with the expected
+ # request object values.
+ assert len(call.mock_calls)
+ _, args, _ = call.mock_calls[0]
+ arg = args[0].subscription
+ mock_val = pubsub.Subscription(name="name_value")
+ assert arg == mock_val
+ arg = args[0].update_mask
+ mock_val = field_mask_pb2.FieldMask(paths=["paths_value"])
+ assert arg == mock_val
+
+
+@pytest.mark.asyncio
+async def test_update_subscription_flattened_error_async():
+ client = SubscriberAsyncClient(
+ credentials=ga_credentials.AnonymousCredentials(),
+ )
+
+ # Attempting to call a method with both a request object and flattened
+ # fields is an error.
+ with pytest.raises(ValueError):
+ await client.update_subscription(
+ pubsub.UpdateSubscriptionRequest(),
+ subscription=pubsub.Subscription(name="name_value"),
+ update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]),
+ )
+
+
@pytest.mark.parametrize(
"request_type",
[
@@ -4189,6 +4290,96 @@ async def test_update_snapshot_field_headers_async():
) in kw["metadata"]
+def test_update_snapshot_flattened():
+ client = SubscriberClient(
+ credentials=ga_credentials.AnonymousCredentials(),
+ )
+
+ # Mock the actual call within the gRPC stub, and fake the request.
+ with mock.patch.object(type(client.transport.update_snapshot), "__call__") as call:
+ # Designate an appropriate return value for the call.
+ call.return_value = pubsub.Snapshot()
+ # Call the method with a truthy value for each flattened field,
+ # using the keyword arguments to the method.
+ client.update_snapshot(
+ snapshot=pubsub.Snapshot(name="name_value"),
+ update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]),
+ )
+
+ # Establish that the underlying call was made with the expected
+ # request object values.
+ assert len(call.mock_calls) == 1
+ _, args, _ = call.mock_calls[0]
+ arg = args[0].snapshot
+ mock_val = pubsub.Snapshot(name="name_value")
+ assert arg == mock_val
+ arg = args[0].update_mask
+ mock_val = field_mask_pb2.FieldMask(paths=["paths_value"])
+ assert arg == mock_val
+
+
+def test_update_snapshot_flattened_error():
+ client = SubscriberClient(
+ credentials=ga_credentials.AnonymousCredentials(),
+ )
+
+ # Attempting to call a method with both a request object and flattened
+ # fields is an error.
+ with pytest.raises(ValueError):
+ client.update_snapshot(
+ pubsub.UpdateSnapshotRequest(),
+ snapshot=pubsub.Snapshot(name="name_value"),
+ update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]),
+ )
+
+
+@pytest.mark.asyncio
+async def test_update_snapshot_flattened_async():
+ client = SubscriberAsyncClient(
+ credentials=ga_credentials.AnonymousCredentials(),
+ )
+
+ # Mock the actual call within the gRPC stub, and fake the request.
+ with mock.patch.object(type(client.transport.update_snapshot), "__call__") as call:
+ # Designate an appropriate return value for the call.
+ call.return_value = pubsub.Snapshot()
+
+ call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(pubsub.Snapshot())
+ # Call the method with a truthy value for each flattened field,
+ # using the keyword arguments to the method.
+ response = await client.update_snapshot(
+ snapshot=pubsub.Snapshot(name="name_value"),
+ update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]),
+ )
+
+ # Establish that the underlying call was made with the expected
+ # request object values.
+ assert len(call.mock_calls)
+ _, args, _ = call.mock_calls[0]
+ arg = args[0].snapshot
+ mock_val = pubsub.Snapshot(name="name_value")
+ assert arg == mock_val
+ arg = args[0].update_mask
+ mock_val = field_mask_pb2.FieldMask(paths=["paths_value"])
+ assert arg == mock_val
+
+
+@pytest.mark.asyncio
+async def test_update_snapshot_flattened_error_async():
+ client = SubscriberAsyncClient(
+ credentials=ga_credentials.AnonymousCredentials(),
+ )
+
+ # Attempting to call a method with both a request object and flattened
+ # fields is an error.
+ with pytest.raises(ValueError):
+ await client.update_snapshot(
+ pubsub.UpdateSnapshotRequest(),
+ snapshot=pubsub.Snapshot(name="name_value"),
+ update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]),
+ )
+
+
@pytest.mark.parametrize(
"request_type",
[