Skip to content

Commit afec9a1

Browse files
feat: add ingestion Cloud Storage fields and Platform Logging fields to Topic (#1974)
* feat: add ingestion Cloud Storage fields and Platform Logging fields to Topic PiperOrigin-RevId: 678307181 Source-Link: googleapis/googleapis@69e9dff Source-Link: googleapis/googleapis-gen@11a52e5 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTFhNTJlNTI3MjMyMjdkM2I2MTIwZjg4ZjFhNTgwZTM5NThlMGNkNSJ9 feat: return listing information for subscriptions created via Analytics Hub PiperOrigin-RevId: 676126585 Source-Link: googleapis/googleapis@de3b4b3 Source-Link: googleapis/googleapis-gen@c3df551 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYzNkZjU1MTYyY2NjOTkyOWM5N2JmZWM5ZmExZDViY2QzYjY1YWY0YSJ9 * build: try switching to raw eslint to exclude owl-bot-staging * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot Co-authored-by: feywind <[email protected]>
1 parent 37b9f71 commit afec9a1

File tree

7 files changed

+2631
-61
lines changed

7 files changed

+2631
-61
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ npm install @google-cloud/pubsub
6666

6767
```javascript
6868
// Imports the Google Cloud client library
69-
const {PubSub} = require('@google-cloud/pubsub');
69+
const { PubSub } = require("@google-cloud/pubsub");
7070

7171
async function quickstart(
72-
projectId = 'your-project-id', // Your Google Cloud Platform project ID
73-
topicNameOrId = 'my-topic', // Name for the new topic to create
74-
subscriptionName = 'my-sub' // Name for the new subscription to create
72+
projectId = 'your-project-id', // Your Google Cloud Platform project ID
73+
topicNameOrId = 'my-topic', // Name for the new topic to create
74+
subscriptionName = 'my-sub' // Name for the new subscription to create
7575
) {
7676
// Instantiates a client
77-
const pubsub = new PubSub({projectId});
77+
const pubsub = new PubSub({ projectId });
7878

7979
// Creates a new topic
8080
const [topic] = await pubsub.createTopic(topicNameOrId);
@@ -84,19 +84,19 @@ async function quickstart(
8484
const [subscription] = await topic.createSubscription(subscriptionName);
8585

8686
// Receive callbacks for new messages on the subscription
87-
subscription.on('message', message => {
87+
subscription.on('message', (message) => {
8888
console.log('Received message:', message.data.toString());
8989
process.exit(0);
9090
});
9191

9292
// Receive callbacks for errors on the subscription
93-
subscription.on('error', error => {
93+
subscription.on('error', (error) => {
9494
console.error('Received error:', error);
9595
process.exit(1);
9696
});
9797

9898
// Send a message to the topic
99-
topic.publishMessage({data: Buffer.from('Test message!')});
99+
topic.publishMessage({ data: Buffer.from('Test message!') });
100100
}
101101

102102
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"prelint": "cd samples; npm link ../; npm install",
4747
"precompile": "gts clean",
4848
"typeless": "npx typeless-sample-bot --outputpath samples --targets samples --recursive",
49-
"posttypeless": "cd samples && npm i && cd .. && npm run fix"
49+
"posttypeless": "cd samples && npm i && cd .. && npx eslint --ignore-pattern owl-bot-staging --fix"
5050
},
5151
"dependencies": {
5252
"@google-cloud/paginator": "^5.0.0",

protos/google/pubsub/v1/pubsub.proto

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,132 @@ message IngestionDataSourceSettings {
237237
string gcp_service_account = 5 [(google.api.field_behavior) = REQUIRED];
238238
}
239239

240+
// Ingestion settings for Cloud Storage.
241+
message CloudStorage {
242+
// Possible states for ingestion from Cloud Storage.
243+
enum State {
244+
// Default value. This value is unused.
245+
STATE_UNSPECIFIED = 0;
246+
247+
// Ingestion is active.
248+
ACTIVE = 1;
249+
250+
// Permission denied encountered while calling the Cloud Storage API. This
251+
// can happen if the Pub/Sub SA has not been granted the
252+
// [appropriate
253+
// permissions](https://cloud.google.com/storage/docs/access-control/iam-permissions):
254+
// - storage.objects.list: to list the objects in a bucket.
255+
// - storage.objects.get: to read the objects in a bucket.
256+
// - storage.buckets.get: to verify the bucket exists.
257+
CLOUD_STORAGE_PERMISSION_DENIED = 2;
258+
259+
// Permission denied encountered while publishing to the topic. This can
260+
// happen if the Pub/Sub SA has not been granted the [appropriate publish
261+
// permissions](https://cloud.google.com/pubsub/docs/access-control#pubsub.publisher)
262+
PUBLISH_PERMISSION_DENIED = 3;
263+
264+
// The provided Cloud Storage bucket doesn't exist.
265+
BUCKET_NOT_FOUND = 4;
266+
267+
// The Cloud Storage bucket has too many objects, ingestion will be
268+
// paused.
269+
TOO_MANY_OBJECTS = 5;
270+
}
271+
272+
// Configuration for reading Cloud Storage data in text format. Each line of
273+
// text as specified by the delimiter will be set to the `data` field of a
274+
// Pub/Sub message.
275+
message TextFormat {
276+
// Optional. When unset, '\n' is used.
277+
optional string delimiter = 1 [(google.api.field_behavior) = OPTIONAL];
278+
}
279+
280+
// Configuration for reading Cloud Storage data in Avro binary format. The
281+
// bytes of each object will be set to the `data` field of a Pub/Sub
282+
// message.
283+
message AvroFormat {}
284+
285+
// Configuration for reading Cloud Storage data written via [Cloud Storage
286+
// subscriptions](https://cloud.google.com/pubsub/docs/cloudstorage). The
287+
// data and attributes fields of the originally exported Pub/Sub message
288+
// will be restored when publishing.
289+
message PubSubAvroFormat {}
290+
291+
// Output only. An output-only field that indicates the state of the Cloud
292+
// Storage ingestion source.
293+
State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
294+
295+
// Optional. Cloud Storage bucket. The bucket name must be without any
296+
// prefix like "gs://". See the [bucket naming requirements]
297+
// (https://cloud.google.com/storage/docs/buckets#naming).
298+
string bucket = 2 [(google.api.field_behavior) = OPTIONAL];
299+
300+
// Defaults to text format.
301+
oneof input_format {
302+
// Optional. Data from Cloud Storage will be interpreted as text.
303+
TextFormat text_format = 3 [(google.api.field_behavior) = OPTIONAL];
304+
305+
// Optional. Data from Cloud Storage will be interpreted in Avro format.
306+
AvroFormat avro_format = 4 [(google.api.field_behavior) = OPTIONAL];
307+
308+
// Optional. It will be assumed data from Cloud Storage was written via
309+
// [Cloud Storage
310+
// subscriptions](https://cloud.google.com/pubsub/docs/cloudstorage).
311+
PubSubAvroFormat pubsub_avro_format = 5
312+
[(google.api.field_behavior) = OPTIONAL];
313+
}
314+
315+
// Optional. Only objects with a larger or equal creation timestamp will be
316+
// ingested.
317+
google.protobuf.Timestamp minimum_object_create_time = 6
318+
[(google.api.field_behavior) = OPTIONAL];
319+
320+
// Optional. Glob pattern used to match objects that will be ingested. If
321+
// unset, all objects will be ingested. See the [supported
322+
// patterns](https://cloud.google.com/storage/docs/json_api/v1/objects/list#list-objects-and-prefixes-using-glob).
323+
string match_glob = 9 [(google.api.field_behavior) = OPTIONAL];
324+
}
325+
240326
// Only one source type can have settings set.
241327
oneof source {
242328
// Optional. Amazon Kinesis Data Streams.
243329
AwsKinesis aws_kinesis = 1 [(google.api.field_behavior) = OPTIONAL];
330+
331+
// Optional. Cloud Storage.
332+
CloudStorage cloud_storage = 2 [(google.api.field_behavior) = OPTIONAL];
333+
}
334+
335+
// Optional. Platform Logs settings. If unset, no Platform Logs will be
336+
// generated.
337+
PlatformLogsSettings platform_logs_settings = 4
338+
[(google.api.field_behavior) = OPTIONAL];
339+
}
340+
341+
// Settings for Platform Logs produced by Pub/Sub.
342+
message PlatformLogsSettings {
343+
// Severity levels of Platform Logs.
344+
enum Severity {
345+
// Default value. Logs level is unspecified. Logs will be disabled.
346+
SEVERITY_UNSPECIFIED = 0;
347+
348+
// Logs will be disabled.
349+
DISABLED = 1;
350+
351+
// Debug logs and higher-severity logs will be written.
352+
DEBUG = 2;
353+
354+
// Info logs and higher-severity logs will be written.
355+
INFO = 3;
356+
357+
// Warning logs and higher-severity logs will be written.
358+
WARNING = 4;
359+
360+
// Only error logs will be written.
361+
ERROR = 5;
244362
}
363+
364+
// Optional. The minimum severity level of Platform Logs that will be written.
365+
Severity severity = 1 [(google.api.field_behavior) = OPTIONAL];
245366
}
246367

247368
// A topic resource.
@@ -774,6 +895,20 @@ message Subscription {
774895
RESOURCE_ERROR = 2;
775896
}
776897

898+
// Information about an associated Analytics Hub subscription
899+
// (https://cloud.google.com/bigquery/docs/analytics-hub-manage-subscriptions).
900+
message AnalyticsHubSubscriptionInfo {
901+
// Optional. The name of the associated Analytics Hub listing resource.
902+
// Pattern:
903+
// "projects/{project}/locations/{location}/dataExchanges/{data_exchange}/listings/{listing}"
904+
string listing = 1 [(google.api.field_behavior) = OPTIONAL];
905+
906+
// Optional. The name of the associated Analytics Hub subscription resource.
907+
// Pattern:
908+
// "projects/{project}/locations/{location}/subscriptions/{subscription}"
909+
string subscription = 2 [(google.api.field_behavior) = OPTIONAL];
910+
}
911+
777912
// Required. The name of the subscription. It must have the format
778913
// `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
779914
// start with a letter, and contain only letters (`[A-Za-z]`), numbers
@@ -922,6 +1057,11 @@ message Subscription {
9221057
// Output only. An output-only field indicating whether or not the
9231058
// subscription can receive messages.
9241059
State state = 19 [(google.api.field_behavior) = OUTPUT_ONLY];
1060+
1061+
// Output only. Information about the associated Analytics Hub subscription.
1062+
// Only set if the subscritpion is created by Analytics Hub.
1063+
AnalyticsHubSubscriptionInfo analytics_hub_subscription_info = 23
1064+
[(google.api.field_behavior) = OUTPUT_ONLY];
9251065
}
9261066

9271067
// A policy that specifies how Pub/Sub retries message delivery.

0 commit comments

Comments
 (0)