Skip to content

Commit a7a4caa

Browse files
feat: add ingestion Cloud Storage fields and Platform Logging fields to Topic (#1248)
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Mike Prieto <michaelpri10@gmail.com>
1 parent 16a9a4a commit a7a4caa

File tree

5 files changed

+270
-2
lines changed

5 files changed

+270
-2
lines changed

google/pubsub/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
from google.pubsub_v1.types.pubsub import MessageStoragePolicy
5656
from google.pubsub_v1.types.pubsub import ModifyAckDeadlineRequest
5757
from google.pubsub_v1.types.pubsub import ModifyPushConfigRequest
58+
from google.pubsub_v1.types.pubsub import PlatformLogsSettings
5859
from google.pubsub_v1.types.pubsub import PublishRequest
5960
from google.pubsub_v1.types.pubsub import PublishResponse
6061
from google.pubsub_v1.types.pubsub import PubsubMessage
@@ -127,6 +128,7 @@
127128
"MessageStoragePolicy",
128129
"ModifyAckDeadlineRequest",
129130
"ModifyPushConfigRequest",
131+
"PlatformLogsSettings",
130132
"PublishRequest",
131133
"PublishResponse",
132134
"PubsubMessage",

google/pubsub_v1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
from .types.pubsub import MessageStoragePolicy
5454
from .types.pubsub import ModifyAckDeadlineRequest
5555
from .types.pubsub import ModifyPushConfigRequest
56+
from .types.pubsub import PlatformLogsSettings
5657
from .types.pubsub import PublishRequest
5758
from .types.pubsub import PublishResponse
5859
from .types.pubsub import PubsubMessage
@@ -132,6 +133,7 @@
132133
"MessageStoragePolicy",
133134
"ModifyAckDeadlineRequest",
134135
"ModifyPushConfigRequest",
136+
"PlatformLogsSettings",
135137
"PublishRequest",
136138
"PublishResponse",
137139
"PublisherClient",

google/pubsub_v1/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
MessageStoragePolicy,
4545
ModifyAckDeadlineRequest,
4646
ModifyPushConfigRequest,
47+
PlatformLogsSettings,
4748
PublishRequest,
4849
PublishResponse,
4950
PubsubMessage,
@@ -122,6 +123,7 @@
122123
"MessageStoragePolicy",
123124
"ModifyAckDeadlineRequest",
124125
"ModifyPushConfigRequest",
126+
"PlatformLogsSettings",
125127
"PublishRequest",
126128
"PublishResponse",
127129
"PubsubMessage",

google/pubsub_v1/types/pubsub.py

Lines changed: 263 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"MessageStoragePolicy",
3232
"SchemaSettings",
3333
"IngestionDataSourceSettings",
34+
"PlatformLogsSettings",
3435
"Topic",
3536
"PubsubMessage",
3637
"GetTopicRequest",
@@ -160,13 +161,25 @@ class SchemaSettings(proto.Message):
160161
class IngestionDataSourceSettings(proto.Message):
161162
r"""Settings for an ingestion data source on a topic.
162163
164+
This message has `oneof`_ fields (mutually exclusive fields).
165+
For each oneof, at most one member field can be set at the same time.
166+
Setting any member of the oneof automatically clears all other
167+
members.
168+
163169
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
164170
165171
Attributes:
166172
aws_kinesis (google.pubsub_v1.types.IngestionDataSourceSettings.AwsKinesis):
167173
Optional. Amazon Kinesis Data Streams.
168174
169175
This field is a member of `oneof`_ ``source``.
176+
cloud_storage (google.pubsub_v1.types.IngestionDataSourceSettings.CloudStorage):
177+
Optional. Cloud Storage.
178+
179+
This field is a member of `oneof`_ ``source``.
180+
platform_logs_settings (google.pubsub_v1.types.PlatformLogsSettings):
181+
Optional. Platform Logs settings. If unset,
182+
no Platform Logs will be generated.
170183
"""
171184

172185
class AwsKinesis(proto.Message):
@@ -259,12 +272,227 @@ class State(proto.Enum):
259272
number=5,
260273
)
261274

275+
class CloudStorage(proto.Message):
276+
r"""Ingestion settings for Cloud Storage.
277+
278+
This message has `oneof`_ fields (mutually exclusive fields).
279+
For each oneof, at most one member field can be set at the same time.
280+
Setting any member of the oneof automatically clears all other
281+
members.
282+
283+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
284+
285+
Attributes:
286+
state (google.pubsub_v1.types.IngestionDataSourceSettings.CloudStorage.State):
287+
Output only. An output-only field that
288+
indicates the state of the Cloud Storage
289+
ingestion source.
290+
bucket (str):
291+
Optional. Cloud Storage bucket. The bucket name must be
292+
without any prefix like "gs://". See the [bucket naming
293+
requirements]
294+
(https://cloud.google.com/storage/docs/buckets#naming).
295+
text_format (google.pubsub_v1.types.IngestionDataSourceSettings.CloudStorage.TextFormat):
296+
Optional. Data from Cloud Storage will be
297+
interpreted as text.
298+
299+
This field is a member of `oneof`_ ``input_format``.
300+
avro_format (google.pubsub_v1.types.IngestionDataSourceSettings.CloudStorage.AvroFormat):
301+
Optional. Data from Cloud Storage will be
302+
interpreted in Avro format.
303+
304+
This field is a member of `oneof`_ ``input_format``.
305+
pubsub_avro_format (google.pubsub_v1.types.IngestionDataSourceSettings.CloudStorage.PubSubAvroFormat):
306+
Optional. It will be assumed data from Cloud Storage was
307+
written via `Cloud Storage
308+
subscriptions <https://cloud.google.com/pubsub/docs/cloudstorage>`__.
309+
310+
This field is a member of `oneof`_ ``input_format``.
311+
minimum_object_create_time (google.protobuf.timestamp_pb2.Timestamp):
312+
Optional. Only objects with a larger or equal
313+
creation timestamp will be ingested.
314+
match_glob (str):
315+
Optional. Glob pattern used to match objects that will be
316+
ingested. If unset, all objects will be ingested. See the
317+
`supported
318+
patterns <https://cloud.google.com/storage/docs/json_api/v1/objects/list#list-objects-and-prefixes-using-glob>`__.
319+
"""
320+
321+
class State(proto.Enum):
322+
r"""Possible states for ingestion from Cloud Storage.
323+
324+
Values:
325+
STATE_UNSPECIFIED (0):
326+
Default value. This value is unused.
327+
ACTIVE (1):
328+
Ingestion is active.
329+
CLOUD_STORAGE_PERMISSION_DENIED (2):
330+
Permission denied encountered while calling the Cloud
331+
Storage API. This can happen if the Pub/Sub SA has not been
332+
granted the `appropriate
333+
permissions <https://cloud.google.com/storage/docs/access-control/iam-permissions>`__:
334+
335+
- storage.objects.list: to list the objects in a bucket.
336+
- storage.objects.get: to read the objects in a bucket.
337+
- storage.buckets.get: to verify the bucket exists.
338+
PUBLISH_PERMISSION_DENIED (3):
339+
Permission denied encountered while publishing to the topic.
340+
This can happen if the Pub/Sub SA has not been granted the
341+
`appropriate publish
342+
permissions <https://cloud.google.com/pubsub/docs/access-control#pubsub.publisher>`__
343+
BUCKET_NOT_FOUND (4):
344+
The provided Cloud Storage bucket doesn't
345+
exist.
346+
TOO_MANY_OBJECTS (5):
347+
The Cloud Storage bucket has too many
348+
objects, ingestion will be paused.
349+
"""
350+
STATE_UNSPECIFIED = 0
351+
ACTIVE = 1
352+
CLOUD_STORAGE_PERMISSION_DENIED = 2
353+
PUBLISH_PERMISSION_DENIED = 3
354+
BUCKET_NOT_FOUND = 4
355+
TOO_MANY_OBJECTS = 5
356+
357+
class TextFormat(proto.Message):
358+
r"""Configuration for reading Cloud Storage data in text format. Each
359+
line of text as specified by the delimiter will be set to the
360+
``data`` field of a Pub/Sub message.
361+
362+
363+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
364+
365+
Attributes:
366+
delimiter (str):
367+
Optional. When unset, '\n' is used.
368+
369+
This field is a member of `oneof`_ ``_delimiter``.
370+
"""
371+
372+
delimiter: str = proto.Field(
373+
proto.STRING,
374+
number=1,
375+
optional=True,
376+
)
377+
378+
class AvroFormat(proto.Message):
379+
r"""Configuration for reading Cloud Storage data in Avro binary format.
380+
The bytes of each object will be set to the ``data`` field of a
381+
Pub/Sub message.
382+
383+
"""
384+
385+
class PubSubAvroFormat(proto.Message):
386+
r"""Configuration for reading Cloud Storage data written via `Cloud
387+
Storage
388+
subscriptions <https://cloud.google.com/pubsub/docs/cloudstorage>`__.
389+
The data and attributes fields of the originally exported Pub/Sub
390+
message will be restored when publishing.
391+
392+
"""
393+
394+
state: "IngestionDataSourceSettings.CloudStorage.State" = proto.Field(
395+
proto.ENUM,
396+
number=1,
397+
enum="IngestionDataSourceSettings.CloudStorage.State",
398+
)
399+
bucket: str = proto.Field(
400+
proto.STRING,
401+
number=2,
402+
)
403+
text_format: "IngestionDataSourceSettings.CloudStorage.TextFormat" = (
404+
proto.Field(
405+
proto.MESSAGE,
406+
number=3,
407+
oneof="input_format",
408+
message="IngestionDataSourceSettings.CloudStorage.TextFormat",
409+
)
410+
)
411+
avro_format: "IngestionDataSourceSettings.CloudStorage.AvroFormat" = (
412+
proto.Field(
413+
proto.MESSAGE,
414+
number=4,
415+
oneof="input_format",
416+
message="IngestionDataSourceSettings.CloudStorage.AvroFormat",
417+
)
418+
)
419+
pubsub_avro_format: "IngestionDataSourceSettings.CloudStorage.PubSubAvroFormat" = proto.Field(
420+
proto.MESSAGE,
421+
number=5,
422+
oneof="input_format",
423+
message="IngestionDataSourceSettings.CloudStorage.PubSubAvroFormat",
424+
)
425+
minimum_object_create_time: timestamp_pb2.Timestamp = proto.Field(
426+
proto.MESSAGE,
427+
number=6,
428+
message=timestamp_pb2.Timestamp,
429+
)
430+
match_glob: str = proto.Field(
431+
proto.STRING,
432+
number=9,
433+
)
434+
262435
aws_kinesis: AwsKinesis = proto.Field(
263436
proto.MESSAGE,
264437
number=1,
265438
oneof="source",
266439
message=AwsKinesis,
267440
)
441+
cloud_storage: CloudStorage = proto.Field(
442+
proto.MESSAGE,
443+
number=2,
444+
oneof="source",
445+
message=CloudStorage,
446+
)
447+
platform_logs_settings: "PlatformLogsSettings" = proto.Field(
448+
proto.MESSAGE,
449+
number=4,
450+
message="PlatformLogsSettings",
451+
)
452+
453+
454+
class PlatformLogsSettings(proto.Message):
455+
r"""Settings for Platform Logs produced by Pub/Sub.
456+
457+
Attributes:
458+
severity (google.pubsub_v1.types.PlatformLogsSettings.Severity):
459+
Optional. The minimum severity level of
460+
Platform Logs that will be written.
461+
"""
462+
463+
class Severity(proto.Enum):
464+
r"""Severity levels of Platform Logs.
465+
466+
Values:
467+
SEVERITY_UNSPECIFIED (0):
468+
Default value. Logs level is unspecified.
469+
Logs will be disabled.
470+
DISABLED (1):
471+
Logs will be disabled.
472+
DEBUG (2):
473+
Debug logs and higher-severity logs will be
474+
written.
475+
INFO (3):
476+
Info logs and higher-severity logs will be
477+
written.
478+
WARNING (4):
479+
Warning logs and higher-severity logs will be
480+
written.
481+
ERROR (5):
482+
Only error logs will be written.
483+
"""
484+
SEVERITY_UNSPECIFIED = 0
485+
DISABLED = 1
486+
DEBUG = 2
487+
INFO = 3
488+
WARNING = 4
489+
ERROR = 5
490+
491+
severity: Severity = proto.Field(
492+
proto.ENUM,
493+
number=1,
494+
enum=Severity,
495+
)
268496

269497

270498
class Topic(proto.Message):
@@ -821,7 +1049,7 @@ class Subscription(proto.Message):
8211049
published. If ``retain_acked_messages`` is true, then this
8221050
also configures the retention of acknowledged messages, and
8231051
thus configures how far back in time a ``Seek`` can be done.
824-
Defaults to 7 days. Cannot be more than 7 days or less than
1052+
Defaults to 7 days. Cannot be more than 31 days or less than
8251053
10 minutes.
8261054
labels (MutableMapping[str, str]):
8271055
Optional. See `Creating and managing
@@ -906,6 +1134,10 @@ class Subscription(proto.Message):
9061134
Output only. An output-only field indicating
9071135
whether or not the subscription can receive
9081136
messages.
1137+
analytics_hub_subscription_info (google.pubsub_v1.types.Subscription.AnalyticsHubSubscriptionInfo):
1138+
Output only. Information about the associated
1139+
Analytics Hub subscription. Only set if the
1140+
subscritpion is created by Analytics Hub.
9091141
"""
9101142

9111143
class State(proto.Enum):
@@ -927,6 +1159,31 @@ class State(proto.Enum):
9271159
ACTIVE = 1
9281160
RESOURCE_ERROR = 2
9291161

1162+
class AnalyticsHubSubscriptionInfo(proto.Message):
1163+
r"""Information about an associated Analytics Hub subscription
1164+
(https://cloud.google.com/bigquery/docs/analytics-hub-manage-subscriptions).
1165+
1166+
Attributes:
1167+
listing (str):
1168+
Optional. The name of the associated Analytics Hub listing
1169+
resource. Pattern:
1170+
"projects/{project}/locations/{location}/dataExchanges/{data_exchange}/listings/{listing}".
1171+
subscription (str):
1172+
Optional. The name of the associated
1173+
Analytics Hub subscription resource. Pattern:
1174+
1175+
"projects/{project}/locations/{location}/subscriptions/{subscription}".
1176+
"""
1177+
1178+
listing: str = proto.Field(
1179+
proto.STRING,
1180+
number=1,
1181+
)
1182+
subscription: str = proto.Field(
1183+
proto.STRING,
1184+
number=2,
1185+
)
1186+
9301187
name: str = proto.Field(
9311188
proto.STRING,
9321189
number=1,
@@ -1009,6 +1266,11 @@ class State(proto.Enum):
10091266
number=19,
10101267
enum=State,
10111268
)
1269+
analytics_hub_subscription_info: AnalyticsHubSubscriptionInfo = proto.Field(
1270+
proto.MESSAGE,
1271+
number=23,
1272+
message=AnalyticsHubSubscriptionInfo,
1273+
)
10121274

10131275

10141276
class RetryPolicy(proto.Message):

scripts/fixup_pubsub_v1_keywords.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class pubsubCallTransformer(cst.CSTTransformer):
4343
'commit_schema': ('name', 'schema', ),
4444
'create_schema': ('parent', 'schema', 'schema_id', ),
4545
'create_snapshot': ('name', 'subscription', 'labels', ),
46-
'create_subscription': ('name', 'topic', 'push_config', 'bigquery_config', 'cloud_storage_config', 'ack_deadline_seconds', 'retain_acked_messages', 'message_retention_duration', 'labels', 'enable_message_ordering', 'expiration_policy', 'filter', 'dead_letter_policy', 'retry_policy', 'detached', 'enable_exactly_once_delivery', 'topic_message_retention_duration', 'state', ),
46+
'create_subscription': ('name', 'topic', 'push_config', 'bigquery_config', 'cloud_storage_config', 'ack_deadline_seconds', 'retain_acked_messages', 'message_retention_duration', 'labels', 'enable_message_ordering', 'expiration_policy', 'filter', 'dead_letter_policy', 'retry_policy', 'detached', 'enable_exactly_once_delivery', 'topic_message_retention_duration', 'state', 'analytics_hub_subscription_info', ),
4747
'create_topic': ('name', 'labels', 'message_storage_policy', 'kms_key_name', 'schema_settings', 'satisfies_pzs', 'message_retention_duration', 'state', 'ingestion_data_source_settings', ),
4848
'delete_schema': ('name', ),
4949
'delete_schema_revision': ('name', 'revision_id', ),

0 commit comments

Comments
 (0)