From 76d8d0f0d491ae68821b6593ab29feb1a22fa80c Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 20 Jun 2024 15:26:06 -0400 Subject: [PATCH 1/8] ci: Enable `constraintsFiltering` for Node.js Libraries (#1943) chore: Enable `constraintsFiltering` for Node.js Libraries Source-Link: https://github.com/googleapis/synthtool/commit/dae1282201b64e4da3ad512632cb4dda70a832a1 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d920257482ca1cd72978f29f7d28765a9f8c758c21ee0708234db5cf4c5016c2 Co-authored-by: Owl Bot --- .github/.OwlBot.lock.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 34bb2086d..9e90d54bf 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest - digest: sha256:68e1cece0d6d3336c4f1cb9d2857b020af5574dff6da6349293d1c6d4eea82d8 -# created: 2024-05-31T15:46:42.989947733Z + digest: sha256:d920257482ca1cd72978f29f7d28765a9f8c758c21ee0708234db5cf4c5016c2 +# created: 2024-06-12T16:18:41.688792375Z From 0bffecc0ac9ee871f2d78151b6365d18b8cceb1a Mon Sep 17 00:00:00 2001 From: Megan Potter <57276408+feywind@users.noreply.github.com> Date: Wed, 26 Jun 2024 17:50:19 -0400 Subject: [PATCH 2/8] chore: update for linter failures (#1947) Just opening a separate PR for this, to keep it clean. --- .gitignore | 1 + owlbot.py | 25 ++-------------- renovate.json | 1 + samples/openTelemetryTracing.js | 2 ++ samples/quickstart.js | 2 ++ samples/system-test/schema.test.ts | 4 +-- samples/typescript/quickstart.ts | 2 ++ system-test/pubsub.ts | 1 - test/gapic_publisher_v1.ts | 48 +++++++++++++++--------------- test/gapic_schema_service_v1.ts | 48 +++++++++++++++--------------- test/gapic_subscriber_v1.ts | 48 +++++++++++++++--------------- 11 files changed, 85 insertions(+), 97 deletions(-) diff --git a/.gitignore b/.gitignore index d4f03a0df..6e0935927 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ /docs/ /out/ /build/ +samples/build/ system-test/secrets.js system-test/*key.json *.lock diff --git a/owlbot.py b/owlbot.py index 0e82b17c5..0fd6e7f91 100644 --- a/owlbot.py +++ b/owlbot.py @@ -14,34 +14,15 @@ import synthtool.languages.node as node -# This code snippet can be used to manually update the typeless bot -# to a different version than OwlBot has baked in, but this shouldn't -# be needed once it's settled down. -import os -from synthtool import shell -from synthtool.log import logger -old_path = os.getcwd() -os.chdir("/synthtool") -logger.debug("Update typeless sample bot [1.3.0]") -shell.run(["npm", "i", "@google-cloud/typeless-sample-bot@1.3.0"]) -os.chdir(old_path) - +# Generate JS samples from TS. node.typeless_samples_hermetic() # We need to run this before the main owlbot processing, to make # sure quickstart.js gets gts fixed before the README is generated. # This needs to be worked out more properly, this is temporary. -logger.debug("Copy eslint config") -shell.run( - ["cp", "-r", f"/synthtool/node_modules", "."], - check=True, -) -logger.debug("Running fix...") -shell.run( - ["npm", "run", "fix"], - check=False, -) +node.fix() +# Main OwlBot processing. node.owlbot_main(templates_excludes=[ 'src/index.ts', '.github/PULL_REQUEST_TEMPLATE.md', diff --git a/renovate.json b/renovate.json index 26428fcfc..c5c702cf4 100644 --- a/renovate.json +++ b/renovate.json @@ -4,6 +4,7 @@ "docker:disable", ":disableDependencyDashboard" ], + "constraintsFiltering": "strict", "pinVersions": false, "rebaseStalePrs": true, "schedule": [ diff --git a/samples/openTelemetryTracing.js b/samples/openTelemetryTracing.js index dae84bdcf..1c0af995a 100644 --- a/samples/openTelemetryTracing.js +++ b/samples/openTelemetryTracing.js @@ -14,6 +14,8 @@ * limitations under the License. */ +/* eslint-disable n/no-process-exit */ + /** * This sample demonstrates how to add OpenTelemetry tracing to the * Google Cloud Pub/Sub API. diff --git a/samples/quickstart.js b/samples/quickstart.js index a5beb94bb..b1f296929 100644 --- a/samples/quickstart.js +++ b/samples/quickstart.js @@ -16,6 +16,8 @@ // look for the source TypeScript sample (.ts) for modifications. 'use strict'; +/* eslint-disable n/no-process-exit */ + // sample-metadata: // title: Quickstart // description: A quick introduction to using the Pub/Sub client library. diff --git a/samples/system-test/schema.test.ts b/samples/system-test/schema.test.ts index bbf192900..21e0753c7 100644 --- a/samples/system-test/schema.test.ts +++ b/samples/system-test/schema.test.ts @@ -31,8 +31,8 @@ import * as defer from 'p-defer'; import {TestResources} from './testResources'; import {commandFor} from './common'; -// Tests run as Node 12. -// eslint-disable-next-line node/no-unsupported-features/node-builtins +// Tests run as Node 14. +// eslint-disable-next-line n/no-unsupported-features/node-builtins import {promises as fs} from 'fs'; const execSync = (cmd: string) => cp.execSync(cmd, {encoding: 'utf-8'}); diff --git a/samples/typescript/quickstart.ts b/samples/typescript/quickstart.ts index ff81eb791..c402f0a35 100644 --- a/samples/typescript/quickstart.ts +++ b/samples/typescript/quickstart.ts @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +/* eslint-disable n/no-process-exit */ + // sample-metadata: // title: Quickstart // description: A quick introduction to using the Pub/Sub client library. diff --git a/system-test/pubsub.ts b/system-test/pubsub.ts index 4301292aa..ca152fda7 100644 --- a/system-test/pubsub.ts +++ b/system-test/pubsub.ts @@ -19,7 +19,6 @@ import defer = require('p-defer'); import * as uuid from 'uuid'; // This is only in Node 10.17+, but it's used for system tests, should be okay. -// eslint-disable-next-line node/no-unsupported-features/node-builtins import {promises as fs} from 'fs'; import { diff --git a/test/gapic_publisher_v1.ts b/test/gapic_publisher_v1.ts index f2254a188..8a15356f1 100644 --- a/test/gapic_publisher_v1.ts +++ b/test/gapic_publisher_v1.ts @@ -1237,9 +1237,9 @@ describe('v1.PublisherClient', () => { assert( (client.descriptors.page.listTopics.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -1285,9 +1285,9 @@ describe('v1.PublisherClient', () => { assert( (client.descriptors.page.listTopics.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -1328,9 +1328,9 @@ describe('v1.PublisherClient', () => { assert( (client.descriptors.page.listTopics.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -1370,9 +1370,9 @@ describe('v1.PublisherClient', () => { assert( (client.descriptors.page.listTopics.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); }); @@ -1822,9 +1822,9 @@ describe('v1.PublisherClient', () => { assert( (client.descriptors.page.listTopicSnapshots.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -1868,9 +1868,9 @@ describe('v1.PublisherClient', () => { assert( (client.descriptors.page.listTopicSnapshots.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -1907,9 +1907,9 @@ describe('v1.PublisherClient', () => { assert( (client.descriptors.page.listTopicSnapshots.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -1947,9 +1947,9 @@ describe('v1.PublisherClient', () => { assert( (client.descriptors.page.listTopicSnapshots.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); }); diff --git a/test/gapic_schema_service_v1.ts b/test/gapic_schema_service_v1.ts index cd96d3d23..0f29cc7e1 100644 --- a/test/gapic_schema_service_v1.ts +++ b/test/gapic_schema_service_v1.ts @@ -1502,9 +1502,9 @@ describe('v1.SchemaServiceClient', () => { assert( (client.descriptors.page.listSchemas.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -1550,9 +1550,9 @@ describe('v1.SchemaServiceClient', () => { assert( (client.descriptors.page.listSchemas.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -1593,9 +1593,9 @@ describe('v1.SchemaServiceClient', () => { assert( (client.descriptors.page.listSchemas.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -1635,9 +1635,9 @@ describe('v1.SchemaServiceClient', () => { assert( (client.descriptors.page.listSchemas.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); }); @@ -1802,9 +1802,9 @@ describe('v1.SchemaServiceClient', () => { assert( (client.descriptors.page.listSchemaRevisions.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -1848,9 +1848,9 @@ describe('v1.SchemaServiceClient', () => { assert( (client.descriptors.page.listSchemaRevisions.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -1891,9 +1891,9 @@ describe('v1.SchemaServiceClient', () => { assert( (client.descriptors.page.listSchemaRevisions.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -1931,9 +1931,9 @@ describe('v1.SchemaServiceClient', () => { assert( (client.descriptors.page.listSchemaRevisions.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); }); diff --git a/test/gapic_subscriber_v1.ts b/test/gapic_subscriber_v1.ts index 18c097733..7a8a738d2 100644 --- a/test/gapic_subscriber_v1.ts +++ b/test/gapic_subscriber_v1.ts @@ -2249,9 +2249,9 @@ describe('v1.SubscriberClient', () => { assert( (client.descriptors.page.listSubscriptions.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2295,9 +2295,9 @@ describe('v1.SubscriberClient', () => { assert( (client.descriptors.page.listSubscriptions.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2338,9 +2338,9 @@ describe('v1.SubscriberClient', () => { assert( (client.descriptors.page.listSubscriptions.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2378,9 +2378,9 @@ describe('v1.SubscriberClient', () => { assert( (client.descriptors.page.listSubscriptions.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); }); @@ -2544,9 +2544,9 @@ describe('v1.SubscriberClient', () => { assert( (client.descriptors.page.listSnapshots.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2590,9 +2590,9 @@ describe('v1.SubscriberClient', () => { assert( (client.descriptors.page.listSnapshots.createStream as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2633,9 +2633,9 @@ describe('v1.SubscriberClient', () => { assert( (client.descriptors.page.listSnapshots.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); @@ -2673,9 +2673,9 @@ describe('v1.SubscriberClient', () => { assert( (client.descriptors.page.listSnapshots.asyncIterate as SinonStub) .getCall(0) - .args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams) ); }); }); From 34b8c03f90618ba6ae506764b9d97d9db84dcada Mon Sep 17 00:00:00 2001 From: DuyLX Date: Fri, 28 Jun 2024 02:18:10 +0700 Subject: [PATCH 3/8] fix(docs samples): update missing argv in sample metadata for push subscription (#1946) Co-authored-by: Megan Potter <57276408+feywind@users.noreply.github.com> --- samples/README.md | 4 ++-- samples/createPushSubscription.js | 2 +- samples/createPushSubscriptionNoWrapper.js | 2 +- samples/typescript/createPushSubscription.ts | 2 +- samples/typescript/createPushSubscriptionNoWrapper.ts | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/samples/README.md b/samples/README.md index b1b445b2a..8b4036b55 100644 --- a/samples/README.md +++ b/samples/README.md @@ -207,7 +207,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node createPushSubscription.js ` +`node createPushSubscription.js ` ----- @@ -226,7 +226,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node createPushSubscriptionNoWrapper.js ` +`node createPushSubscriptionNoWrapper.js ` ----- diff --git a/samples/createPushSubscription.js b/samples/createPushSubscription.js index 10115b98f..aa9623e80 100644 --- a/samples/createPushSubscription.js +++ b/samples/createPushSubscription.js @@ -27,7 +27,7 @@ // sample-metadata: // title: Create Push Subscription // description: Creates a new push subscription. -// usage: node createPushSubscription.js +// usage: node createPushSubscription.js // [START pubsub_create_push_subscription] /** diff --git a/samples/createPushSubscriptionNoWrapper.js b/samples/createPushSubscriptionNoWrapper.js index c26f1080a..fcf70cb6b 100644 --- a/samples/createPushSubscriptionNoWrapper.js +++ b/samples/createPushSubscriptionNoWrapper.js @@ -27,7 +27,7 @@ // sample-metadata: // title: Create Push Subscription With No Wrapper // description: Creates a new push subscription, but disables wrapping for payloads. -// usage: node createPushSubscriptionNoWrapper.js +// usage: node createPushSubscriptionNoWrapper.js // [START pubsub_create_unwrapped_push_subscription] /** diff --git a/samples/typescript/createPushSubscription.ts b/samples/typescript/createPushSubscription.ts index 808f3aa8c..bc36cf782 100644 --- a/samples/typescript/createPushSubscription.ts +++ b/samples/typescript/createPushSubscription.ts @@ -23,7 +23,7 @@ // sample-metadata: // title: Create Push Subscription // description: Creates a new push subscription. -// usage: node createPushSubscription.js +// usage: node createPushSubscription.js // [START pubsub_create_push_subscription] /** diff --git a/samples/typescript/createPushSubscriptionNoWrapper.ts b/samples/typescript/createPushSubscriptionNoWrapper.ts index f0d97e33c..550688d59 100644 --- a/samples/typescript/createPushSubscriptionNoWrapper.ts +++ b/samples/typescript/createPushSubscriptionNoWrapper.ts @@ -23,7 +23,7 @@ // sample-metadata: // title: Create Push Subscription With No Wrapper // description: Creates a new push subscription, but disables wrapping for payloads. -// usage: node createPushSubscriptionNoWrapper.js +// usage: node createPushSubscriptionNoWrapper.js // [START pubsub_create_unwrapped_push_subscription] /** From ac48418755a1f0c740cb2329cc2b5a676fd5433c Mon Sep 17 00:00:00 2001 From: Megan Potter <57276408+feywind@users.noreply.github.com> Date: Mon, 8 Jul 2024 17:31:24 -0400 Subject: [PATCH 4/8] samples: add samples for cloud storage buckets (#1931) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: ignore samples/build/ * fix: convert string ports to number ports to match grpc * feat: provide redacted topic and subscription admin clients * tests: allow for storage bucket name gen * samples: add sample for subscription with cloud storage bucket * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * samples: remove gapic getters to be split to another PR * samples: update for review changes * 🦉 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 --- README.md | 1 + samples/README.md | 20 ++++ samples/createSubscriptionWithCloudStorage.js | 99 +++++++++++++++++++ samples/package.json | 1 + samples/system-test/subscriptions.test.ts | 32 +++++- samples/system-test/testResources.ts | 10 ++ .../createSubscriptionWithCloudStorage.ts | 95 ++++++++++++++++++ src/pubsub.ts | 1 + 8 files changed, 258 insertions(+), 1 deletion(-) create mode 100644 samples/createSubscriptionWithCloudStorage.js create mode 100644 samples/typescript/createSubscriptionWithCloudStorage.ts diff --git a/README.md b/README.md index 175f24bbb..735571360 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-pubsub/tree | Create Push Subscription | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createPushSubscription.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createPushSubscription.js,samples/README.md) | | Create Push Subscription With No Wrapper | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createPushSubscriptionNoWrapper.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createPushSubscriptionNoWrapper.js,samples/README.md) | | Create Subscription | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createSubscription.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createSubscription.js,samples/README.md) | +| Create a Cloud Storage subscription | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createSubscriptionWithCloudStorage.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createSubscriptionWithCloudStorage.js,samples/README.md) | | Create Subscription With Dead Letter Policy | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createSubscriptionWithDeadLetterPolicy.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createSubscriptionWithDeadLetterPolicy.js,samples/README.md) | | Create an exactly-once delivery subscription | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createSubscriptionWithExactlyOnceDelivery.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createSubscriptionWithExactlyOnceDelivery.js,samples/README.md) | | Create Subscription With Filtering | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createSubscriptionWithFiltering.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createSubscriptionWithFiltering.js,samples/README.md) | diff --git a/samples/README.md b/samples/README.md index 8b4036b55..f4f59a37c 100644 --- a/samples/README.md +++ b/samples/README.md @@ -28,6 +28,7 @@ guides. * [Create Push Subscription](#create-push-subscription) * [Create Push Subscription With No Wrapper](#create-push-subscription-with-no-wrapper) * [Create Subscription](#create-subscription) + * [Create a Cloud Storage subscription](#create-a-cloud-storage-subscription) * [Create Subscription With Dead Letter Policy](#create-subscription-with-dead-letter-policy) * [Create an exactly-once delivery subscription](#create-an-exactly-once-delivery-subscription) * [Create Subscription With Filtering](#create-subscription-with-filtering) @@ -253,6 +254,25 @@ __Usage:__ +### Create a Cloud Storage subscription + +Demonstrates how to create a subscription with Cloud Storage. + +View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createSubscriptionWithCloudStorage.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createSubscriptionWithCloudStorage.js,samples/README.md) + +__Usage:__ + + +`node createSubscriptionWithCloudStorage.js ` + + +----- + + + + ### Create Subscription With Dead Letter Policy Creates a new subscription With Dead Letter Policy. diff --git a/samples/createSubscriptionWithCloudStorage.js b/samples/createSubscriptionWithCloudStorage.js new file mode 100644 index 000000000..bc75416cb --- /dev/null +++ b/samples/createSubscriptionWithCloudStorage.js @@ -0,0 +1,99 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This is a generated sample, using the typeless sample bot. Please +// look for the source TypeScript sample (.ts) for modifications. +'use strict'; + +/** + * This snippet demonstrates how to perform basic operations on + * schemas with the Google Cloud Pub/Sub API. + * + * For more information, see the README.md under /pubsub and the documentation + * at https://cloud.google.com/pubsub/docs. + */ + +// sample-metadata: +// title: Create a Cloud Storage subscription +// description: Demonstrates how to create a subscription with Cloud Storage. +// usage: node createSubscriptionWithCloudStorage.js + +// [START pubsub_create_cloud_storage_subscription] +/** + * TODO(developer): Uncomment these variables before running the sample. + */ +// const topicName = 'YOUR_TOPIC_NAME'; +// const subscriptionName = 'YOUR_SUBSCRIPTION_NAME'; +// const bucket = 'YOUR_BUCKET_ID'; +// const filenamePrefix = 'YOUR_FILENAME_PREFIX'; +// const filenameSuffix = 'YOUR_FILENAME_SUFFIX'; +// const maxDuration = 60; + +// Imports the Google Cloud client library +const {PubSub} = require('@google-cloud/pubsub'); + +// Creates a client; cache this for further use +const pubSubClient = new PubSub(); + +async function createCloudStorageSubscription( + topicName, + subscriptionName, + bucket, + filenamePrefix, + filenameSuffix, + maxDuration +) { + const options = { + cloudStorageConfig: { + bucket, + filenamePrefix, + filenameSuffix, + maxDuration: { + seconds: maxDuration, + }, + }, + }; + + await pubSubClient + .topic(topicName) + .createSubscription(subscriptionName, options); + + console.log( + `Created subscription ${subscriptionName} with a cloud storage configuration.` + ); +} +// [END pubsub_create_cloud_storage_subscription] + +function main( + topicName = 'YOUR_TOPIC_NAME', + subscriptionName = 'YOUR_SUBSCRIPTION_NAME', + bucket = 'YOUR_BUCKET_NAME', + filenamePrefix = 'YOUR_FILENAME_PREFIX', + filenameSuffix = 'YOUR_FILENAME_SUFFIX', + maxDuration = 60 +) { + createCloudStorageSubscription( + topicName, + subscriptionName, + bucket, + filenamePrefix, + filenameSuffix, + maxDuration + ).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); +} + +main(...process.argv.slice(2)); diff --git a/samples/package.json b/samples/package.json index a023e06ec..25c4687c6 100644 --- a/samples/package.json +++ b/samples/package.json @@ -22,6 +22,7 @@ }, "dependencies": { "@google-cloud/pubsub": "^4.5.0", + "@google-cloud/storage": "^7.11.1", "@opentelemetry/api": "^1.6.0", "@opentelemetry/tracing": "^0.24.0", "avro-js": "^1.11.3", diff --git a/samples/system-test/subscriptions.test.ts b/samples/system-test/subscriptions.test.ts index bcd60c3fb..d3375e56e 100644 --- a/samples/system-test/subscriptions.test.ts +++ b/samples/system-test/subscriptions.test.ts @@ -13,6 +13,7 @@ // limitations under the License. import {BigQuery} from '@google-cloud/bigquery'; +import {Bucket, Storage} from '@google-cloud/storage'; import { CreateSubscriptionOptions, PubSub, @@ -74,7 +75,7 @@ describe('subscriptions', () => { async function createBigQueryTable(datasetId: string, tableId: string) { const bigquery = new BigQuery({ - projectId: projectId, + projectId, }); const datasetOptions = { @@ -108,6 +109,17 @@ describe('subscriptions', () => { await bigquery.dataset(datasetId).delete(deleteOptions); } + async function createStorageBucket(testName: string): Promise { + const storage = new Storage({ + projectId, + }); + + const name = resources.generateStorageName(testName); + + const [bucket] = await storage.createBucket(name); + return bucket; + } + async function cleanSubs() { const [subscriptions] = await pubsub.getSubscriptions(); await Promise.all( @@ -428,6 +440,24 @@ describe('subscriptions', () => { assert(subscriptionDetached === true); }); + it('should create a subscription with a cloud storage config', async () => { + const testId = 'sub_storage'; + const topic = await createTopic(testId); + const subName = reserveSub(testId); + const bucket = await createStorageBucket(testId); + const bucketName = bucket.name; + try { + const output = execSync( + `${commandFor('createSubscriptionWithCloudStorage')} ${ + topic.name + } projects/${projectId}/subscriptions/${subName} ${bucketName} 'prefix' 'suffix' 60` + ); + assert.include(output, 'Created subscription'); + } finally { + bucket.delete(); + } + }); + it('should create a subscription with dead letter policy.', async () => { const testId = 'dead_letter'; const topic = await createTopic(testId), diff --git a/samples/system-test/testResources.ts b/samples/system-test/testResources.ts index 1887698aa..045b01079 100644 --- a/samples/system-test/testResources.ts +++ b/samples/system-test/testResources.ts @@ -101,6 +101,16 @@ export class TestResources { ); } + /** + * Generates a unique resource name for one run of a test within + * a test suite for Cloud Storage resources. + */ + generateStorageName(testId: string): string { + return [normalizeId(this.getPrefix(testId)), this.tokenMaker.uuid()].join( + '_' + ); + } + /*! * Given a list of resource names (and a test ID), this will return * a list of all resources that should be deleted to clean up for diff --git a/samples/typescript/createSubscriptionWithCloudStorage.ts b/samples/typescript/createSubscriptionWithCloudStorage.ts new file mode 100644 index 000000000..9f6cafce2 --- /dev/null +++ b/samples/typescript/createSubscriptionWithCloudStorage.ts @@ -0,0 +1,95 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * This snippet demonstrates how to perform basic operations on + * schemas with the Google Cloud Pub/Sub API. + * + * For more information, see the README.md under /pubsub and the documentation + * at https://cloud.google.com/pubsub/docs. + */ + +// sample-metadata: +// title: Create a Cloud Storage subscription +// description: Demonstrates how to create a subscription with Cloud Storage. +// usage: node createSubscriptionWithCloudStorage.js + +// [START pubsub_create_cloud_storage_subscription] +/** + * TODO(developer): Uncomment these variables before running the sample. + */ +// const topicName = 'YOUR_TOPIC_NAME'; +// const subscriptionName = 'YOUR_SUBSCRIPTION_NAME'; +// const bucket = 'YOUR_BUCKET_ID'; +// const filenamePrefix = 'YOUR_FILENAME_PREFIX'; +// const filenameSuffix = 'YOUR_FILENAME_SUFFIX'; +// const maxDuration = 60; + +// Imports the Google Cloud client library +import {CreateSubscriptionOptions, PubSub} from '@google-cloud/pubsub'; + +// Creates a client; cache this for further use +const pubSubClient = new PubSub(); + +async function createCloudStorageSubscription( + topicName: string, + subscriptionName: string, + bucket: string, + filenamePrefix: string, + filenameSuffix: string, + maxDuration: number +) { + const options: CreateSubscriptionOptions = { + cloudStorageConfig: { + bucket, + filenamePrefix, + filenameSuffix, + maxDuration: { + seconds: maxDuration, + }, + }, + }; + + await pubSubClient + .topic(topicName) + .createSubscription(subscriptionName, options); + + console.log( + `Created subscription ${subscriptionName} with a cloud storage configuration.` + ); +} +// [END pubsub_create_cloud_storage_subscription] + +function main( + topicName = 'YOUR_TOPIC_NAME', + subscriptionName = 'YOUR_SUBSCRIPTION_NAME', + bucket = 'YOUR_BUCKET_NAME', + filenamePrefix = 'YOUR_FILENAME_PREFIX', + filenameSuffix = 'YOUR_FILENAME_SUFFIX', + maxDuration = 60 +) { + createCloudStorageSubscription( + topicName, + subscriptionName, + bucket, + filenamePrefix, + filenameSuffix, + maxDuration + ).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); +} + +main(...process.argv.slice(2)); diff --git a/src/pubsub.ts b/src/pubsub.ts index a2df1d01c..03a2ff9eb 100644 --- a/src/pubsub.ts +++ b/src/pubsub.ts @@ -307,6 +307,7 @@ export class PubSub { allScopes[scope] = true; } } + this.options = Object.assign( { libName: 'gccl', From de0fad72315b54ab4b53621a124aa8e4785798e5 Mon Sep 17 00:00:00 2001 From: Megan Potter <57276408+feywind@users.noreply.github.com> Date: Wed, 10 Jul 2024 15:31:26 -0400 Subject: [PATCH 5/8] build: we need dev dependencies to fix() (#1953) --- owlbot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/owlbot.py b/owlbot.py index 0fd6e7f91..10dfd88ea 100644 --- a/owlbot.py +++ b/owlbot.py @@ -20,6 +20,7 @@ # We need to run this before the main owlbot processing, to make # sure quickstart.js gets gts fixed before the README is generated. # This needs to be worked out more properly, this is temporary. +node.install() node.fix() # Main OwlBot processing. From 120fa1bca0516185e109260c69ea91eb7ddeecd0 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 10 Jul 2024 16:58:04 -0400 Subject: [PATCH 6/8] feat: add use_topic_schema for Cloud Storage Subscriptions (#1948) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add use_topic_schema for Cloud Storage Subscriptions PiperOrigin-RevId: 643385701 Source-Link: https://github.com/googleapis/googleapis/commit/f29a82a206156fd665eaa01cb7987170ac0250f0 Source-Link: https://github.com/googleapis/googleapis-gen/commit/f8f3f60ad2ab4e81fe024368ad0430900174e82b Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZjhmM2Y2MGFkMmFiNGU4MWZlMDI0MzY4YWQwNDMwOTAwMTc0ZTgyYiJ9 * build: ignore owl-bot-staging while doing owlbot PRs * build: exclude the owl-bot-staging tree from the header CI * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * build: more updates to help owlbot --------- Co-authored-by: Owl Bot Co-authored-by: feywind <57276408+feywind@users.noreply.github.com> --- .eslintignore | 1 + .github/.header-checker-lint.yaml | 12 ++++++++++ .gitignore | 1 - owlbot.py | 4 +++- protos/google/pubsub/v1/pubsub.proto | 8 +++++++ protos/protos.d.ts | 9 +++++++- protos/protos.js | 33 +++++++++++++++++++++++++++- protos/protos.json | 10 ++++++++- samples/.gitignore | 1 + 9 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 .github/.header-checker-lint.yaml create mode 100644 samples/.gitignore diff --git a/.eslintignore b/.eslintignore index c4a0963e9..a5e47c7e7 100644 --- a/.eslintignore +++ b/.eslintignore @@ -3,6 +3,7 @@ test/fixtures build/ docs/ +owl-bot-staging/ protos/ samples/generated/ system-test/**/fixtures diff --git a/.github/.header-checker-lint.yaml b/.github/.header-checker-lint.yaml new file mode 100644 index 000000000..e74512f1c --- /dev/null +++ b/.github/.header-checker-lint.yaml @@ -0,0 +1,12 @@ +allowedCopyrightHolders: + - 'Google LLC' +allowedLicenses: + - 'Apache-2.0' + - 'MIT' + - 'BSD-3' +sourceFileExtensions: + - 'ts' + - 'js' + - 'java' +ignoreFiles: + - 'owl-bot-staging/**' diff --git a/.gitignore b/.gitignore index 6e0935927..d4f03a0df 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ /docs/ /out/ /build/ -samples/build/ system-test/secrets.js system-test/*key.json *.lock diff --git a/owlbot.py b/owlbot.py index 10dfd88ea..f3e6252cc 100644 --- a/owlbot.py +++ b/owlbot.py @@ -27,5 +27,7 @@ node.owlbot_main(templates_excludes=[ 'src/index.ts', '.github/PULL_REQUEST_TEMPLATE.md', - '.github/release-please.yml' + '.github/release-please.yml', + '.github/header-checker-lint.yaml', + '.eslintignore' ]) diff --git a/protos/google/pubsub/v1/pubsub.proto b/protos/google/pubsub/v1/pubsub.proto index 8546dacf9..b70bda11a 100644 --- a/protos/google/pubsub/v1/pubsub.proto +++ b/protos/google/pubsub/v1/pubsub.proto @@ -1168,6 +1168,10 @@ message CloudStorageConfig { // data (for example, an ordering_key, if present) are added as entries in // the attributes map. bool write_metadata = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. When true, the output Cloud Storage file will be serialized + // using the topic schema, if it exists. + bool use_topic_schema = 2 [(google.api.field_behavior) = OPTIONAL]; } // Possible states for a Cloud Storage subscription. @@ -1188,6 +1192,10 @@ message CloudStorageConfig { // Cannot write to the destination because enforce_in_transit is set to true // and the destination locations are not in the allowed regions. IN_TRANSIT_LOCATION_RESTRICTION = 4; + + // Cannot write to the Cloud Storage bucket due to an incompatibility + // between the topic schema and subscription settings. + SCHEMA_MISMATCH = 5; } // Required. User-provided name for the Cloud Storage bucket. diff --git a/protos/protos.d.ts b/protos/protos.d.ts index 17d730c34..19956f26c 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -3979,6 +3979,9 @@ export namespace google { /** AvroConfig writeMetadata */ writeMetadata?: (boolean|null); + + /** AvroConfig useTopicSchema */ + useTopicSchema?: (boolean|null); } /** Represents an AvroConfig. */ @@ -3993,6 +3996,9 @@ export namespace google { /** AvroConfig writeMetadata. */ public writeMetadata: boolean; + /** AvroConfig useTopicSchema. */ + public useTopicSchema: boolean; + /** * Creates a new AvroConfig instance using the specified properties. * @param [properties] Properties to set @@ -4077,7 +4083,8 @@ export namespace google { ACTIVE = 1, PERMISSION_DENIED = 2, NOT_FOUND = 3, - IN_TRANSIT_LOCATION_RESTRICTION = 4 + IN_TRANSIT_LOCATION_RESTRICTION = 4, + SCHEMA_MISMATCH = 5 } } diff --git a/protos/protos.js b/protos/protos.js index 65103b824..b439f7b68 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -8986,6 +8986,7 @@ case 2: case 3: case 4: + case 5: break; } if (message.serviceAccountEmail != null && message.hasOwnProperty("serviceAccountEmail")) @@ -9065,6 +9066,10 @@ case 4: message.state = 4; break; + case "SCHEMA_MISMATCH": + case 5: + message.state = 5; + break; } if (object.serviceAccountEmail != null) message.serviceAccountEmail = String(object.serviceAccountEmail); @@ -9338,6 +9343,7 @@ * @memberof google.pubsub.v1.CloudStorageConfig * @interface IAvroConfig * @property {boolean|null} [writeMetadata] AvroConfig writeMetadata + * @property {boolean|null} [useTopicSchema] AvroConfig useTopicSchema */ /** @@ -9363,6 +9369,14 @@ */ AvroConfig.prototype.writeMetadata = false; + /** + * AvroConfig useTopicSchema. + * @member {boolean} useTopicSchema + * @memberof google.pubsub.v1.CloudStorageConfig.AvroConfig + * @instance + */ + AvroConfig.prototype.useTopicSchema = false; + /** * Creates a new AvroConfig instance using the specified properties. * @function create @@ -9389,6 +9403,8 @@ writer = $Writer.create(); if (message.writeMetadata != null && Object.hasOwnProperty.call(message, "writeMetadata")) writer.uint32(/* id 1, wireType 0 =*/8).bool(message.writeMetadata); + if (message.useTopicSchema != null && Object.hasOwnProperty.call(message, "useTopicSchema")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.useTopicSchema); return writer; }; @@ -9427,6 +9443,10 @@ message.writeMetadata = reader.bool(); break; } + case 2: { + message.useTopicSchema = reader.bool(); + break; + } default: reader.skipType(tag & 7); break; @@ -9465,6 +9485,9 @@ if (message.writeMetadata != null && message.hasOwnProperty("writeMetadata")) if (typeof message.writeMetadata !== "boolean") return "writeMetadata: boolean expected"; + if (message.useTopicSchema != null && message.hasOwnProperty("useTopicSchema")) + if (typeof message.useTopicSchema !== "boolean") + return "useTopicSchema: boolean expected"; return null; }; @@ -9482,6 +9505,8 @@ var message = new $root.google.pubsub.v1.CloudStorageConfig.AvroConfig(); if (object.writeMetadata != null) message.writeMetadata = Boolean(object.writeMetadata); + if (object.useTopicSchema != null) + message.useTopicSchema = Boolean(object.useTopicSchema); return message; }; @@ -9498,10 +9523,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.writeMetadata = false; + object.useTopicSchema = false; + } if (message.writeMetadata != null && message.hasOwnProperty("writeMetadata")) object.writeMetadata = message.writeMetadata; + if (message.useTopicSchema != null && message.hasOwnProperty("useTopicSchema")) + object.useTopicSchema = message.useTopicSchema; return object; }; @@ -9543,6 +9572,7 @@ * @property {number} PERMISSION_DENIED=2 PERMISSION_DENIED value * @property {number} NOT_FOUND=3 NOT_FOUND value * @property {number} IN_TRANSIT_LOCATION_RESTRICTION=4 IN_TRANSIT_LOCATION_RESTRICTION value + * @property {number} SCHEMA_MISMATCH=5 SCHEMA_MISMATCH value */ CloudStorageConfig.State = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -9551,6 +9581,7 @@ values[valuesById[2] = "PERMISSION_DENIED"] = 2; values[valuesById[3] = "NOT_FOUND"] = 3; values[valuesById[4] = "IN_TRANSIT_LOCATION_RESTRICTION"] = 4; + values[valuesById[5] = "SCHEMA_MISMATCH"] = 5; return values; })(); diff --git a/protos/protos.json b/protos/protos.json index e37e3bd25..6497622c4 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -1389,6 +1389,13 @@ "options": { "(google.api.field_behavior)": "OPTIONAL" } + }, + "useTopicSchema": { + "type": "bool", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -1398,7 +1405,8 @@ "ACTIVE": 1, "PERMISSION_DENIED": 2, "NOT_FOUND": 3, - "IN_TRANSIT_LOCATION_RESTRICTION": 4 + "IN_TRANSIT_LOCATION_RESTRICTION": 4, + "SCHEMA_MISMATCH": 5 } } } diff --git a/samples/.gitignore b/samples/.gitignore new file mode 100644 index 000000000..567609b12 --- /dev/null +++ b/samples/.gitignore @@ -0,0 +1 @@ +build/ From 90546f634cc4e510185e20a4d1ba1c74ebc59b85 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 12 Jul 2024 20:24:20 +0000 Subject: [PATCH 7/8] feat: add max messages batching for Cloud Storage subscriptions (#1956) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 651799920 Source-Link: https://togithub.com/googleapis/googleapis/commit/8148b2fde13d3ed79cf285e9c529572aa8cf6ef7 Source-Link: https://togithub.com/googleapis/googleapis-gen/commit/1a41634b2c8b7c5c7ea79e9d86f514b532f17d08 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMWE0MTYzNGIyYzhiN2M1YzdlYTc5ZTlkODZmNTE0YjUzMmYxN2QwOCJ9 --- .eslintignore | 6 ++--- protos/google/pubsub/v1/pubsub.proto | 4 +++ protos/protos.d.ts | 6 +++++ protos/protos.js | 37 ++++++++++++++++++++++++++++ protos/protos.json | 7 ++++++ 5 files changed, 56 insertions(+), 4 deletions(-) diff --git a/.eslintignore b/.eslintignore index a5e47c7e7..cfc348ec4 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,9 +1,7 @@ **/node_modules -**/coverage -test/fixtures +**/.coverage build/ docs/ -owl-bot-staging/ protos/ +system-test/ samples/generated/ -system-test/**/fixtures diff --git a/protos/google/pubsub/v1/pubsub.proto b/protos/google/pubsub/v1/pubsub.proto index b70bda11a..b5092087a 100644 --- a/protos/google/pubsub/v1/pubsub.proto +++ b/protos/google/pubsub/v1/pubsub.proto @@ -1240,6 +1240,10 @@ message CloudStorageConfig { // be exceeded in cases where messages are larger than the limit. int64 max_bytes = 7 [(google.api.field_behavior) = OPTIONAL]; + // Optional. The maximum number of messages that can be written to a Cloud + // Storage file before a new file is created. Min 1000 messages. + int64 max_messages = 8 [(google.api.field_behavior) = OPTIONAL]; + // Output only. An output-only field that indicates whether or not the // subscription can receive messages. State state = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; diff --git a/protos/protos.d.ts b/protos/protos.d.ts index 19956f26c..69f782b8d 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -3754,6 +3754,9 @@ export namespace google { /** CloudStorageConfig maxBytes */ maxBytes?: (number|Long|string|null); + /** CloudStorageConfig maxMessages */ + maxMessages?: (number|Long|string|null); + /** CloudStorageConfig state */ state?: (google.pubsub.v1.CloudStorageConfig.State|keyof typeof google.pubsub.v1.CloudStorageConfig.State|null); @@ -3794,6 +3797,9 @@ export namespace google { /** CloudStorageConfig maxBytes. */ public maxBytes: (number|Long|string); + /** CloudStorageConfig maxMessages. */ + public maxMessages: (number|Long|string); + /** CloudStorageConfig state. */ public state: (google.pubsub.v1.CloudStorageConfig.State|keyof typeof google.pubsub.v1.CloudStorageConfig.State); diff --git a/protos/protos.js b/protos/protos.js index b439f7b68..5b9a057d5 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -8672,6 +8672,7 @@ * @property {google.pubsub.v1.CloudStorageConfig.IAvroConfig|null} [avroConfig] CloudStorageConfig avroConfig * @property {google.protobuf.IDuration|null} [maxDuration] CloudStorageConfig maxDuration * @property {number|Long|null} [maxBytes] CloudStorageConfig maxBytes + * @property {number|Long|null} [maxMessages] CloudStorageConfig maxMessages * @property {google.pubsub.v1.CloudStorageConfig.State|null} [state] CloudStorageConfig state * @property {string|null} [serviceAccountEmail] CloudStorageConfig serviceAccountEmail */ @@ -8755,6 +8756,14 @@ */ CloudStorageConfig.prototype.maxBytes = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + /** + * CloudStorageConfig maxMessages. + * @member {number|Long} maxMessages + * @memberof google.pubsub.v1.CloudStorageConfig + * @instance + */ + CloudStorageConfig.prototype.maxMessages = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + /** * CloudStorageConfig state. * @member {google.pubsub.v1.CloudStorageConfig.State} state @@ -8823,6 +8832,8 @@ $root.google.protobuf.Duration.encode(message.maxDuration, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); if (message.maxBytes != null && Object.hasOwnProperty.call(message, "maxBytes")) writer.uint32(/* id 7, wireType 0 =*/56).int64(message.maxBytes); + if (message.maxMessages != null && Object.hasOwnProperty.call(message, "maxMessages")) + writer.uint32(/* id 8, wireType 0 =*/64).int64(message.maxMessages); if (message.state != null && Object.hasOwnProperty.call(message, "state")) writer.uint32(/* id 9, wireType 0 =*/72).int32(message.state); if (message.filenameDatetimeFormat != null && Object.hasOwnProperty.call(message, "filenameDatetimeFormat")) @@ -8895,6 +8906,10 @@ message.maxBytes = reader.int64(); break; } + case 8: { + message.maxMessages = reader.int64(); + break; + } case 9: { message.state = reader.int32(); break; @@ -8977,6 +8992,9 @@ if (message.maxBytes != null && message.hasOwnProperty("maxBytes")) if (!$util.isInteger(message.maxBytes) && !(message.maxBytes && $util.isInteger(message.maxBytes.low) && $util.isInteger(message.maxBytes.high))) return "maxBytes: integer|Long expected"; + if (message.maxMessages != null && message.hasOwnProperty("maxMessages")) + if (!$util.isInteger(message.maxMessages) && !(message.maxMessages && $util.isInteger(message.maxMessages.low) && $util.isInteger(message.maxMessages.high))) + return "maxMessages: integer|Long expected"; if (message.state != null && message.hasOwnProperty("state")) switch (message.state) { default: @@ -9039,6 +9057,15 @@ message.maxBytes = object.maxBytes; else if (typeof object.maxBytes === "object") message.maxBytes = new $util.LongBits(object.maxBytes.low >>> 0, object.maxBytes.high >>> 0).toNumber(); + if (object.maxMessages != null) + if ($util.Long) + (message.maxMessages = $util.Long.fromValue(object.maxMessages)).unsigned = false; + else if (typeof object.maxMessages === "string") + message.maxMessages = parseInt(object.maxMessages, 10); + else if (typeof object.maxMessages === "number") + message.maxMessages = object.maxMessages; + else if (typeof object.maxMessages === "object") + message.maxMessages = new $util.LongBits(object.maxMessages.low >>> 0, object.maxMessages.high >>> 0).toNumber(); switch (object.state) { default: if (typeof object.state === "number") { @@ -9099,6 +9126,11 @@ object.maxBytes = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; } else object.maxBytes = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.maxMessages = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.maxMessages = options.longs === String ? "0" : 0; object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; object.filenameDatetimeFormat = ""; object.serviceAccountEmail = ""; @@ -9126,6 +9158,11 @@ object.maxBytes = options.longs === String ? String(message.maxBytes) : message.maxBytes; else object.maxBytes = options.longs === String ? $util.Long.prototype.toString.call(message.maxBytes) : options.longs === Number ? new $util.LongBits(message.maxBytes.low >>> 0, message.maxBytes.high >>> 0).toNumber() : message.maxBytes; + if (message.maxMessages != null && message.hasOwnProperty("maxMessages")) + if (typeof message.maxMessages === "number") + object.maxMessages = options.longs === String ? String(message.maxMessages) : message.maxMessages; + else + object.maxMessages = options.longs === String ? $util.Long.prototype.toString.call(message.maxMessages) : options.longs === Number ? new $util.LongBits(message.maxMessages.low >>> 0, message.maxMessages.high >>> 0).toNumber() : message.maxMessages; if (message.state != null && message.hasOwnProperty("state")) object.state = options.enums === String ? $root.google.pubsub.v1.CloudStorageConfig.State[message.state] === undefined ? message.state : $root.google.pubsub.v1.CloudStorageConfig.State[message.state] : message.state; if (message.filenameDatetimeFormat != null && message.hasOwnProperty("filenameDatetimeFormat")) diff --git a/protos/protos.json b/protos/protos.json index 6497622c4..70e570e04 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -1362,6 +1362,13 @@ "(google.api.field_behavior)": "OPTIONAL" } }, + "maxMessages": { + "type": "int64", + "id": 8, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, "state": { "type": "State", "id": 9, From b8b625da7611ee3faa8c1aebe604c7a1eee4674c Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Fri, 23 Aug 2024 16:29:52 -0400 Subject: [PATCH 8/8] chore(main): release 4.6.0 (#1950) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 13 +++++++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dc7dd3a0..bb5e66b42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,19 @@ [1]: https://www.npmjs.com/package/@google-cloud/pubsub?activeTab=versions +## [4.6.0](https://github.com/googleapis/nodejs-pubsub/compare/v4.5.0...v4.6.0) (2024-07-12) + + +### Features + +* Add max messages batching for Cloud Storage subscriptions ([#1956](https://github.com/googleapis/nodejs-pubsub/issues/1956)) ([90546f6](https://github.com/googleapis/nodejs-pubsub/commit/90546f634cc4e510185e20a4d1ba1c74ebc59b85)) +* Add use_topic_schema for Cloud Storage Subscriptions ([#1948](https://github.com/googleapis/nodejs-pubsub/issues/1948)) ([120fa1b](https://github.com/googleapis/nodejs-pubsub/commit/120fa1bca0516185e109260c69ea91eb7ddeecd0)) + + +### Bug Fixes + +* **docs samples:** Update missing argv in sample metadata for push subscription ([#1946](https://github.com/googleapis/nodejs-pubsub/issues/1946)) ([34b8c03](https://github.com/googleapis/nodejs-pubsub/commit/34b8c03f90618ba6ae506764b9d97d9db84dcada)) + ## [4.5.0](https://github.com/googleapis/nodejs-pubsub/compare/v4.4.1...v4.5.0) (2024-06-11) diff --git a/package.json b/package.json index be0ebb806..48eb81474 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/pubsub", "description": "Cloud Pub/Sub Client Library for Node.js", - "version": "4.5.0", + "version": "4.6.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 25c4687c6..5d1cb416c 100644 --- a/samples/package.json +++ b/samples/package.json @@ -21,7 +21,7 @@ "precompile": "npm run clean" }, "dependencies": { - "@google-cloud/pubsub": "^4.5.0", + "@google-cloud/pubsub": "^4.6.0", "@google-cloud/storage": "^7.11.1", "@opentelemetry/api": "^1.6.0", "@opentelemetry/tracing": "^0.24.0",