From 5bb3c50821deb4b2c5200a13fab502bd2f0f4159 Mon Sep 17 00:00:00 2001 From: Megan Potter <57276408+feywind@users.noreply.github.com> Date: Wed, 17 Jan 2024 15:19:01 -0500 Subject: [PATCH 1/8] samples: add sample for unwrapped push subscriptions (#1865) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * samples: add sample for push subscription with no wrapper * samples: update samples/createPushSubscriptionNoWrapper.js Co-authored-by: Alex Hong <9397363+hongalex@users.noreply.github.com> * samples: update samples/createPushSubscriptionNoWrapper.js Co-authored-by: Alex Hong <9397363+hongalex@users.noreply.github.com> * samples: update copyright createPushSubscriptionNoWrapper.js * samples: update copyright createPushSubscriptionNoWrapper.ts * samples: update region tag in ts as well * chore: remove commented code in subscriptions.test.ts * docs: update comments to be clearer * samples: update push subscription samples to take a URL parameter for extra clarity * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * tests: use a real URL for the actual testing --------- Co-authored-by: Alex Hong <9397363+hongalex@users.noreply.github.com> Co-authored-by: Owl Bot --- README.md | 1 + samples/README.md | 20 +++++ samples/createPushSubscription.js | 16 +++- samples/createPushSubscriptionNoWrapper.js | 87 +++++++++++++++++++ samples/system-test/subscriptions.test.ts | 21 ++++- samples/typescript/createPushSubscription.ts | 11 ++- .../createPushSubscriptionNoWrapper.ts | 83 ++++++++++++++++++ 7 files changed, 233 insertions(+), 6 deletions(-) create mode 100644 samples/createPushSubscriptionNoWrapper.js create mode 100644 samples/typescript/createPushSubscriptionNoWrapper.ts diff --git a/README.md b/README.md index ceefb3891..6a2dfa06d 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-pubsub/tree | Create BigQuery Subscription | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createBigQuerySubscription.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/createBigQuerySubscription.js,samples/README.md) | | Create a Proto based Schema | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createProtoSchema.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/createProtoSchema.js,samples/README.md) | | 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 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) | diff --git a/samples/README.md b/samples/README.md index 749f4493f..6260da752 100644 --- a/samples/README.md +++ b/samples/README.md @@ -24,6 +24,7 @@ guides. * [Create BigQuery Subscription](#create-bigquery-subscription) * [Create a Proto based Schema](#create-a-proto-based-schema) * [Create Push Subscription](#create-push-subscription) + * [Create Push Subscription With No Wrapper](#create-push-subscription-with-no-wrapper) * [Create Subscription](#create-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) @@ -165,6 +166,25 @@ __Usage:__ +### Create Push Subscription With No Wrapper + +Creates a new push subscription, but disables wrapping for payloads. + +View the [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) + +__Usage:__ + + +`node createPushSubscriptionNoWrapper.js ` + + +----- + + + + ### Create Subscription Creates a new subscription. diff --git a/samples/createPushSubscription.js b/samples/createPushSubscription.js index 12afa91b5..10115b98f 100644 --- a/samples/createPushSubscription.js +++ b/samples/createPushSubscription.js @@ -33,6 +33,7 @@ /** * TODO(developer): Uncomment these variables before running the sample. */ +// const pushEndpoint = 'YOUR_ENDPOINT_URL'; // const topicNameOrId = 'YOUR_TOPIC_NAME_OR_ID'; // const subscriptionNameOrId = 'YOUR_SUBSCRIPTION_NAME_OR_ID'; @@ -42,12 +43,16 @@ const {PubSub} = require('@google-cloud/pubsub'); // Creates a client; cache this for further use const pubSubClient = new PubSub(); -async function createPushSubscription(topicNameOrId, subscriptionNameOrId) { +async function createPushSubscription( + pushEndpoint, + topicNameOrId, + subscriptionNameOrId +) { const options = { pushConfig: { // Set to an HTTPS endpoint of your choice. If necessary, register // (authorize) the domain on which the server is hosted. - pushEndpoint: `https://${pubSubClient.projectId}.appspot.com/push`, + pushEndpoint, }, }; @@ -59,10 +64,15 @@ async function createPushSubscription(topicNameOrId, subscriptionNameOrId) { // [END pubsub_create_push_subscription] function main( + pushEndpoint = 'YOUR_ENDPOINT_URL', topicNameOrId = 'YOUR_TOPIC_NAME_OR_ID', subscriptionNameOrId = 'YOUR_SUBSCRIPTION_NAME_OR_ID' ) { - createPushSubscription(topicNameOrId, subscriptionNameOrId).catch(err => { + createPushSubscription( + pushEndpoint, + topicNameOrId, + subscriptionNameOrId + ).catch(err => { console.error(err.message); process.exitCode = 1; }); diff --git a/samples/createPushSubscriptionNoWrapper.js b/samples/createPushSubscriptionNoWrapper.js new file mode 100644 index 000000000..c26f1080a --- /dev/null +++ b/samples/createPushSubscriptionNoWrapper.js @@ -0,0 +1,87 @@ +// 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 application demonstrates how to perform basic operations on + * subscriptions 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 Push Subscription With No Wrapper +// description: Creates a new push subscription, but disables wrapping for payloads. +// usage: node createPushSubscriptionNoWrapper.js + +// [START pubsub_create_unwrapped_push_subscription] +/** + * TODO(developer): Uncomment these variables before running the sample. + */ +// const pushEndpoint = 'YOUR_ENDPOINT_URL'; +// const topicNameOrId = 'YOUR_TOPIC_NAME_OR_ID'; +// const subscriptionNameOrId = 'YOUR_SUBSCRIPTION_NAME_OR_ID'; + +// 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 createPushSubscriptionNoWrapper( + pushEndpoint, + topicNameOrId, + subscriptionNameOrId +) { + const options = { + pushConfig: { + // Set to an HTTPS endpoint of your choice. If necessary, register + // (authorize) the domain on which the server is hosted. + pushEndpoint, + // When true, writes the Pub/Sub message metadata to + // `x-goog-pubsub-:` headers of the HTTP request. Writes the + // Pub/Sub message attributes to `:` headers of the HTTP request. + noWrapper: { + writeMetadata: true, + }, + }, + }; + + await pubSubClient + .topic(topicNameOrId) + .createSubscription(subscriptionNameOrId, options); + console.log(`Subscription ${subscriptionNameOrId} created.`); +} +// [END pubsub_create_unwrapped_push_subscription] + +function main( + pushEndpoint = 'YOUR_ENDPOINT_URL', + topicNameOrId = 'YOUR_TOPIC_NAME_OR_ID', + subscriptionNameOrId = 'YOUR_SUBSCRIPTION_NAME_OR_ID' +) { + createPushSubscriptionNoWrapper( + pushEndpoint, + topicNameOrId, + subscriptionNameOrId + ).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); +} + +main(...process.argv.slice(2)); diff --git a/samples/system-test/subscriptions.test.ts b/samples/system-test/subscriptions.test.ts index 4ce7c12df..bcd60c3fb 100644 --- a/samples/system-test/subscriptions.test.ts +++ b/samples/system-test/subscriptions.test.ts @@ -178,14 +178,33 @@ describe('subscriptions', () => { const testId = 'push_sub'; const topic = await createTopic(testId); const subName = reserveSub(testId); + const url = `https://${pubsub.projectId}.appspot.com/push`; const output = execSync( - `${commandFor('createPushSubscription')} ${topic.name} ${subName}` + `${commandFor('createPushSubscription')} ${url} ${topic.name} ${subName}` ); assert.include(output, `Subscription ${subName} created.`); const [subscriptions] = await pubsub.topic(topic.name).getSubscriptions(); assert(subscriptions.some(s => s.name === fullSubName(subName))); }); + it('should create a push subscription w/no wrapper', async () => { + const testId = 'push_sub_nw'; + const topic = await createTopic(testId); + const subName = reserveSub(testId); + const url = `https://${pubsub.projectId}.appspot.com/push`; + const output = execSync( + `${commandFor('createPushSubscriptionNoWrapper')} ${url} ${ + topic.name + } ${subName}` + ); + assert.include(output, `Subscription ${subName} created.`); + const sub = await pubsub.subscription(subName); + const [subInfo] = await sub.get(); + assert(subInfo.name === fullSubName(subName)); + const [meta] = await subInfo.getMetadata(); + assert(meta.pushConfig!.noWrapper!.writeMetadata === true); + }); + it('should create a BigQuery subscription', async () => { const testId = 'bigquery_sub'; const topic = await createTopic(testId); diff --git a/samples/typescript/createPushSubscription.ts b/samples/typescript/createPushSubscription.ts index a1a0f31e8..808f3aa8c 100644 --- a/samples/typescript/createPushSubscription.ts +++ b/samples/typescript/createPushSubscription.ts @@ -29,6 +29,7 @@ /** * TODO(developer): Uncomment these variables before running the sample. */ +// const pushEndpoint = 'YOUR_ENDPOINT_URL'; // const topicNameOrId = 'YOUR_TOPIC_NAME_OR_ID'; // const subscriptionNameOrId = 'YOUR_SUBSCRIPTION_NAME_OR_ID'; @@ -39,6 +40,7 @@ import {PubSub, CreateSubscriptionOptions} from '@google-cloud/pubsub'; const pubSubClient = new PubSub(); async function createPushSubscription( + pushEndpoint: string, topicNameOrId: string, subscriptionNameOrId: string ) { @@ -46,7 +48,7 @@ async function createPushSubscription( pushConfig: { // Set to an HTTPS endpoint of your choice. If necessary, register // (authorize) the domain on which the server is hosted. - pushEndpoint: `https://${pubSubClient.projectId}.appspot.com/push`, + pushEndpoint, }, }; @@ -58,10 +60,15 @@ async function createPushSubscription( // [END pubsub_create_push_subscription] function main( + pushEndpoint = 'YOUR_ENDPOINT_URL', topicNameOrId = 'YOUR_TOPIC_NAME_OR_ID', subscriptionNameOrId = 'YOUR_SUBSCRIPTION_NAME_OR_ID' ) { - createPushSubscription(topicNameOrId, subscriptionNameOrId).catch(err => { + createPushSubscription( + pushEndpoint, + topicNameOrId, + subscriptionNameOrId + ).catch(err => { console.error(err.message); process.exitCode = 1; }); diff --git a/samples/typescript/createPushSubscriptionNoWrapper.ts b/samples/typescript/createPushSubscriptionNoWrapper.ts new file mode 100644 index 000000000..f0d97e33c --- /dev/null +++ b/samples/typescript/createPushSubscriptionNoWrapper.ts @@ -0,0 +1,83 @@ +// 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 application demonstrates how to perform basic operations on + * subscriptions 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 Push Subscription With No Wrapper +// description: Creates a new push subscription, but disables wrapping for payloads. +// usage: node createPushSubscriptionNoWrapper.js + +// [START pubsub_create_unwrapped_push_subscription] +/** + * TODO(developer): Uncomment these variables before running the sample. + */ +// const pushEndpoint = 'YOUR_ENDPOINT_URL'; +// const topicNameOrId = 'YOUR_TOPIC_NAME_OR_ID'; +// const subscriptionNameOrId = 'YOUR_SUBSCRIPTION_NAME_OR_ID'; + +// Imports the Google Cloud client library +import {PubSub, CreateSubscriptionOptions} from '@google-cloud/pubsub'; + +// Creates a client; cache this for further use +const pubSubClient = new PubSub(); + +async function createPushSubscriptionNoWrapper( + pushEndpoint: string, + topicNameOrId: string, + subscriptionNameOrId: string +) { + const options: CreateSubscriptionOptions = { + pushConfig: { + // Set to an HTTPS endpoint of your choice. If necessary, register + // (authorize) the domain on which the server is hosted. + pushEndpoint, + // When true, writes the Pub/Sub message metadata to + // `x-goog-pubsub-:` headers of the HTTP request. Writes the + // Pub/Sub message attributes to `:` headers of the HTTP request. + noWrapper: { + writeMetadata: true, + }, + }, + }; + + await pubSubClient + .topic(topicNameOrId) + .createSubscription(subscriptionNameOrId, options); + console.log(`Subscription ${subscriptionNameOrId} created.`); +} +// [END pubsub_create_unwrapped_push_subscription] + +function main( + pushEndpoint = 'YOUR_ENDPOINT_URL', + topicNameOrId = 'YOUR_TOPIC_NAME_OR_ID', + subscriptionNameOrId = 'YOUR_SUBSCRIPTION_NAME_OR_ID' +) { + createPushSubscriptionNoWrapper( + pushEndpoint, + topicNameOrId, + subscriptionNameOrId + ).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); +} + +main(...process.argv.slice(2)); From ac0e701c5eaa81a909463a6ac9c30d8fc89b1e3f Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Wed, 31 Jan 2024 19:44:51 +0100 Subject: [PATCH 2/8] chore(deps): update dependency gapic-tools to ^0.3.0 (#1872) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update dependency gapic-tools to ^0.3.0 * 🦉 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 --- package.json | 2 +- protos/protos.d.ts | 280 ++++++++++-- protos/protos.js | 1083 +++++++++++++++++++++++++++++++++++++++----- protos/protos.json | 118 +++-- 4 files changed, 1300 insertions(+), 183 deletions(-) diff --git a/package.json b/package.json index 7284be1a9..4ad24e802 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "c8": "^9.0.0", "codecov": "^3.0.0", "execa": "^5.0.0", - "gapic-tools": "^0.2.0", + "gapic-tools": "^0.3.0", "gts": "^5.0.0", "jsdoc": "^4.0.0", "jsdoc-fresh": "^3.0.0", diff --git a/protos/protos.d.ts b/protos/protos.d.ts index ee6416f9d..eb65e4c60 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -9899,6 +9899,9 @@ export namespace google { /** MethodSettings longRunning */ longRunning?: (google.api.MethodSettings.ILongRunning|null); + + /** MethodSettings autoPopulatedFields */ + autoPopulatedFields?: (string[]|null); } /** Represents a MethodSettings. */ @@ -9916,6 +9919,9 @@ export namespace google { /** MethodSettings longRunning. */ public longRunning?: (google.api.MethodSettings.ILongRunning|null); + /** MethodSettings autoPopulatedFields. */ + public autoPopulatedFields: string[]; + /** * Creates a new MethodSettings instance using the specified properties. * @param [properties] Properties to set @@ -10152,7 +10158,8 @@ export namespace google { INPUT_ONLY = 4, IMMUTABLE = 5, UNORDERED_LIST = 6, - NON_EMPTY_DEFAULT = 7 + NON_EMPTY_DEFAULT = 7, + IDENTIFIER = 8 } /** Properties of a ResourceDescriptor. */ @@ -10508,6 +10515,21 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Edition enum. */ + enum Edition { + EDITION_UNKNOWN = 0, + EDITION_PROTO2 = 998, + EDITION_PROTO3 = 999, + EDITION_2023 = 1000, + EDITION_2024 = 1001, + EDITION_1_TEST_ONLY = 1, + EDITION_2_TEST_ONLY = 2, + EDITION_99997_TEST_ONLY = 99997, + EDITION_99998_TEST_ONLY = 99998, + EDITION_99999_TEST_ONLY = 99999, + EDITION_MAX = 2147483647 + } + /** Properties of a FileDescriptorProto. */ interface IFileDescriptorProto { @@ -10548,7 +10570,7 @@ export namespace google { syntax?: (string|null); /** FileDescriptorProto edition */ - edition?: (string|null); + edition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); } /** Represents a FileDescriptorProto. */ @@ -10597,7 +10619,7 @@ export namespace google { public syntax: string; /** FileDescriptorProto edition. */ - public edition: string; + public edition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); /** * Creates a new FileDescriptorProto instance using the specified properties. @@ -11472,8 +11494,8 @@ export namespace google { /** Label enum. */ enum Label { LABEL_OPTIONAL = 1, - LABEL_REQUIRED = 2, - LABEL_REPEATED = 3 + LABEL_REPEATED = 3, + LABEL_REQUIRED = 2 } } @@ -12185,9 +12207,6 @@ export namespace google { /** FileOptions pyGenericServices */ pyGenericServices?: (boolean|null); - /** FileOptions phpGenericServices */ - phpGenericServices?: (boolean|null); - /** FileOptions deprecated */ deprecated?: (boolean|null); @@ -12264,9 +12283,6 @@ export namespace google { /** FileOptions pyGenericServices. */ public pyGenericServices: boolean; - /** FileOptions phpGenericServices. */ - public phpGenericServices: boolean; - /** FileOptions deprecated. */ public deprecated: boolean; @@ -12740,7 +12756,7 @@ export namespace google { interface IEditionDefault { /** EditionDefault edition */ - edition?: (string|null); + edition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); /** EditionDefault value */ value?: (string|null); @@ -12756,7 +12772,7 @@ export namespace google { constructor(properties?: google.protobuf.FieldOptions.IEditionDefault); /** EditionDefault edition. */ - public edition: string; + public edition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); /** EditionDefault value. */ public value: string; @@ -13676,17 +13692,14 @@ export namespace google { /** FeatureSet repeatedFieldEncoding */ repeatedFieldEncoding?: (google.protobuf.FeatureSet.RepeatedFieldEncoding|keyof typeof google.protobuf.FeatureSet.RepeatedFieldEncoding|null); - /** FeatureSet stringFieldValidation */ - stringFieldValidation?: (google.protobuf.FeatureSet.StringFieldValidation|keyof typeof google.protobuf.FeatureSet.StringFieldValidation|null); + /** FeatureSet utf8Validation */ + utf8Validation?: (google.protobuf.FeatureSet.Utf8Validation|keyof typeof google.protobuf.FeatureSet.Utf8Validation|null); /** FeatureSet messageEncoding */ messageEncoding?: (google.protobuf.FeatureSet.MessageEncoding|keyof typeof google.protobuf.FeatureSet.MessageEncoding|null); /** FeatureSet jsonFormat */ jsonFormat?: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat|null); - - /** FeatureSet rawFeatures */ - rawFeatures?: (google.protobuf.IFeatureSet|null); } /** Represents a FeatureSet. */ @@ -13707,8 +13720,8 @@ export namespace google { /** FeatureSet repeatedFieldEncoding. */ public repeatedFieldEncoding: (google.protobuf.FeatureSet.RepeatedFieldEncoding|keyof typeof google.protobuf.FeatureSet.RepeatedFieldEncoding); - /** FeatureSet stringFieldValidation. */ - public stringFieldValidation: (google.protobuf.FeatureSet.StringFieldValidation|keyof typeof google.protobuf.FeatureSet.StringFieldValidation); + /** FeatureSet utf8Validation. */ + public utf8Validation: (google.protobuf.FeatureSet.Utf8Validation|keyof typeof google.protobuf.FeatureSet.Utf8Validation); /** FeatureSet messageEncoding. */ public messageEncoding: (google.protobuf.FeatureSet.MessageEncoding|keyof typeof google.protobuf.FeatureSet.MessageEncoding); @@ -13716,9 +13729,6 @@ export namespace google { /** FeatureSet jsonFormat. */ public jsonFormat: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat); - /** FeatureSet rawFeatures. */ - public rawFeatures?: (google.protobuf.IFeatureSet|null); - /** * Creates a new FeatureSet instance using the specified properties. * @param [properties] Properties to set @@ -13821,11 +13831,10 @@ export namespace google { EXPANDED = 2 } - /** StringFieldValidation enum. */ - enum StringFieldValidation { - STRING_FIELD_VALIDATION_UNKNOWN = 0, - MANDATORY = 1, - HINT = 2, + /** Utf8Validation enum. */ + enum Utf8Validation { + UTF8_VALIDATION_UNKNOWN = 0, + VERIFY = 2, NONE = 3 } @@ -13844,6 +13853,221 @@ export namespace google { } } + /** Properties of a FeatureSetDefaults. */ + interface IFeatureSetDefaults { + + /** FeatureSetDefaults defaults */ + defaults?: (google.protobuf.FeatureSetDefaults.IFeatureSetEditionDefault[]|null); + + /** FeatureSetDefaults minimumEdition */ + minimumEdition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSetDefaults maximumEdition */ + maximumEdition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + } + + /** Represents a FeatureSetDefaults. */ + class FeatureSetDefaults implements IFeatureSetDefaults { + + /** + * Constructs a new FeatureSetDefaults. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFeatureSetDefaults); + + /** FeatureSetDefaults defaults. */ + public defaults: google.protobuf.FeatureSetDefaults.IFeatureSetEditionDefault[]; + + /** FeatureSetDefaults minimumEdition. */ + public minimumEdition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSetDefaults maximumEdition. */ + public maximumEdition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** + * Creates a new FeatureSetDefaults instance using the specified properties. + * @param [properties] Properties to set + * @returns FeatureSetDefaults instance + */ + public static create(properties?: google.protobuf.IFeatureSetDefaults): google.protobuf.FeatureSetDefaults; + + /** + * Encodes the specified FeatureSetDefaults message. Does not implicitly {@link google.protobuf.FeatureSetDefaults.verify|verify} messages. + * @param message FeatureSetDefaults message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IFeatureSetDefaults, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FeatureSetDefaults message, length delimited. Does not implicitly {@link google.protobuf.FeatureSetDefaults.verify|verify} messages. + * @param message FeatureSetDefaults message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IFeatureSetDefaults, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FeatureSetDefaults message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FeatureSetDefaults + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FeatureSetDefaults; + + /** + * Decodes a FeatureSetDefaults message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FeatureSetDefaults + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FeatureSetDefaults; + + /** + * Verifies a FeatureSetDefaults message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a FeatureSetDefaults message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FeatureSetDefaults + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FeatureSetDefaults; + + /** + * Creates a plain object from a FeatureSetDefaults message. Also converts values to other types if specified. + * @param message FeatureSetDefaults + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FeatureSetDefaults, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FeatureSetDefaults to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FeatureSetDefaults + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace FeatureSetDefaults { + + /** Properties of a FeatureSetEditionDefault. */ + interface IFeatureSetEditionDefault { + + /** FeatureSetEditionDefault edition */ + edition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSetEditionDefault features */ + features?: (google.protobuf.IFeatureSet|null); + } + + /** Represents a FeatureSetEditionDefault. */ + class FeatureSetEditionDefault implements IFeatureSetEditionDefault { + + /** + * Constructs a new FeatureSetEditionDefault. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FeatureSetDefaults.IFeatureSetEditionDefault); + + /** FeatureSetEditionDefault edition. */ + public edition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSetEditionDefault features. */ + public features?: (google.protobuf.IFeatureSet|null); + + /** + * Creates a new FeatureSetEditionDefault instance using the specified properties. + * @param [properties] Properties to set + * @returns FeatureSetEditionDefault instance + */ + public static create(properties?: google.protobuf.FeatureSetDefaults.IFeatureSetEditionDefault): google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault; + + /** + * Encodes the specified FeatureSetEditionDefault message. Does not implicitly {@link google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.verify|verify} messages. + * @param message FeatureSetEditionDefault message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FeatureSetDefaults.IFeatureSetEditionDefault, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FeatureSetEditionDefault message, length delimited. Does not implicitly {@link google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.verify|verify} messages. + * @param message FeatureSetEditionDefault message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FeatureSetDefaults.IFeatureSetEditionDefault, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FeatureSetEditionDefault message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FeatureSetEditionDefault + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault; + + /** + * Decodes a FeatureSetEditionDefault message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FeatureSetEditionDefault + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault; + + /** + * Verifies a FeatureSetEditionDefault message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a FeatureSetEditionDefault message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FeatureSetEditionDefault + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault; + + /** + * Creates a plain object from a FeatureSetEditionDefault message. Also converts values to other types if specified. + * @param message FeatureSetEditionDefault + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FeatureSetEditionDefault to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FeatureSetEditionDefault + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + /** Properties of a SourceCodeInfo. */ interface ISourceCodeInfo { diff --git a/protos/protos.js b/protos/protos.js index 496d846c0..b4d71be66 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -23658,6 +23658,7 @@ * @interface IMethodSettings * @property {string|null} [selector] MethodSettings selector * @property {google.api.MethodSettings.ILongRunning|null} [longRunning] MethodSettings longRunning + * @property {Array.|null} [autoPopulatedFields] MethodSettings autoPopulatedFields */ /** @@ -23669,6 +23670,7 @@ * @param {google.api.IMethodSettings=} [properties] Properties to set */ function MethodSettings(properties) { + this.autoPopulatedFields = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -23691,6 +23693,14 @@ */ MethodSettings.prototype.longRunning = null; + /** + * MethodSettings autoPopulatedFields. + * @member {Array.} autoPopulatedFields + * @memberof google.api.MethodSettings + * @instance + */ + MethodSettings.prototype.autoPopulatedFields = $util.emptyArray; + /** * Creates a new MethodSettings instance using the specified properties. * @function create @@ -23719,6 +23729,9 @@ writer.uint32(/* id 1, wireType 2 =*/10).string(message.selector); if (message.longRunning != null && Object.hasOwnProperty.call(message, "longRunning")) $root.google.api.MethodSettings.LongRunning.encode(message.longRunning, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.autoPopulatedFields != null && message.autoPopulatedFields.length) + for (var i = 0; i < message.autoPopulatedFields.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.autoPopulatedFields[i]); return writer; }; @@ -23761,6 +23774,12 @@ message.longRunning = $root.google.api.MethodSettings.LongRunning.decode(reader, reader.uint32()); break; } + case 3: { + if (!(message.autoPopulatedFields && message.autoPopulatedFields.length)) + message.autoPopulatedFields = []; + message.autoPopulatedFields.push(reader.string()); + break; + } default: reader.skipType(tag & 7); break; @@ -23804,6 +23823,13 @@ if (error) return "longRunning." + error; } + if (message.autoPopulatedFields != null && message.hasOwnProperty("autoPopulatedFields")) { + if (!Array.isArray(message.autoPopulatedFields)) + return "autoPopulatedFields: array expected"; + for (var i = 0; i < message.autoPopulatedFields.length; ++i) + if (!$util.isString(message.autoPopulatedFields[i])) + return "autoPopulatedFields: string[] expected"; + } return null; }; @@ -23826,6 +23852,13 @@ throw TypeError(".google.api.MethodSettings.longRunning: object expected"); message.longRunning = $root.google.api.MethodSettings.LongRunning.fromObject(object.longRunning); } + if (object.autoPopulatedFields) { + if (!Array.isArray(object.autoPopulatedFields)) + throw TypeError(".google.api.MethodSettings.autoPopulatedFields: array expected"); + message.autoPopulatedFields = []; + for (var i = 0; i < object.autoPopulatedFields.length; ++i) + message.autoPopulatedFields[i] = String(object.autoPopulatedFields[i]); + } return message; }; @@ -23842,6 +23875,8 @@ if (!options) options = {}; var object = {}; + if (options.arrays || options.defaults) + object.autoPopulatedFields = []; if (options.defaults) { object.selector = ""; object.longRunning = null; @@ -23850,6 +23885,11 @@ object.selector = message.selector; if (message.longRunning != null && message.hasOwnProperty("longRunning")) object.longRunning = $root.google.api.MethodSettings.LongRunning.toObject(message.longRunning, options); + if (message.autoPopulatedFields && message.autoPopulatedFields.length) { + object.autoPopulatedFields = []; + for (var j = 0; j < message.autoPopulatedFields.length; ++j) + object.autoPopulatedFields[j] = message.autoPopulatedFields[j]; + } return object; }; @@ -24250,6 +24290,7 @@ * @property {number} IMMUTABLE=5 IMMUTABLE value * @property {number} UNORDERED_LIST=6 UNORDERED_LIST value * @property {number} NON_EMPTY_DEFAULT=7 NON_EMPTY_DEFAULT value + * @property {number} IDENTIFIER=8 IDENTIFIER value */ api.FieldBehavior = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -24261,6 +24302,7 @@ values[valuesById[5] = "IMMUTABLE"] = 5; values[valuesById[6] = "UNORDERED_LIST"] = 6; values[valuesById[7] = "NON_EMPTY_DEFAULT"] = 7; + values[valuesById[8] = "IDENTIFIER"] = 8; return values; })(); @@ -25184,6 +25226,38 @@ return FileDescriptorSet; })(); + /** + * Edition enum. + * @name google.protobuf.Edition + * @enum {number} + * @property {number} EDITION_UNKNOWN=0 EDITION_UNKNOWN value + * @property {number} EDITION_PROTO2=998 EDITION_PROTO2 value + * @property {number} EDITION_PROTO3=999 EDITION_PROTO3 value + * @property {number} EDITION_2023=1000 EDITION_2023 value + * @property {number} EDITION_2024=1001 EDITION_2024 value + * @property {number} EDITION_1_TEST_ONLY=1 EDITION_1_TEST_ONLY value + * @property {number} EDITION_2_TEST_ONLY=2 EDITION_2_TEST_ONLY value + * @property {number} EDITION_99997_TEST_ONLY=99997 EDITION_99997_TEST_ONLY value + * @property {number} EDITION_99998_TEST_ONLY=99998 EDITION_99998_TEST_ONLY value + * @property {number} EDITION_99999_TEST_ONLY=99999 EDITION_99999_TEST_ONLY value + * @property {number} EDITION_MAX=2147483647 EDITION_MAX value + */ + protobuf.Edition = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "EDITION_UNKNOWN"] = 0; + values[valuesById[998] = "EDITION_PROTO2"] = 998; + values[valuesById[999] = "EDITION_PROTO3"] = 999; + values[valuesById[1000] = "EDITION_2023"] = 1000; + values[valuesById[1001] = "EDITION_2024"] = 1001; + values[valuesById[1] = "EDITION_1_TEST_ONLY"] = 1; + values[valuesById[2] = "EDITION_2_TEST_ONLY"] = 2; + values[valuesById[99997] = "EDITION_99997_TEST_ONLY"] = 99997; + values[valuesById[99998] = "EDITION_99998_TEST_ONLY"] = 99998; + values[valuesById[99999] = "EDITION_99999_TEST_ONLY"] = 99999; + values[valuesById[2147483647] = "EDITION_MAX"] = 2147483647; + return values; + })(); + protobuf.FileDescriptorProto = (function() { /** @@ -25202,7 +25276,7 @@ * @property {google.protobuf.IFileOptions|null} [options] FileDescriptorProto options * @property {google.protobuf.ISourceCodeInfo|null} [sourceCodeInfo] FileDescriptorProto sourceCodeInfo * @property {string|null} [syntax] FileDescriptorProto syntax - * @property {string|null} [edition] FileDescriptorProto edition + * @property {google.protobuf.Edition|null} [edition] FileDescriptorProto edition */ /** @@ -25325,11 +25399,11 @@ /** * FileDescriptorProto edition. - * @member {string} edition + * @member {google.protobuf.Edition} edition * @memberof google.protobuf.FileDescriptorProto * @instance */ - FileDescriptorProto.prototype.edition = ""; + FileDescriptorProto.prototype.edition = 0; /** * Creates a new FileDescriptorProto instance using the specified properties. @@ -25387,7 +25461,7 @@ if (message.syntax != null && Object.hasOwnProperty.call(message, "syntax")) writer.uint32(/* id 12, wireType 2 =*/98).string(message.syntax); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) - writer.uint32(/* id 13, wireType 2 =*/106).string(message.edition); + writer.uint32(/* id 14, wireType 0 =*/112).int32(message.edition); return writer; }; @@ -25494,8 +25568,8 @@ message.syntax = reader.string(); break; } - case 13: { - message.edition = reader.string(); + case 14: { + message.edition = reader.int32(); break; } default: @@ -25610,8 +25684,22 @@ if (!$util.isString(message.syntax)) return "syntax: string expected"; if (message.edition != null && message.hasOwnProperty("edition")) - if (!$util.isString(message.edition)) - return "edition: string expected"; + switch (message.edition) { + default: + return "edition: enum value expected"; + case 0: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } return null; }; @@ -25704,8 +25792,58 @@ } if (object.syntax != null) message.syntax = String(object.syntax); - if (object.edition != null) - message.edition = String(object.edition); + switch (object.edition) { + default: + if (typeof object.edition === "number") { + message.edition = object.edition; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.edition = 0; + break; + case "EDITION_PROTO2": + case 998: + message.edition = 998; + break; + case "EDITION_PROTO3": + case 999: + message.edition = 999; + break; + case "EDITION_2023": + case 1000: + message.edition = 1000; + break; + case "EDITION_2024": + case 1001: + message.edition = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.edition = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.edition = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.edition = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.edition = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.edition = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.edition = 2147483647; + break; + } return message; }; @@ -25737,7 +25875,7 @@ object.options = null; object.sourceCodeInfo = null; object.syntax = ""; - object.edition = ""; + object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -25785,7 +25923,7 @@ if (message.syntax != null && message.hasOwnProperty("syntax")) object.syntax = message.syntax; if (message.edition != null && message.hasOwnProperty("edition")) - object.edition = message.edition; + object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; return object; }; @@ -27824,8 +27962,8 @@ default: return "label: enum value expected"; case 1: - case 2: case 3: + case 2: break; } if (message.type != null && message.hasOwnProperty("type")) @@ -27905,14 +28043,14 @@ case 1: message.label = 1; break; - case "LABEL_REQUIRED": - case 2: - message.label = 2; - break; case "LABEL_REPEATED": case 3: message.label = 3; break; + case "LABEL_REQUIRED": + case 2: + message.label = 2; + break; } switch (object.type) { default: @@ -28142,14 +28280,14 @@ * @name google.protobuf.FieldDescriptorProto.Label * @enum {number} * @property {number} LABEL_OPTIONAL=1 LABEL_OPTIONAL value - * @property {number} LABEL_REQUIRED=2 LABEL_REQUIRED value * @property {number} LABEL_REPEATED=3 LABEL_REPEATED value + * @property {number} LABEL_REQUIRED=2 LABEL_REQUIRED value */ FieldDescriptorProto.Label = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[1] = "LABEL_OPTIONAL"] = 1; - values[valuesById[2] = "LABEL_REQUIRED"] = 2; values[valuesById[3] = "LABEL_REPEATED"] = 3; + values[valuesById[2] = "LABEL_REQUIRED"] = 2; return values; })(); @@ -29848,7 +29986,6 @@ * @property {boolean|null} [ccGenericServices] FileOptions ccGenericServices * @property {boolean|null} [javaGenericServices] FileOptions javaGenericServices * @property {boolean|null} [pyGenericServices] FileOptions pyGenericServices - * @property {boolean|null} [phpGenericServices] FileOptions phpGenericServices * @property {boolean|null} [deprecated] FileOptions deprecated * @property {boolean|null} [ccEnableArenas] FileOptions ccEnableArenas * @property {string|null} [objcClassPrefix] FileOptions objcClassPrefix @@ -29960,14 +30097,6 @@ */ FileOptions.prototype.pyGenericServices = false; - /** - * FileOptions phpGenericServices. - * @member {boolean} phpGenericServices - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.phpGenericServices = false; - /** * FileOptions deprecated. * @member {boolean} deprecated @@ -30122,8 +30251,6 @@ writer.uint32(/* id 40, wireType 2 =*/322).string(message.phpClassPrefix); if (message.phpNamespace != null && Object.hasOwnProperty.call(message, "phpNamespace")) writer.uint32(/* id 41, wireType 2 =*/330).string(message.phpNamespace); - if (message.phpGenericServices != null && Object.hasOwnProperty.call(message, "phpGenericServices")) - writer.uint32(/* id 42, wireType 0 =*/336).bool(message.phpGenericServices); if (message.phpMetadataNamespace != null && Object.hasOwnProperty.call(message, "phpMetadataNamespace")) writer.uint32(/* id 44, wireType 2 =*/354).string(message.phpMetadataNamespace); if (message.rubyPackage != null && Object.hasOwnProperty.call(message, "rubyPackage")) @@ -30210,10 +30337,6 @@ message.pyGenericServices = reader.bool(); break; } - case 42: { - message.phpGenericServices = reader.bool(); - break; - } case 23: { message.deprecated = reader.bool(); break; @@ -30337,9 +30460,6 @@ if (message.pyGenericServices != null && message.hasOwnProperty("pyGenericServices")) if (typeof message.pyGenericServices !== "boolean") return "pyGenericServices: boolean expected"; - if (message.phpGenericServices != null && message.hasOwnProperty("phpGenericServices")) - if (typeof message.phpGenericServices !== "boolean") - return "phpGenericServices: boolean expected"; if (message.deprecated != null && message.hasOwnProperty("deprecated")) if (typeof message.deprecated !== "boolean") return "deprecated: boolean expected"; @@ -30443,8 +30563,6 @@ message.javaGenericServices = Boolean(object.javaGenericServices); if (object.pyGenericServices != null) message.pyGenericServices = Boolean(object.pyGenericServices); - if (object.phpGenericServices != null) - message.phpGenericServices = Boolean(object.phpGenericServices); if (object.deprecated != null) message.deprecated = Boolean(object.deprecated); if (object.ccEnableArenas != null) @@ -30526,7 +30644,6 @@ object.swiftPrefix = ""; object.phpClassPrefix = ""; object.phpNamespace = ""; - object.phpGenericServices = false; object.phpMetadataNamespace = ""; object.rubyPackage = ""; object.features = null; @@ -30565,8 +30682,6 @@ object.phpClassPrefix = message.phpClassPrefix; if (message.phpNamespace != null && message.hasOwnProperty("phpNamespace")) object.phpNamespace = message.phpNamespace; - if (message.phpGenericServices != null && message.hasOwnProperty("phpGenericServices")) - object.phpGenericServices = message.phpGenericServices; if (message.phpMetadataNamespace != null && message.hasOwnProperty("phpMetadataNamespace")) object.phpMetadataNamespace = message.phpMetadataNamespace; if (message.rubyPackage != null && message.hasOwnProperty("rubyPackage")) @@ -31501,6 +31616,7 @@ case 5: case 6: case 7: + case 8: break; } } @@ -31717,6 +31833,10 @@ case 7: message[".google.api.fieldBehavior"][i] = 7; break; + case "IDENTIFIER": + case 8: + message[".google.api.fieldBehavior"][i] = 8; + break; } } if (object[".google.api.resourceReference"] != null) { @@ -31914,7 +32034,7 @@ * Properties of an EditionDefault. * @memberof google.protobuf.FieldOptions * @interface IEditionDefault - * @property {string|null} [edition] EditionDefault edition + * @property {google.protobuf.Edition|null} [edition] EditionDefault edition * @property {string|null} [value] EditionDefault value */ @@ -31935,11 +32055,11 @@ /** * EditionDefault edition. - * @member {string} edition + * @member {google.protobuf.Edition} edition * @memberof google.protobuf.FieldOptions.EditionDefault * @instance */ - EditionDefault.prototype.edition = ""; + EditionDefault.prototype.edition = 0; /** * EditionDefault value. @@ -31973,10 +32093,10 @@ EditionDefault.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.edition); if (message.value != null && Object.hasOwnProperty.call(message, "value")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.value); + if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.edition); return writer; }; @@ -32011,8 +32131,8 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 1: { - message.edition = reader.string(); + case 3: { + message.edition = reader.int32(); break; } case 2: { @@ -32055,8 +32175,22 @@ if (typeof message !== "object" || message === null) return "object expected"; if (message.edition != null && message.hasOwnProperty("edition")) - if (!$util.isString(message.edition)) - return "edition: string expected"; + switch (message.edition) { + default: + return "edition: enum value expected"; + case 0: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } if (message.value != null && message.hasOwnProperty("value")) if (!$util.isString(message.value)) return "value: string expected"; @@ -32075,8 +32209,58 @@ if (object instanceof $root.google.protobuf.FieldOptions.EditionDefault) return object; var message = new $root.google.protobuf.FieldOptions.EditionDefault(); - if (object.edition != null) - message.edition = String(object.edition); + switch (object.edition) { + default: + if (typeof object.edition === "number") { + message.edition = object.edition; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.edition = 0; + break; + case "EDITION_PROTO2": + case 998: + message.edition = 998; + break; + case "EDITION_PROTO3": + case 999: + message.edition = 999; + break; + case "EDITION_2023": + case 1000: + message.edition = 1000; + break; + case "EDITION_2024": + case 1001: + message.edition = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.edition = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.edition = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.edition = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.edition = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.edition = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.edition = 2147483647; + break; + } if (object.value != null) message.value = String(object.value); return message; @@ -32096,13 +32280,13 @@ options = {}; var object = {}; if (options.defaults) { - object.edition = ""; object.value = ""; + object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; } - if (message.edition != null && message.hasOwnProperty("edition")) - object.edition = message.edition; if (message.value != null && message.hasOwnProperty("value")) object.value = message.value; + if (message.edition != null && message.hasOwnProperty("edition")) + object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; return object; }; @@ -34382,10 +34566,9 @@ * @property {google.protobuf.FeatureSet.FieldPresence|null} [fieldPresence] FeatureSet fieldPresence * @property {google.protobuf.FeatureSet.EnumType|null} [enumType] FeatureSet enumType * @property {google.protobuf.FeatureSet.RepeatedFieldEncoding|null} [repeatedFieldEncoding] FeatureSet repeatedFieldEncoding - * @property {google.protobuf.FeatureSet.StringFieldValidation|null} [stringFieldValidation] FeatureSet stringFieldValidation + * @property {google.protobuf.FeatureSet.Utf8Validation|null} [utf8Validation] FeatureSet utf8Validation * @property {google.protobuf.FeatureSet.MessageEncoding|null} [messageEncoding] FeatureSet messageEncoding * @property {google.protobuf.FeatureSet.JsonFormat|null} [jsonFormat] FeatureSet jsonFormat - * @property {google.protobuf.IFeatureSet|null} [rawFeatures] FeatureSet rawFeatures */ /** @@ -34428,12 +34611,12 @@ FeatureSet.prototype.repeatedFieldEncoding = 0; /** - * FeatureSet stringFieldValidation. - * @member {google.protobuf.FeatureSet.StringFieldValidation} stringFieldValidation + * FeatureSet utf8Validation. + * @member {google.protobuf.FeatureSet.Utf8Validation} utf8Validation * @memberof google.protobuf.FeatureSet * @instance */ - FeatureSet.prototype.stringFieldValidation = 0; + FeatureSet.prototype.utf8Validation = 0; /** * FeatureSet messageEncoding. @@ -34451,14 +34634,6 @@ */ FeatureSet.prototype.jsonFormat = 0; - /** - * FeatureSet rawFeatures. - * @member {google.protobuf.IFeatureSet|null|undefined} rawFeatures - * @memberof google.protobuf.FeatureSet - * @instance - */ - FeatureSet.prototype.rawFeatures = null; - /** * Creates a new FeatureSet instance using the specified properties. * @function create @@ -34489,14 +34664,12 @@ writer.uint32(/* id 2, wireType 0 =*/16).int32(message.enumType); if (message.repeatedFieldEncoding != null && Object.hasOwnProperty.call(message, "repeatedFieldEncoding")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message.repeatedFieldEncoding); - if (message.stringFieldValidation != null && Object.hasOwnProperty.call(message, "stringFieldValidation")) - writer.uint32(/* id 4, wireType 0 =*/32).int32(message.stringFieldValidation); + if (message.utf8Validation != null && Object.hasOwnProperty.call(message, "utf8Validation")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.utf8Validation); if (message.messageEncoding != null && Object.hasOwnProperty.call(message, "messageEncoding")) writer.uint32(/* id 5, wireType 0 =*/40).int32(message.messageEncoding); if (message.jsonFormat != null && Object.hasOwnProperty.call(message, "jsonFormat")) writer.uint32(/* id 6, wireType 0 =*/48).int32(message.jsonFormat); - if (message.rawFeatures != null && Object.hasOwnProperty.call(message, "rawFeatures")) - $root.google.protobuf.FeatureSet.encode(message.rawFeatures, writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); return writer; }; @@ -34544,7 +34717,7 @@ break; } case 4: { - message.stringFieldValidation = reader.int32(); + message.utf8Validation = reader.int32(); break; } case 5: { @@ -34555,10 +34728,6 @@ message.jsonFormat = reader.int32(); break; } - case 999: { - message.rawFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); - break; - } default: reader.skipType(tag & 7); break; @@ -34622,12 +34791,11 @@ case 2: break; } - if (message.stringFieldValidation != null && message.hasOwnProperty("stringFieldValidation")) - switch (message.stringFieldValidation) { + if (message.utf8Validation != null && message.hasOwnProperty("utf8Validation")) + switch (message.utf8Validation) { default: - return "stringFieldValidation: enum value expected"; + return "utf8Validation: enum value expected"; case 0: - case 1: case 2: case 3: break; @@ -34650,11 +34818,6 @@ case 2: break; } - if (message.rawFeatures != null && message.hasOwnProperty("rawFeatures")) { - var error = $root.google.protobuf.FeatureSet.verify(message.rawFeatures); - if (error) - return "rawFeatures." + error; - } return null; }; @@ -34734,28 +34897,24 @@ message.repeatedFieldEncoding = 2; break; } - switch (object.stringFieldValidation) { + switch (object.utf8Validation) { default: - if (typeof object.stringFieldValidation === "number") { - message.stringFieldValidation = object.stringFieldValidation; + if (typeof object.utf8Validation === "number") { + message.utf8Validation = object.utf8Validation; break; } break; - case "STRING_FIELD_VALIDATION_UNKNOWN": + case "UTF8_VALIDATION_UNKNOWN": case 0: - message.stringFieldValidation = 0; - break; - case "MANDATORY": - case 1: - message.stringFieldValidation = 1; + message.utf8Validation = 0; break; - case "HINT": + case "VERIFY": case 2: - message.stringFieldValidation = 2; + message.utf8Validation = 2; break; case "NONE": case 3: - message.stringFieldValidation = 3; + message.utf8Validation = 3; break; } switch (object.messageEncoding) { @@ -34798,11 +34957,6 @@ message.jsonFormat = 2; break; } - if (object.rawFeatures != null) { - if (typeof object.rawFeatures !== "object") - throw TypeError(".google.protobuf.FeatureSet.rawFeatures: object expected"); - message.rawFeatures = $root.google.protobuf.FeatureSet.fromObject(object.rawFeatures); - } return message; }; @@ -34823,10 +34977,9 @@ object.fieldPresence = options.enums === String ? "FIELD_PRESENCE_UNKNOWN" : 0; object.enumType = options.enums === String ? "ENUM_TYPE_UNKNOWN" : 0; object.repeatedFieldEncoding = options.enums === String ? "REPEATED_FIELD_ENCODING_UNKNOWN" : 0; - object.stringFieldValidation = options.enums === String ? "STRING_FIELD_VALIDATION_UNKNOWN" : 0; + object.utf8Validation = options.enums === String ? "UTF8_VALIDATION_UNKNOWN" : 0; object.messageEncoding = options.enums === String ? "MESSAGE_ENCODING_UNKNOWN" : 0; object.jsonFormat = options.enums === String ? "JSON_FORMAT_UNKNOWN" : 0; - object.rawFeatures = null; } if (message.fieldPresence != null && message.hasOwnProperty("fieldPresence")) object.fieldPresence = options.enums === String ? $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] === undefined ? message.fieldPresence : $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] : message.fieldPresence; @@ -34834,14 +34987,12 @@ object.enumType = options.enums === String ? $root.google.protobuf.FeatureSet.EnumType[message.enumType] === undefined ? message.enumType : $root.google.protobuf.FeatureSet.EnumType[message.enumType] : message.enumType; if (message.repeatedFieldEncoding != null && message.hasOwnProperty("repeatedFieldEncoding")) object.repeatedFieldEncoding = options.enums === String ? $root.google.protobuf.FeatureSet.RepeatedFieldEncoding[message.repeatedFieldEncoding] === undefined ? message.repeatedFieldEncoding : $root.google.protobuf.FeatureSet.RepeatedFieldEncoding[message.repeatedFieldEncoding] : message.repeatedFieldEncoding; - if (message.stringFieldValidation != null && message.hasOwnProperty("stringFieldValidation")) - object.stringFieldValidation = options.enums === String ? $root.google.protobuf.FeatureSet.StringFieldValidation[message.stringFieldValidation] === undefined ? message.stringFieldValidation : $root.google.protobuf.FeatureSet.StringFieldValidation[message.stringFieldValidation] : message.stringFieldValidation; + if (message.utf8Validation != null && message.hasOwnProperty("utf8Validation")) + object.utf8Validation = options.enums === String ? $root.google.protobuf.FeatureSet.Utf8Validation[message.utf8Validation] === undefined ? message.utf8Validation : $root.google.protobuf.FeatureSet.Utf8Validation[message.utf8Validation] : message.utf8Validation; if (message.messageEncoding != null && message.hasOwnProperty("messageEncoding")) object.messageEncoding = options.enums === String ? $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] === undefined ? message.messageEncoding : $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] : message.messageEncoding; if (message.jsonFormat != null && message.hasOwnProperty("jsonFormat")) object.jsonFormat = options.enums === String ? $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] === undefined ? message.jsonFormat : $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] : message.jsonFormat; - if (message.rawFeatures != null && message.hasOwnProperty("rawFeatures")) - object.rawFeatures = $root.google.protobuf.FeatureSet.toObject(message.rawFeatures, options); return object; }; @@ -34922,19 +35073,17 @@ })(); /** - * StringFieldValidation enum. - * @name google.protobuf.FeatureSet.StringFieldValidation + * Utf8Validation enum. + * @name google.protobuf.FeatureSet.Utf8Validation * @enum {number} - * @property {number} STRING_FIELD_VALIDATION_UNKNOWN=0 STRING_FIELD_VALIDATION_UNKNOWN value - * @property {number} MANDATORY=1 MANDATORY value - * @property {number} HINT=2 HINT value + * @property {number} UTF8_VALIDATION_UNKNOWN=0 UTF8_VALIDATION_UNKNOWN value + * @property {number} VERIFY=2 VERIFY value * @property {number} NONE=3 NONE value */ - FeatureSet.StringFieldValidation = (function() { + FeatureSet.Utf8Validation = (function() { var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "STRING_FIELD_VALIDATION_UNKNOWN"] = 0; - values[valuesById[1] = "MANDATORY"] = 1; - values[valuesById[2] = "HINT"] = 2; + values[valuesById[0] = "UTF8_VALIDATION_UNKNOWN"] = 0; + values[valuesById[2] = "VERIFY"] = 2; values[valuesById[3] = "NONE"] = 3; return values; })(); @@ -34974,6 +35123,702 @@ return FeatureSet; })(); + protobuf.FeatureSetDefaults = (function() { + + /** + * Properties of a FeatureSetDefaults. + * @memberof google.protobuf + * @interface IFeatureSetDefaults + * @property {Array.|null} [defaults] FeatureSetDefaults defaults + * @property {google.protobuf.Edition|null} [minimumEdition] FeatureSetDefaults minimumEdition + * @property {google.protobuf.Edition|null} [maximumEdition] FeatureSetDefaults maximumEdition + */ + + /** + * Constructs a new FeatureSetDefaults. + * @memberof google.protobuf + * @classdesc Represents a FeatureSetDefaults. + * @implements IFeatureSetDefaults + * @constructor + * @param {google.protobuf.IFeatureSetDefaults=} [properties] Properties to set + */ + function FeatureSetDefaults(properties) { + this.defaults = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FeatureSetDefaults defaults. + * @member {Array.} defaults + * @memberof google.protobuf.FeatureSetDefaults + * @instance + */ + FeatureSetDefaults.prototype.defaults = $util.emptyArray; + + /** + * FeatureSetDefaults minimumEdition. + * @member {google.protobuf.Edition} minimumEdition + * @memberof google.protobuf.FeatureSetDefaults + * @instance + */ + FeatureSetDefaults.prototype.minimumEdition = 0; + + /** + * FeatureSetDefaults maximumEdition. + * @member {google.protobuf.Edition} maximumEdition + * @memberof google.protobuf.FeatureSetDefaults + * @instance + */ + FeatureSetDefaults.prototype.maximumEdition = 0; + + /** + * Creates a new FeatureSetDefaults instance using the specified properties. + * @function create + * @memberof google.protobuf.FeatureSetDefaults + * @static + * @param {google.protobuf.IFeatureSetDefaults=} [properties] Properties to set + * @returns {google.protobuf.FeatureSetDefaults} FeatureSetDefaults instance + */ + FeatureSetDefaults.create = function create(properties) { + return new FeatureSetDefaults(properties); + }; + + /** + * Encodes the specified FeatureSetDefaults message. Does not implicitly {@link google.protobuf.FeatureSetDefaults.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FeatureSetDefaults + * @static + * @param {google.protobuf.IFeatureSetDefaults} message FeatureSetDefaults message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSetDefaults.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.defaults != null && message.defaults.length) + for (var i = 0; i < message.defaults.length; ++i) + $root.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.encode(message.defaults[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.minimumEdition != null && Object.hasOwnProperty.call(message, "minimumEdition")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.minimumEdition); + if (message.maximumEdition != null && Object.hasOwnProperty.call(message, "maximumEdition")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.maximumEdition); + return writer; + }; + + /** + * Encodes the specified FeatureSetDefaults message, length delimited. Does not implicitly {@link google.protobuf.FeatureSetDefaults.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FeatureSetDefaults + * @static + * @param {google.protobuf.IFeatureSetDefaults} message FeatureSetDefaults message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSetDefaults.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FeatureSetDefaults message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FeatureSetDefaults + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FeatureSetDefaults} FeatureSetDefaults + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSetDefaults.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FeatureSetDefaults(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.defaults && message.defaults.length)) + message.defaults = []; + message.defaults.push($root.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.decode(reader, reader.uint32())); + break; + } + case 4: { + message.minimumEdition = reader.int32(); + break; + } + case 5: { + message.maximumEdition = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FeatureSetDefaults message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FeatureSetDefaults + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FeatureSetDefaults} FeatureSetDefaults + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSetDefaults.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FeatureSetDefaults message. + * @function verify + * @memberof google.protobuf.FeatureSetDefaults + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FeatureSetDefaults.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.defaults != null && message.hasOwnProperty("defaults")) { + if (!Array.isArray(message.defaults)) + return "defaults: array expected"; + for (var i = 0; i < message.defaults.length; ++i) { + var error = $root.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.verify(message.defaults[i]); + if (error) + return "defaults." + error; + } + } + if (message.minimumEdition != null && message.hasOwnProperty("minimumEdition")) + switch (message.minimumEdition) { + default: + return "minimumEdition: enum value expected"; + case 0: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.maximumEdition != null && message.hasOwnProperty("maximumEdition")) + switch (message.maximumEdition) { + default: + return "maximumEdition: enum value expected"; + case 0: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + return null; + }; + + /** + * Creates a FeatureSetDefaults message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FeatureSetDefaults + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FeatureSetDefaults} FeatureSetDefaults + */ + FeatureSetDefaults.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FeatureSetDefaults) + return object; + var message = new $root.google.protobuf.FeatureSetDefaults(); + if (object.defaults) { + if (!Array.isArray(object.defaults)) + throw TypeError(".google.protobuf.FeatureSetDefaults.defaults: array expected"); + message.defaults = []; + for (var i = 0; i < object.defaults.length; ++i) { + if (typeof object.defaults[i] !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.defaults: object expected"); + message.defaults[i] = $root.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.fromObject(object.defaults[i]); + } + } + switch (object.minimumEdition) { + default: + if (typeof object.minimumEdition === "number") { + message.minimumEdition = object.minimumEdition; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.minimumEdition = 0; + break; + case "EDITION_PROTO2": + case 998: + message.minimumEdition = 998; + break; + case "EDITION_PROTO3": + case 999: + message.minimumEdition = 999; + break; + case "EDITION_2023": + case 1000: + message.minimumEdition = 1000; + break; + case "EDITION_2024": + case 1001: + message.minimumEdition = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.minimumEdition = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.minimumEdition = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.minimumEdition = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.minimumEdition = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.minimumEdition = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.minimumEdition = 2147483647; + break; + } + switch (object.maximumEdition) { + default: + if (typeof object.maximumEdition === "number") { + message.maximumEdition = object.maximumEdition; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.maximumEdition = 0; + break; + case "EDITION_PROTO2": + case 998: + message.maximumEdition = 998; + break; + case "EDITION_PROTO3": + case 999: + message.maximumEdition = 999; + break; + case "EDITION_2023": + case 1000: + message.maximumEdition = 1000; + break; + case "EDITION_2024": + case 1001: + message.maximumEdition = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.maximumEdition = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.maximumEdition = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.maximumEdition = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.maximumEdition = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.maximumEdition = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.maximumEdition = 2147483647; + break; + } + return message; + }; + + /** + * Creates a plain object from a FeatureSetDefaults message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FeatureSetDefaults + * @static + * @param {google.protobuf.FeatureSetDefaults} message FeatureSetDefaults + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FeatureSetDefaults.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.defaults = []; + if (options.defaults) { + object.minimumEdition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.maximumEdition = options.enums === String ? "EDITION_UNKNOWN" : 0; + } + if (message.defaults && message.defaults.length) { + object.defaults = []; + for (var j = 0; j < message.defaults.length; ++j) + object.defaults[j] = $root.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.toObject(message.defaults[j], options); + } + if (message.minimumEdition != null && message.hasOwnProperty("minimumEdition")) + object.minimumEdition = options.enums === String ? $root.google.protobuf.Edition[message.minimumEdition] === undefined ? message.minimumEdition : $root.google.protobuf.Edition[message.minimumEdition] : message.minimumEdition; + if (message.maximumEdition != null && message.hasOwnProperty("maximumEdition")) + object.maximumEdition = options.enums === String ? $root.google.protobuf.Edition[message.maximumEdition] === undefined ? message.maximumEdition : $root.google.protobuf.Edition[message.maximumEdition] : message.maximumEdition; + return object; + }; + + /** + * Converts this FeatureSetDefaults to JSON. + * @function toJSON + * @memberof google.protobuf.FeatureSetDefaults + * @instance + * @returns {Object.} JSON object + */ + FeatureSetDefaults.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FeatureSetDefaults + * @function getTypeUrl + * @memberof google.protobuf.FeatureSetDefaults + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FeatureSetDefaults.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FeatureSetDefaults"; + }; + + FeatureSetDefaults.FeatureSetEditionDefault = (function() { + + /** + * Properties of a FeatureSetEditionDefault. + * @memberof google.protobuf.FeatureSetDefaults + * @interface IFeatureSetEditionDefault + * @property {google.protobuf.Edition|null} [edition] FeatureSetEditionDefault edition + * @property {google.protobuf.IFeatureSet|null} [features] FeatureSetEditionDefault features + */ + + /** + * Constructs a new FeatureSetEditionDefault. + * @memberof google.protobuf.FeatureSetDefaults + * @classdesc Represents a FeatureSetEditionDefault. + * @implements IFeatureSetEditionDefault + * @constructor + * @param {google.protobuf.FeatureSetDefaults.IFeatureSetEditionDefault=} [properties] Properties to set + */ + function FeatureSetEditionDefault(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FeatureSetEditionDefault edition. + * @member {google.protobuf.Edition} edition + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @instance + */ + FeatureSetEditionDefault.prototype.edition = 0; + + /** + * FeatureSetEditionDefault features. + * @member {google.protobuf.IFeatureSet|null|undefined} features + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @instance + */ + FeatureSetEditionDefault.prototype.features = null; + + /** + * Creates a new FeatureSetEditionDefault instance using the specified properties. + * @function create + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @static + * @param {google.protobuf.FeatureSetDefaults.IFeatureSetEditionDefault=} [properties] Properties to set + * @returns {google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault} FeatureSetEditionDefault instance + */ + FeatureSetEditionDefault.create = function create(properties) { + return new FeatureSetEditionDefault(properties); + }; + + /** + * Encodes the specified FeatureSetEditionDefault message. Does not implicitly {@link google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @static + * @param {google.protobuf.FeatureSetDefaults.IFeatureSetEditionDefault} message FeatureSetEditionDefault message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSetEditionDefault.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.features != null && Object.hasOwnProperty.call(message, "features")) + $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.edition); + return writer; + }; + + /** + * Encodes the specified FeatureSetEditionDefault message, length delimited. Does not implicitly {@link google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @static + * @param {google.protobuf.FeatureSetDefaults.IFeatureSetEditionDefault} message FeatureSetEditionDefault message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSetEditionDefault.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FeatureSetEditionDefault message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault} FeatureSetEditionDefault + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSetEditionDefault.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 3: { + message.edition = reader.int32(); + break; + } + case 2: { + message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FeatureSetEditionDefault message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault} FeatureSetEditionDefault + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSetEditionDefault.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FeatureSetEditionDefault message. + * @function verify + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FeatureSetEditionDefault.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.edition != null && message.hasOwnProperty("edition")) + switch (message.edition) { + default: + return "edition: enum value expected"; + case 0: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.features != null && message.hasOwnProperty("features")) { + var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (error) + return "features." + error; + } + return null; + }; + + /** + * Creates a FeatureSetEditionDefault message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault} FeatureSetEditionDefault + */ + FeatureSetEditionDefault.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault) + return object; + var message = new $root.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault(); + switch (object.edition) { + default: + if (typeof object.edition === "number") { + message.edition = object.edition; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.edition = 0; + break; + case "EDITION_PROTO2": + case 998: + message.edition = 998; + break; + case "EDITION_PROTO3": + case 999: + message.edition = 999; + break; + case "EDITION_2023": + case 1000: + message.edition = 1000; + break; + case "EDITION_2024": + case 1001: + message.edition = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.edition = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.edition = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.edition = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.edition = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.edition = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.edition = 2147483647; + break; + } + if (object.features != null) { + if (typeof object.features !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.features: object expected"); + message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + } + return message; + }; + + /** + * Creates a plain object from a FeatureSetEditionDefault message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @static + * @param {google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault} message FeatureSetEditionDefault + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FeatureSetEditionDefault.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.features = null; + object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + } + if (message.features != null && message.hasOwnProperty("features")) + object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.edition != null && message.hasOwnProperty("edition")) + object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + return object; + }; + + /** + * Converts this FeatureSetEditionDefault to JSON. + * @function toJSON + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @instance + * @returns {Object.} JSON object + */ + FeatureSetEditionDefault.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FeatureSetEditionDefault + * @function getTypeUrl + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FeatureSetEditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault"; + }; + + return FeatureSetEditionDefault; + })(); + + return FeatureSetDefaults; + })(); + protobuf.SourceCodeInfo = (function() { /** diff --git a/protos/protos.json b/protos/protos.json index f1332af79..3cdd783dd 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -2407,6 +2407,11 @@ "longRunning": { "type": "LongRunning", "id": 2 + }, + "autoPopulatedFields": { + "rule": "repeated", + "type": "string", + "id": 3 } }, "nested": { @@ -2478,7 +2483,8 @@ "INPUT_ONLY": 4, "IMMUTABLE": 5, "UNORDERED_LIST": 6, - "NON_EMPTY_DEFAULT": 7 + "NON_EMPTY_DEFAULT": 7, + "IDENTIFIER": 8 } }, "resourceReference": { @@ -2580,6 +2586,21 @@ } } }, + "Edition": { + "values": { + "EDITION_UNKNOWN": 0, + "EDITION_PROTO2": 998, + "EDITION_PROTO3": 999, + "EDITION_2023": 1000, + "EDITION_2024": 1001, + "EDITION_1_TEST_ONLY": 1, + "EDITION_2_TEST_ONLY": 2, + "EDITION_99997_TEST_ONLY": 99997, + "EDITION_99998_TEST_ONLY": 99998, + "EDITION_99999_TEST_ONLY": 99999, + "EDITION_MAX": 2147483647 + } + }, "FileDescriptorProto": { "fields": { "name": { @@ -2644,8 +2665,8 @@ "id": 12 }, "edition": { - "type": "string", - "id": 13 + "type": "Edition", + "id": 14 } } }, @@ -2754,7 +2775,8 @@ "type": "VerificationState", "id": 3, "options": { - "default": "UNVERIFIED" + "default": "UNVERIFIED", + "retention": "RETENTION_SOURCE" } } }, @@ -2876,8 +2898,8 @@ "Label": { "values": { "LABEL_OPTIONAL": 1, - "LABEL_REQUIRED": 2, - "LABEL_REPEATED": 3 + "LABEL_REPEATED": 3, + "LABEL_REQUIRED": 2 } } } @@ -3065,13 +3087,6 @@ "default": false } }, - "phpGenericServices": { - "type": "bool", - "id": 42, - "options": { - "default": false - } - }, "deprecated": { "type": "bool", "id": 23, @@ -3131,6 +3146,10 @@ ] ], "reserved": [ + [ + 42, + 42 + ], [ 38, 38 @@ -3356,8 +3375,8 @@ "EditionDefault": { "fields": { "edition": { - "type": "string", - "id": 1 + "type": "Edition", + "id": 3 }, "value": { "type": "string", @@ -3587,7 +3606,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", - "edition_defaults.edition": "2023", + "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } }, @@ -3597,7 +3616,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", - "edition_defaults.edition": "2023", + "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } }, @@ -3607,18 +3626,18 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", - "edition_defaults.edition": "2023", + "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } }, - "stringFieldValidation": { - "type": "StringFieldValidation", + "utf8Validation": { + "type": "Utf8Validation", "id": 4, "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", - "edition_defaults.edition": "2023", - "edition_defaults.value": "MANDATORY" + "edition_defaults.edition": "EDITION_PROTO3", + "edition_defaults.value": "VERIFY" } }, "messageEncoding": { @@ -3627,7 +3646,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", - "edition_defaults.edition": "2023", + "edition_defaults.edition": "EDITION_PROTO2", "edition_defaults.value": "LENGTH_PREFIXED" } }, @@ -3637,16 +3656,9 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", - "edition_defaults.edition": "2023", + "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "ALLOW" } - }, - "rawFeatures": { - "type": "FeatureSet", - "id": 999, - "options": { - "targets": "TARGET_TYPE_UNKNOWN" - } } }, "extensions": [ @@ -3663,6 +3675,12 @@ 9999 ] ], + "reserved": [ + [ + 999, + 999 + ] + ], "nested": { "FieldPresence": { "values": { @@ -3686,11 +3704,10 @@ "EXPANDED": 2 } }, - "StringFieldValidation": { + "Utf8Validation": { "values": { - "STRING_FIELD_VALIDATION_UNKNOWN": 0, - "MANDATORY": 1, - "HINT": 2, + "UTF8_VALIDATION_UNKNOWN": 0, + "VERIFY": 2, "NONE": 3 } }, @@ -3710,6 +3727,37 @@ } } }, + "FeatureSetDefaults": { + "fields": { + "defaults": { + "rule": "repeated", + "type": "FeatureSetEditionDefault", + "id": 1 + }, + "minimumEdition": { + "type": "Edition", + "id": 4 + }, + "maximumEdition": { + "type": "Edition", + "id": 5 + } + }, + "nested": { + "FeatureSetEditionDefault": { + "fields": { + "edition": { + "type": "Edition", + "id": 3 + }, + "features": { + "type": "FeatureSet", + "id": 2 + } + } + } + } + }, "SourceCodeInfo": { "fields": { "location": { From 09fc4241c8782d2f60c1a78dda316628eca5f751 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 31 Jan 2024 14:01:37 -0500 Subject: [PATCH 3/8] feat: add enforce_in_transit fields and optional annotations (#1873) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: improve retry logic for streaming API calls build: update typescript generator version to 4.3.0 The streaming API call retry logic has changed, which in some rare cases may require code changes. Please feel free to reach out to us in the issues if you experience new problems with retrying streaming calls after this update. PiperOrigin-RevId: 599622271 Source-Link: https://github.com/googleapis/googleapis/commit/6239c217f083277d7a43c8bee55969654c3b2fee Source-Link: https://github.com/googleapis/googleapis-gen/commit/da13d8222d3ba33734501999864458640f1405ae Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZGExM2Q4MjIyZDNiYTMzNzM0NTAxOTk5ODY0NDU4NjQwZjE0MDVhZSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: add `ingestion_data_source_settings` field to `Topic` PiperOrigin-RevId: 600786127 Source-Link: https://github.com/googleapis/googleapis/commit/708f769ea3987faa1b810fcb44d9e0ee9172b352 Source-Link: https://github.com/googleapis/googleapis-gen/commit/3b85818ca8f12ace75390cea24e5f3df5ac70be7 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiM2I4NTgxOGNhOGYxMmFjZTc1MzkwY2VhMjRlNWYzZGY1YWM3MGJlNyJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: add enforce_in_transit fields and optional annotations PiperOrigin-RevId: 601205737 Source-Link: https://github.com/googleapis/googleapis/commit/27f83015e8aacb6695f56435b3185f6d45fad995 Source-Link: https://github.com/googleapis/googleapis-gen/commit/daf775c7ecd90de69e1304b840a28d201c025f08 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZGFmNzc1YzdlY2Q5MGRlNjllMTMwNGI4NDBhMjhkMjAxYzAyNWYwOCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 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: Megan Potter <57276408+feywind@users.noreply.github.com> --- protos/google/pubsub/v1/pubsub.proto | 855 ++++++++++++++++----------- protos/google/pubsub/v1/schema.proto | 4 +- protos/protos.d.ts | 271 ++++++++- protos/protos.js | 713 ++++++++++++++++++++++ protos/protos.json | 600 +++++++++++++++---- src/v1/publisher_client.ts | 156 ++--- src/v1/schema_service_client.ts | 4 +- src/v1/subscriber_client.ts | 206 +++---- 8 files changed, 2175 insertions(+), 634 deletions(-) diff --git a/protos/google/pubsub/v1/pubsub.proto b/protos/google/pubsub/v1/pubsub.proto index 393893b10..c548b2680 100644 --- a/protos/google/pubsub/v1/pubsub.proto +++ b/protos/google/pubsub/v1/pubsub.proto @@ -53,8 +53,8 @@ service Publisher { option (google.api.method_signature) = "name"; } - // Updates an existing topic. Note that certain properties of a - // topic are not modifiable. + // Updates an existing topic by updating the fields specified in the update + // mask. Note that certain properties of a topic are not modifiable. rpc UpdateTopic(UpdateTopicRequest) returns (Topic) { option (google.api.http) = { patch: "/v1/{topic.name=projects/*/topics/*}" @@ -137,13 +137,21 @@ service Publisher { // A policy constraining the storage of messages published to the topic. message MessageStoragePolicy { - // A list of IDs of Google Cloud regions where messages that are published - // to the topic may be persisted in storage. Messages published by publishers - // running in non-allowed Google Cloud regions (or running outside of Google - // Cloud altogether) are routed for storage in one of the allowed regions. - // An empty list means that no regions are allowed, and is not a valid - // configuration. - repeated string allowed_persistence_regions = 1; + // Optional. A list of IDs of Google Cloud regions where messages that are + // published to the topic may be persisted in storage. Messages published by + // publishers running in non-allowed Google Cloud regions (or running outside + // of Google Cloud altogether) are routed for storage in one of the allowed + // regions. An empty list means that no regions are allowed, and is not a + // valid configuration. + repeated string allowed_persistence_regions = 1 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If true, `allowed_persistence_regions` is also used to enforce + // in-transit guarantees for messages. That is, Pub/Sub will fail + // Publish operations on this topic and subscribe operations + // on any subscription attached to this topic in any region that is + // not in `allowed_persistence_regions`. + bool enforce_in_transit = 2 [(google.api.field_behavior) = OPTIONAL]; } // Settings for validating messages published against a schema. @@ -157,18 +165,83 @@ message SchemaSettings { (google.api.resource_reference) = { type: "pubsub.googleapis.com/Schema" } ]; - // The encoding of messages validated against `schema`. - Encoding encoding = 2; + // Optional. The encoding of messages validated against `schema`. + Encoding encoding = 2 [(google.api.field_behavior) = OPTIONAL]; - // The minimum (inclusive) revision allowed for validating messages. If empty - // or not present, allow any revision to be validated against last_revision or - // any revision created before. - string first_revision_id = 3; + // Optional. The minimum (inclusive) revision allowed for validating messages. + // If empty or not present, allow any revision to be validated against + // last_revision or any revision created before. + string first_revision_id = 3 [(google.api.field_behavior) = OPTIONAL]; - // The maximum (inclusive) revision allowed for validating messages. If empty - // or not present, allow any revision to be validated against first_revision - // or any revision created after. - string last_revision_id = 4; + // Optional. The maximum (inclusive) revision allowed for validating messages. + // If empty or not present, allow any revision to be validated against + // first_revision or any revision created after. + string last_revision_id = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Settings for an ingestion data source on a topic. +message IngestionDataSourceSettings { + // Ingestion settings for Amazon Kinesis Data Streams. + message AwsKinesis { + // Possible states for managed ingestion from Amazon Kinesis Data Streams. + enum State { + // Default value. This value is unused. + STATE_UNSPECIFIED = 0; + + // Ingestion is active. + ACTIVE = 1; + + // Permission denied encountered while consuming data from Kinesis. + // This can happen if: + // - The provided `aws_role_arn` does not exist or does not have the + // appropriate permissions attached. + // - The provided `aws_role_arn` is not set up properly for Identity + // Federation using `gcp_service_account`. + // - The Pub/Sub SA is not granted the + // `iam.serviceAccounts.getOpenIdToken` permission on + // `gcp_service_account`. + KINESIS_PERMISSION_DENIED = 2; + + // Permission denied encountered while publishing to the topic. This can + // happen due to Pub/Sub SA has not been granted the [appropriate publish + // permissions](https://cloud.google.com/pubsub/docs/access-control#pubsub.publisher) + PUBLISH_PERMISSION_DENIED = 3; + + // The Kinesis stream does not exist. + STREAM_NOT_FOUND = 4; + + // The Kinesis consumer does not exist. + CONSUMER_NOT_FOUND = 5; + } + + // Output only. An output-only field that indicates the state of the Kinesis + // ingestion source. + State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. The Kinesis stream ARN to ingest data from. + string stream_arn = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The Kinesis consumer ARN to used for ingestion in Enhanced + // Fan-Out mode. The consumer must be already created and ready to be used. + string consumer_arn = 3 [(google.api.field_behavior) = REQUIRED]; + + // Required. AWS role ARN to be used for Federated Identity authentication + // with Kinesis. Check the Pub/Sub docs for how to set up this role and the + // required permissions that need to be attached to it. + string aws_role_arn = 4 [(google.api.field_behavior) = REQUIRED]; + + // Required. The GCP service account to be used for Federated Identity + // authentication with Kinesis (via a `AssumeRoleWithWebIdentity` call for + // the provided role). The `aws_role_arn` must be set up with + // `accounts.google.com:sub` equals to this service account number. + string gcp_service_account = 5 [(google.api.field_behavior) = REQUIRED]; + } + + // Only one source type can have settings set. + oneof source { + // Optional. Amazon Kinesis Data Streams. + AwsKinesis aws_kinesis = 1 [(google.api.field_behavior) = OPTIONAL]; + } } // A topic resource. @@ -179,6 +252,20 @@ message Topic { pattern: "_deleted-topic_" }; + // The state of the topic. + enum State { + // Default value. This value is unused. + STATE_UNSPECIFIED = 0; + + // The topic does not have any persistent errors. + ACTIVE = 1; + + // Ingestion from the data source has encountered a permanent error. + // See the more detailed error state in the corresponding ingestion + // source configuration. + INGESTION_RESOURCE_ERROR = 2; + } + // Required. The name of the topic. It must have the format // `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter, // and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), @@ -187,37 +274,48 @@ message Topic { // must not start with `"goog"`. string name = 1 [(google.api.field_behavior) = REQUIRED]; - // See [Creating and managing labels] + // Optional. See [Creating and managing labels] // (https://cloud.google.com/pubsub/docs/labels). - map labels = 2; + map labels = 2 [(google.api.field_behavior) = OPTIONAL]; - // Policy constraining the set of Google Cloud Platform regions where messages - // published to the topic may be stored. If not present, then no constraints - // are in effect. - MessageStoragePolicy message_storage_policy = 3; + // Optional. Policy constraining the set of Google Cloud Platform regions + // where messages published to the topic may be stored. If not present, then + // no constraints are in effect. + MessageStoragePolicy message_storage_policy = 3 + [(google.api.field_behavior) = OPTIONAL]; - // The resource name of the Cloud KMS CryptoKey to be used to protect access - // to messages published on this topic. + // Optional. The resource name of the Cloud KMS CryptoKey to be used to + // protect access to messages published on this topic. // // The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*`. - string kms_key_name = 5; + string kms_key_name = 5 [(google.api.field_behavior) = OPTIONAL]; - // Settings for validating messages published against a schema. - SchemaSettings schema_settings = 6; + // Optional. Settings for validating messages published against a schema. + SchemaSettings schema_settings = 6 [(google.api.field_behavior) = OPTIONAL]; - // Reserved for future use. This field is set only in responses from the - // server; it is ignored if it is set in any requests. - bool satisfies_pzs = 7; + // Optional. Reserved for future use. This field is set only in responses from + // the server; it is ignored if it is set in any requests. + bool satisfies_pzs = 7 [(google.api.field_behavior) = OPTIONAL]; - // Indicates the minimum duration to retain a message after it is published to - // the topic. If this field is set, messages published to the topic in the - // last `message_retention_duration` are always available to subscribers. For - // instance, it allows any attached subscription to [seek to a + // Optional. Indicates the minimum duration to retain a message after it is + // published to the topic. If this field is set, messages published to the + // topic in the last `message_retention_duration` are always available to + // subscribers. For instance, it allows any attached subscription to [seek to + // a // timestamp](https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time) // that is up to `message_retention_duration` in the past. If this field is // not set, message retention is controlled by settings on individual // subscriptions. Cannot be more than 31 days or less than 10 minutes. - google.protobuf.Duration message_retention_duration = 8; + google.protobuf.Duration message_retention_duration = 8 + [(google.api.field_behavior) = OPTIONAL]; + + // Output only. An output-only field indicating the state of the topic. + State state = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Settings for managed ingestion from a data source into this + // topic. + IngestionDataSourceSettings ingestion_data_source_settings = 10 + [(google.api.field_behavior) = OPTIONAL]; } // A message that is published by publishers and consumed by subscribers. The @@ -229,14 +327,14 @@ message Topic { // (https://cloud.google.com/pubsub/quotas) for more information about message // limits. message PubsubMessage { - // The message data field. If this field is empty, the message must contain - // at least one attribute. - bytes data = 1; + // Optional. The message data field. If this field is empty, the message must + // contain at least one attribute. + bytes data = 1 [(google.api.field_behavior) = OPTIONAL]; - // Attributes for this message. If this field is empty, the message must - // contain non-empty data. This can be used to filter messages on the + // Optional. Attributes for this message. If this field is empty, the message + // must contain non-empty data. This can be used to filter messages on the // subscription. - map attributes = 2; + map attributes = 2 [(google.api.field_behavior) = OPTIONAL]; // ID of this message, assigned by the server when the message is published. // Guaranteed to be unique within the topic. This value may be read by a @@ -249,15 +347,15 @@ message PubsubMessage { // publisher in a `Publish` call. google.protobuf.Timestamp publish_time = 4; - // If non-empty, identifies related messages for which publish order should be - // respected. If a `Subscription` has `enable_message_ordering` set to `true`, - // messages published with the same non-empty `ordering_key` value will be - // delivered to subscribers in the order in which they are received by the - // Pub/Sub system. All `PubsubMessage`s published in a given `PublishRequest` - // must specify the same `ordering_key` value. - // For more information, see [ordering + // Optional. If non-empty, identifies related messages for which publish order + // should be respected. If a `Subscription` has `enable_message_ordering` set + // to `true`, messages published with the same non-empty `ordering_key` value + // will be delivered to subscribers in the order in which they are received by + // the Pub/Sub system. All `PubsubMessage`s published in a given + // `PublishRequest` must specify the same `ordering_key` value. For more + // information, see [ordering // messages](https://cloud.google.com/pubsub/docs/ordering). - string ordering_key = 5; + string ordering_key = 5 [(google.api.field_behavior) = OPTIONAL]; } // Request for the GetTopic method. @@ -299,10 +397,10 @@ message PublishRequest { // Response for the `Publish` method. message PublishResponse { - // The server-assigned ID of each published message, in the same order as - // the messages in the request. IDs are guaranteed to be unique within - // the topic. - repeated string message_ids = 1; + // Optional. The server-assigned ID of each published message, in the same + // order as the messages in the request. IDs are guaranteed to be unique + // within the topic. + repeated string message_ids = 1 [(google.api.field_behavior) = OPTIONAL]; } // Request for the `ListTopics` method. @@ -316,23 +414,23 @@ message ListTopicsRequest { } ]; - // Maximum number of topics to return. - int32 page_size = 2; + // Optional. Maximum number of topics to return. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - // The value returned by the last `ListTopicsResponse`; indicates that this is - // a continuation of a prior `ListTopics` call, and that the system should - // return the next page of data. - string page_token = 3; + // Optional. The value returned by the last `ListTopicsResponse`; indicates + // that this is a continuation of a prior `ListTopics` call, and that the + // system should return the next page of data. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; } // Response for the `ListTopics` method. message ListTopicsResponse { - // The resulting topics. - repeated Topic topics = 1; + // Optional. The resulting topics. + repeated Topic topics = 1 [(google.api.field_behavior) = OPTIONAL]; - // If not empty, indicates that there may be more topics that match the - // request; this value should be passed in a new `ListTopicsRequest`. - string next_page_token = 2; + // Optional. If not empty, indicates that there may be more topics that match + // the request; this value should be passed in a new `ListTopicsRequest`. + string next_page_token = 2 [(google.api.field_behavior) = OPTIONAL]; } // Request for the `ListTopicSubscriptions` method. @@ -344,26 +442,30 @@ message ListTopicSubscriptionsRequest { (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" } ]; - // Maximum number of subscription names to return. - int32 page_size = 2; + // Optional. Maximum number of subscription names to return. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - // The value returned by the last `ListTopicSubscriptionsResponse`; indicates - // that this is a continuation of a prior `ListTopicSubscriptions` call, and - // that the system should return the next page of data. - string page_token = 3; + // Optional. The value returned by the last `ListTopicSubscriptionsResponse`; + // indicates that this is a continuation of a prior `ListTopicSubscriptions` + // call, and that the system should return the next page of data. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; } // Response for the `ListTopicSubscriptions` method. message ListTopicSubscriptionsResponse { - // The names of subscriptions attached to the topic specified in the request. - repeated string subscriptions = 1 [(google.api.resource_reference) = { - type: "pubsub.googleapis.com/Subscription" - }]; + // Optional. The names of subscriptions attached to the topic specified in the + // request. + repeated string subscriptions = 1 [ + (google.api.field_behavior) = OPTIONAL, + (google.api.resource_reference) = { + type: "pubsub.googleapis.com/Subscription" + } + ]; - // If not empty, indicates that there may be more subscriptions that match - // the request; this value should be passed in a new + // Optional. If not empty, indicates that there may be more subscriptions that + // match the request; this value should be passed in a new // `ListTopicSubscriptionsRequest` to get more subscriptions. - string next_page_token = 2; + string next_page_token = 2 [(google.api.field_behavior) = OPTIONAL]; } // Request for the `ListTopicSnapshots` method. @@ -375,24 +477,24 @@ message ListTopicSnapshotsRequest { (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" } ]; - // Maximum number of snapshot names to return. - int32 page_size = 2; + // Optional. Maximum number of snapshot names to return. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - // The value returned by the last `ListTopicSnapshotsResponse`; indicates - // that this is a continuation of a prior `ListTopicSnapshots` call, and - // that the system should return the next page of data. - string page_token = 3; + // Optional. The value returned by the last `ListTopicSnapshotsResponse`; + // indicates that this is a continuation of a prior `ListTopicSnapshots` call, + // and that the system should return the next page of data. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; } // Response for the `ListTopicSnapshots` method. message ListTopicSnapshotsResponse { - // The names of the snapshots that match the request. - repeated string snapshots = 1; + // Optional. The names of the snapshots that match the request. + repeated string snapshots = 1 [(google.api.field_behavior) = OPTIONAL]; - // If not empty, indicates that there may be more snapshots that match - // the request; this value should be passed in a new + // Optional. If not empty, indicates that there may be more snapshots that + // match the request; this value should be passed in a new // `ListTopicSnapshotsRequest` to get more snapshots. - string next_page_token = 2; + string next_page_token = 2 [(google.api.field_behavior) = OPTIONAL]; } // Request for the `DeleteTopic` method. @@ -458,8 +560,9 @@ service Subscriber { option (google.api.method_signature) = "subscription"; } - // Updates an existing subscription. Note that certain properties of a - // subscription, such as its topic, are not modifiable. + // Updates an existing subscription by updating the fields specified in the + // update mask. Note that certain properties of a subscription, such as its + // topic, are not modifiable. rpc UpdateSubscription(UpdateSubscriptionRequest) returns (Subscription) { option (google.api.http) = { patch: "/v1/{subscription.name=projects/*/subscriptions/*}" @@ -604,7 +707,8 @@ service Subscriber { option (google.api.method_signature) = "name,subscription"; } - // Updates an existing snapshot. Snapshots are used in + // Updates an existing snapshot by updating the fields specified in the update + // mask. Snapshots are used in // [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, // which allow you to manage message acknowledgments in bulk. That is, you can // set the acknowledgment state of messages in an existing subscription to the @@ -687,23 +791,24 @@ message Subscription { (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" } ]; - // If push delivery is used with this subscription, this field is - // used to configure it. - PushConfig push_config = 4; - - // If delivery to BigQuery is used with this subscription, this field is + // Optional. If push delivery is used with this subscription, this field is // used to configure it. - BigQueryConfig bigquery_config = 18; + PushConfig push_config = 4 [(google.api.field_behavior) = OPTIONAL]; - // If delivery to Google Cloud Storage is used with this subscription, this + // Optional. If delivery to BigQuery is used with this subscription, this // field is used to configure it. - CloudStorageConfig cloud_storage_config = 22; - - // The approximate amount of time (on a best-effort basis) Pub/Sub waits for - // the subscriber to acknowledge receipt before resending the message. In the - // interval after the message is delivered and before it is acknowledged, it - // is considered to be _outstanding_. During that time period, the - // message will not be redelivered (on a best-effort basis). + BigQueryConfig bigquery_config = 18 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If delivery to Google Cloud Storage is used with this + // subscription, this field is used to configure it. + CloudStorageConfig cloud_storage_config = 22 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The approximate amount of time (on a best-effort basis) Pub/Sub + // waits for the subscriber to acknowledge receipt before resending the + // message. In the interval after the message is delivered and before it is + // acknowledged, it is considered to be _outstanding_. During that time + // period, the message will not be redelivered (on a best-effort basis). // // For pull subscriptions, this value is used as the initial value for the ack // deadline. To override this value for a given message, call @@ -719,78 +824,81 @@ message Subscription { // // If the subscriber never acknowledges the message, the Pub/Sub // system will eventually redeliver the message. - int32 ack_deadline_seconds = 5; + int32 ack_deadline_seconds = 5 [(google.api.field_behavior) = OPTIONAL]; - // Indicates whether to retain acknowledged messages. If true, then + // Optional. Indicates whether to retain acknowledged messages. If true, then // messages are not expunged from the subscription's backlog, even if they are // acknowledged, until they fall out of the `message_retention_duration` // window. This must be true if you would like to [`Seek` to a timestamp] // (https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time) in // the past to replay previously-acknowledged messages. - bool retain_acked_messages = 7; + bool retain_acked_messages = 7 [(google.api.field_behavior) = OPTIONAL]; - // How long to retain unacknowledged messages in the subscription's backlog, - // from the moment a message is published. - // If `retain_acked_messages` is true, then this also configures the retention - // of acknowledged messages, and thus configures how far back in time a `Seek` - // can be done. Defaults to 7 days. Cannot be more than 7 days or less than 10 - // minutes. - google.protobuf.Duration message_retention_duration = 8; + // Optional. How long to retain unacknowledged messages in the subscription's + // backlog, from the moment a message is published. If `retain_acked_messages` + // is true, then this also configures the retention of acknowledged messages, + // and thus configures how far back in time a `Seek` can be done. Defaults to + // 7 days. Cannot be more than 7 days or less than 10 minutes. + google.protobuf.Duration message_retention_duration = 8 + [(google.api.field_behavior) = OPTIONAL]; - // See [Creating and managing + // Optional. See [Creating and managing // labels](https://cloud.google.com/pubsub/docs/labels). - map labels = 9; - - // If true, messages published with the same `ordering_key` in `PubsubMessage` - // will be delivered to the subscribers in the order in which they - // are received by the Pub/Sub system. Otherwise, they may be delivered in - // any order. - bool enable_message_ordering = 10; - - // A policy that specifies the conditions for this subscription's expiration. - // A subscription is considered active as long as any connected subscriber is - // successfully consuming messages from the subscription or is issuing - // operations on the subscription. If `expiration_policy` is not set, a - // *default policy* with `ttl` of 31 days will be used. The minimum allowed + map labels = 9 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If true, messages published with the same `ordering_key` in + // `PubsubMessage` will be delivered to the subscribers in the order in which + // they are received by the Pub/Sub system. Otherwise, they may be delivered + // in any order. + bool enable_message_ordering = 10 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A policy that specifies the conditions for this subscription's + // expiration. A subscription is considered active as long as any connected + // subscriber is successfully consuming messages from the subscription or is + // issuing operations on the subscription. If `expiration_policy` is not set, + // a *default policy* with `ttl` of 31 days will be used. The minimum allowed // value for `expiration_policy.ttl` is 1 day. If `expiration_policy` is set, // but `expiration_policy.ttl` is not set, the subscription never expires. - ExpirationPolicy expiration_policy = 11; + ExpirationPolicy expiration_policy = 11 + [(google.api.field_behavior) = OPTIONAL]; - // An expression written in the Pub/Sub [filter + // Optional. An expression written in the Pub/Sub [filter // language](https://cloud.google.com/pubsub/docs/filtering). If non-empty, // then only `PubsubMessage`s whose `attributes` field matches the filter are // delivered on this subscription. If empty, then no messages are filtered // out. - string filter = 12; + string filter = 12 [(google.api.field_behavior) = OPTIONAL]; - // A policy that specifies the conditions for dead lettering messages in - // this subscription. If dead_letter_policy is not set, dead lettering - // is disabled. + // Optional. A policy that specifies the conditions for dead lettering + // messages in this subscription. If dead_letter_policy is not set, dead + // lettering is disabled. // - // The Cloud Pub/Sub service account associated with this subscriptions's + // The Pub/Sub service account associated with this subscriptions's // parent project (i.e., // service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have // permission to Acknowledge() messages on this subscription. - DeadLetterPolicy dead_letter_policy = 13; + DeadLetterPolicy dead_letter_policy = 13 + [(google.api.field_behavior) = OPTIONAL]; - // A policy that specifies how Pub/Sub retries message delivery for this - // subscription. + // Optional. A policy that specifies how Pub/Sub retries message delivery for + // this subscription. // // If not set, the default retry policy is applied. This generally implies // that messages will be retried as soon as possible for healthy subscribers. // RetryPolicy will be triggered on NACKs or acknowledgement deadline // exceeded events for a given message. - RetryPolicy retry_policy = 14; + RetryPolicy retry_policy = 14 [(google.api.field_behavior) = OPTIONAL]; - // Indicates whether the subscription is detached from its topic. Detached - // subscriptions don't receive messages from their topic and don't retain any - // backlog. `Pull` and `StreamingPull` requests will return + // Optional. Indicates whether the subscription is detached from its topic. + // Detached subscriptions don't receive messages from their topic and don't + // retain any backlog. `Pull` and `StreamingPull` requests will return // FAILED_PRECONDITION. If the subscription is a push subscription, pushes to // the endpoint will not be made. - bool detached = 15; + bool detached = 15 [(google.api.field_behavior) = OPTIONAL]; - // If true, Pub/Sub provides the following guarantees for the delivery of - // a message with a given value of `message_id` on this subscription: + // Optional. If true, Pub/Sub provides the following guarantees for the + // delivery of a message with a given value of `message_id` on this + // subscription: // // * The message sent to a subscriber is guaranteed not to be resent // before the message's acknowledgement deadline expires. @@ -800,7 +908,8 @@ message Subscription { // when `enable_exactly_once_delivery` is true if the message was published // multiple times by a publisher client. These copies are considered distinct // by Pub/Sub and have distinct `message_id` values. - bool enable_exactly_once_delivery = 16; + bool enable_exactly_once_delivery = 16 + [(google.api.field_behavior) = OPTIONAL]; // Output only. Indicates the minimum duration for which a message is retained // after it is published to the subscription's topic. If this field is set, @@ -816,7 +925,7 @@ message Subscription { State state = 19 [(google.api.field_behavior) = OUTPUT_ONLY]; } -// A policy that specifies how Cloud Pub/Sub retries message delivery. +// A policy that specifies how Pub/Sub retries message delivery. // // Retry delay will be exponential based on provided minimum and maximum // backoffs. https://en.wikipedia.org/wiki/Exponential_backoff. @@ -828,13 +937,16 @@ message Subscription { // between consecutive deliveries may not match the configuration. That is, // delay can be more or less than configured backoff. message RetryPolicy { - // The minimum delay between consecutive deliveries of a given message. - // Value should be between 0 and 600 seconds. Defaults to 10 seconds. - google.protobuf.Duration minimum_backoff = 1; - - // The maximum delay between consecutive deliveries of a given message. - // Value should be between 0 and 600 seconds. Defaults to 600 seconds. - google.protobuf.Duration maximum_backoff = 2; + // Optional. The minimum delay between consecutive deliveries of a given + // message. Value should be between 0 and 600 seconds. Defaults to 10 seconds. + google.protobuf.Duration minimum_backoff = 1 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maximum delay between consecutive deliveries of a given + // message. Value should be between 0 and 600 seconds. Defaults to 600 + // seconds. + google.protobuf.Duration maximum_backoff = 2 + [(google.api.field_behavior) = OPTIONAL]; } // Dead lettering is done on a best effort basis. The same message might be @@ -843,19 +955,19 @@ message RetryPolicy { // If validation on any of the fields fails at subscription creation/updation, // the create/update subscription request will fail. message DeadLetterPolicy { - // The name of the topic to which dead letter messages should be published. - // Format is `projects/{project}/topics/{topic}`.The Cloud Pub/Sub service - // account associated with the enclosing subscription's parent project (i.e., - // service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have - // permission to Publish() to this topic. + // Optional. The name of the topic to which dead letter messages should be + // published. Format is `projects/{project}/topics/{topic}`.The Pub/Sub + // service account associated with the enclosing subscription's parent project + // (i.e., service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must + // have permission to Publish() to this topic. // // The operation will fail if the topic does not exist. // Users should ensure that there is a subscription attached to this topic // since messages published to a topic with no subscriptions are lost. - string dead_letter_topic = 1; + string dead_letter_topic = 1 [(google.api.field_behavior) = OPTIONAL]; - // The maximum number of delivery attempts for any message. The value must be - // between 5 and 100. + // Optional. The maximum number of delivery attempts for any message. The + // value must be between 5 and 100. // // The number of delivery attempts is defined as 1 + (the sum of number of // NACKs and number of times the acknowledgement deadline has been exceeded @@ -867,19 +979,19 @@ message DeadLetterPolicy { // This field will be honored on a best effort basis. // // If this parameter is 0, a default value of 5 is used. - int32 max_delivery_attempts = 2; + int32 max_delivery_attempts = 2 [(google.api.field_behavior) = OPTIONAL]; } // A policy that specifies the conditions for resource expiration (i.e., // automatic resource deletion). message ExpirationPolicy { - // Specifies the "time-to-live" duration for an associated resource. The - // resource expires if it is not active for a period of `ttl`. The definition - // of "activity" depends on the type of the associated resource. The minimum - // and maximum allowed values for `ttl` depend on the type of the associated - // resource, as well. If `ttl` is not set, the associated resource never - // expires. - google.protobuf.Duration ttl = 1; + // Optional. Specifies the "time-to-live" duration for an associated resource. + // The resource expires if it is not active for a period of `ttl`. The + // definition of "activity" depends on the type of the associated resource. + // The minimum and maximum allowed values for `ttl` depend on the type of the + // associated resource, as well. If `ttl` is not set, the associated resource + // never expires. + google.protobuf.Duration ttl = 1 [(google.api.field_behavior) = OPTIONAL]; } // Configuration for a push delivery endpoint. @@ -888,20 +1000,21 @@ message PushConfig { // [OpenID Connect // token](https://developers.google.com/identity/protocols/OpenIDConnect). message OidcToken { - // [Service account + // Optional. [Service account // email](https://cloud.google.com/iam/docs/service-accounts) // used for generating the OIDC token. For more information // on setting up authentication, see // [Push subscriptions](https://cloud.google.com/pubsub/docs/push). - string service_account_email = 1; - - // Audience to be used when generating OIDC token. The audience claim - // identifies the recipients that the JWT is intended for. The audience - // value is a single case-sensitive string. Having multiple values (array) - // for the audience field is not supported. More info about the OIDC JWT - // token audience here: https://tools.ietf.org/html/rfc7519#section-4.1.3 - // Note: if not specified, the Push endpoint URL will be used. - string audience = 2; + string service_account_email = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Audience to be used when generating OIDC token. The audience + // claim identifies the recipients that the JWT is intended for. The + // audience value is a single case-sensitive string. Having multiple values + // (array) for the audience field is not supported. More info about the OIDC + // JWT token audience here: + // https://tools.ietf.org/html/rfc7519#section-4.1.3 Note: if not specified, + // the Push endpoint URL will be used. + string audience = 2 [(google.api.field_behavior) = OPTIONAL]; } // The payload to the push endpoint is in the form of the JSON representation @@ -911,18 +1024,18 @@ message PushConfig { // Sets the `data` field as the HTTP body for delivery. message NoWrapper { - // When true, writes the Pub/Sub message metadata to + // Optional. When true, writes the Pub/Sub message metadata to // `x-goog-pubsub-:` headers of the HTTP request. Writes the // Pub/Sub message attributes to `:` headers of the HTTP request. - bool write_metadata = 1; + bool write_metadata = 1 [(google.api.field_behavior) = OPTIONAL]; } - // A URL locating the endpoint to which messages should be pushed. + // Optional. A URL locating the endpoint to which messages should be pushed. // For example, a Webhook endpoint might use `https://example.com/push`. - string push_endpoint = 1; + string push_endpoint = 1 [(google.api.field_behavior) = OPTIONAL]; - // Endpoint configuration attributes that can be used to control different - // aspects of the message delivery. + // Optional. Endpoint configuration attributes that can be used to control + // different aspects of the message delivery. // // The only currently supported attribute is `x-goog-version`, which you can // use to change the format of the pushed message. This attribute @@ -942,29 +1055,30 @@ message PushConfig { // // For example: // `attributes { "x-goog-version": "v1" }` - map attributes = 2; + map attributes = 2 [(google.api.field_behavior) = OPTIONAL]; // An authentication method used by push endpoints to verify the source of // push requests. This can be used with push endpoints that are private by - // default to allow requests only from the Cloud Pub/Sub system, for example. + // default to allow requests only from the Pub/Sub system, for example. // This field is optional and should be set only by users interested in // authenticated push. oneof authentication_method { - // If specified, Pub/Sub will generate and attach an OIDC JWT token as an - // `Authorization` header in the HTTP request for every pushed message. - OidcToken oidc_token = 3; + // Optional. If specified, Pub/Sub will generate and attach an OIDC JWT + // token as an `Authorization` header in the HTTP request for every pushed + // message. + OidcToken oidc_token = 3 [(google.api.field_behavior) = OPTIONAL]; } // The format of the delivered message to the push endpoint is defined by // the chosen wrapper. When unset, `PubsubWrapper` is used. oneof wrapper { - // When set, the payload to the push endpoint is in the form of the JSON - // representation of a PubsubMessage + // Optional. When set, the payload to the push endpoint is in the form of + // the JSON representation of a PubsubMessage // (https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#pubsubmessage). - PubsubWrapper pubsub_wrapper = 4; + PubsubWrapper pubsub_wrapper = 4 [(google.api.field_behavior) = OPTIONAL]; - // When set, the payload to the push endpoint is not wrapped. - NoWrapper no_wrapper = 5; + // Optional. When set, the payload to the push endpoint is not wrapped. + NoWrapper no_wrapper = 5 [(google.api.field_behavior) = OPTIONAL]; } } @@ -991,30 +1105,34 @@ message BigQueryConfig { // Cannot write to the BigQuery table due to a schema mismatch. SCHEMA_MISMATCH = 4; + + // 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 = 5; } - // The name of the table to which to write data, of the form + // Optional. The name of the table to which to write data, of the form // {projectId}.{datasetId}.{tableId} - string table = 1; + string table = 1 [(google.api.field_behavior) = OPTIONAL]; // Optional. When true, use the topic's schema as the columns to write to in // BigQuery, if it exists. `use_topic_schema` and `use_table_schema` cannot be // enabled at the same time. bool use_topic_schema = 2 [(google.api.field_behavior) = OPTIONAL]; - // When true, write the subscription name, message_id, publish_time, + // Optional. When true, write the subscription name, message_id, publish_time, // attributes, and ordering_key to additional columns in the table. The // subscription name, message_id, and publish_time fields are put in their own // columns while all other message properties (other than data) are written to // a JSON object in the attributes column. - bool write_metadata = 3; + bool write_metadata = 3 [(google.api.field_behavior) = OPTIONAL]; - // When true and use_topic_schema is true, any fields that are a part of the - // topic schema that are not part of the BigQuery table schema are dropped - // when writing to BigQuery. Otherwise, the schemas must be kept in sync and - // any messages with extra fields are not written and remain in the + // Optional. When true and use_topic_schema is true, any fields that are a + // part of the topic schema that are not part of the BigQuery table schema are + // dropped when writing to BigQuery. Otherwise, the schemas must be kept in + // sync and any messages with extra fields are not written and remain in the // subscription's backlog. - bool drop_unknown_fields = 4; + bool drop_unknown_fields = 4 [(google.api.field_behavior) = OPTIONAL]; // Output only. An output-only field that indicates whether or not the // subscription can receive messages. @@ -1036,13 +1154,13 @@ message CloudStorageConfig { // Configuration for writing message data in Avro format. // Message payloads and metadata will be written to files as an Avro binary. message AvroConfig { - // When true, write the subscription name, message_id, publish_time, - // attributes, and ordering_key as additional fields in the output. The - // subscription name, message_id, and publish_time fields are put in their - // own fields while all other message properties other than data (for - // example, an ordering_key, if present) are added as entries in the - // attributes map. - bool write_metadata = 1; + // Optional. When true, write the subscription name, message_id, + // publish_time, attributes, and ordering_key as additional fields in the + // output. The subscription name, message_id, and publish_time fields are + // put in their own fields while all other message properties other than + // 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]; } // Possible states for a Cloud Storage subscription. @@ -1059,6 +1177,10 @@ message CloudStorageConfig { // Cannot write to the Cloud Storage bucket because it does not exist. NOT_FOUND = 3; + + // 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; } // Required. User-provided name for the Cloud Storage bucket. @@ -1067,33 +1189,36 @@ message CloudStorageConfig { // requirements] (https://cloud.google.com/storage/docs/buckets#naming). string bucket = 1 [(google.api.field_behavior) = REQUIRED]; - // User-provided prefix for Cloud Storage filename. See the [object naming - // requirements](https://cloud.google.com/storage/docs/objects#naming). - string filename_prefix = 2; + // Optional. User-provided prefix for Cloud Storage filename. See the [object + // naming requirements](https://cloud.google.com/storage/docs/objects#naming). + string filename_prefix = 2 [(google.api.field_behavior) = OPTIONAL]; - // User-provided suffix for Cloud Storage filename. See the [object naming - // requirements](https://cloud.google.com/storage/docs/objects#naming). Must - // not end in "/". - string filename_suffix = 3; + // Optional. User-provided suffix for Cloud Storage filename. See the [object + // naming requirements](https://cloud.google.com/storage/docs/objects#naming). + // Must not end in "/". + string filename_suffix = 3 [(google.api.field_behavior) = OPTIONAL]; // Defaults to text format. oneof output_format { - // If set, message data will be written to Cloud Storage in text format. - TextConfig text_config = 4; + // Optional. If set, message data will be written to Cloud Storage in text + // format. + TextConfig text_config = 4 [(google.api.field_behavior) = OPTIONAL]; - // If set, message data will be written to Cloud Storage in Avro format. - AvroConfig avro_config = 5; + // Optional. If set, message data will be written to Cloud Storage in Avro + // format. + AvroConfig avro_config = 5 [(google.api.field_behavior) = OPTIONAL]; } - // The maximum duration that can elapse before a new Cloud Storage file is - // created. Min 1 minute, max 10 minutes, default 5 minutes. May not exceed - // the subscription's acknowledgement deadline. - google.protobuf.Duration max_duration = 6; + // Optional. The maximum duration that can elapse before a new Cloud Storage + // file is created. Min 1 minute, max 10 minutes, default 5 minutes. May not + // exceed the subscription's acknowledgement deadline. + google.protobuf.Duration max_duration = 6 + [(google.api.field_behavior) = OPTIONAL]; - // The maximum bytes that can be written to a Cloud Storage file before a new - // file is created. Min 1 KB, max 10 GiB. The max_bytes limit may be exceeded - // in cases where messages are larger than the limit. - int64 max_bytes = 7; + // Optional. The maximum bytes that can be written to a Cloud Storage file + // before a new file is created. Min 1 KB, max 10 GiB. The max_bytes limit may + // be exceeded in cases where messages are larger than the limit. + int64 max_bytes = 7 [(google.api.field_behavior) = OPTIONAL]; // Output only. An output-only field that indicates whether or not the // subscription can receive messages. @@ -1102,14 +1227,14 @@ message CloudStorageConfig { // A message and its corresponding acknowledgment ID. message ReceivedMessage { - // This ID can be used to acknowledge the received message. - string ack_id = 1; + // Optional. This ID can be used to acknowledge the received message. + string ack_id = 1 [(google.api.field_behavior) = OPTIONAL]; - // The message. - PubsubMessage message = 2; + // Optional. The message. + PubsubMessage message = 2 [(google.api.field_behavior) = OPTIONAL]; - // The approximate number of times that Cloud Pub/Sub has attempted to deliver - // the associated message to a subscriber. + // Optional. The approximate number of times that Pub/Sub has attempted to + // deliver the associated message to a subscriber. // // More precisely, this is 1 + (number of NACKs) + // (number of ack_deadline exceeds) for this message. @@ -1124,7 +1249,7 @@ message ReceivedMessage { // value of 1. The value is calculated at best effort and is approximate. // // If a DeadLetterPolicy is not set on the subscription, this will be 0. - int32 delivery_attempt = 3; + int32 delivery_attempt = 3 [(google.api.field_behavior) = OPTIONAL]; } // Request for the GetSubscription method. @@ -1161,24 +1286,25 @@ message ListSubscriptionsRequest { } ]; - // Maximum number of subscriptions to return. - int32 page_size = 2; + // Optional. Maximum number of subscriptions to return. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - // The value returned by the last `ListSubscriptionsResponse`; indicates that - // this is a continuation of a prior `ListSubscriptions` call, and that the - // system should return the next page of data. - string page_token = 3; + // Optional. The value returned by the last `ListSubscriptionsResponse`; + // indicates that this is a continuation of a prior `ListSubscriptions` call, + // and that the system should return the next page of data. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; } // Response for the `ListSubscriptions` method. message ListSubscriptionsResponse { - // The subscriptions that match the request. - repeated Subscription subscriptions = 1; + // Optional. The subscriptions that match the request. + repeated Subscription subscriptions = 1 + [(google.api.field_behavior) = OPTIONAL]; - // If not empty, indicates that there may be more subscriptions that match - // the request; this value should be passed in a new + // Optional. If not empty, indicates that there may be more subscriptions that + // match the request; this value should be passed in a new // `ListSubscriptionsRequest` to get more subscriptions. - string next_page_token = 2; + string next_page_token = 2 [(google.api.field_behavior) = OPTIONAL]; } // Request for the DeleteSubscription method. @@ -1242,12 +1368,13 @@ message PullRequest { // Response for the `Pull` method. message PullResponse { - // Received Pub/Sub messages. The list will be empty if there are no more - // messages available in the backlog, or if no messages could be returned + // Optional. Received Pub/Sub messages. The list will be empty if there 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. - repeated ReceivedMessage received_messages = 1; + repeated ReceivedMessage received_messages = 1 + [(google.api.field_behavior) = OPTIONAL]; } // Request for the ModifyAckDeadline method. @@ -1271,7 +1398,8 @@ message ModifyAckDeadlineRequest { // delivery to another subscriber client. This typically results in an // increase in the rate of message redeliveries (that is, duplicates). // The minimum deadline you can specify is 0 seconds. - // The maximum deadline you can specify is 600 seconds (10 minutes). + // The maximum deadline you can specify in a single request is 600 seconds + // (10 minutes). int32 ack_deadline_seconds = 3 [(google.api.field_behavior) = REQUIRED]; } @@ -1307,14 +1435,15 @@ message StreamingPullRequest { } ]; - // List of acknowledgement IDs for acknowledging previously received messages - // (received on this stream or a different stream). If an ack ID has expired, - // the corresponding message may be redelivered later. Acknowledging a message - // more than once will not result in an error. If the acknowledgement ID is - // malformed, the stream will be aborted with status `INVALID_ARGUMENT`. - repeated string ack_ids = 2; + // Optional. List of acknowledgement IDs for acknowledging previously received + // messages (received on this stream or a different stream). If an ack ID has + // expired, the corresponding message may be redelivered later. Acknowledging + // a message more than once will not result in an error. If the + // acknowledgement ID is malformed, the stream will be aborted with status + // `INVALID_ARGUMENT`. + repeated string ack_ids = 2 [(google.api.field_behavior) = OPTIONAL]; - // The list of new ack deadlines for the IDs listed in + // Optional. The list of new ack deadlines for the IDs listed in // `modify_deadline_ack_ids`. The size of this list must be the same as the // size of `modify_deadline_ack_ids`. If it differs the stream will be aborted // with `INVALID_ARGUMENT`. Each element in this list is applied to the @@ -1325,14 +1454,16 @@ message StreamingPullRequest { // the message is immediately made available for another streaming or // non-streaming pull request. If the value is < 0 (an error), the stream will // be aborted with status `INVALID_ARGUMENT`. - repeated int32 modify_deadline_seconds = 3; + repeated int32 modify_deadline_seconds = 3 + [(google.api.field_behavior) = OPTIONAL]; - // List of acknowledgement IDs whose deadline will be modified based on the - // corresponding element in `modify_deadline_seconds`. This field can be used - // to indicate that more time is needed to process a message by the + // Optional. List of acknowledgement IDs whose deadline will be modified based + // on the corresponding element in `modify_deadline_seconds`. This field can + // be used to indicate that more time is needed to process a message by the // subscriber, or to make the message available for redelivery if the // processing was interrupted. - repeated string modify_deadline_ack_ids = 4; + repeated string modify_deadline_ack_ids = 4 + [(google.api.field_behavior) = OPTIONAL]; // Required. The ack deadline to use for the stream. This must be provided in // the first request on the stream, but it can also be updated on subsequent @@ -1341,16 +1472,16 @@ message StreamingPullRequest { int32 stream_ack_deadline_seconds = 5 [(google.api.field_behavior) = REQUIRED]; - // A unique identifier that is used to distinguish client instances from each - // other. Only needs to be provided on the initial request. When a stream - // disconnects and reconnects for the same stream, the client_id should be set - // to the same value so that state associated with the old stream can be - // transferred to the new stream. The same client_id should not be used for + // Optional. A unique identifier that is used to distinguish client instances + // from each other. Only needs to be provided on the initial request. When a + // stream disconnects and reconnects for the same stream, the client_id should + // be set to the same value so that state associated with the old stream can + // be transferred to the new stream. The same client_id should not be used for // different client instances. - string client_id = 6; + string client_id = 6 [(google.api.field_behavior) = OPTIONAL]; - // Flow control settings for the maximum number of outstanding messages. When - // there are `max_outstanding_messages` or more currently sent to the + // Optional. Flow control settings for the maximum number of outstanding + // messages. When there are `max_outstanding_messages` currently sent to the // streaming pull client that have not yet been acked or nacked, the server // stops sending more messages. The sending of messages resumes once the // number of outstanding messages is less than this value. If the value is @@ -1358,18 +1489,18 @@ message StreamingPullRequest { // property can only be set on the initial StreamingPullRequest. If it is set // on a subsequent request, the stream will be aborted with status // `INVALID_ARGUMENT`. - int64 max_outstanding_messages = 7; - - // Flow control settings for the maximum number of outstanding bytes. When - // there are `max_outstanding_bytes` or more worth of messages currently sent - // to the streaming pull client that have not yet been acked or nacked, the - // server will stop sending more messages. The sending of messages resumes - // once the number of outstanding bytes is less than this value. If the value - // is <= 0, there is no limit to the number of outstanding bytes. This - // property can only be set on the initial StreamingPullRequest. If it is set - // on a subsequent request, the stream will be aborted with status + int64 max_outstanding_messages = 7 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Flow control settings for the maximum number of outstanding + // bytes. When there are `max_outstanding_bytes` or more worth of messages + // currently sent to the streaming pull client that have not yet been acked or + // nacked, the server will stop sending more messages. The sending of messages + // resumes once the number of outstanding bytes is less than this value. If + // the value is <= 0, there is no limit to the number of outstanding bytes. + // This property can only be set on the initial StreamingPullRequest. If it is + // set on a subsequent request, the stream will be aborted with status // `INVALID_ARGUMENT`. - int64 max_outstanding_bytes = 8; + int64 max_outstanding_bytes = 8 [(google.api.field_behavior) = OPTIONAL]; } // Response for the `StreamingPull` method. This response is used to stream @@ -1378,56 +1509,69 @@ message StreamingPullResponse { // Acknowledgement IDs sent in one or more previous requests to acknowledge a // previously received message. message AcknowledgeConfirmation { - // Successfully processed acknowledgement IDs. - repeated string ack_ids = 1; - - // List of acknowledgement IDs that were malformed or whose acknowledgement - // deadline has expired. - repeated string invalid_ack_ids = 2; - - // List of acknowledgement IDs that were out of order. - repeated string unordered_ack_ids = 3; - - // List of acknowledgement IDs that failed processing with temporary issues. - repeated string temporary_failed_ack_ids = 4; + // Optional. Successfully processed acknowledgement IDs. + repeated string ack_ids = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. List of acknowledgement IDs that were malformed or whose + // acknowledgement deadline has expired. + repeated string invalid_ack_ids = 2 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. List of acknowledgement IDs that were out of order. + repeated string unordered_ack_ids = 3 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. List of acknowledgement IDs that failed processing with + // temporary issues. + repeated string temporary_failed_ack_ids = 4 + [(google.api.field_behavior) = OPTIONAL]; } // Acknowledgement IDs sent in one or more previous requests to modify the // deadline for a specific message. message ModifyAckDeadlineConfirmation { - // Successfully processed acknowledgement IDs. - repeated string ack_ids = 1; - - // List of acknowledgement IDs that were malformed or whose acknowledgement - // deadline has expired. - repeated string invalid_ack_ids = 2; - - // List of acknowledgement IDs that failed processing with temporary issues. - repeated string temporary_failed_ack_ids = 3; + // Optional. Successfully processed acknowledgement IDs. + repeated string ack_ids = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. List of acknowledgement IDs that were malformed or whose + // acknowledgement deadline has expired. + repeated string invalid_ack_ids = 2 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. List of acknowledgement IDs that failed processing with + // temporary issues. + repeated string temporary_failed_ack_ids = 3 + [(google.api.field_behavior) = OPTIONAL]; } // Subscription properties sent as part of the response. message SubscriptionProperties { - // True iff exactly once delivery is enabled for this subscription. - bool exactly_once_delivery_enabled = 1; + // Optional. True iff exactly once delivery is enabled for this + // subscription. + bool exactly_once_delivery_enabled = 1 + [(google.api.field_behavior) = OPTIONAL]; - // True iff message ordering is enabled for this subscription. - bool message_ordering_enabled = 2; + // Optional. True iff message ordering is enabled for this subscription. + bool message_ordering_enabled = 2 [(google.api.field_behavior) = OPTIONAL]; } - // Received Pub/Sub messages. This will not be empty. - repeated ReceivedMessage received_messages = 1; + // Optional. Received Pub/Sub messages. This will not be empty. + repeated ReceivedMessage received_messages = 1 + [(google.api.field_behavior) = OPTIONAL]; - // This field will only be set if `enable_exactly_once_delivery` is set to - // `true`. - AcknowledgeConfirmation acknowledge_confirmation = 5; + // Optional. This field will only be set if `enable_exactly_once_delivery` is + // set to `true`. + AcknowledgeConfirmation acknowledge_confirmation = 5 + [(google.api.field_behavior) = OPTIONAL]; - // This field will only be set if `enable_exactly_once_delivery` is set to - // `true`. - ModifyAckDeadlineConfirmation modify_ack_deadline_confirmation = 3; + // Optional. This field will only be set if `enable_exactly_once_delivery` is + // set to `true`. + ModifyAckDeadlineConfirmation modify_ack_deadline_confirmation = 3 + [(google.api.field_behavior) = OPTIONAL]; - // Properties associated with this subscription. - SubscriptionProperties subscription_properties = 4; + // Optional. Properties associated with this subscription. + SubscriptionProperties subscription_properties = 4 + [(google.api.field_behavior) = OPTIONAL]; } // Request for the `CreateSnapshot` method. @@ -1459,9 +1603,9 @@ message CreateSnapshotRequest { } ]; - // See [Creating and managing + // Optional. See [Creating and managing // labels](https://cloud.google.com/pubsub/docs/labels). - map labels = 3; + map labels = 3 [(google.api.field_behavior) = OPTIONAL]; } // Request for the UpdateSnapshot method. @@ -1486,15 +1630,17 @@ message Snapshot { pattern: "projects/{project}/snapshots/{snapshot}" }; - // The name of the snapshot. - string name = 1; + // Optional. The name of the snapshot. + string name = 1 [(google.api.field_behavior) = OPTIONAL]; - // The name of the topic from which this snapshot is retaining messages. + // Optional. The name of the topic from which this snapshot is retaining + // messages. string topic = 2 [ + (google.api.field_behavior) = OPTIONAL, (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" } ]; - // The snapshot is guaranteed to exist up until this time. + // Optional. The snapshot is guaranteed to exist up until this time. // A newly-created snapshot expires no later than 7 days from the time of its // creation. Its exact lifetime is determined at creation by the existing // backlog in the source subscription. Specifically, the lifetime of the @@ -1504,11 +1650,12 @@ message Snapshot { // will always capture this 3-day-old backlog as long as the snapshot // exists -- will expire in 4 days. The service will refuse to create a // snapshot that would expire in less than 1 hour after creation. - google.protobuf.Timestamp expire_time = 3; + google.protobuf.Timestamp expire_time = 3 + [(google.api.field_behavior) = OPTIONAL]; - // See [Creating and managing labels] + // Optional. See [Creating and managing labels] // (https://cloud.google.com/pubsub/docs/labels). - map labels = 4; + map labels = 4 [(google.api.field_behavior) = OPTIONAL]; } // Request for the GetSnapshot method. @@ -1532,23 +1679,24 @@ message ListSnapshotsRequest { } ]; - // Maximum number of snapshots to return. - int32 page_size = 2; + // Optional. Maximum number of snapshots to return. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - // The value returned by the last `ListSnapshotsResponse`; indicates that this - // is a continuation of a prior `ListSnapshots` call, and that the system - // should return the next page of data. - string page_token = 3; + // Optional. The value returned by the last `ListSnapshotsResponse`; indicates + // that this is a continuation of a prior `ListSnapshots` call, and that the + // system should return the next page of data. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; } // Response for the `ListSnapshots` method. message ListSnapshotsResponse { - // The resulting snapshots. - repeated Snapshot snapshots = 1; + // Optional. The resulting snapshots. + repeated Snapshot snapshots = 1 [(google.api.field_behavior) = OPTIONAL]; - // If not empty, indicates that there may be more snapshot that match the - // request; this value should be passed in a new `ListSnapshotsRequest`. - string next_page_token = 2; + // Optional. If not empty, indicates that there may be more snapshot that + // match the request; this value should be passed in a new + // `ListSnapshotsRequest`. + string next_page_token = 2 [(google.api.field_behavior) = OPTIONAL]; } // Request for the `DeleteSnapshot` method. @@ -1572,7 +1720,7 @@ message SeekRequest { ]; oneof target { - // The time to seek to. + // Optional. The time to seek to. // Messages retained in the subscription that were published before this // time are marked as acknowledged, and messages retained in the // subscription that were published after this time are marked as @@ -1583,14 +1731,17 @@ message SeekRequest { // window (or to a point before the system's notion of the subscription // creation time), only retained messages will be marked as unacknowledged, // and already-expunged messages will not be restored. - google.protobuf.Timestamp time = 2; - - // The snapshot to seek to. The snapshot's topic must be the same as that of - // the provided subscription. - // Format is `projects/{project}/snapshots/{snap}`. - string snapshot = 3 [(google.api.resource_reference) = { - type: "pubsub.googleapis.com/Snapshot" - }]; + google.protobuf.Timestamp time = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The snapshot to seek to. The snapshot's topic must be the same + // as that of the provided subscription. Format is + // `projects/{project}/snapshots/{snap}`. + string snapshot = 3 [ + (google.api.field_behavior) = OPTIONAL, + (google.api.resource_reference) = { + type: "pubsub.googleapis.com/Snapshot" + } + ]; } } diff --git a/protos/google/pubsub/v1/schema.proto b/protos/google/pubsub/v1/schema.proto index 32aa0d75c..bd17cf0f8 100644 --- a/protos/google/pubsub/v1/schema.proto +++ b/protos/google/pubsub/v1/schema.proto @@ -202,8 +202,8 @@ message CreateSchemaRequest { // The ID to use for the schema, which will become the final component of // the schema's resource name. // - // See https://cloud.google.com/pubsub/docs/admin#resource_names for resource - // name constraints. + // See https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names for + // resource name constraints. string schema_id = 3; } diff --git a/protos/protos.d.ts b/protos/protos.d.ts index eb65e4c60..dda11424e 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -241,6 +241,9 @@ export namespace google { /** MessageStoragePolicy allowedPersistenceRegions */ allowedPersistenceRegions?: (string[]|null); + + /** MessageStoragePolicy enforceInTransit */ + enforceInTransit?: (boolean|null); } /** Represents a MessageStoragePolicy. */ @@ -255,6 +258,9 @@ export namespace google { /** MessageStoragePolicy allowedPersistenceRegions. */ public allowedPersistenceRegions: string[]; + /** MessageStoragePolicy enforceInTransit. */ + public enforceInTransit: boolean; + /** * Creates a new MessageStoragePolicy instance using the specified properties. * @param [properties] Properties to set @@ -448,6 +454,243 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of an IngestionDataSourceSettings. */ + interface IIngestionDataSourceSettings { + + /** IngestionDataSourceSettings awsKinesis */ + awsKinesis?: (google.pubsub.v1.IngestionDataSourceSettings.IAwsKinesis|null); + } + + /** Represents an IngestionDataSourceSettings. */ + class IngestionDataSourceSettings implements IIngestionDataSourceSettings { + + /** + * Constructs a new IngestionDataSourceSettings. + * @param [properties] Properties to set + */ + constructor(properties?: google.pubsub.v1.IIngestionDataSourceSettings); + + /** IngestionDataSourceSettings awsKinesis. */ + public awsKinesis?: (google.pubsub.v1.IngestionDataSourceSettings.IAwsKinesis|null); + + /** IngestionDataSourceSettings source. */ + public source?: "awsKinesis"; + + /** + * Creates a new IngestionDataSourceSettings instance using the specified properties. + * @param [properties] Properties to set + * @returns IngestionDataSourceSettings instance + */ + public static create(properties?: google.pubsub.v1.IIngestionDataSourceSettings): google.pubsub.v1.IngestionDataSourceSettings; + + /** + * Encodes the specified IngestionDataSourceSettings message. Does not implicitly {@link google.pubsub.v1.IngestionDataSourceSettings.verify|verify} messages. + * @param message IngestionDataSourceSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.pubsub.v1.IIngestionDataSourceSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified IngestionDataSourceSettings message, length delimited. Does not implicitly {@link google.pubsub.v1.IngestionDataSourceSettings.verify|verify} messages. + * @param message IngestionDataSourceSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.pubsub.v1.IIngestionDataSourceSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an IngestionDataSourceSettings message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns IngestionDataSourceSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.pubsub.v1.IngestionDataSourceSettings; + + /** + * Decodes an IngestionDataSourceSettings message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns IngestionDataSourceSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.pubsub.v1.IngestionDataSourceSettings; + + /** + * Verifies an IngestionDataSourceSettings message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an IngestionDataSourceSettings message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns IngestionDataSourceSettings + */ + public static fromObject(object: { [k: string]: any }): google.pubsub.v1.IngestionDataSourceSettings; + + /** + * Creates a plain object from an IngestionDataSourceSettings message. Also converts values to other types if specified. + * @param message IngestionDataSourceSettings + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.pubsub.v1.IngestionDataSourceSettings, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this IngestionDataSourceSettings to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for IngestionDataSourceSettings + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace IngestionDataSourceSettings { + + /** Properties of an AwsKinesis. */ + interface IAwsKinesis { + + /** AwsKinesis state */ + state?: (google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis.State|keyof typeof google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis.State|null); + + /** AwsKinesis streamArn */ + streamArn?: (string|null); + + /** AwsKinesis consumerArn */ + consumerArn?: (string|null); + + /** AwsKinesis awsRoleArn */ + awsRoleArn?: (string|null); + + /** AwsKinesis gcpServiceAccount */ + gcpServiceAccount?: (string|null); + } + + /** Represents an AwsKinesis. */ + class AwsKinesis implements IAwsKinesis { + + /** + * Constructs a new AwsKinesis. + * @param [properties] Properties to set + */ + constructor(properties?: google.pubsub.v1.IngestionDataSourceSettings.IAwsKinesis); + + /** AwsKinesis state. */ + public state: (google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis.State|keyof typeof google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis.State); + + /** AwsKinesis streamArn. */ + public streamArn: string; + + /** AwsKinesis consumerArn. */ + public consumerArn: string; + + /** AwsKinesis awsRoleArn. */ + public awsRoleArn: string; + + /** AwsKinesis gcpServiceAccount. */ + public gcpServiceAccount: string; + + /** + * Creates a new AwsKinesis instance using the specified properties. + * @param [properties] Properties to set + * @returns AwsKinesis instance + */ + public static create(properties?: google.pubsub.v1.IngestionDataSourceSettings.IAwsKinesis): google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis; + + /** + * Encodes the specified AwsKinesis message. Does not implicitly {@link google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis.verify|verify} messages. + * @param message AwsKinesis message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.pubsub.v1.IngestionDataSourceSettings.IAwsKinesis, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AwsKinesis message, length delimited. Does not implicitly {@link google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis.verify|verify} messages. + * @param message AwsKinesis message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.pubsub.v1.IngestionDataSourceSettings.IAwsKinesis, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AwsKinesis message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AwsKinesis + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis; + + /** + * Decodes an AwsKinesis message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AwsKinesis + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis; + + /** + * Verifies an AwsKinesis message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an AwsKinesis message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AwsKinesis + */ + public static fromObject(object: { [k: string]: any }): google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis; + + /** + * Creates a plain object from an AwsKinesis message. Also converts values to other types if specified. + * @param message AwsKinesis + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AwsKinesis to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AwsKinesis + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace AwsKinesis { + + /** State enum. */ + enum State { + STATE_UNSPECIFIED = 0, + ACTIVE = 1, + KINESIS_PERMISSION_DENIED = 2, + PUBLISH_PERMISSION_DENIED = 3, + STREAM_NOT_FOUND = 4, + CONSUMER_NOT_FOUND = 5 + } + } + } + /** Properties of a Topic. */ interface ITopic { @@ -471,6 +714,12 @@ export namespace google { /** Topic messageRetentionDuration */ messageRetentionDuration?: (google.protobuf.IDuration|null); + + /** Topic state */ + state?: (google.pubsub.v1.Topic.State|keyof typeof google.pubsub.v1.Topic.State|null); + + /** Topic ingestionDataSourceSettings */ + ingestionDataSourceSettings?: (google.pubsub.v1.IIngestionDataSourceSettings|null); } /** Represents a Topic. */ @@ -503,6 +752,12 @@ export namespace google { /** Topic messageRetentionDuration. */ public messageRetentionDuration?: (google.protobuf.IDuration|null); + /** Topic state. */ + public state: (google.pubsub.v1.Topic.State|keyof typeof google.pubsub.v1.Topic.State); + + /** Topic ingestionDataSourceSettings. */ + public ingestionDataSourceSettings?: (google.pubsub.v1.IIngestionDataSourceSettings|null); + /** * Creates a new Topic instance using the specified properties. * @param [properties] Properties to set @@ -581,6 +836,16 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + namespace Topic { + + /** State enum. */ + enum State { + STATE_UNSPECIFIED = 0, + ACTIVE = 1, + INGESTION_RESOURCE_ERROR = 2 + } + } + /** Properties of a PubsubMessage. */ interface IPubsubMessage { @@ -3451,7 +3716,8 @@ export namespace google { ACTIVE = 1, PERMISSION_DENIED = 2, NOT_FOUND = 3, - SCHEMA_MISMATCH = 4 + SCHEMA_MISMATCH = 4, + IN_TRANSIT_LOCATION_RESTRICTION = 5 } } @@ -3792,7 +4058,8 @@ export namespace google { STATE_UNSPECIFIED = 0, ACTIVE = 1, PERMISSION_DENIED = 2, - NOT_FOUND = 3 + NOT_FOUND = 3, + IN_TRANSIT_LOCATION_RESTRICTION = 4 } } diff --git a/protos/protos.js b/protos/protos.js index b4d71be66..fa620f8e5 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -396,6 +396,7 @@ * @memberof google.pubsub.v1 * @interface IMessageStoragePolicy * @property {Array.|null} [allowedPersistenceRegions] MessageStoragePolicy allowedPersistenceRegions + * @property {boolean|null} [enforceInTransit] MessageStoragePolicy enforceInTransit */ /** @@ -422,6 +423,14 @@ */ MessageStoragePolicy.prototype.allowedPersistenceRegions = $util.emptyArray; + /** + * MessageStoragePolicy enforceInTransit. + * @member {boolean} enforceInTransit + * @memberof google.pubsub.v1.MessageStoragePolicy + * @instance + */ + MessageStoragePolicy.prototype.enforceInTransit = false; + /** * Creates a new MessageStoragePolicy instance using the specified properties. * @function create @@ -449,6 +458,8 @@ if (message.allowedPersistenceRegions != null && message.allowedPersistenceRegions.length) for (var i = 0; i < message.allowedPersistenceRegions.length; ++i) writer.uint32(/* id 1, wireType 2 =*/10).string(message.allowedPersistenceRegions[i]); + if (message.enforceInTransit != null && Object.hasOwnProperty.call(message, "enforceInTransit")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.enforceInTransit); return writer; }; @@ -489,6 +500,10 @@ message.allowedPersistenceRegions.push(reader.string()); break; } + case 2: { + message.enforceInTransit = reader.bool(); + break; + } default: reader.skipType(tag & 7); break; @@ -531,6 +546,9 @@ if (!$util.isString(message.allowedPersistenceRegions[i])) return "allowedPersistenceRegions: string[] expected"; } + if (message.enforceInTransit != null && message.hasOwnProperty("enforceInTransit")) + if (typeof message.enforceInTransit !== "boolean") + return "enforceInTransit: boolean expected"; return null; }; @@ -553,6 +571,8 @@ for (var i = 0; i < object.allowedPersistenceRegions.length; ++i) message.allowedPersistenceRegions[i] = String(object.allowedPersistenceRegions[i]); } + if (object.enforceInTransit != null) + message.enforceInTransit = Boolean(object.enforceInTransit); return message; }; @@ -571,11 +591,15 @@ var object = {}; if (options.arrays || options.defaults) object.allowedPersistenceRegions = []; + if (options.defaults) + object.enforceInTransit = false; if (message.allowedPersistenceRegions && message.allowedPersistenceRegions.length) { object.allowedPersistenceRegions = []; for (var j = 0; j < message.allowedPersistenceRegions.length; ++j) object.allowedPersistenceRegions[j] = message.allowedPersistenceRegions[j]; } + if (message.enforceInTransit != null && message.hasOwnProperty("enforceInTransit")) + object.enforceInTransit = message.enforceInTransit; return object; }; @@ -905,6 +929,590 @@ return SchemaSettings; })(); + v1.IngestionDataSourceSettings = (function() { + + /** + * Properties of an IngestionDataSourceSettings. + * @memberof google.pubsub.v1 + * @interface IIngestionDataSourceSettings + * @property {google.pubsub.v1.IngestionDataSourceSettings.IAwsKinesis|null} [awsKinesis] IngestionDataSourceSettings awsKinesis + */ + + /** + * Constructs a new IngestionDataSourceSettings. + * @memberof google.pubsub.v1 + * @classdesc Represents an IngestionDataSourceSettings. + * @implements IIngestionDataSourceSettings + * @constructor + * @param {google.pubsub.v1.IIngestionDataSourceSettings=} [properties] Properties to set + */ + function IngestionDataSourceSettings(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * IngestionDataSourceSettings awsKinesis. + * @member {google.pubsub.v1.IngestionDataSourceSettings.IAwsKinesis|null|undefined} awsKinesis + * @memberof google.pubsub.v1.IngestionDataSourceSettings + * @instance + */ + IngestionDataSourceSettings.prototype.awsKinesis = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * IngestionDataSourceSettings source. + * @member {"awsKinesis"|undefined} source + * @memberof google.pubsub.v1.IngestionDataSourceSettings + * @instance + */ + Object.defineProperty(IngestionDataSourceSettings.prototype, "source", { + get: $util.oneOfGetter($oneOfFields = ["awsKinesis"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new IngestionDataSourceSettings instance using the specified properties. + * @function create + * @memberof google.pubsub.v1.IngestionDataSourceSettings + * @static + * @param {google.pubsub.v1.IIngestionDataSourceSettings=} [properties] Properties to set + * @returns {google.pubsub.v1.IngestionDataSourceSettings} IngestionDataSourceSettings instance + */ + IngestionDataSourceSettings.create = function create(properties) { + return new IngestionDataSourceSettings(properties); + }; + + /** + * Encodes the specified IngestionDataSourceSettings message. Does not implicitly {@link google.pubsub.v1.IngestionDataSourceSettings.verify|verify} messages. + * @function encode + * @memberof google.pubsub.v1.IngestionDataSourceSettings + * @static + * @param {google.pubsub.v1.IIngestionDataSourceSettings} message IngestionDataSourceSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + IngestionDataSourceSettings.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.awsKinesis != null && Object.hasOwnProperty.call(message, "awsKinesis")) + $root.google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis.encode(message.awsKinesis, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified IngestionDataSourceSettings message, length delimited. Does not implicitly {@link google.pubsub.v1.IngestionDataSourceSettings.verify|verify} messages. + * @function encodeDelimited + * @memberof google.pubsub.v1.IngestionDataSourceSettings + * @static + * @param {google.pubsub.v1.IIngestionDataSourceSettings} message IngestionDataSourceSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + IngestionDataSourceSettings.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an IngestionDataSourceSettings message from the specified reader or buffer. + * @function decode + * @memberof google.pubsub.v1.IngestionDataSourceSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.pubsub.v1.IngestionDataSourceSettings} IngestionDataSourceSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + IngestionDataSourceSettings.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.pubsub.v1.IngestionDataSourceSettings(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.awsKinesis = $root.google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an IngestionDataSourceSettings message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.pubsub.v1.IngestionDataSourceSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.pubsub.v1.IngestionDataSourceSettings} IngestionDataSourceSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + IngestionDataSourceSettings.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an IngestionDataSourceSettings message. + * @function verify + * @memberof google.pubsub.v1.IngestionDataSourceSettings + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + IngestionDataSourceSettings.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.awsKinesis != null && message.hasOwnProperty("awsKinesis")) { + properties.source = 1; + { + var error = $root.google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis.verify(message.awsKinesis); + if (error) + return "awsKinesis." + error; + } + } + return null; + }; + + /** + * Creates an IngestionDataSourceSettings message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.pubsub.v1.IngestionDataSourceSettings + * @static + * @param {Object.} object Plain object + * @returns {google.pubsub.v1.IngestionDataSourceSettings} IngestionDataSourceSettings + */ + IngestionDataSourceSettings.fromObject = function fromObject(object) { + if (object instanceof $root.google.pubsub.v1.IngestionDataSourceSettings) + return object; + var message = new $root.google.pubsub.v1.IngestionDataSourceSettings(); + if (object.awsKinesis != null) { + if (typeof object.awsKinesis !== "object") + throw TypeError(".google.pubsub.v1.IngestionDataSourceSettings.awsKinesis: object expected"); + message.awsKinesis = $root.google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis.fromObject(object.awsKinesis); + } + return message; + }; + + /** + * Creates a plain object from an IngestionDataSourceSettings message. Also converts values to other types if specified. + * @function toObject + * @memberof google.pubsub.v1.IngestionDataSourceSettings + * @static + * @param {google.pubsub.v1.IngestionDataSourceSettings} message IngestionDataSourceSettings + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + IngestionDataSourceSettings.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.awsKinesis != null && message.hasOwnProperty("awsKinesis")) { + object.awsKinesis = $root.google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis.toObject(message.awsKinesis, options); + if (options.oneofs) + object.source = "awsKinesis"; + } + return object; + }; + + /** + * Converts this IngestionDataSourceSettings to JSON. + * @function toJSON + * @memberof google.pubsub.v1.IngestionDataSourceSettings + * @instance + * @returns {Object.} JSON object + */ + IngestionDataSourceSettings.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for IngestionDataSourceSettings + * @function getTypeUrl + * @memberof google.pubsub.v1.IngestionDataSourceSettings + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + IngestionDataSourceSettings.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.pubsub.v1.IngestionDataSourceSettings"; + }; + + IngestionDataSourceSettings.AwsKinesis = (function() { + + /** + * Properties of an AwsKinesis. + * @memberof google.pubsub.v1.IngestionDataSourceSettings + * @interface IAwsKinesis + * @property {google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis.State|null} [state] AwsKinesis state + * @property {string|null} [streamArn] AwsKinesis streamArn + * @property {string|null} [consumerArn] AwsKinesis consumerArn + * @property {string|null} [awsRoleArn] AwsKinesis awsRoleArn + * @property {string|null} [gcpServiceAccount] AwsKinesis gcpServiceAccount + */ + + /** + * Constructs a new AwsKinesis. + * @memberof google.pubsub.v1.IngestionDataSourceSettings + * @classdesc Represents an AwsKinesis. + * @implements IAwsKinesis + * @constructor + * @param {google.pubsub.v1.IngestionDataSourceSettings.IAwsKinesis=} [properties] Properties to set + */ + function AwsKinesis(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * AwsKinesis state. + * @member {google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis.State} state + * @memberof google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis + * @instance + */ + AwsKinesis.prototype.state = 0; + + /** + * AwsKinesis streamArn. + * @member {string} streamArn + * @memberof google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis + * @instance + */ + AwsKinesis.prototype.streamArn = ""; + + /** + * AwsKinesis consumerArn. + * @member {string} consumerArn + * @memberof google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis + * @instance + */ + AwsKinesis.prototype.consumerArn = ""; + + /** + * AwsKinesis awsRoleArn. + * @member {string} awsRoleArn + * @memberof google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis + * @instance + */ + AwsKinesis.prototype.awsRoleArn = ""; + + /** + * AwsKinesis gcpServiceAccount. + * @member {string} gcpServiceAccount + * @memberof google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis + * @instance + */ + AwsKinesis.prototype.gcpServiceAccount = ""; + + /** + * Creates a new AwsKinesis instance using the specified properties. + * @function create + * @memberof google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis + * @static + * @param {google.pubsub.v1.IngestionDataSourceSettings.IAwsKinesis=} [properties] Properties to set + * @returns {google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis} AwsKinesis instance + */ + AwsKinesis.create = function create(properties) { + return new AwsKinesis(properties); + }; + + /** + * Encodes the specified AwsKinesis message. Does not implicitly {@link google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis.verify|verify} messages. + * @function encode + * @memberof google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis + * @static + * @param {google.pubsub.v1.IngestionDataSourceSettings.IAwsKinesis} message AwsKinesis message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AwsKinesis.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.state != null && Object.hasOwnProperty.call(message, "state")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.state); + if (message.streamArn != null && Object.hasOwnProperty.call(message, "streamArn")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.streamArn); + if (message.consumerArn != null && Object.hasOwnProperty.call(message, "consumerArn")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.consumerArn); + if (message.awsRoleArn != null && Object.hasOwnProperty.call(message, "awsRoleArn")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.awsRoleArn); + if (message.gcpServiceAccount != null && Object.hasOwnProperty.call(message, "gcpServiceAccount")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.gcpServiceAccount); + return writer; + }; + + /** + * Encodes the specified AwsKinesis message, length delimited. Does not implicitly {@link google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis.verify|verify} messages. + * @function encodeDelimited + * @memberof google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis + * @static + * @param {google.pubsub.v1.IngestionDataSourceSettings.IAwsKinesis} message AwsKinesis message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AwsKinesis.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AwsKinesis message from the specified reader or buffer. + * @function decode + * @memberof google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis} AwsKinesis + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AwsKinesis.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.state = reader.int32(); + break; + } + case 2: { + message.streamArn = reader.string(); + break; + } + case 3: { + message.consumerArn = reader.string(); + break; + } + case 4: { + message.awsRoleArn = reader.string(); + break; + } + case 5: { + message.gcpServiceAccount = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AwsKinesis message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis} AwsKinesis + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AwsKinesis.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AwsKinesis message. + * @function verify + * @memberof google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AwsKinesis.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.state != null && message.hasOwnProperty("state")) + switch (message.state) { + default: + return "state: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + break; + } + if (message.streamArn != null && message.hasOwnProperty("streamArn")) + if (!$util.isString(message.streamArn)) + return "streamArn: string expected"; + if (message.consumerArn != null && message.hasOwnProperty("consumerArn")) + if (!$util.isString(message.consumerArn)) + return "consumerArn: string expected"; + if (message.awsRoleArn != null && message.hasOwnProperty("awsRoleArn")) + if (!$util.isString(message.awsRoleArn)) + return "awsRoleArn: string expected"; + if (message.gcpServiceAccount != null && message.hasOwnProperty("gcpServiceAccount")) + if (!$util.isString(message.gcpServiceAccount)) + return "gcpServiceAccount: string expected"; + return null; + }; + + /** + * Creates an AwsKinesis message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis + * @static + * @param {Object.} object Plain object + * @returns {google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis} AwsKinesis + */ + AwsKinesis.fromObject = function fromObject(object) { + if (object instanceof $root.google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis) + return object; + var message = new $root.google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis(); + switch (object.state) { + default: + if (typeof object.state === "number") { + message.state = object.state; + break; + } + break; + case "STATE_UNSPECIFIED": + case 0: + message.state = 0; + break; + case "ACTIVE": + case 1: + message.state = 1; + break; + case "KINESIS_PERMISSION_DENIED": + case 2: + message.state = 2; + break; + case "PUBLISH_PERMISSION_DENIED": + case 3: + message.state = 3; + break; + case "STREAM_NOT_FOUND": + case 4: + message.state = 4; + break; + case "CONSUMER_NOT_FOUND": + case 5: + message.state = 5; + break; + } + if (object.streamArn != null) + message.streamArn = String(object.streamArn); + if (object.consumerArn != null) + message.consumerArn = String(object.consumerArn); + if (object.awsRoleArn != null) + message.awsRoleArn = String(object.awsRoleArn); + if (object.gcpServiceAccount != null) + message.gcpServiceAccount = String(object.gcpServiceAccount); + return message; + }; + + /** + * Creates a plain object from an AwsKinesis message. Also converts values to other types if specified. + * @function toObject + * @memberof google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis + * @static + * @param {google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis} message AwsKinesis + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AwsKinesis.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; + object.streamArn = ""; + object.consumerArn = ""; + object.awsRoleArn = ""; + object.gcpServiceAccount = ""; + } + if (message.state != null && message.hasOwnProperty("state")) + object.state = options.enums === String ? $root.google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis.State[message.state] === undefined ? message.state : $root.google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis.State[message.state] : message.state; + if (message.streamArn != null && message.hasOwnProperty("streamArn")) + object.streamArn = message.streamArn; + if (message.consumerArn != null && message.hasOwnProperty("consumerArn")) + object.consumerArn = message.consumerArn; + if (message.awsRoleArn != null && message.hasOwnProperty("awsRoleArn")) + object.awsRoleArn = message.awsRoleArn; + if (message.gcpServiceAccount != null && message.hasOwnProperty("gcpServiceAccount")) + object.gcpServiceAccount = message.gcpServiceAccount; + return object; + }; + + /** + * Converts this AwsKinesis to JSON. + * @function toJSON + * @memberof google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis + * @instance + * @returns {Object.} JSON object + */ + AwsKinesis.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AwsKinesis + * @function getTypeUrl + * @memberof google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AwsKinesis.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis"; + }; + + /** + * State enum. + * @name google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis.State + * @enum {number} + * @property {number} STATE_UNSPECIFIED=0 STATE_UNSPECIFIED value + * @property {number} ACTIVE=1 ACTIVE value + * @property {number} KINESIS_PERMISSION_DENIED=2 KINESIS_PERMISSION_DENIED value + * @property {number} PUBLISH_PERMISSION_DENIED=3 PUBLISH_PERMISSION_DENIED value + * @property {number} STREAM_NOT_FOUND=4 STREAM_NOT_FOUND value + * @property {number} CONSUMER_NOT_FOUND=5 CONSUMER_NOT_FOUND value + */ + AwsKinesis.State = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "ACTIVE"] = 1; + values[valuesById[2] = "KINESIS_PERMISSION_DENIED"] = 2; + values[valuesById[3] = "PUBLISH_PERMISSION_DENIED"] = 3; + values[valuesById[4] = "STREAM_NOT_FOUND"] = 4; + values[valuesById[5] = "CONSUMER_NOT_FOUND"] = 5; + return values; + })(); + + return AwsKinesis; + })(); + + return IngestionDataSourceSettings; + })(); + v1.Topic = (function() { /** @@ -918,6 +1526,8 @@ * @property {google.pubsub.v1.ISchemaSettings|null} [schemaSettings] Topic schemaSettings * @property {boolean|null} [satisfiesPzs] Topic satisfiesPzs * @property {google.protobuf.IDuration|null} [messageRetentionDuration] Topic messageRetentionDuration + * @property {google.pubsub.v1.Topic.State|null} [state] Topic state + * @property {google.pubsub.v1.IIngestionDataSourceSettings|null} [ingestionDataSourceSettings] Topic ingestionDataSourceSettings */ /** @@ -992,6 +1602,22 @@ */ Topic.prototype.messageRetentionDuration = null; + /** + * Topic state. + * @member {google.pubsub.v1.Topic.State} state + * @memberof google.pubsub.v1.Topic + * @instance + */ + Topic.prototype.state = 0; + + /** + * Topic ingestionDataSourceSettings. + * @member {google.pubsub.v1.IIngestionDataSourceSettings|null|undefined} ingestionDataSourceSettings + * @memberof google.pubsub.v1.Topic + * @instance + */ + Topic.prototype.ingestionDataSourceSettings = null; + /** * Creates a new Topic instance using the specified properties. * @function create @@ -1031,6 +1657,10 @@ writer.uint32(/* id 7, wireType 0 =*/56).bool(message.satisfiesPzs); if (message.messageRetentionDuration != null && Object.hasOwnProperty.call(message, "messageRetentionDuration")) $root.google.protobuf.Duration.encode(message.messageRetentionDuration, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.state != null && Object.hasOwnProperty.call(message, "state")) + writer.uint32(/* id 9, wireType 0 =*/72).int32(message.state); + if (message.ingestionDataSourceSettings != null && Object.hasOwnProperty.call(message, "ingestionDataSourceSettings")) + $root.google.pubsub.v1.IngestionDataSourceSettings.encode(message.ingestionDataSourceSettings, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); return writer; }; @@ -1112,6 +1742,14 @@ message.messageRetentionDuration = $root.google.protobuf.Duration.decode(reader, reader.uint32()); break; } + case 9: { + message.state = reader.int32(); + break; + } + case 10: { + message.ingestionDataSourceSettings = $root.google.pubsub.v1.IngestionDataSourceSettings.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -1179,6 +1817,20 @@ if (error) return "messageRetentionDuration." + error; } + if (message.state != null && message.hasOwnProperty("state")) + switch (message.state) { + default: + return "state: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.ingestionDataSourceSettings != null && message.hasOwnProperty("ingestionDataSourceSettings")) { + var error = $root.google.pubsub.v1.IngestionDataSourceSettings.verify(message.ingestionDataSourceSettings); + if (error) + return "ingestionDataSourceSettings." + error; + } return null; }; @@ -1222,6 +1874,31 @@ throw TypeError(".google.pubsub.v1.Topic.messageRetentionDuration: object expected"); message.messageRetentionDuration = $root.google.protobuf.Duration.fromObject(object.messageRetentionDuration); } + switch (object.state) { + default: + if (typeof object.state === "number") { + message.state = object.state; + break; + } + break; + case "STATE_UNSPECIFIED": + case 0: + message.state = 0; + break; + case "ACTIVE": + case 1: + message.state = 1; + break; + case "INGESTION_RESOURCE_ERROR": + case 2: + message.state = 2; + break; + } + if (object.ingestionDataSourceSettings != null) { + if (typeof object.ingestionDataSourceSettings !== "object") + throw TypeError(".google.pubsub.v1.Topic.ingestionDataSourceSettings: object expected"); + message.ingestionDataSourceSettings = $root.google.pubsub.v1.IngestionDataSourceSettings.fromObject(object.ingestionDataSourceSettings); + } return message; }; @@ -1247,6 +1924,8 @@ object.schemaSettings = null; object.satisfiesPzs = false; object.messageRetentionDuration = null; + object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; + object.ingestionDataSourceSettings = null; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -1266,6 +1945,10 @@ object.satisfiesPzs = message.satisfiesPzs; if (message.messageRetentionDuration != null && message.hasOwnProperty("messageRetentionDuration")) object.messageRetentionDuration = $root.google.protobuf.Duration.toObject(message.messageRetentionDuration, options); + if (message.state != null && message.hasOwnProperty("state")) + object.state = options.enums === String ? $root.google.pubsub.v1.Topic.State[message.state] === undefined ? message.state : $root.google.pubsub.v1.Topic.State[message.state] : message.state; + if (message.ingestionDataSourceSettings != null && message.hasOwnProperty("ingestionDataSourceSettings")) + object.ingestionDataSourceSettings = $root.google.pubsub.v1.IngestionDataSourceSettings.toObject(message.ingestionDataSourceSettings, options); return object; }; @@ -1295,6 +1978,22 @@ return typeUrlPrefix + "/google.pubsub.v1.Topic"; }; + /** + * State enum. + * @name google.pubsub.v1.Topic.State + * @enum {number} + * @property {number} STATE_UNSPECIFIED=0 STATE_UNSPECIFIED value + * @property {number} ACTIVE=1 ACTIVE value + * @property {number} INGESTION_RESOURCE_ERROR=2 INGESTION_RESOURCE_ERROR value + */ + Topic.State = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "ACTIVE"] = 1; + values[valuesById[2] = "INGESTION_RESOURCE_ERROR"] = 2; + return values; + })(); + return Topic; })(); @@ -7783,6 +8482,7 @@ case 2: case 3: case 4: + case 5: break; } if (message.useTableSchema != null && message.hasOwnProperty("useTableSchema")) @@ -7838,6 +8538,10 @@ case 4: message.state = 4; break; + case "IN_TRANSIT_LOCATION_RESTRICTION": + case 5: + message.state = 5; + break; } if (object.useTableSchema != null) message.useTableSchema = Boolean(object.useTableSchema); @@ -7915,6 +8619,7 @@ * @property {number} PERMISSION_DENIED=2 PERMISSION_DENIED value * @property {number} NOT_FOUND=3 NOT_FOUND value * @property {number} SCHEMA_MISMATCH=4 SCHEMA_MISMATCH value + * @property {number} IN_TRANSIT_LOCATION_RESTRICTION=5 IN_TRANSIT_LOCATION_RESTRICTION value */ BigQueryConfig.State = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -7923,6 +8628,7 @@ values[valuesById[2] = "PERMISSION_DENIED"] = 2; values[valuesById[3] = "NOT_FOUND"] = 3; values[valuesById[4] = "SCHEMA_MISMATCH"] = 4; + values[valuesById[5] = "IN_TRANSIT_LOCATION_RESTRICTION"] = 5; return values; })(); @@ -8223,6 +8929,7 @@ case 1: case 2: case 3: + case 4: break; } return null; @@ -8293,6 +9000,10 @@ case 3: message.state = 3; break; + case "IN_TRANSIT_LOCATION_RESTRICTION": + case 4: + message.state = 4; + break; } return message; }; @@ -8762,6 +9473,7 @@ * @property {number} ACTIVE=1 ACTIVE value * @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 */ CloudStorageConfig.State = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -8769,6 +9481,7 @@ values[valuesById[1] = "ACTIVE"] = 1; values[valuesById[2] = "PERMISSION_DENIED"] = 2; values[valuesById[3] = "NOT_FOUND"] = 3; + values[valuesById[4] = "IN_TRANSIT_LOCATION_RESTRICTION"] = 4; return values; })(); diff --git a/protos/protos.json b/protos/protos.json index 3cdd783dd..9fecd46b3 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -193,7 +193,17 @@ "allowedPersistenceRegions": { "rule": "repeated", "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "enforceInTransit": { + "type": "bool", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -209,15 +219,95 @@ }, "encoding": { "type": "Encoding", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "firstRevisionId": { "type": "string", - "id": 3 + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "lastRevisionId": { "type": "string", - "id": 4 + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "IngestionDataSourceSettings": { + "oneofs": { + "source": { + "oneof": [ + "awsKinesis" + ] + } + }, + "fields": { + "awsKinesis": { + "type": "AwsKinesis", + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + }, + "nested": { + "AwsKinesis": { + "fields": { + "state": { + "type": "State", + "id": 1, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "streamArn": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "consumerArn": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "awsRoleArn": { + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "gcpServiceAccount": { + "type": "string", + "id": 5, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + }, + "nested": { + "State": { + "values": { + "STATE_UNSPECIFIED": 0, + "ACTIVE": 1, + "KINESIS_PERMISSION_DENIED": 2, + "PUBLISH_PERMISSION_DENIED": 3, + "STREAM_NOT_FOUND": 4, + "CONSUMER_NOT_FOUND": 5 + } + } + } } } }, @@ -237,27 +327,68 @@ "labels": { "keyType": "string", "type": "string", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "messageStoragePolicy": { "type": "MessageStoragePolicy", - "id": 3 + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "kmsKeyName": { "type": "string", - "id": 5 + "id": 5, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "schemaSettings": { "type": "SchemaSettings", - "id": 6 + "id": 6, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "satisfiesPzs": { "type": "bool", - "id": 7 + "id": 7, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "messageRetentionDuration": { "type": "google.protobuf.Duration", - "id": 8 + "id": 8, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "state": { + "type": "State", + "id": 9, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "ingestionDataSourceSettings": { + "type": "IngestionDataSourceSettings", + "id": 10, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + }, + "nested": { + "State": { + "values": { + "STATE_UNSPECIFIED": 0, + "ACTIVE": 1, + "INGESTION_RESOURCE_ERROR": 2 + } } } }, @@ -265,12 +396,18 @@ "fields": { "data": { "type": "bytes", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "attributes": { "keyType": "string", "type": "string", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "messageId": { "type": "string", @@ -282,7 +419,10 @@ }, "orderingKey": { "type": "string", - "id": 5 + "id": 5, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -341,7 +481,10 @@ "messageIds": { "rule": "repeated", "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -357,11 +500,17 @@ }, "pageSize": { "type": "int32", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "pageToken": { "type": "string", - "id": 3 + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -370,11 +519,17 @@ "topics": { "rule": "repeated", "type": "Topic", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "nextPageToken": { "type": "string", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -390,11 +545,17 @@ }, "pageSize": { "type": "int32", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "pageToken": { "type": "string", - "id": 3 + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -405,12 +566,16 @@ "type": "string", "id": 1, "options": { + "(google.api.field_behavior)": "OPTIONAL", "(google.api.resource_reference).type": "pubsub.googleapis.com/Subscription" } }, "nextPageToken": { "type": "string", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -426,11 +591,17 @@ }, "pageSize": { "type": "int32", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "pageToken": { "type": "string", - "id": 3 + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -439,11 +610,17 @@ "snapshots": { "rule": "repeated", "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "nextPageToken": { "type": "string", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -798,60 +975,102 @@ }, "pushConfig": { "type": "PushConfig", - "id": 4 + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "bigqueryConfig": { "type": "BigQueryConfig", - "id": 18 + "id": 18, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "cloudStorageConfig": { "type": "CloudStorageConfig", - "id": 22 + "id": 22, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "ackDeadlineSeconds": { "type": "int32", - "id": 5 + "id": 5, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "retainAckedMessages": { "type": "bool", - "id": 7 + "id": 7, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "messageRetentionDuration": { "type": "google.protobuf.Duration", - "id": 8 + "id": 8, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "labels": { "keyType": "string", "type": "string", - "id": 9 + "id": 9, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "enableMessageOrdering": { "type": "bool", - "id": 10 + "id": 10, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "expirationPolicy": { "type": "ExpirationPolicy", - "id": 11 + "id": 11, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "filter": { "type": "string", - "id": 12 + "id": 12, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "deadLetterPolicy": { "type": "DeadLetterPolicy", - "id": 13 + "id": 13, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "retryPolicy": { "type": "RetryPolicy", - "id": 14 + "id": 14, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "detached": { "type": "bool", - "id": 15 + "id": 15, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "enableExactlyOnceDelivery": { "type": "bool", - "id": 16 + "id": 16, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "topicMessageRetentionDuration": { "type": "google.protobuf.Duration", @@ -882,11 +1101,17 @@ "fields": { "minimumBackoff": { "type": "google.protobuf.Duration", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "maximumBackoff": { "type": "google.protobuf.Duration", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -894,11 +1119,17 @@ "fields": { "deadLetterTopic": { "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "maxDeliveryAttempts": { "type": "int32", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -906,7 +1137,10 @@ "fields": { "ttl": { "type": "google.protobuf.Duration", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -927,24 +1161,39 @@ "fields": { "pushEndpoint": { "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "attributes": { "keyType": "string", "type": "string", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "oidcToken": { "type": "OidcToken", - "id": 3 + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "pubsubWrapper": { "type": "PubsubWrapper", - "id": 4 + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "noWrapper": { "type": "NoWrapper", - "id": 5 + "id": 5, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } }, "nested": { @@ -952,11 +1201,17 @@ "fields": { "serviceAccountEmail": { "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "audience": { "type": "string", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -967,7 +1222,10 @@ "fields": { "writeMetadata": { "type": "bool", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } } @@ -977,7 +1235,10 @@ "fields": { "table": { "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "useTopicSchema": { "type": "bool", @@ -988,11 +1249,17 @@ }, "writeMetadata": { "type": "bool", - "id": 3 + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "dropUnknownFields": { "type": "bool", - "id": 4 + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "state": { "type": "State", @@ -1016,7 +1283,8 @@ "ACTIVE": 1, "PERMISSION_DENIED": 2, "NOT_FOUND": 3, - "SCHEMA_MISMATCH": 4 + "SCHEMA_MISMATCH": 4, + "IN_TRANSIT_LOCATION_RESTRICTION": 5 } } } @@ -1040,27 +1308,45 @@ }, "filenamePrefix": { "type": "string", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "filenameSuffix": { "type": "string", - "id": 3 + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "textConfig": { "type": "TextConfig", - "id": 4 + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "avroConfig": { "type": "AvroConfig", - "id": 5 + "id": 5, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "maxDuration": { "type": "google.protobuf.Duration", - "id": 6 + "id": 6, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "maxBytes": { "type": "int64", - "id": 7 + "id": 7, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "state": { "type": "State", @@ -1078,7 +1364,10 @@ "fields": { "writeMetadata": { "type": "bool", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -1087,7 +1376,8 @@ "STATE_UNSPECIFIED": 0, "ACTIVE": 1, "PERMISSION_DENIED": 2, - "NOT_FOUND": 3 + "NOT_FOUND": 3, + "IN_TRANSIT_LOCATION_RESTRICTION": 4 } } } @@ -1096,15 +1386,24 @@ "fields": { "ackId": { "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "message": { "type": "PubsubMessage", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "deliveryAttempt": { "type": "int32", - "id": 3 + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -1150,11 +1449,17 @@ }, "pageSize": { "type": "int32", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "pageToken": { "type": "string", - "id": 3 + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -1163,11 +1468,17 @@ "subscriptions": { "rule": "repeated", "type": "Subscription", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "nextPageToken": { "type": "string", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -1234,7 +1545,10 @@ "receivedMessages": { "rule": "repeated", "type": "ReceivedMessage", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -1298,17 +1612,26 @@ "ackIds": { "rule": "repeated", "type": "string", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "modifyDeadlineSeconds": { "rule": "repeated", "type": "int32", - "id": 3 + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "modifyDeadlineAckIds": { "rule": "repeated", "type": "string", - "id": 4 + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "streamAckDeadlineSeconds": { "type": "int32", @@ -1319,15 +1642,24 @@ }, "clientId": { "type": "string", - "id": 6 + "id": 6, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "maxOutstandingMessages": { "type": "int64", - "id": 7 + "id": 7, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "maxOutstandingBytes": { "type": "int64", - "id": 8 + "id": 8, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -1336,19 +1668,31 @@ "receivedMessages": { "rule": "repeated", "type": "ReceivedMessage", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "acknowledgeConfirmation": { "type": "AcknowledgeConfirmation", - "id": 5 + "id": 5, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "modifyAckDeadlineConfirmation": { "type": "ModifyAckDeadlineConfirmation", - "id": 3 + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "subscriptionProperties": { "type": "SubscriptionProperties", - "id": 4 + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } }, "nested": { @@ -1357,22 +1701,34 @@ "ackIds": { "rule": "repeated", "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "invalidAckIds": { "rule": "repeated", "type": "string", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "unorderedAckIds": { "rule": "repeated", "type": "string", - "id": 3 + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "temporaryFailedAckIds": { "rule": "repeated", "type": "string", - "id": 4 + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -1381,17 +1737,26 @@ "ackIds": { "rule": "repeated", "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "invalidAckIds": { "rule": "repeated", "type": "string", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "temporaryFailedAckIds": { "rule": "repeated", "type": "string", - "id": 3 + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -1399,11 +1764,17 @@ "fields": { "exactlyOnceDeliveryEnabled": { "type": "bool", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "messageOrderingEnabled": { "type": "bool", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } } @@ -1430,7 +1801,10 @@ "labels": { "keyType": "string", "type": "string", - "id": 3 + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -1460,23 +1834,33 @@ "fields": { "name": { "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "topic": { "type": "string", "id": 2, "options": { + "(google.api.field_behavior)": "OPTIONAL", "(google.api.resource_reference).type": "pubsub.googleapis.com/Topic" } }, "expireTime": { "type": "google.protobuf.Timestamp", - "id": 3 + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "labels": { "keyType": "string", "type": "string", - "id": 4 + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -1504,11 +1888,17 @@ }, "pageSize": { "type": "int32", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "pageToken": { "type": "string", - "id": 3 + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -1517,11 +1907,17 @@ "snapshots": { "rule": "repeated", "type": "Snapshot", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "nextPageToken": { "type": "string", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -1557,12 +1953,16 @@ }, "time": { "type": "google.protobuf.Timestamp", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } }, "snapshot": { "type": "string", "id": 3, "options": { + "(google.api.field_behavior)": "OPTIONAL", "(google.api.resource_reference).type": "pubsub.googleapis.com/Snapshot" } } diff --git a/src/v1/publisher_client.ts b/src/v1/publisher_client.ts index 33e4e85db..d08e12139 100644 --- a/src/v1/publisher_client.ts +++ b/src/v1/publisher_client.ts @@ -397,32 +397,38 @@ export class PublisherClient { * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent * signs (`%`). It must be between 3 and 255 characters in length, and it * must not start with `"goog"`. - * @param {number[]} request.labels - * See [Creating and managing labels] + * @param {number[]} [request.labels] + * Optional. See [Creating and managing labels] * (https://cloud.google.com/pubsub/docs/labels). - * @param {google.pubsub.v1.MessageStoragePolicy} request.messageStoragePolicy - * Policy constraining the set of Google Cloud Platform regions where messages - * published to the topic may be stored. If not present, then no constraints - * are in effect. - * @param {string} request.kmsKeyName - * The resource name of the Cloud KMS CryptoKey to be used to protect access - * to messages published on this topic. + * @param {google.pubsub.v1.MessageStoragePolicy} [request.messageStoragePolicy] + * Optional. Policy constraining the set of Google Cloud Platform regions + * where messages published to the topic may be stored. If not present, then + * no constraints are in effect. + * @param {string} [request.kmsKeyName] + * Optional. The resource name of the Cloud KMS CryptoKey to be used to + * protect access to messages published on this topic. * * The expected format is `projects/* /locations/* /keyRings/* /cryptoKeys/*`. - * @param {google.pubsub.v1.SchemaSettings} request.schemaSettings - * Settings for validating messages published against a schema. - * @param {boolean} request.satisfiesPzs - * Reserved for future use. This field is set only in responses from the - * server; it is ignored if it is set in any requests. - * @param {google.protobuf.Duration} request.messageRetentionDuration - * Indicates the minimum duration to retain a message after it is published to - * the topic. If this field is set, messages published to the topic in the - * last `message_retention_duration` are always available to subscribers. For - * instance, it allows any attached subscription to [seek to a + * @param {google.pubsub.v1.SchemaSettings} [request.schemaSettings] + * Optional. Settings for validating messages published against a schema. + * @param {boolean} [request.satisfiesPzs] + * Optional. Reserved for future use. This field is set only in responses from + * the server; it is ignored if it is set in any requests. + * @param {google.protobuf.Duration} [request.messageRetentionDuration] + * Optional. Indicates the minimum duration to retain a message after it is + * published to the topic. If this field is set, messages published to the + * topic in the last `message_retention_duration` are always available to + * subscribers. For instance, it allows any attached subscription to [seek to + * a * timestamp](https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time) * that is up to `message_retention_duration` in the past. If this field is * not set, message retention is controlled by settings on individual * subscriptions. Cannot be more than 31 days or less than 10 minutes. + * @param {google.pubsub.v1.Topic.State} request.state + * Output only. An output-only field indicating the state of the topic. + * @param {google.pubsub.v1.IngestionDataSourceSettings} [request.ingestionDataSourceSettings] + * Optional. Settings for managed ingestion from a data source into this + * topic. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -497,8 +503,8 @@ export class PublisherClient { return this.innerApiCalls.createTopic(request, options, callback); } /** - * Updates an existing topic. Note that certain properties of a - * topic are not modifiable. + * Updates an existing topic by updating the fields specified in the update + * mask. Note that certain properties of a topic are not modifiable. * * @param {Object} request * The request object that will be sent. @@ -926,12 +932,12 @@ export class PublisherClient { * @param {string} request.project * Required. The name of the project in which to list topics. * Format is `projects/{project-id}`. - * @param {number} request.pageSize - * Maximum number of topics to return. - * @param {string} request.pageToken - * The value returned by the last `ListTopicsResponse`; indicates that this is - * a continuation of a prior `ListTopics` call, and that the system should - * return the next page of data. + * @param {number} [request.pageSize] + * Optional. Maximum number of topics to return. + * @param {string} [request.pageToken] + * Optional. The value returned by the last `ListTopicsResponse`; indicates + * that this is a continuation of a prior `ListTopics` call, and that the + * system should return the next page of data. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -1018,12 +1024,12 @@ export class PublisherClient { * @param {string} request.project * Required. The name of the project in which to list topics. * Format is `projects/{project-id}`. - * @param {number} request.pageSize - * Maximum number of topics to return. - * @param {string} request.pageToken - * The value returned by the last `ListTopicsResponse`; indicates that this is - * a continuation of a prior `ListTopics` call, and that the system should - * return the next page of data. + * @param {number} [request.pageSize] + * Optional. Maximum number of topics to return. + * @param {string} [request.pageToken] + * Optional. The value returned by the last `ListTopicsResponse`; indicates + * that this is a continuation of a prior `ListTopics` call, and that the + * system should return the next page of data. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Stream} @@ -1066,12 +1072,12 @@ export class PublisherClient { * @param {string} request.project * Required. The name of the project in which to list topics. * Format is `projects/{project-id}`. - * @param {number} request.pageSize - * Maximum number of topics to return. - * @param {string} request.pageToken - * The value returned by the last `ListTopicsResponse`; indicates that this is - * a continuation of a prior `ListTopics` call, and that the system should - * return the next page of data. + * @param {number} [request.pageSize] + * Optional. Maximum number of topics to return. + * @param {string} [request.pageToken] + * Optional. The value returned by the last `ListTopicsResponse`; indicates + * that this is a continuation of a prior `ListTopics` call, and that the + * system should return the next page of data. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Object} @@ -1111,12 +1117,12 @@ export class PublisherClient { * @param {string} request.topic * Required. The name of the topic that subscriptions are attached to. * Format is `projects/{project}/topics/{topic}`. - * @param {number} request.pageSize - * Maximum number of subscription names to return. - * @param {string} request.pageToken - * The value returned by the last `ListTopicSubscriptionsResponse`; indicates - * that this is a continuation of a prior `ListTopicSubscriptions` call, and - * that the system should return the next page of data. + * @param {number} [request.pageSize] + * Optional. Maximum number of subscription names to return. + * @param {string} [request.pageToken] + * Optional. The value returned by the last `ListTopicSubscriptionsResponse`; + * indicates that this is a continuation of a prior `ListTopicSubscriptions` + * call, and that the system should return the next page of data. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -1215,12 +1221,12 @@ export class PublisherClient { * @param {string} request.topic * Required. The name of the topic that subscriptions are attached to. * Format is `projects/{project}/topics/{topic}`. - * @param {number} request.pageSize - * Maximum number of subscription names to return. - * @param {string} request.pageToken - * The value returned by the last `ListTopicSubscriptionsResponse`; indicates - * that this is a continuation of a prior `ListTopicSubscriptions` call, and - * that the system should return the next page of data. + * @param {number} [request.pageSize] + * Optional. Maximum number of subscription names to return. + * @param {string} [request.pageToken] + * Optional. The value returned by the last `ListTopicSubscriptionsResponse`; + * indicates that this is a continuation of a prior `ListTopicSubscriptions` + * call, and that the system should return the next page of data. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Stream} @@ -1263,12 +1269,12 @@ export class PublisherClient { * @param {string} request.topic * Required. The name of the topic that subscriptions are attached to. * Format is `projects/{project}/topics/{topic}`. - * @param {number} request.pageSize - * Maximum number of subscription names to return. - * @param {string} request.pageToken - * The value returned by the last `ListTopicSubscriptionsResponse`; indicates - * that this is a continuation of a prior `ListTopicSubscriptions` call, and - * that the system should return the next page of data. + * @param {number} [request.pageSize] + * Optional. Maximum number of subscription names to return. + * @param {string} [request.pageToken] + * Optional. The value returned by the last `ListTopicSubscriptionsResponse`; + * indicates that this is a continuation of a prior `ListTopicSubscriptions` + * call, and that the system should return the next page of data. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Object} @@ -1312,12 +1318,12 @@ export class PublisherClient { * @param {string} request.topic * Required. The name of the topic that snapshots are attached to. * Format is `projects/{project}/topics/{topic}`. - * @param {number} request.pageSize - * Maximum number of snapshot names to return. - * @param {string} request.pageToken - * The value returned by the last `ListTopicSnapshotsResponse`; indicates - * that this is a continuation of a prior `ListTopicSnapshots` call, and - * that the system should return the next page of data. + * @param {number} [request.pageSize] + * Optional. Maximum number of snapshot names to return. + * @param {string} [request.pageToken] + * Optional. The value returned by the last `ListTopicSnapshotsResponse`; + * indicates that this is a continuation of a prior `ListTopicSnapshots` call, + * and that the system should return the next page of data. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -1406,12 +1412,12 @@ export class PublisherClient { * @param {string} request.topic * Required. The name of the topic that snapshots are attached to. * Format is `projects/{project}/topics/{topic}`. - * @param {number} request.pageSize - * Maximum number of snapshot names to return. - * @param {string} request.pageToken - * The value returned by the last `ListTopicSnapshotsResponse`; indicates - * that this is a continuation of a prior `ListTopicSnapshots` call, and - * that the system should return the next page of data. + * @param {number} [request.pageSize] + * Optional. Maximum number of snapshot names to return. + * @param {string} [request.pageToken] + * Optional. The value returned by the last `ListTopicSnapshotsResponse`; + * indicates that this is a continuation of a prior `ListTopicSnapshots` call, + * and that the system should return the next page of data. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Stream} @@ -1454,12 +1460,12 @@ export class PublisherClient { * @param {string} request.topic * Required. The name of the topic that snapshots are attached to. * Format is `projects/{project}/topics/{topic}`. - * @param {number} request.pageSize - * Maximum number of snapshot names to return. - * @param {string} request.pageToken - * The value returned by the last `ListTopicSnapshotsResponse`; indicates - * that this is a continuation of a prior `ListTopicSnapshots` call, and - * that the system should return the next page of data. + * @param {number} [request.pageSize] + * Optional. Maximum number of snapshot names to return. + * @param {string} [request.pageToken] + * Optional. The value returned by the last `ListTopicSnapshotsResponse`; + * indicates that this is a continuation of a prior `ListTopicSnapshots` call, + * and that the system should return the next page of data. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Object} diff --git a/src/v1/schema_service_client.ts b/src/v1/schema_service_client.ts index f65bd434f..3e86492ea 100644 --- a/src/v1/schema_service_client.ts +++ b/src/v1/schema_service_client.ts @@ -378,8 +378,8 @@ export class SchemaServiceClient { * The ID to use for the schema, which will become the final component of * the schema's resource name. * - * See https://cloud.google.com/pubsub/docs/admin#resource_names for resource - * name constraints. + * See https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names for + * resource name constraints. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. diff --git a/src/v1/subscriber_client.ts b/src/v1/subscriber_client.ts index bc0b4fdee..aab6b661a 100644 --- a/src/v1/subscriber_client.ts +++ b/src/v1/subscriber_client.ts @@ -221,7 +221,8 @@ export class SubscriberClient { this.descriptors.stream = { streamingPull: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.BIDI_STREAMING, - !!opts.fallback + !!opts.fallback, + /* gaxStreamingRetries: */ true ), }; @@ -418,21 +419,21 @@ export class SubscriberClient { * Required. The name of the topic from which this subscription is receiving * messages. Format is `projects/{project}/topics/{topic}`. The value of this * field will be `_deleted-topic_` if the topic has been deleted. - * @param {google.pubsub.v1.PushConfig} request.pushConfig - * If push delivery is used with this subscription, this field is - * used to configure it. - * @param {google.pubsub.v1.BigQueryConfig} request.bigqueryConfig - * If delivery to BigQuery is used with this subscription, this field is + * @param {google.pubsub.v1.PushConfig} [request.pushConfig] + * Optional. If push delivery is used with this subscription, this field is * used to configure it. - * @param {google.pubsub.v1.CloudStorageConfig} request.cloudStorageConfig - * If delivery to Google Cloud Storage is used with this subscription, this + * @param {google.pubsub.v1.BigQueryConfig} [request.bigqueryConfig] + * Optional. If delivery to BigQuery is used with this subscription, this * field is used to configure it. - * @param {number} request.ackDeadlineSeconds - * The approximate amount of time (on a best-effort basis) Pub/Sub waits for - * the subscriber to acknowledge receipt before resending the message. In the - * interval after the message is delivered and before it is acknowledged, it - * is considered to be _outstanding_. During that time period, the - * message will not be redelivered (on a best-effort basis). + * @param {google.pubsub.v1.CloudStorageConfig} [request.cloudStorageConfig] + * Optional. If delivery to Google Cloud Storage is used with this + * subscription, this field is used to configure it. + * @param {number} [request.ackDeadlineSeconds] + * Optional. The approximate amount of time (on a best-effort basis) Pub/Sub + * waits for the subscriber to acknowledge receipt before resending the + * message. In the interval after the message is delivered and before it is + * acknowledged, it is considered to be _outstanding_. During that time + * period, the message will not be redelivered (on a best-effort basis). * * For pull subscriptions, this value is used as the initial value for the ack * deadline. To override this value for a given message, call @@ -448,68 +449,68 @@ export class SubscriberClient { * * If the subscriber never acknowledges the message, the Pub/Sub * system will eventually redeliver the message. - * @param {boolean} request.retainAckedMessages - * Indicates whether to retain acknowledged messages. If true, then + * @param {boolean} [request.retainAckedMessages] + * Optional. Indicates whether to retain acknowledged messages. If true, then * messages are not expunged from the subscription's backlog, even if they are * acknowledged, until they fall out of the `message_retention_duration` * window. This must be true if you would like to [`Seek` to a timestamp] * (https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time) in * the past to replay previously-acknowledged messages. - * @param {google.protobuf.Duration} request.messageRetentionDuration - * How long to retain unacknowledged messages in the subscription's backlog, - * from the moment a message is published. - * If `retain_acked_messages` is true, then this also configures the retention - * of acknowledged messages, and thus configures how far back in time a `Seek` - * can be done. Defaults to 7 days. Cannot be more than 7 days or less than 10 - * minutes. - * @param {number[]} request.labels - * See [Creating and managing + * @param {google.protobuf.Duration} [request.messageRetentionDuration] + * Optional. How long to retain unacknowledged messages in the subscription's + * backlog, from the moment a message is published. If `retain_acked_messages` + * is true, then this also configures the retention of acknowledged messages, + * and thus configures how far back in time a `Seek` can be done. Defaults to + * 7 days. Cannot be more than 7 days or less than 10 minutes. + * @param {number[]} [request.labels] + * Optional. See [Creating and managing * labels](https://cloud.google.com/pubsub/docs/labels). - * @param {boolean} request.enableMessageOrdering - * If true, messages published with the same `ordering_key` in `PubsubMessage` - * will be delivered to the subscribers in the order in which they - * are received by the Pub/Sub system. Otherwise, they may be delivered in - * any order. - * @param {google.pubsub.v1.ExpirationPolicy} request.expirationPolicy - * A policy that specifies the conditions for this subscription's expiration. - * A subscription is considered active as long as any connected subscriber is - * successfully consuming messages from the subscription or is issuing - * operations on the subscription. If `expiration_policy` is not set, a - * *default policy* with `ttl` of 31 days will be used. The minimum allowed + * @param {boolean} [request.enableMessageOrdering] + * Optional. If true, messages published with the same `ordering_key` in + * `PubsubMessage` will be delivered to the subscribers in the order in which + * they are received by the Pub/Sub system. Otherwise, they may be delivered + * in any order. + * @param {google.pubsub.v1.ExpirationPolicy} [request.expirationPolicy] + * Optional. A policy that specifies the conditions for this subscription's + * expiration. A subscription is considered active as long as any connected + * subscriber is successfully consuming messages from the subscription or is + * issuing operations on the subscription. If `expiration_policy` is not set, + * a *default policy* with `ttl` of 31 days will be used. The minimum allowed * value for `expiration_policy.ttl` is 1 day. If `expiration_policy` is set, * but `expiration_policy.ttl` is not set, the subscription never expires. - * @param {string} request.filter - * An expression written in the Pub/Sub [filter + * @param {string} [request.filter] + * Optional. An expression written in the Pub/Sub [filter * language](https://cloud.google.com/pubsub/docs/filtering). If non-empty, * then only `PubsubMessage`s whose `attributes` field matches the filter are * delivered on this subscription. If empty, then no messages are filtered * out. - * @param {google.pubsub.v1.DeadLetterPolicy} request.deadLetterPolicy - * A policy that specifies the conditions for dead lettering messages in - * this subscription. If dead_letter_policy is not set, dead lettering - * is disabled. + * @param {google.pubsub.v1.DeadLetterPolicy} [request.deadLetterPolicy] + * Optional. A policy that specifies the conditions for dead lettering + * messages in this subscription. If dead_letter_policy is not set, dead + * lettering is disabled. * - * The Cloud Pub/Sub service account associated with this subscriptions's + * The Pub/Sub service account associated with this subscriptions's * parent project (i.e., * service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have * permission to Acknowledge() messages on this subscription. - * @param {google.pubsub.v1.RetryPolicy} request.retryPolicy - * A policy that specifies how Pub/Sub retries message delivery for this - * subscription. + * @param {google.pubsub.v1.RetryPolicy} [request.retryPolicy] + * Optional. A policy that specifies how Pub/Sub retries message delivery for + * this subscription. * * If not set, the default retry policy is applied. This generally implies * that messages will be retried as soon as possible for healthy subscribers. * RetryPolicy will be triggered on NACKs or acknowledgement deadline * exceeded events for a given message. - * @param {boolean} request.detached - * Indicates whether the subscription is detached from its topic. Detached - * subscriptions don't receive messages from their topic and don't retain any - * backlog. `Pull` and `StreamingPull` requests will return + * @param {boolean} [request.detached] + * Optional. Indicates whether the subscription is detached from its topic. + * Detached subscriptions don't receive messages from their topic and don't + * retain any backlog. `Pull` and `StreamingPull` requests will return * FAILED_PRECONDITION. If the subscription is a push subscription, pushes to * the endpoint will not be made. - * @param {boolean} request.enableExactlyOnceDelivery - * If true, Pub/Sub provides the following guarantees for the delivery of - * a message with a given value of `message_id` on this subscription: + * @param {boolean} [request.enableExactlyOnceDelivery] + * Optional. If true, Pub/Sub provides the following guarantees for the + * delivery of a message with a given value of `message_id` on this + * subscription: * * * The message sent to a subscriber is guaranteed not to be resent * before the message's acknowledgement deadline expires. @@ -684,8 +685,9 @@ export class SubscriberClient { return this.innerApiCalls.getSubscription(request, options, callback); } /** - * Updates an existing subscription. Note that certain properties of a - * subscription, such as its topic, are not modifiable. + * Updates an existing subscription by updating the fields specified in the + * update mask. Note that certain properties of a subscription, such as its + * topic, are not modifiable. * * @param {Object} request * The request object that will be sent. @@ -874,7 +876,8 @@ export class SubscriberClient { * delivery to another subscriber client. This typically results in an * increase in the rate of message redeliveries (that is, duplicates). * The minimum deadline you can specify is 0 seconds. - * The maximum deadline you can specify is 600 seconds (10 minutes). + * The maximum deadline you can specify in a single request is 600 seconds + * (10 minutes). * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -1347,8 +1350,8 @@ export class SubscriberClient { * (b) Any messages published to the subscription's topic following the * successful completion of the CreateSnapshot request. * Format is `projects/{project}/subscriptions/{sub}`. - * @param {number[]} request.labels - * See [Creating and managing + * @param {number[]} [request.labels] + * Optional. See [Creating and managing * labels](https://cloud.google.com/pubsub/docs/labels). * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. @@ -1424,7 +1427,8 @@ export class SubscriberClient { return this.innerApiCalls.createSnapshot(request, options, callback); } /** - * Updates an existing snapshot. Snapshots are used in + * Updates an existing snapshot by updating the fields specified in the update + * mask. Snapshots are used in * [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, * which allow you to manage message acknowledgments in bulk. That is, you can * set the acknowledgment state of messages in an existing subscription to the @@ -1612,8 +1616,8 @@ export class SubscriberClient { * The request object that will be sent. * @param {string} request.subscription * Required. The subscription to affect. - * @param {google.protobuf.Timestamp} request.time - * The time to seek to. + * @param {google.protobuf.Timestamp} [request.time] + * Optional. The time to seek to. * Messages retained in the subscription that were published before this * time are marked as acknowledged, and messages retained in the * subscription that were published after this time are marked as @@ -1624,10 +1628,10 @@ export class SubscriberClient { * window (or to a point before the system's notion of the subscription * creation time), only retained messages will be marked as unacknowledged, * and already-expunged messages will not be restored. - * @param {string} request.snapshot - * The snapshot to seek to. The snapshot's topic must be the same as that of - * the provided subscription. - * Format is `projects/{project}/snapshots/{snap}`. + * @param {string} [request.snapshot] + * Optional. The snapshot to seek to. The snapshot's topic must be the same + * as that of the provided subscription. Format is + * `projects/{project}/snapshots/{snap}`. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -1733,12 +1737,12 @@ export class SubscriberClient { * @param {string} request.project * Required. The name of the project in which to list subscriptions. * Format is `projects/{project-id}`. - * @param {number} request.pageSize - * Maximum number of subscriptions to return. - * @param {string} request.pageToken - * The value returned by the last `ListSubscriptionsResponse`; indicates that - * this is a continuation of a prior `ListSubscriptions` call, and that the - * system should return the next page of data. + * @param {number} [request.pageSize] + * Optional. Maximum number of subscriptions to return. + * @param {string} [request.pageToken] + * Optional. The value returned by the last `ListSubscriptionsResponse`; + * indicates that this is a continuation of a prior `ListSubscriptions` call, + * and that the system should return the next page of data. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -1825,12 +1829,12 @@ export class SubscriberClient { * @param {string} request.project * Required. The name of the project in which to list subscriptions. * Format is `projects/{project-id}`. - * @param {number} request.pageSize - * Maximum number of subscriptions to return. - * @param {string} request.pageToken - * The value returned by the last `ListSubscriptionsResponse`; indicates that - * this is a continuation of a prior `ListSubscriptions` call, and that the - * system should return the next page of data. + * @param {number} [request.pageSize] + * Optional. Maximum number of subscriptions to return. + * @param {string} [request.pageToken] + * Optional. The value returned by the last `ListSubscriptionsResponse`; + * indicates that this is a continuation of a prior `ListSubscriptions` call, + * and that the system should return the next page of data. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Stream} @@ -1873,12 +1877,12 @@ export class SubscriberClient { * @param {string} request.project * Required. The name of the project in which to list subscriptions. * Format is `projects/{project-id}`. - * @param {number} request.pageSize - * Maximum number of subscriptions to return. - * @param {string} request.pageToken - * The value returned by the last `ListSubscriptionsResponse`; indicates that - * this is a continuation of a prior `ListSubscriptions` call, and that the - * system should return the next page of data. + * @param {number} [request.pageSize] + * Optional. Maximum number of subscriptions to return. + * @param {string} [request.pageToken] + * Optional. The value returned by the last `ListSubscriptionsResponse`; + * indicates that this is a continuation of a prior `ListSubscriptions` call, + * and that the system should return the next page of data. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Object} @@ -1922,12 +1926,12 @@ export class SubscriberClient { * @param {string} request.project * Required. The name of the project in which to list snapshots. * Format is `projects/{project-id}`. - * @param {number} request.pageSize - * Maximum number of snapshots to return. - * @param {string} request.pageToken - * The value returned by the last `ListSnapshotsResponse`; indicates that this - * is a continuation of a prior `ListSnapshots` call, and that the system - * should return the next page of data. + * @param {number} [request.pageSize] + * Optional. Maximum number of snapshots to return. + * @param {string} [request.pageToken] + * Optional. The value returned by the last `ListSnapshotsResponse`; indicates + * that this is a continuation of a prior `ListSnapshots` call, and that the + * system should return the next page of data. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -2014,12 +2018,12 @@ export class SubscriberClient { * @param {string} request.project * Required. The name of the project in which to list snapshots. * Format is `projects/{project-id}`. - * @param {number} request.pageSize - * Maximum number of snapshots to return. - * @param {string} request.pageToken - * The value returned by the last `ListSnapshotsResponse`; indicates that this - * is a continuation of a prior `ListSnapshots` call, and that the system - * should return the next page of data. + * @param {number} [request.pageSize] + * Optional. Maximum number of snapshots to return. + * @param {string} [request.pageToken] + * Optional. The value returned by the last `ListSnapshotsResponse`; indicates + * that this is a continuation of a prior `ListSnapshots` call, and that the + * system should return the next page of data. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Stream} @@ -2062,12 +2066,12 @@ export class SubscriberClient { * @param {string} request.project * Required. The name of the project in which to list snapshots. * Format is `projects/{project-id}`. - * @param {number} request.pageSize - * Maximum number of snapshots to return. - * @param {string} request.pageToken - * The value returned by the last `ListSnapshotsResponse`; indicates that this - * is a continuation of a prior `ListSnapshots` call, and that the system - * should return the next page of data. + * @param {number} [request.pageSize] + * Optional. Maximum number of snapshots to return. + * @param {string} [request.pageToken] + * Optional. The value returned by the last `ListSnapshotsResponse`; indicates + * that this is a continuation of a prior `ListSnapshots` call, and that the + * system should return the next page of data. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Object} From 044e1494d82fd64010f7c6f872982d659e753499 Mon Sep 17 00:00:00 2001 From: Megan Potter <57276408+feywind@users.noreply.github.com> Date: Wed, 31 Jan 2024 14:18:39 -0500 Subject: [PATCH 4/8] feat: add schema revision samples (#1870) This adds support for easily getting a schema gapic client, along with samples for schema revisions. --- .gitignore | 1 + README.md | 9 + samples/README.md | 180 +++++++++++++++++ samples/commitAvroSchema.js | 80 ++++++++ samples/commitProtoSchema.js | 80 ++++++++ samples/createTopicWithSchemaRevisions.js | 93 +++++++++ samples/deleteSchemaRevision.js | 70 +++++++ samples/getSchemaRevision.js | 71 +++++++ samples/listSchemaRevisions.js | 68 +++++++ samples/listenForAvroRecords.js | 3 +- samples/listenForAvroRecordsWithRevisions.js | 139 +++++++++++++ samples/package.json | 12 +- samples/rollbackSchema.js | 71 +++++++ samples/system-test/schema.test.ts | 182 +++++++++++++++++- samples/typescript/avro-js.d.ts | 11 +- samples/typescript/commitAvroSchema.ts | 76 ++++++++ samples/typescript/commitProtoSchema.ts | 76 ++++++++ .../createTopicWithSchemaRevisions.ts | 89 +++++++++ samples/typescript/deleteSchemaRevision.ts | 69 +++++++ samples/typescript/getSchemaRevision.ts | 67 +++++++ samples/typescript/listSchemaRevisions.ts | 64 ++++++ samples/typescript/listenForAvroRecords.ts | 3 +- .../listenForAvroRecordsWithRevisions.ts | 140 ++++++++++++++ samples/typescript/rollbackSchema.ts | 67 +++++++ samples/typescript/updateTopicSchema.ts | 73 +++++++ samples/updateTopicSchema.js | 77 ++++++++ src/pubsub.ts | 14 +- src/schema.ts | 12 +- test/pubsub.ts | 10 +- test/schema.ts | 4 +- 30 files changed, 1885 insertions(+), 26 deletions(-) create mode 100644 samples/commitAvroSchema.js create mode 100644 samples/commitProtoSchema.js create mode 100644 samples/createTopicWithSchemaRevisions.js create mode 100644 samples/deleteSchemaRevision.js create mode 100644 samples/getSchemaRevision.js create mode 100644 samples/listSchemaRevisions.js create mode 100644 samples/listenForAvroRecordsWithRevisions.js create mode 100644 samples/rollbackSchema.js create mode 100644 samples/typescript/commitAvroSchema.ts create mode 100644 samples/typescript/commitProtoSchema.ts create mode 100644 samples/typescript/createTopicWithSchemaRevisions.ts create mode 100644 samples/typescript/deleteSchemaRevision.ts create mode 100644 samples/typescript/getSchemaRevision.ts create mode 100644 samples/typescript/listSchemaRevisions.ts create mode 100644 samples/typescript/listenForAvroRecordsWithRevisions.ts create mode 100644 samples/typescript/rollbackSchema.ts create mode 100644 samples/typescript/updateTopicSchema.ts create mode 100644 samples/updateTopicSchema.js diff --git a/.gitignore b/.gitignore index d4f03a0df..79df01522 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ system-test/*key.json .DS_Store package-lock.json __pycache__ +samples/build/ diff --git a/README.md b/README.md index 6a2dfa06d..9267ec11e 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,8 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-pubsub/tree | Sample | Source Code | Try it | | --------------------------- | --------------------------------- | ------ | +| Commit an Avro-Based Schema | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/commitAvroSchema.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/commitAvroSchema.js,samples/README.md) | +| Commit an Proto-Based Schema | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/commitProtoSchema.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/commitProtoSchema.js,samples/README.md) | | Create an Avro based Schema | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createAvroSchema.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/createAvroSchema.js,samples/README.md) | | Create BigQuery Subscription | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createBigQuerySubscription.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/createBigQuerySubscription.js,samples/README.md) | | Create a Proto based Schema | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createProtoSchema.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/createProtoSchema.js,samples/README.md) | @@ -136,19 +138,24 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-pubsub/tree | Create Subscription With Retry Policy | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createSubscriptionWithRetryPolicy.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/createSubscriptionWithRetryPolicy.js,samples/README.md) | | Create Topic | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createTopic.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/createTopic.js,samples/README.md) | | Create Topic With Schema | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createTopicWithSchema.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/createTopicWithSchema.js,samples/README.md) | +| Create Topic With Schema Revisions | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createTopicWithSchemaRevisions.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/createTopicWithSchemaRevisions.js,samples/README.md) | | Delete a previously created schema | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/deleteSchema.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/deleteSchema.js,samples/README.md) | +| Delete a Schema Revision | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/deleteSchemaRevision.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/deleteSchemaRevision.js,samples/README.md) | | Delete Subscription | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/deleteSubscription.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/deleteSubscription.js,samples/README.md) | | Delete Topic | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/deleteTopic.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/deleteTopic.js,samples/README.md) | | Detach Subscription | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/detachSubscription.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/detachSubscription.js,samples/README.md) | | Get a previously created schema | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/getSchema.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/getSchema.js,samples/README.md) | +| Get a previously created schema revision | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/getSchemaRevision.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/getSchemaRevision.js,samples/README.md) | | Get Subscription | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/getSubscription.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/getSubscription.js,samples/README.md) | | Get Subscription Policy | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/getSubscriptionPolicy.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/getSubscriptionPolicy.js,samples/README.md) | | Get Topic Policy | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/getTopicPolicy.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/getTopicPolicy.js,samples/README.md) | | List All Topics | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/listAllTopics.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/listAllTopics.js,samples/README.md) | +| List Revisions on a Schema | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/listSchemaRevisions.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/listSchemaRevisions.js,samples/README.md) | | List schemas on a project | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/listSchemas.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/listSchemas.js,samples/README.md) | | List Subscriptions | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/listSubscriptions.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/listSubscriptions.js,samples/README.md) | | List Subscriptions On a Topic | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/listTopicSubscriptions.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/listTopicSubscriptions.js,samples/README.md) | | Listen For Avro Records | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/listenForAvroRecords.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/listenForAvroRecords.js,samples/README.md) | +| Listen For Avro Records With Revisions | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/listenForAvroRecordsWithRevisions.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/listenForAvroRecordsWithRevisions.js,samples/README.md) | | Listen For Errors | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/listenForErrors.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/listenForErrors.js,samples/README.md) | | Listen For Messages | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/listenForMessages.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/listenForMessages.js,samples/README.md) | | Listen with exactly-once delivery | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/listenForMessagesWithExactlyOnceDelivery.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/listenForMessagesWithExactlyOnceDelivery.js,samples/README.md) | @@ -167,6 +174,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-pubsub/tree | Quickstart | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/quickstart.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/quickstart.js,samples/README.md) | | Remove Dead Letter Policy | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/removeDeadLetterPolicy.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/removeDeadLetterPolicy.js,samples/README.md) | | Resume Publish | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/resumePublish.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/resumePublish.js,samples/README.md) | +| Rollback a Schema | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/rollbackSchema.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/rollbackSchema.js,samples/README.md) | | Set Subscription IAM Policy | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/setSubscriptionPolicy.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/setSubscriptionPolicy.js,samples/README.md) | | Set Topic IAM Policy | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/setTopicPolicy.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/setTopicPolicy.js,samples/README.md) | | Subscribe With Flow Control Settings | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/subscribeWithFlowControlSettings.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/subscribeWithFlowControlSettings.js,samples/README.md) | @@ -176,6 +184,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-pubsub/tree | Test Subscription Permissions | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/testSubscriptionPermissions.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/testSubscriptionPermissions.js,samples/README.md) | | Test Topic Permissions | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/testTopicPermissions.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/testTopicPermissions.js,samples/README.md) | | Update Dead Letter Policy | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/updateDeadLetterPolicy.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/updateDeadLetterPolicy.js,samples/README.md) | +| Update Topic Schema | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/updateTopicSchema.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/updateTopicSchema.js,samples/README.md) | | Validate a schema definition | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/validateSchema.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/validateSchema.js,samples/README.md) | diff --git a/samples/README.md b/samples/README.md index 6260da752..d8fa96fa0 100644 --- a/samples/README.md +++ b/samples/README.md @@ -20,6 +20,8 @@ guides. * [Before you begin](#before-you-begin) * [Samples](#samples) + * [Commit an Avro-Based Schema](#commit-an-avro-based-schema) + * [Commit an Proto-Based Schema](#commit-an-proto-based-schema) * [Create an Avro based Schema](#create-an-avro-based-schema) * [Create BigQuery Subscription](#create-bigquery-subscription) * [Create a Proto based Schema](#create-a-proto-based-schema) @@ -33,19 +35,24 @@ guides. * [Create Subscription With Retry Policy](#create-subscription-with-retry-policy) * [Create Topic](#create-topic) * [Create Topic With Schema](#create-topic-with-schema) + * [Create Topic With Schema Revisions](#create-topic-with-schema-revisions) * [Delete a previously created schema](#delete-a-previously-created-schema) + * [Delete a Schema Revision](#delete-a-schema-revision) * [Delete Subscription](#delete-subscription) * [Delete Topic](#delete-topic) * [Detach Subscription](#detach-subscription) * [Get a previously created schema](#get-a-previously-created-schema) + * [Get a previously created schema revision](#get-a-previously-created-schema-revision) * [Get Subscription](#get-subscription) * [Get Subscription Policy](#get-subscription-policy) * [Get Topic Policy](#get-topic-policy) * [List All Topics](#list-all-topics) + * [List Revisions on a Schema](#list-revisions-on-a-schema) * [List schemas on a project](#list-schemas-on-a-project) * [List Subscriptions](#list-subscriptions) * [List Subscriptions On a Topic](#list-subscriptions-on-a-topic) * [Listen For Avro Records](#listen-for-avro-records) + * [Listen For Avro Records With Revisions](#listen-for-avro-records-with-revisions) * [Listen For Errors](#listen-for-errors) * [Listen For Messages](#listen-for-messages) * [Listen with exactly-once delivery](#listen-with-exactly-once-delivery) @@ -64,6 +71,7 @@ guides. * [Quickstart](#quickstart) * [Remove Dead Letter Policy](#remove-dead-letter-policy) * [Resume Publish](#resume-publish) + * [Rollback a Schema](#rollback-a-schema) * [Set Subscription IAM Policy](#set-subscription-iam-policy) * [Set Topic IAM Policy](#set-topic-iam-policy) * [Subscribe With Flow Control Settings](#subscribe-with-flow-control-settings) @@ -73,6 +81,7 @@ guides. * [Test Subscription Permissions](#test-subscription-permissions) * [Test Topic Permissions](#test-topic-permissions) * [Update Dead Letter Policy](#update-dead-letter-policy) + * [Update Topic Schema](#update-topic-schema) * [Validate a schema definition](#validate-a-schema-definition) ## Before you begin @@ -90,6 +99,44 @@ Before running the samples, make sure you've followed the steps outlined in +### Commit an Avro-Based Schema + +Commits a new schema definition revision on a project, using Avro + +View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/commitAvroSchema.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/commitAvroSchema.js,samples/README.md) + +__Usage:__ + + +`node commitAvroSchema.js ` + + +----- + + + + +### Commit an Proto-Based Schema + +Commits a new schema definition revision on a project, using Protos + +View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/commitProtoSchema.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/commitProtoSchema.js,samples/README.md) + +__Usage:__ + + +`node commitProtoSchema.js ` + + +----- + + + + ### Create an Avro based Schema Creates a new schema definition on a project, using Avro @@ -337,6 +384,25 @@ __Usage:__ +### Create Topic With Schema Revisions + +Creates a new topic, with a schema definition and revisions. + +View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createTopicWithSchemaRevisions.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/createTopicWithSchemaRevisions.js,samples/README.md) + +__Usage:__ + + +`node createTopicWithSchema.js ` + + +----- + + + + ### Delete a previously created schema Deletes a schema which was previously created in the project. @@ -356,6 +422,25 @@ __Usage:__ +### Delete a Schema Revision + +Deletes a schema revision on a project + +View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/deleteSchemaRevision.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/deleteSchemaRevision.js,samples/README.md) + +__Usage:__ + + +`node deleteSchemaRevision.js ` + + +----- + + + + ### Delete Subscription Deletes an existing subscription from a topic. @@ -432,6 +517,25 @@ __Usage:__ +### Get a previously created schema revision + +Gets information about a schema revision which was previously created in the project. + +View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/getSchemaRevision.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/getSchemaRevision.js,samples/README.md) + +__Usage:__ + + +`node getSchemaRevision.js ` + + +----- + + + + ### Get Subscription Gets the metadata for a subscription. @@ -508,6 +612,25 @@ __Usage:__ +### List Revisions on a Schema + +Gets a list of revisions on a schema which was previously created in the project. + +View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/listSchemaRevisions.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/listSchemaRevisions.js,samples/README.md) + +__Usage:__ + + +`node listSchemaRevisions.js ` + + +----- + + + + ### List schemas on a project Gets a list of schemas which were previously created in the project. @@ -584,6 +707,25 @@ __Usage:__ +### Listen For Avro Records With Revisions + +Listens for records in Avro encoding from a subscription with schema revisions. + +View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/listenForAvroRecordsWithRevisions.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/listenForAvroRecordsWithRevisions.js,samples/README.md) + +__Usage:__ + + +`node listenForAvroRecordsWithRevisions.js [timeout-in-seconds]` + + +----- + + + + ### Listen For Errors Listens to messages and errors for a subscription. @@ -926,6 +1068,25 @@ __Usage:__ +### Rollback a Schema + +Rolls back a schema on a project + +View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/rollbackSchema.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/rollbackSchema.js,samples/README.md) + +__Usage:__ + + +`node rollbackSchema.js ` + + +----- + + + + ### Set Subscription IAM Policy Sets the IAM policy for a subscription. @@ -1097,6 +1258,25 @@ __Usage:__ +### Update Topic Schema + +Update the schema on a topic. + +View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/updateTopicSchema.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/updateTopicSchema.js,samples/README.md) + +__Usage:__ + + +`node updateTopicSchema.js ` + + +----- + + + + ### Validate a schema definition Validates an Avro-based schema definition before creation (or other use). diff --git a/samples/commitAvroSchema.js b/samples/commitAvroSchema.js new file mode 100644 index 000000000..b9a6eff73 --- /dev/null +++ b/samples/commitAvroSchema.js @@ -0,0 +1,80 @@ +// 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 application 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: Commit an Avro-Based Schema +// description: Commits a new schema definition revision on a project, using Avro +// usage: node commitAvroSchema.js + +// [START pubsub_commit_avro_schema] +/** + * TODO(developer): Uncomment these variables before running the sample. + */ +// const schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID'; +// const avscFile = 'path/to/an/avro/schema/file/(.avsc)/formatted/in/json'; + +// Imports the Google Cloud client library +const {PubSub, SchemaTypes} = require('@google-cloud/pubsub'); + +const fs = require('fs'); + +// Creates a client; cache this for further use +const pubSubClient = new PubSub(); + +async function commitAvroSchema(schemaNameOrId, avscFile) { + // Get the fully qualified schema name. + const schema = pubSubClient.schema(schemaNameOrId); + const name = await schema.getName(); + + // Read the new schema definition from storage. + const definition = fs.readFileSync(avscFile).toString(); + + // Use the gapic client to commit the new definition. + const schemaClient = await pubSubClient.getSchemaClient(); + const [result] = await schemaClient.commitSchema({ + name, + schema: { + name, + type: SchemaTypes.Avro, + definition, + }, + }); + + console.log(`Schema ${name} committed with revision ${result.revisionId}.`); +} +// [END pubsub_commit_avro_schema] + +function main( + schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID', + avscFile = 'path/to/an/avro/schema/file/(.avsc)/formatted/in/json' +) { + commitAvroSchema(schemaNameOrId, avscFile).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); +} + +main(...process.argv.slice(2)); diff --git a/samples/commitProtoSchema.js b/samples/commitProtoSchema.js new file mode 100644 index 000000000..997a1df45 --- /dev/null +++ b/samples/commitProtoSchema.js @@ -0,0 +1,80 @@ +// 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 application 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: Commit an Proto-Based Schema +// description: Commits a new schema definition revision on a project, using Protos +// usage: node commitProtoSchema.js + +// [START pubsub_commit_proto_schema] +/** + * TODO(developer): Uncomment these variables before running the sample. + */ +// const schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID'; +// const protoFile = 'path/to/a/proto/schema/file/(.proto)/formatted/in/protcol/buffers'; + +// Imports the Google Cloud client library +const {PubSub, SchemaTypes} = require('@google-cloud/pubsub'); + +const fs = require('fs'); + +// Creates a client; cache this for further use +const pubSubClient = new PubSub(); + +async function commitProtoSchema(schemaNameOrId, protoFile) { + // Get the fully qualified schema name. + const schema = pubSubClient.schema(schemaNameOrId); + const name = await schema.getName(); + + // Read the new schema definition from storage. + const definition = fs.readFileSync(protoFile).toString(); + + // Use the gapic client to commit the new definition. + const schemaClient = await pubSubClient.getSchemaClient(); + const [result] = await schemaClient.commitSchema({ + name, + schema: { + name, + type: SchemaTypes.ProtocolBuffer, + definition, + }, + }); + + console.log(`Schema ${name} committed with revision ${result.revisionId}.`); +} +// [END pubsub_commit_proto_schema] + +function main( + schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID', + protoFile = 'path/to/a/proto/schema/file/(.proto)/formatted/in/protcol/buffers' +) { + commitProtoSchema(schemaNameOrId, protoFile).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); +} + +main(...process.argv.slice(2)); diff --git a/samples/createTopicWithSchemaRevisions.js b/samples/createTopicWithSchemaRevisions.js new file mode 100644 index 000000000..37934e736 --- /dev/null +++ b/samples/createTopicWithSchemaRevisions.js @@ -0,0 +1,93 @@ +// 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 +// +// https://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 sample demonstrates how to perform basic operations on topics 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 Topic With Schema Revisions +// description: Creates a new topic, with a schema definition and revisions. +// usage: node createTopicWithSchema.js + +// [START pubsub_create_topic_with_schema_revisions] +/** + * TODO(developer): Uncomment these variables before running the sample. + */ +// const topicNameOrId = 'YOUR_TOPIC_NAME_OR_ID'; +// const schemaName = 'YOUR_SCHEMA_NAME_OR_ID'; +// const encodingType = 'BINARY'; +// const firstRevisionId = 'YOUR_REVISION_ID'; +// const lastRevisionId = 'YOUR_REVISION_ID'; + +// 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 createTopicWithSchemaRevisions( + topicNameOrId, + schemaNameOrId, + encodingType, + firstRevisionId, + lastRevisionId +) { + // Get the fully qualified schema name. + const schema = pubSubClient.schema(schemaNameOrId); + const fullName = await schema.getName(); + + // Creates a new topic with a schema. Note that you might also + // pass Encodings.Json or Encodings.Binary here. + await pubSubClient.createTopic({ + name: topicNameOrId, + schemaSettings: { + schema: fullName, + encoding: encodingType, + firstRevisionId, + lastRevisionId, + }, + }); + console.log(`Topic ${topicNameOrId} created with schema ${fullName}.`); +} +// [END pubsub_create_topic_with_schema_revisions] + +function main( + topicNameOrId = 'YOUR_TOPIC_NAME_OR_ID', + schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID', + encodingType = 'BINARY', + firstRevisionId = 'YOUR_REVISION_ID', + lastRevisionId = 'YOUR_REVISION_ID' +) { + createTopicWithSchemaRevisions( + topicNameOrId, + schemaNameOrId, + encodingType, + firstRevisionId, + lastRevisionId + ).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); +} + +main(...process.argv.slice(2)); diff --git a/samples/deleteSchemaRevision.js b/samples/deleteSchemaRevision.js new file mode 100644 index 000000000..bbdafde15 --- /dev/null +++ b/samples/deleteSchemaRevision.js @@ -0,0 +1,70 @@ +// 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 application 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: Delete a Schema Revision +// description: Deletes a schema revision on a project +// usage: node deleteSchemaRevision.js + +// [START pubsub_delete_schema_revision] +/** + * TODO(developer): Uncomment these variables before running the sample. + */ +// const schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID'; +// const revisionId = 'YOUR_REVISION_ID'; + +// 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 deleteSchemaRevision(schemaNameOrId, revisionId) { + // Get the fully qualified schema name. + const schema = pubSubClient.schema(schemaNameOrId); + const name = await schema.getName(); + + // Use the gapic client to delete the schema revision. + const schemaClient = await pubSubClient.getSchemaClient(); + await schemaClient.deleteSchemaRevision({ + name: `${name}@${revisionId}`, + }); + + console.log(`Schema ${name} revision ${revisionId} deleted.`); +} +// [END pubsub_delete_schema_revision] + +function main( + schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID', + revisionId = 'YOUR_REVISION_ID' +) { + deleteSchemaRevision(schemaNameOrId, revisionId).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); +} + +main(...process.argv.slice(2)); diff --git a/samples/getSchemaRevision.js b/samples/getSchemaRevision.js new file mode 100644 index 000000000..8cb5278b7 --- /dev/null +++ b/samples/getSchemaRevision.js @@ -0,0 +1,71 @@ +// 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: Get a previously created schema revision +// description: Gets information about a schema revision which was previously created in the project. +// usage: node getSchemaRevision.js + +// [START pubsub_get_schema_revision] +/** + * TODO(developer): Uncomment this variable before running the sample. + */ +// const schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID'; +// const revisionId = 'YOUR_REVISION_ID'; + +// 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 getSchemaRevision(schemaNameOrId, revisionId) { + const schema = pubSubClient.schema(schemaNameOrId); + const name = await schema.getName(); + + // Use the gapic client to delete the schema revision. + const schemaClient = await pubSubClient.getSchemaClient(); + const schemaInfo = await schemaClient.getSchema({ + name: `${name}@${revisionId}`, + }); + + console.log( + `Schema ${name}@${revisionId} info: ${JSON.stringify(schemaInfo, null, 4)}.` + ); +} +// [END pubsub_get_schema_revision] + +function main( + schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID', + revisionId = 'YOUR_REVISION_ID' +) { + getSchemaRevision(schemaNameOrId, revisionId).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); +} + +main(...process.argv.slice(2)); diff --git a/samples/listSchemaRevisions.js b/samples/listSchemaRevisions.js new file mode 100644 index 000000000..b6a621b87 --- /dev/null +++ b/samples/listSchemaRevisions.js @@ -0,0 +1,68 @@ +// 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 application 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: List Revisions on a Schema +// description: Gets a list of revisions on a schema which was previously created in the project. +// usage: node listSchemaRevisions.js + +// [START pubsub_list_schema_revisions] +/** + * TODO(developer): Uncomment this variable before running the sample. + */ +// const schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID'; + +// 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 listSchemaRevisions(schemaNameOrId) { + // Get the fully qualified schema name. + const schema = pubSubClient.schema(schemaNameOrId); + const name = await schema.getName(); + + // Use the gapic client to list the schema revisions. + const schemaClient = await pubSubClient.getSchemaClient(); + const [results] = await schemaClient.listSchemaRevisions({ + name, + }); + for (const rev of results) { + console.log(rev.revisionId, rev.revisionCreateTime); + } + console.log(`Listed revisions of schema ${name}.`); +} +// [END pubsub_list_schema_revisions] + +function main(schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID') { + listSchemaRevisions(schemaNameOrId).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); +} + +main(...process.argv.slice(2)); diff --git a/samples/listenForAvroRecords.js b/samples/listenForAvroRecords.js index b0dbc7aee..10ff478fa 100644 --- a/samples/listenForAvroRecords.js +++ b/samples/listenForAvroRecords.js @@ -104,7 +104,8 @@ function main( try { listenForAvroRecords(subscriptionNameOrId, timeout); - } catch (err) { + } catch (e) { + const err = e; console.error(err.message); process.exitCode = 1; } diff --git a/samples/listenForAvroRecordsWithRevisions.js b/samples/listenForAvroRecordsWithRevisions.js new file mode 100644 index 000000000..a4a46bf8d --- /dev/null +++ b/samples/listenForAvroRecordsWithRevisions.js @@ -0,0 +1,139 @@ +// 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 + * subscriptions 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: Listen For Avro Records With Revisions +// description: Listens for records in Avro encoding from a subscription with schema revisions. +// usage: node listenForAvroRecordsWithRevisions.js [timeout-in-seconds] + +// [START pubsub_subscribe_avro_records_with_revisions] +/** + * TODO(developer): Uncomment these variables before running the sample. + */ +// const subscriptionNameOrId = 'YOUR_SUBSCRIPTION_NAME_OR_ID'; +// const timeout = 60; + +// Imports the Google Cloud client library +const {PubSub, Schema, Encodings} = require('@google-cloud/pubsub'); + +// And the Apache Avro library; this lacks typings, so for +// TypeScript, a few synthetic types were created. +const avro = require('avro-js'); + +// Creates a client; cache this for further use +const pubSubClient = new PubSub(); + +async function listenForAvroRecordsWithRevisions( + subscriptionNameOrId, + timeout +) { + // References an existing subscription + const subscription = pubSubClient.subscription(subscriptionNameOrId); + + // Cache decoders for various schema revisions. + const revisionReaders = new Map(); + + // We need a schema admin service client to retrieve revisions. + const schemaClient = await pubSubClient.getSchemaClient(); + + // Create an event handler to handle messages + let messageCount = 0; + const messageHandler = async message => { + // Get the schema metadata from the message. + const schemaMetadata = Schema.metadataFromMessage(message.attributes); + + let reader; + try { + // Do we already have a decoder for this revision? + const revision = schemaMetadata.revision; + if (revisionReaders.has(revision)) { + reader = revisionReaders.get(revision); + } else { + // This is the first time we are seeing this revision. We need to + // fetch the schema and cache its decoder. + const [schema] = await schemaClient.getSchema({ + name: `${schemaMetadata.name}@${schemaMetadata.revision}`, + }); + reader = avro.parse(schema.definition); + revisionReaders.set(revision, reader); + } + } catch (err) { + console.log('Could not get schema', err); + message.nack(); + return; + } + + let result; + switch (schemaMetadata.encoding) { + case Encodings.Binary: + result = reader.fromBuffer(message.data); + break; + case Encodings.Json: + result = reader.fromString(message.data.toString()); + break; + default: + console.log(`Unknown schema encoding: ${schemaMetadata.encoding}`); + message.nack(); + return; + } + + console.log(`Received message ${message.id}:`); + console.log(`\tData: ${JSON.stringify(result, null, 4)}`); + console.log(`\tAttributes: ${message.attributes}`); + console.log( + `\tProvince ${result.name} is abbreviated as ${result.post_abbr}` + ); + messageCount += 1; + + // Ack the message. + message.ack(); + }; + + // Listen for new messages until timeout is hit + subscription.on('message', messageHandler); + + setTimeout(() => { + subscription.removeListener('message', messageHandler); + console.log(`${messageCount} message(s) received.`); + }, timeout * 1000); +} +// [END pubsub_subscribe_avro_records_with_revisions] + +function main( + subscriptionNameOrId = 'YOUR_SUBSCRIPTION_NAME_OR_ID', + timeout = 60 +) { + timeout = Number(timeout); + + listenForAvroRecordsWithRevisions(subscriptionNameOrId, timeout).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 70065c0a5..e095c9c65 100644 --- a/samples/package.json +++ b/samples/package.json @@ -22,21 +22,21 @@ }, "dependencies": { "@google-cloud/pubsub": "^4.1.1", - "@opentelemetry/api": "^1.0.0", + "@opentelemetry/api": "^1.6.0", "@opentelemetry/tracing": "^0.24.0", - "avro-js": "^1.10.1", + "avro-js": "^1.11.3", "p-defer": "^3.0.0", - "protobufjs": "^7.0.0" + "protobufjs": "~7.2.5" }, "devDependencies": { "@google-cloud/bigquery": "^7.0.0", "@types/chai": "^4.2.16", "@types/rimraf": "^3.0.0", "chai": "^4.2.0", - "gts": "^3.1.0", - "mocha": "^8.0.0", + "gts": "^5.0.0", + "mocha": "^9.2.2", "rimraf": "^5.0.0", - "typescript": "~4.3.0", + "typescript": "^5.1.6", "uuid": "^9.0.0" } } diff --git a/samples/rollbackSchema.js b/samples/rollbackSchema.js new file mode 100644 index 000000000..ae5d8fc3f --- /dev/null +++ b/samples/rollbackSchema.js @@ -0,0 +1,71 @@ +// 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 application 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: Rollback a Schema +// description: Rolls back a schema on a project +// usage: node rollbackSchema.js + +// [START pubsub_rollback_schema] +/** + * TODO(developer): Uncomment these variables before running the sample. + */ +// const schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID'; +// const revisionId = 'YOUR_REVISION_ID'; + +// 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 rollbackSchema(schemaNameOrId, revisionId) { + // Get the fully qualified schema name. + const schema = pubSubClient.schema(schemaNameOrId); + const name = await schema.getName(); + + // Use the gapic client to roll back the schema revision. + const schemaClient = await pubSubClient.getSchemaClient(); + await schemaClient.rollbackSchema({ + name, + revisionId, + }); + + console.log(`Schema ${name} revision ${revisionId} rolled back.`); +} +// [END pubsub_rollback_schema] + +function main( + schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID', + revisionId = 'YOUR_REVISION_ID' +) { + rollbackSchema(schemaNameOrId, revisionId).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); +} + +main(...process.argv.slice(2)); diff --git a/samples/system-test/schema.test.ts b/samples/system-test/schema.test.ts index b7b44f9b9..bbf192900 100644 --- a/samples/system-test/schema.test.ts +++ b/samples/system-test/schema.test.ts @@ -40,6 +40,7 @@ const execSync = (cmd: string) => cp.execSync(cmd, {encoding: 'utf-8'}); describe('schema', () => { const projectId = process.env.GCLOUD_PROJECT; const pubsub = new PubSub({projectId}); + const clientPromise = pubsub.getSchemaClient(); const resources = new TestResources('schema'); @@ -56,7 +57,11 @@ describe('schema', () => { } function fullSchemaName(base: string) { - return `projects/${projectId}/schemas/${base}`; + if (base.includes('/')) { + return base; + } else { + return `projects/${projectId}/schemas/${base}`; + } } async function cleanAllSchemas() { @@ -126,16 +131,46 @@ describe('schema', () => { return schema; } + async function commitSchema( + schemaId: string, + type: 'avro' | 'proto' + ): Promise { + const suffix = type === 'avro' ? 'avsc' : 'proto'; + const typeId = + type === 'avro' ? SchemaTypes.Avro : SchemaTypes.ProtocolBuffer; + const definition = ( + await fs.readFile(fixturePath(`provinces.${suffix}`)) + ).toString(); + + const schema = pubsub.schema(schemaId); + const schemaName = await schema.getName(); + const schemaClient = await clientPromise; + const [result] = await schemaClient.commitSchema({ + name: schemaName, + schema: { + name: schemaName, + type: typeId, + definition, + }, + }); + + return result; + } + async function createTopicWithSchema( testName: string, schemaName: string, - encodingType: SchemaEncoding + encodingType: SchemaEncoding, + firstRevisionId?: string, + lastRevisionId?: string ): Promise { const topicId = getTopicId(testName); const [topic] = await pubsub.createTopic({ name: topicId, schemaSettings: { schema: fullSchemaName(schemaName), + firstRevisionId, + lastRevisionId, encoding: encodingType, }, }); @@ -155,6 +190,30 @@ describe('schema', () => { return sub; } + it('should commit an avro schema', async () => { + const schema = await createSchema('commit_schema_avro', 'avro'); + const name = await schema.getName(); + const output = execSync( + `${commandFor('commitAvroSchema')} ${name} ${fixturePath( + 'provinces.avsc' + )}` + ); + assert.include(output, name); + assert.include(output, 'committed'); + }); + + it('should commit an proto schema', async () => { + const schema = await createSchema('commit_schema_proto', 'proto'); + const name = await schema.getName(); + const output = execSync( + `${commandFor('commitProtoSchema')} ${name} ${fixturePath( + 'provinces.proto' + )}` + ); + assert.include(output, name); + assert.include(output, 'committed'); + }); + it('should create an avro schema', async () => { const schemaId = getSchemaId('create_avro'); const output = execSync( @@ -212,6 +271,28 @@ describe('schema', () => { assert.include(topic.metadata?.schemaSettings?.schema, schema.id); }); + it('should create a topic with schema revisions', async () => { + const id = 'create_topic_rev'; + const schema = await createSchema(id, 'proto'); + const committed = await commitSchema(await schema.getName(), 'proto'); + const revId = committed.revisionId!; + + const topicId = getTopicId(id); + const output = execSync( + `${commandFor('createTopicWithSchemaRevisions')} ${topicId} ${ + schema.id + } BINARY ${revId} ${revId}` + ); + assert.include(output, topicId); + assert.include(output, schema.id); + assert.include(output, 'created with'); + + const [topic] = await pubsub.topic(topicId).get(); + assert.include(topic.metadata?.schemaSettings?.schema, schema.id); + assert.strictEqual(topic.metadata?.schemaSettings?.firstRevisionId, revId); + assert.strictEqual(topic.metadata?.schemaSettings?.lastRevisionId, revId); + }); + it('should delete a schema', async () => { const schema = await createSchema('delete', 'proto'); @@ -228,6 +309,53 @@ describe('schema', () => { }*/ }); + it('should delete a schema revision', async () => { + const id = 'delete_rev'; + const schema = await createSchema(id, 'proto'); + const name = await schema.getName(); + await commitSchema(name, 'proto'); + const committed2 = await commitSchema(name, 'proto'); + const revId = committed2.revisionId!; + + const output = execSync( + `${commandFor('deleteSchemaRevision')} ${schema.id} ${revId}` + ); + assert.include(output, schema.id); + assert.include(output, 'deleted.'); + }); + + it('should rollback a schema revision', async () => { + const id = 'rollback_rev'; + const schema = await createSchema(id, 'proto'); + const name = await schema.getName(); + const committed = await commitSchema(name, 'proto'); + const revId = committed.revisionId!; + await commitSchema(name, 'proto'); + + const output = execSync( + `${commandFor('rollbackSchema')} ${schema.id} ${revId}` + ); + assert.include(output, schema.id); + assert.include(output, 'rolled back.'); + }); + + it("should list a schema's revisions", async () => { + const id = 'list_rev'; + const schema = await createSchema(id, 'proto'); + const committed = await commitSchema(await schema.getName(), 'proto'); + const revId = committed.revisionId!; + const committed2 = await commitSchema(await schema.getName(), 'proto'); + const revId2 = committed2.revisionId!; + + const output = execSync( + `${commandFor('listSchemaRevisions')} ${schema.id}` + ); + assert.include(output, schema.id); + assert.include(output, revId); + assert.include(output, revId2); + assert.include(output, 'Listed revisions'); + }); + it('should get a schema', async () => { const schema = await createSchema('get', 'proto'); @@ -237,6 +365,20 @@ describe('schema', () => { assert.include(output, 'PROTO'); }); + it('should get a schema revision', async () => { + const schema = await createSchema('get_rev', 'proto'); + const committed = await commitSchema(await schema.getName(), 'proto'); + const revId = committed.revisionId!; + + const output = execSync( + `${commandFor('getSchemaRevision')} ${schema.id} ${revId}` + ); + assert.include(output, schema.id); + assert.include(output, revId); + assert.include(output, 'info:'); + assert.include(output, 'PROTO'); + }); + it('should listen for avro records', async () => { const id = 'listen_avro'; const schema = await createSchema(id, 'avro'); @@ -261,6 +403,42 @@ describe('schema', () => { assert.include(output, 'AB'); }); + it('should listen for avro records with revisions', async () => { + const id = 'listen_avro_rev'; + const schema = await createSchema(id, 'avro'); + const schemaName = await schema.getName(); + const rev1 = await commitSchema(schemaName, 'avro'); + const rev2 = await commitSchema(schemaName, 'avro'); + if (!rev1.revisionId || !rev2.revisionId) { + assert.ok(false, 'revisions could not be committed'); + } + const topic = await createTopicWithSchema( + id, + schema.id, + Encodings.Json, + rev1.revisionId ?? undefined, + rev2.revisionId ?? undefined + ); + const sub = await createSub(id, topic.name); + + topic.publishMessage({ + data: Buffer.from( + JSON.stringify({ + name: 'Alberta', + post_abbr: 'AB', + }) + ), + }); + await topic.flush(); + + const output = execSync( + `${commandFor('listenForAvroRecordsWithRevisions')} ${sub.name} 10` + ); + assert.include(output, 'Received message'); + assert.include(output, 'Alberta'); + assert.include(output, 'AB'); + }); + it('should listen for protobuf messages', async () => { const id = 'listen_proto'; const schema = await createSchema(id, 'proto'); diff --git a/samples/typescript/avro-js.d.ts b/samples/typescript/avro-js.d.ts index 1c6c80b44..20937ee94 100644 --- a/samples/typescript/avro-js.d.ts +++ b/samples/typescript/avro-js.d.ts @@ -13,4 +13,13 @@ // limitations under the License. // This one doesn't seem to have typings. -declare module 'avro-js'; +declare module 'avro-js' { + function parse(def: string): Parser; + + class Parser { + fromBuffer(buf: Buffer): T; + fromString(str: string): T; + toBuffer(item: T): Buffer; + toString(item: T): string; + } +} diff --git a/samples/typescript/commitAvroSchema.ts b/samples/typescript/commitAvroSchema.ts new file mode 100644 index 000000000..983aab6c0 --- /dev/null +++ b/samples/typescript/commitAvroSchema.ts @@ -0,0 +1,76 @@ +// 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 application 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: Commit an Avro-Based Schema +// description: Commits a new schema definition revision on a project, using Avro +// usage: node commitAvroSchema.js + +// [START pubsub_commit_avro_schema] +/** + * TODO(developer): Uncomment these variables before running the sample. + */ +// const schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID'; +// const avscFile = 'path/to/an/avro/schema/file/(.avsc)/formatted/in/json'; + +// Imports the Google Cloud client library +import {PubSub, SchemaTypes} from '@google-cloud/pubsub'; + +import * as fs from 'fs'; + +// Creates a client; cache this for further use +const pubSubClient = new PubSub(); + +async function commitAvroSchema(schemaNameOrId: string, avscFile: string) { + // Get the fully qualified schema name. + const schema = pubSubClient.schema(schemaNameOrId); + const name = await schema.getName(); + + // Read the new schema definition from storage. + const definition: string = fs.readFileSync(avscFile).toString(); + + // Use the gapic client to commit the new definition. + const schemaClient = await pubSubClient.getSchemaClient(); + const [result] = await schemaClient.commitSchema({ + name, + schema: { + name, + type: SchemaTypes.Avro, + definition, + }, + }); + + console.log(`Schema ${name} committed with revision ${result.revisionId}.`); +} +// [END pubsub_commit_avro_schema] + +function main( + schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID', + avscFile = 'path/to/an/avro/schema/file/(.avsc)/formatted/in/json' +) { + commitAvroSchema(schemaNameOrId, avscFile).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); +} + +main(...process.argv.slice(2)); diff --git a/samples/typescript/commitProtoSchema.ts b/samples/typescript/commitProtoSchema.ts new file mode 100644 index 000000000..b540ed98e --- /dev/null +++ b/samples/typescript/commitProtoSchema.ts @@ -0,0 +1,76 @@ +// 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 application 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: Commit an Proto-Based Schema +// description: Commits a new schema definition revision on a project, using Protos +// usage: node commitProtoSchema.js + +// [START pubsub_commit_proto_schema] +/** + * TODO(developer): Uncomment these variables before running the sample. + */ +// const schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID'; +// const protoFile = 'path/to/a/proto/schema/file/(.proto)/formatted/in/protcol/buffers'; + +// Imports the Google Cloud client library +import {PubSub, SchemaTypes} from '@google-cloud/pubsub'; + +import * as fs from 'fs'; + +// Creates a client; cache this for further use +const pubSubClient = new PubSub(); + +async function commitProtoSchema(schemaNameOrId: string, protoFile: string) { + // Get the fully qualified schema name. + const schema = pubSubClient.schema(schemaNameOrId); + const name = await schema.getName(); + + // Read the new schema definition from storage. + const definition: string = fs.readFileSync(protoFile).toString(); + + // Use the gapic client to commit the new definition. + const schemaClient = await pubSubClient.getSchemaClient(); + const [result] = await schemaClient.commitSchema({ + name, + schema: { + name, + type: SchemaTypes.ProtocolBuffer, + definition, + }, + }); + + console.log(`Schema ${name} committed with revision ${result.revisionId}.`); +} +// [END pubsub_commit_proto_schema] + +function main( + schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID', + protoFile = 'path/to/a/proto/schema/file/(.proto)/formatted/in/protcol/buffers' +) { + commitProtoSchema(schemaNameOrId, protoFile).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); +} + +main(...process.argv.slice(2)); diff --git a/samples/typescript/createTopicWithSchemaRevisions.ts b/samples/typescript/createTopicWithSchemaRevisions.ts new file mode 100644 index 000000000..62d70d860 --- /dev/null +++ b/samples/typescript/createTopicWithSchemaRevisions.ts @@ -0,0 +1,89 @@ +// 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 +// +// https://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 sample demonstrates how to perform basic operations on topics 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 Topic With Schema Revisions +// description: Creates a new topic, with a schema definition and revisions. +// usage: node createTopicWithSchema.js + +// [START pubsub_create_topic_with_schema_revisions] +/** + * TODO(developer): Uncomment these variables before running the sample. + */ +// const topicNameOrId = 'YOUR_TOPIC_NAME_OR_ID'; +// const schemaName = 'YOUR_SCHEMA_NAME_OR_ID'; +// const encodingType = 'BINARY'; +// const firstRevisionId = 'YOUR_REVISION_ID'; +// const lastRevisionId = 'YOUR_REVISION_ID'; + +// Imports the Google Cloud client library +import {PubSub} from '@google-cloud/pubsub'; + +// Creates a client; cache this for further use +const pubSubClient = new PubSub(); + +async function createTopicWithSchemaRevisions( + topicNameOrId: string, + schemaNameOrId: string, + encodingType: 'BINARY' | 'JSON', + firstRevisionId: string, + lastRevisionId: string +) { + // Get the fully qualified schema name. + const schema = pubSubClient.schema(schemaNameOrId); + const fullName = await schema.getName(); + + // Creates a new topic with a schema. Note that you might also + // pass Encodings.Json or Encodings.Binary here. + await pubSubClient.createTopic({ + name: topicNameOrId, + schemaSettings: { + schema: fullName, + encoding: encodingType, + firstRevisionId, + lastRevisionId, + }, + }); + console.log(`Topic ${topicNameOrId} created with schema ${fullName}.`); +} +// [END pubsub_create_topic_with_schema_revisions] + +function main( + topicNameOrId = 'YOUR_TOPIC_NAME_OR_ID', + schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID', + encodingType: 'BINARY' | 'JSON' = 'BINARY', + firstRevisionId = 'YOUR_REVISION_ID', + lastRevisionId = 'YOUR_REVISION_ID' +) { + createTopicWithSchemaRevisions( + topicNameOrId, + schemaNameOrId, + encodingType, + firstRevisionId, + lastRevisionId + ).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); +} + +main(...process.argv.slice(2)); diff --git a/samples/typescript/deleteSchemaRevision.ts b/samples/typescript/deleteSchemaRevision.ts new file mode 100644 index 000000000..c7d5928f0 --- /dev/null +++ b/samples/typescript/deleteSchemaRevision.ts @@ -0,0 +1,69 @@ +// 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 application 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: Delete a Schema Revision +// description: Deletes a schema revision on a project +// usage: node deleteSchemaRevision.js + +// [START pubsub_delete_schema_revision] +/** + * TODO(developer): Uncomment these variables before running the sample. + */ +// const schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID'; +// const revisionId = 'YOUR_REVISION_ID'; + +// Imports the Google Cloud client library +import {PubSub} from '@google-cloud/pubsub'; + +// Creates a client; cache this for further use +const pubSubClient = new PubSub(); + +async function deleteSchemaRevision( + schemaNameOrId: string, + revisionId: string +) { + // Get the fully qualified schema name. + const schema = pubSubClient.schema(schemaNameOrId); + const name = await schema.getName(); + + // Use the gapic client to delete the schema revision. + const schemaClient = await pubSubClient.getSchemaClient(); + await schemaClient.deleteSchemaRevision({ + name: `${name}@${revisionId}`, + }); + + console.log(`Schema ${name} revision ${revisionId} deleted.`); +} +// [END pubsub_delete_schema_revision] + +function main( + schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID', + revisionId = 'YOUR_REVISION_ID' +) { + deleteSchemaRevision(schemaNameOrId, revisionId).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); +} + +main(...process.argv.slice(2)); diff --git a/samples/typescript/getSchemaRevision.ts b/samples/typescript/getSchemaRevision.ts new file mode 100644 index 000000000..1650cc9e2 --- /dev/null +++ b/samples/typescript/getSchemaRevision.ts @@ -0,0 +1,67 @@ +// 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: Get a previously created schema revision +// description: Gets information about a schema revision which was previously created in the project. +// usage: node getSchemaRevision.js + +// [START pubsub_get_schema_revision] +/** + * TODO(developer): Uncomment this variable before running the sample. + */ +// const schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID'; +// const revisionId = 'YOUR_REVISION_ID'; + +// Imports the Google Cloud client library +import {PubSub} from '@google-cloud/pubsub'; + +// Creates a client; cache this for further use +const pubSubClient = new PubSub(); + +async function getSchemaRevision(schemaNameOrId: string, revisionId: string) { + const schema = pubSubClient.schema(schemaNameOrId); + const name = await schema.getName(); + + // Use the gapic client to delete the schema revision. + const schemaClient = await pubSubClient.getSchemaClient(); + const schemaInfo = await schemaClient.getSchema({ + name: `${name}@${revisionId}`, + }); + + console.log( + `Schema ${name}@${revisionId} info: ${JSON.stringify(schemaInfo, null, 4)}.` + ); +} +// [END pubsub_get_schema_revision] + +function main( + schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID', + revisionId = 'YOUR_REVISION_ID' +) { + getSchemaRevision(schemaNameOrId, revisionId).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); +} + +main(...process.argv.slice(2)); diff --git a/samples/typescript/listSchemaRevisions.ts b/samples/typescript/listSchemaRevisions.ts new file mode 100644 index 000000000..e7b49bdce --- /dev/null +++ b/samples/typescript/listSchemaRevisions.ts @@ -0,0 +1,64 @@ +// 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 application 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: List Revisions on a Schema +// description: Gets a list of revisions on a schema which was previously created in the project. +// usage: node listSchemaRevisions.js + +// [START pubsub_list_schema_revisions] +/** + * TODO(developer): Uncomment this variable before running the sample. + */ +// const schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID'; + +// Imports the Google Cloud client library +import {PubSub} from '@google-cloud/pubsub'; + +// Creates a client; cache this for further use +const pubSubClient = new PubSub(); + +async function listSchemaRevisions(schemaNameOrId: string) { + // Get the fully qualified schema name. + const schema = pubSubClient.schema(schemaNameOrId); + const name = await schema.getName(); + + // Use the gapic client to list the schema revisions. + const schemaClient = await pubSubClient.getSchemaClient(); + const [results] = await schemaClient.listSchemaRevisions({ + name, + }); + for (const rev of results) { + console.log(rev.revisionId, rev.revisionCreateTime); + } + console.log(`Listed revisions of schema ${name}.`); +} +// [END pubsub_list_schema_revisions] + +function main(schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID') { + listSchemaRevisions(schemaNameOrId).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); +} + +main(...process.argv.slice(2)); diff --git a/samples/typescript/listenForAvroRecords.ts b/samples/typescript/listenForAvroRecords.ts index f479e04c1..665141731 100644 --- a/samples/typescript/listenForAvroRecords.ts +++ b/samples/typescript/listenForAvroRecords.ts @@ -100,7 +100,8 @@ function main( try { listenForAvroRecords(subscriptionNameOrId, timeout); - } catch (err) { + } catch (e) { + const err = e as Error; console.error(err.message); process.exitCode = 1; } diff --git a/samples/typescript/listenForAvroRecordsWithRevisions.ts b/samples/typescript/listenForAvroRecordsWithRevisions.ts new file mode 100644 index 000000000..cb5f4e7cf --- /dev/null +++ b/samples/typescript/listenForAvroRecordsWithRevisions.ts @@ -0,0 +1,140 @@ +// 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 + * subscriptions 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: Listen For Avro Records With Revisions +// description: Listens for records in Avro encoding from a subscription with schema revisions. +// usage: node listenForAvroRecordsWithRevisions.js [timeout-in-seconds] + +// [START pubsub_subscribe_avro_records_with_revisions] +/** + * TODO(developer): Uncomment these variables before running the sample. + */ +// const subscriptionNameOrId = 'YOUR_SUBSCRIPTION_NAME_OR_ID'; +// const timeout = 60; + +// Imports the Google Cloud client library +import {PubSub, Schema, Encodings, Message} from '@google-cloud/pubsub'; + +// And the Apache Avro library; this lacks typings, so for +// TypeScript, a few synthetic types were created. +import * as avro from 'avro-js'; + +// Creates a client; cache this for further use +const pubSubClient = new PubSub(); + +interface ProvinceObject { + name: string; + post_abbr: string; +} + +async function listenForAvroRecordsWithRevisions( + subscriptionNameOrId: string, + timeout: number +) { + // References an existing subscription + const subscription = pubSubClient.subscription(subscriptionNameOrId); + + // Cache decoders for various schema revisions. + const revisionReaders = new Map(); + + // We need a schema admin service client to retrieve revisions. + const schemaClient = await pubSubClient.getSchemaClient(); + + // Create an event handler to handle messages + let messageCount = 0; + const messageHandler = async (message: Message) => { + // Get the schema metadata from the message. + const schemaMetadata = Schema.metadataFromMessage(message.attributes); + + let reader: avro.Parser; + try { + // Do we already have a decoder for this revision? + const revision = schemaMetadata.revision!; + if (revisionReaders.has(revision)) { + reader = revisionReaders.get(revision)!; + } else { + // This is the first time we are seeing this revision. We need to + // fetch the schema and cache its decoder. + const [schema] = await schemaClient.getSchema({ + name: `${schemaMetadata.name}@${schemaMetadata.revision}`, + }); + reader = avro.parse(schema.definition!); + revisionReaders.set(revision, reader); + } + } catch (err: unknown) { + console.log('Could not get schema', err); + message.nack(); + return; + } + + let result: ProvinceObject | undefined; + switch (schemaMetadata.encoding) { + case Encodings.Binary: + result = reader.fromBuffer(message.data); + break; + case Encodings.Json: + result = reader.fromString(message.data.toString()); + break; + default: + console.log(`Unknown schema encoding: ${schemaMetadata.encoding}`); + message.nack(); + return; + } + + console.log(`Received message ${message.id}:`); + console.log(`\tData: ${JSON.stringify(result, null, 4)}`); + console.log(`\tAttributes: ${message.attributes}`); + console.log( + `\tProvince ${result?.name} is abbreviated as ${result?.post_abbr}` + ); + messageCount += 1; + + // Ack the message. + message.ack(); + }; + + // Listen for new messages until timeout is hit + subscription.on('message', messageHandler); + + setTimeout(() => { + subscription.removeListener('message', messageHandler); + console.log(`${messageCount} message(s) received.`); + }, timeout * 1000); +} +// [END pubsub_subscribe_avro_records_with_revisions] + +function main( + subscriptionNameOrId = 'YOUR_SUBSCRIPTION_NAME_OR_ID', + timeout = 60 +) { + timeout = Number(timeout); + + listenForAvroRecordsWithRevisions(subscriptionNameOrId, timeout).catch( + err => { + console.error(err.message); + process.exitCode = 1; + } + ); +} + +main(...process.argv.slice(2)); diff --git a/samples/typescript/rollbackSchema.ts b/samples/typescript/rollbackSchema.ts new file mode 100644 index 000000000..d2e1ac30f --- /dev/null +++ b/samples/typescript/rollbackSchema.ts @@ -0,0 +1,67 @@ +// 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 application 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: Rollback a Schema +// description: Rolls back a schema on a project +// usage: node rollbackSchema.js + +// [START pubsub_rollback_schema] +/** + * TODO(developer): Uncomment these variables before running the sample. + */ +// const schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID'; +// const revisionId = 'YOUR_REVISION_ID'; + +// Imports the Google Cloud client library +import {PubSub} from '@google-cloud/pubsub'; + +// Creates a client; cache this for further use +const pubSubClient = new PubSub(); + +async function rollbackSchema(schemaNameOrId: string, revisionId: string) { + // Get the fully qualified schema name. + const schema = pubSubClient.schema(schemaNameOrId); + const name = await schema.getName(); + + // Use the gapic client to roll back the schema revision. + const schemaClient = await pubSubClient.getSchemaClient(); + await schemaClient.rollbackSchema({ + name, + revisionId, + }); + + console.log(`Schema ${name} revision ${revisionId} rolled back.`); +} +// [END pubsub_rollback_schema] + +function main( + schemaNameOrId = 'YOUR_SCHEMA_NAME_OR_ID', + revisionId = 'YOUR_REVISION_ID' +) { + rollbackSchema(schemaNameOrId, revisionId).catch(err => { + console.error(err.message); + process.exitCode = 1; + }); +} + +main(...process.argv.slice(2)); diff --git a/samples/typescript/updateTopicSchema.ts b/samples/typescript/updateTopicSchema.ts new file mode 100644 index 000000000..c31bad802 --- /dev/null +++ b/samples/typescript/updateTopicSchema.ts @@ -0,0 +1,73 @@ +// 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 application demonstrates how to perform basic operations on + * subscriptions 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: Update Topic Schema +// description: Update the schema on a topic. +// usage: node updateTopicSchema.js + +// [START pubsub_update_topic_schema] +/** + * TODO(developer): Uncomment these variables before running the sample. + */ +// const topicNameOrId = 'YOUR_TOPIC_NAME_OR_ID'; +// const firstRevisionId = 'YOUR_REVISION_ID'; +// const lastRevisionId = 'YOUR_REVISION_ID'; + +// Imports the Google Cloud client library +import {PubSub, TopicMetadata} from '@google-cloud/pubsub'; + +// Creates a client; cache this for further use +const pubSubClient = new PubSub(); + +async function updateTopicSchema( + topicNameOrId: string, + firstRevisionId: string, + lastRevisionId: string +) { + const metadata: TopicMetadata = { + schemaSettings: { + firstRevisionId, + lastRevisionId, + }, + }; + + await pubSubClient.topic(topicNameOrId).setMetadata(metadata); + + console.log('Schema metadata updated successfully.'); +} +// [END pubsub_update_topic_schema] + +function main( + topicNameOrId = 'YOUR_TOPIC_NAME_OR_ID', + firstRevisionId = 'YOUR_REVISION_ID', + lastRevisionId = 'YOUR_REVISION_ID' +) { + updateTopicSchema(topicNameOrId, firstRevisionId, lastRevisionId).catch( + err => { + console.error(err.message); + process.exitCode = 1; + } + ); +} + +main(...process.argv.slice(2)); diff --git a/samples/updateTopicSchema.js b/samples/updateTopicSchema.js new file mode 100644 index 000000000..5de59bcd9 --- /dev/null +++ b/samples/updateTopicSchema.js @@ -0,0 +1,77 @@ +// 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 application demonstrates how to perform basic operations on + * subscriptions 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: Update Topic Schema +// description: Update the schema on a topic. +// usage: node updateTopicSchema.js + +// [START pubsub_update_topic_schema] +/** + * TODO(developer): Uncomment these variables before running the sample. + */ +// const topicNameOrId = 'YOUR_TOPIC_NAME_OR_ID'; +// const firstRevisionId = 'YOUR_REVISION_ID'; +// const lastRevisionId = 'YOUR_REVISION_ID'; + +// 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 updateTopicSchema( + topicNameOrId, + firstRevisionId, + lastRevisionId +) { + const metadata = { + schemaSettings: { + firstRevisionId, + lastRevisionId, + }, + }; + + await pubSubClient.topic(topicNameOrId).setMetadata(metadata); + + console.log('Schema metadata updated successfully.'); +} +// [END pubsub_update_topic_schema] + +function main( + topicNameOrId = 'YOUR_TOPIC_NAME_OR_ID', + firstRevisionId = 'YOUR_REVISION_ID', + lastRevisionId = 'YOUR_REVISION_ID' +) { + updateTopicSchema(topicNameOrId, firstRevisionId, lastRevisionId).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 e7fc0d819..a0aa2876a 100644 --- a/src/pubsub.ts +++ b/src/pubsub.ts @@ -400,7 +400,7 @@ export class PubSub { }, }; - const client = await this.getSchemaClient_(); + const client = await this.getSchemaClient(); await client.createSchema(request, gaxOpts); return new Schema(this, schemaName); } @@ -841,7 +841,7 @@ export class PubSub { view: SchemaView = SchemaViews.Basic, options?: CallOptions ): AsyncIterable { - const client = await this.getSchemaClient_(); + const client = await this.getSchemaClient(); const query = { parent: this.name, view, @@ -1218,10 +1218,12 @@ export class PubSub { } /** - * Gets a schema client, creating one if needed. - * @private + * Gets a schema client, creating one if needed. This is a shortcut for + * `new v1.SchemaServiceClient(await pubsub.getClientConfig())`. + * + * @returns {Promise} */ - async getSchemaClient_(): Promise { + async getSchemaClient(): Promise { if (!this.schemaClient) { const options = await this.getClientConfig(); this.schemaClient = new v1.SchemaServiceClient(options); @@ -1450,7 +1452,7 @@ export class PubSub { * @returns {Promise} */ async validateSchema(schema: ISchema, gaxOpts?: CallOptions): Promise { - const client = await this.getSchemaClient_(); + const client = await this.getSchemaClient(); await client.validateSchema( { parent: this.name, diff --git a/src/schema.ts b/src/schema.ts index 93cb624af..a332d0aff 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -144,7 +144,7 @@ export class Schema { view: SchemaView = SchemaViews.Full, gaxOpts?: CallOptions ): Promise { - const client = await this.pubsub.getSchemaClient_(); + const client = await this.pubsub.getSchemaClient(); const name = await this.getName(); const [schema] = await client.getSchema( { @@ -167,7 +167,7 @@ export class Schema { * @returns {Promise} */ async delete(gaxOpts?: CallOptions): Promise { - const client = await this.pubsub.getSchemaClient_(); + const client = await this.pubsub.getSchemaClient(); const name = await this.getName(); await client.deleteSchema( { @@ -202,7 +202,7 @@ export class Schema { | keyof typeof google.pubsub.v1.Encoding, gaxOpts?: CallOptions ): Promise { - const client = await this.pubsub.getSchemaClient_(); + const client = await this.pubsub.getSchemaClient(); const name = await this.getName(); await client.validateMessage( @@ -244,6 +244,7 @@ export class Schema { static metadataFromMessage(attributes: Attributes): SchemaMessageMetadata { return { name: attributes['googclient_schemaname'], + revision: attributes['googclient_schemarevisionid'], encoding: attributes[ 'googclient_schemaencoding' ] as unknown as SchemaEncoding, @@ -261,6 +262,11 @@ export interface SchemaMessageMetadata { */ name?: string; + /** + * Schema revision; this goes with {@link name} as needed. + */ + revision?: string; + /** * Encoding; this will be Encodings.Json or Encodings.Binary. */ diff --git a/test/pubsub.ts b/test/pubsub.ts index 668857690..08803c0d8 100644 --- a/test/pubsub.ts +++ b/test/pubsub.ts @@ -1686,7 +1686,7 @@ describe('PubSub', () => { it('should close the schema client when it has been opened', async () => { // Force it to create a client. - const client = await pubsub.getSchemaClient_?.(); + const client = await pubsub.getSchemaClient?.(); sandbox.stub(client!, 'close').resolves(); await pubsub.close?.(); }); @@ -1707,7 +1707,7 @@ describe('PubSub', () => { const name = Schema.formatName_(pubsub.projectId!, schemaId); // Grab the schema client it'll be using so we can stub it. - const client = await pubsub.getSchemaClient_!(); + const client = await pubsub.getSchemaClient!(); const def = defer(); sandbox.stub(client, 'createSchema').callsFake(req => { assert.strictEqual(req.parent, pubsub.name); @@ -1726,7 +1726,7 @@ describe('PubSub', () => { it('calls down to listSchemas correctly', async () => { // Grab the schema client it'll be using so we can stub it. - const client = await pubsub.getSchemaClient_!(); + const client = await pubsub.getSchemaClient!(); sandbox.stub(client, 'listSchemasAsync').callsFake((req, gaxOpts) => { assert.strictEqual(req!.parent, pubsub.name); @@ -1754,7 +1754,7 @@ describe('PubSub', () => { it('defaults to BASIC for listSchemas', async () => { // Grab the schema client it'll be using so we can stub it. - const client = await pubsub.getSchemaClient_?.(); + const client = await pubsub.getSchemaClient?.(); sandbox.stub(client!, 'listSchemasAsync').callsFake(req => { assert.strictEqual(req!.view, 'BASIC'); @@ -1777,7 +1777,7 @@ describe('PubSub', () => { }); it('calls validateSchema() on the client when validateSchema() is called', async () => { - const client = await pubsub.getSchemaClient_!(); + const client = await pubsub.getSchemaClient!(); const ischema: ISchema = { name: 'test', type: SchemaTypes.Avro, diff --git a/test/schema.ts b/test/schema.ts index 578a1e61d..d1e629464 100644 --- a/test/schema.ts +++ b/test/schema.ts @@ -49,7 +49,7 @@ describe('Schema', () => { // These depend on the create-on-first-call structure in PubSub. // If that changes, this will also need to be updated. - schemaClient = await pubsub.getSchemaClient_(); + schemaClient = await pubsub.getSchemaClient(); schema = pubsub.schema(schemaName); }); @@ -175,11 +175,13 @@ describe('Schema', () => { it('loads metadata from a received message', () => { const testAttrs = { googclient_schemaencoding: 'JSON', + googclient_schemarevisionid: 'revision', googclient_schemaname: 'foobar', }; const metadata = Schema.metadataFromMessage(testAttrs); assert.deepStrictEqual(metadata, { name: 'foobar', + revision: 'revision', encoding: 'JSON', }); }); From 2ee0dba67e6d66d9a678796de6172bcafd28796b Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Wed, 31 Jan 2024 20:54:03 +0100 Subject: [PATCH 5/8] fix(deps): update dependency @opentelemetry/semantic-conventions to ~1.20.0 (#1871) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(deps): update dependency @opentelemetry/semantic-conventions to ~1.20.0 * 🦉 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: Megan Potter <57276408+feywind@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4ad24e802..cbbc91bdb 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@google-cloud/projectify": "^4.0.0", "@google-cloud/promisify": "^4.0.0", "@opentelemetry/api": "^1.6.0", - "@opentelemetry/semantic-conventions": "~1.19.0", + "@opentelemetry/semantic-conventions": "~1.20.0", "@types/duplexify": "^3.6.0", "@types/long": "^4.0.0", "arrify": "^2.0.0", From 6bfde079a47b1584196e7aa4caf71673d58c671c Mon Sep 17 00:00:00 2001 From: Richard Nias <7244202+richardnias@users.noreply.github.com> Date: Wed, 31 Jan 2024 21:24:15 +0100 Subject: [PATCH 6/8] docs: correct max messages (#1874) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [X] Make sure to open an issue as a [bug/issue](https://togithub.com/googleapis/nodejs-pubsub/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) Fixes #1744 🦕 Note: If you are opening a pull request against a `legacy` branch, PLEASE BE AWARE that we generally won't accept these except for things like important security fixes, and only for a limited time. --- src/subscription.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/subscription.ts b/src/subscription.ts index b3585b588..a39f66e8c 100644 --- a/src/subscription.ts +++ b/src/subscription.ts @@ -161,7 +161,7 @@ export declare interface Subscription { * Upon the closing of the subscriber: * on(event: 'close', listener: Function): this; * - * By default Subscription objects allow you to process 100 messages at the same + * By default Subscription objects allow you to process 1000 messages at the same * time. You can fine tune this value by adjusting the * `options.flowControl.maxMessages` option. * From 0fe61a95b3bfc21bd1a5176c7fbd7f822ece5a5c Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Thu, 1 Feb 2024 10:50:15 +0100 Subject: [PATCH 7/8] fix(deps): update dependency @opentelemetry/semantic-conventions to ~1.21.0 (#1876) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@opentelemetry/semantic-conventions](https://togithub.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-semantic-conventions) ([source](https://togithub.com/open-telemetry/opentelemetry-js)) | [`~1.20.0` -> `~1.21.0`](https://renovatebot.com/diffs/npm/@opentelemetry%2fsemantic-conventions/1.20.0/1.21.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@opentelemetry%2fsemantic-conventions/1.21.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@opentelemetry%2fsemantic-conventions/1.21.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@opentelemetry%2fsemantic-conventions/1.20.0/1.21.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@opentelemetry%2fsemantic-conventions/1.20.0/1.21.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
open-telemetry/opentelemetry-js (@​opentelemetry/semantic-conventions) ### [`v1.21.0`](https://togithub.com/open-telemetry/opentelemetry-js/blob/HEAD/CHANGELOG.md#1210) [Compare Source](https://togithub.com/open-telemetry/opentelemetry-js/compare/v1.20.0...v1.21.0) ##### :rocket: (Enhancement) - feat(sdk-metrics): add constructor option to add metric readers [#​4427](https://togithub.com/open-telemetry/opentelemetry-js/pull/4427) [@​pichlermarc](https://togithub.com/pichlermarc) - deprecates `MeterProvider.addMetricReader()` please use the constructor option `readers` instead. ##### :bug: (Bug Fix) - fix(sdk-trace-base): ensure attribute value length limit is enforced on span creation [#​4417](https://togithub.com/open-telemetry/opentelemetry-js/pull/4417) [@​pichlermarc](https://togithub.com/pichlermarc) - fix(sdk-trace-base): Export processed spans while exporter failed [#​4287](https://togithub.com/open-telemetry/opentelemetry-js/pull/4287) [@​Zirak](https://togithub.com/Zirak) ##### :house: (Internal) - chore(opentelemetry-context-zone-peer-dep): support zone.js ^v0.13.0 [#​4320](https://togithub.com/open-telemetry/opentelemetry-js/pull/4320) - refactor(core): drop unnecessary assignment of HOSTNAME [#​4421](https://togithub.com/open-telemetry/opentelemetry-js/pull/4421) [@​pichlermarc](https://togithub.com/pichlermarc) - test(opentelemetry-context-zone-peer-dep): transpile zone.js in tests [#​4423](https://togithub.com/open-telemetry/opentelemetry-js/pull/4423) [@​legendecas](https://togithub.com/legendecas)
--- ### Configuration 📅 **Schedule**: Branch creation - "after 9am and before 3pm" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/googleapis/nodejs-pubsub). --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cbbc91bdb..32aeaba9e 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@google-cloud/projectify": "^4.0.0", "@google-cloud/promisify": "^4.0.0", "@opentelemetry/api": "^1.6.0", - "@opentelemetry/semantic-conventions": "~1.20.0", + "@opentelemetry/semantic-conventions": "~1.21.0", "@types/duplexify": "^3.6.0", "@types/long": "^4.0.0", "arrify": "^2.0.0", From 979174c0a180febfe2a32971e7fabb354636db59 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 13:05:45 -0500 Subject: [PATCH 8/8] chore(main): release 4.2.0 (#1875) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 14 ++++++++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a0a57759..c24b8ff13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,20 @@ [1]: https://www.npmjs.com/package/@google-cloud/pubsub?activeTab=versions +## [4.2.0](https://github.com/googleapis/nodejs-pubsub/compare/v4.1.1...v4.2.0) (2024-02-01) + + +### Features + +* Add enforce_in_transit fields and optional annotations ([#1873](https://github.com/googleapis/nodejs-pubsub/issues/1873)) ([09fc424](https://github.com/googleapis/nodejs-pubsub/commit/09fc4241c8782d2f60c1a78dda316628eca5f751)) +* Add schema revision samples ([#1870](https://github.com/googleapis/nodejs-pubsub/issues/1870)) ([044e149](https://github.com/googleapis/nodejs-pubsub/commit/044e1494d82fd64010f7c6f872982d659e753499)) + + +### Bug Fixes + +* **deps:** Update dependency @opentelemetry/semantic-conventions to ~1.20.0 ([#1871](https://github.com/googleapis/nodejs-pubsub/issues/1871)) ([2ee0dba](https://github.com/googleapis/nodejs-pubsub/commit/2ee0dba67e6d66d9a678796de6172bcafd28796b)) +* **deps:** Update dependency @opentelemetry/semantic-conventions to ~1.21.0 ([#1876](https://github.com/googleapis/nodejs-pubsub/issues/1876)) ([0fe61a9](https://github.com/googleapis/nodejs-pubsub/commit/0fe61a95b3bfc21bd1a5176c7fbd7f822ece5a5c)) + ## [4.1.1](https://github.com/googleapis/nodejs-pubsub/compare/v4.1.0...v4.1.1) (2024-01-05) diff --git a/package.json b/package.json index 32aeaba9e..0df8e7ed0 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.1.1", + "version": "4.2.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index e095c9c65..778c2783b 100644 --- a/samples/package.json +++ b/samples/package.json @@ -21,7 +21,7 @@ "precompile": "npm run clean" }, "dependencies": { - "@google-cloud/pubsub": "^4.1.1", + "@google-cloud/pubsub": "^4.2.0", "@opentelemetry/api": "^1.6.0", "@opentelemetry/tracing": "^0.24.0", "avro-js": "^1.11.3",