diff --git a/protos/google/pubsub/v1/pubsub.proto b/protos/google/pubsub/v1/pubsub.proto index 909863eb9..9bc678e3a 100644 --- a/protos/google/pubsub/v1/pubsub.proto +++ b/protos/google/pubsub/v1/pubsub.proto @@ -24,6 +24,7 @@ import "google/protobuf/duration.proto"; import "google/protobuf/empty.proto"; import "google/protobuf/field_mask.proto"; import "google/protobuf/timestamp.proto"; +import "google/pubsub/v1/schema.proto"; option cc_enable_arenas = true; option csharp_namespace = "Google.Cloud.PubSub.V1"; @@ -42,8 +43,8 @@ service Publisher { "https://www.googleapis.com/auth/cloud-platform," "https://www.googleapis.com/auth/pubsub"; - // Creates the given topic with the given name. See the [resource name rules]( - // https://cloud.google.com/pubsub/docs/admin#resource_names). + // Creates the given topic with the given name. See the [resource name rules] + // (https://cloud.google.com/pubsub/docs/admin#resource_names). rpc CreateTopic(Topic) returns (Topic) { option (google.api.http) = { put: "/v1/{name=projects/*/topics/*}" @@ -143,6 +144,21 @@ message MessageStoragePolicy { repeated string allowed_persistence_regions = 1; } +// Settings for validating messages published against a schema. +message SchemaSettings { + // Required. The name of the schema that messages published should be + // validated against. Format is `projects/{project}/schemas/{schema}`. The + // value of this field will be `_deleted-schema_` if the schema has been + // deleted. + string schema = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "pubsub.googleapis.com/Schema" } + ]; + + // The encoding of messages validated against `schema`. + Encoding encoding = 2; +} + // A topic resource. message Topic { option (google.api.resource) = { @@ -173,6 +189,15 @@ message Topic { // // The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*`. string kms_key_name = 5; + + // Settings for validating messages published against a schema. + // + // EXPERIMENTAL: Schema support is in development and may not work yet. + SchemaSettings schema_settings = 6; + + // 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; } // A message that is published by publishers and consumed by subscribers. The @@ -587,8 +612,8 @@ service Subscriber { } // Seeks an existing subscription to a point in time or to a given snapshot, - // whichever is provided in the request. Snapshots are used in [Seek]( - // https://cloud.google.com/pubsub/docs/replay-overview) operations, which + // whichever is provided in the request. 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 // state captured by a snapshot. Note that both the subscription and the diff --git a/protos/google/pubsub/v1/schema.proto b/protos/google/pubsub/v1/schema.proto new file mode 100644 index 000000000..ae402ac4d --- /dev/null +++ b/protos/google/pubsub/v1/schema.proto @@ -0,0 +1,289 @@ +// Copyright 2020 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. + +syntax = "proto3"; + +package google.pubsub.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/empty.proto"; + +option cc_enable_arenas = true; +option csharp_namespace = "Google.Cloud.PubSub.V1"; +option go_package = "google.golang.org/genproto/googleapis/pubsub/v1;pubsub"; +option java_multiple_files = true; +option java_outer_classname = "SchemaProto"; +option java_package = "com.google.pubsub.v1"; +option php_namespace = "Google\\Cloud\\PubSub\\V1"; +option ruby_package = "Google::Cloud::PubSub::V1"; + +// Service for doing schema-related operations. +// +// EXPERIMENTAL: The Schema service is in development and may not work yet. + +service SchemaService { + option (google.api.default_host) = "pubsub.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/pubsub"; + + // Creates a schema. + rpc CreateSchema(CreateSchemaRequest) returns (Schema) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/schemas" + body: "schema" + }; + option (google.api.method_signature) = "parent,schema,schema_id"; + } + + // Gets a schema. + rpc GetSchema(GetSchemaRequest) returns (Schema) { + option (google.api.http) = { + get: "/v1/{name=projects/*/schemas/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists schemas in a project. + rpc ListSchemas(ListSchemasRequest) returns (ListSchemasResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*}/schemas" + }; + option (google.api.method_signature) = "parent"; + } + + // Deletes a schema. + rpc DeleteSchema(DeleteSchemaRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/schemas/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Validates a schema. + rpc ValidateSchema(ValidateSchemaRequest) returns (ValidateSchemaResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/schemas:validate" + body: "*" + }; + option (google.api.method_signature) = "parent,schema"; + } + + // Validates a message against a schema. + rpc ValidateMessage(ValidateMessageRequest) + returns (ValidateMessageResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/schemas:validateMessage" + body: "*" + }; + } +} + +// A schema resource. +message Schema { + option (google.api.resource) = { + type: "pubsub.googleapis.com/Schema" + pattern: "projects/{project}/schemas/{schema}" + }; + + // Possible schema definition types. + enum Type { + // Default value. This value is unused. + TYPE_UNSPECIFIED = 0; + + // A Protocol Buffer schema definition. + PROTOCOL_BUFFER = 1; + + // An Avro schema definition. + AVRO = 2; + } + + // Required. Name of the schema. + // Format is `projects/{project}/schemas/{schema}`. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // The type of the schema definition. + Type type = 2; + + // The definition of the schema. This should contain a string representing + // the full definition of the schema that is a valid schema definition of + // the type specified in `type`. + string definition = 3; +} + +// Request for the CreateSchema method. +message CreateSchemaRequest { + // Required. The name of the project in which to create the schema. + // Format is `projects/{project-id}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "pubsub.googleapis.com/Schema" + } + ]; + + // Required. The schema object to create. + // + // This schema's `name` parameter is ignored. The schema object returned + // by CreateSchema will have a `name` made using the given `parent` and + // `schema_id`. + Schema schema = 2 [(google.api.field_behavior) = REQUIRED]; + + // 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. + string schema_id = 3; +} + +// View of Schema object fields to be returned by GetSchema and ListSchemas. +enum SchemaView { + // The default / unset value. + // The API will default to the BASIC view. + SCHEMA_VIEW_UNSPECIFIED = 0; + + // Include the name and type of the schema, but not the definition. + BASIC = 1; + + // Include all Schema object fields. + FULL = 2; +} + +// Request for the GetSchema method. +message GetSchemaRequest { + // Required. The name of the schema to get. + // Format is `projects/{project}/schemas/{schema}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "pubsub.googleapis.com/Schema" } + ]; + + // The set of fields to return in the response. If not set, returns a Schema + // with `name` and `type`, but not `definition`. Set to `FULL` to retrieve all + // fields. + SchemaView view = 2; +} + +// Request for the `ListSchemas` method. +message ListSchemasRequest { + // Required. The name of the project in which to list schemas. + // Format is `projects/{project-id}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // The set of Schema fields to return in the response. If not set, returns + // Schemas with `name` and `type`, but not `definition`. Set to `FULL` to + // retrieve all fields. + SchemaView view = 2; + + // Maximum number of schemas to return. + int32 page_size = 3; + + // The value returned by the last `ListSchemasResponse`; indicates that + // this is a continuation of a prior `ListSchemas` call, and that the + // system should return the next page of data. + string page_token = 4; +} + +// Response for the `ListSchemas` method. +message ListSchemasResponse { + // The resulting schemas. + repeated Schema schemas = 1; + + // If not empty, indicates that there may be more schemas that match the + // request; this value should be passed in a new `ListSchemasRequest`. + string next_page_token = 2; +} + +// Request for the `DeleteSchema` method. +message DeleteSchemaRequest { + // Required. Name of the schema to delete. + // Format is `projects/{project}/schemas/{schema}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "pubsub.googleapis.com/Schema" } + ]; +} + +// Request for the `ValidateSchema` method. +message ValidateSchemaRequest { + // Required. The name of the project in which to validate schemas. + // Format is `projects/{project-id}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Required. The schema object to validate. + Schema schema = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response for the `ValidateSchema` method. +message ValidateSchemaResponse {} + +// Request for the `ValidateMessage` method. +message ValidateMessageRequest { + // Required. The name of the project in which to validate schemas. + // Format is `projects/{project-id}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + oneof schema_spec { + // Name of the schema against which to validate. + // + // Format is `projects/{project}/schemas/{schema}`. + string name = 2 [ + (google.api.resource_reference) = { type: "pubsub.googleapis.com/Schema" } + ]; + + // Ad-hoc schema against which to validate + Schema schema = 3; + } + + // Message to validate against the provided `schema_spec`. + bytes message = 4; + + // The encoding expected for messages + Encoding encoding = 5; +} + +// Response for the `ValidateMessage` method. +message ValidateMessageResponse {} + +// Possible encoding types for messages. +enum Encoding { + // Unspecified + ENCODING_UNSPECIFIED = 0; + + // JSON encoding + JSON = 1; + + // Binary encoding, as defined by the schema type. For some schema types, + // binary encoding may not be available. + BINARY = 2; +} diff --git a/protos/protos.d.ts b/protos/protos.d.ts index a224ed79f..3f1eff323 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -326,6 +326,102 @@ export namespace google { public toJSON(): { [k: string]: any }; } + /** Properties of a SchemaSettings. */ + interface ISchemaSettings { + + /** SchemaSettings schema */ + schema?: (string|null); + + /** SchemaSettings encoding */ + encoding?: (google.pubsub.v1.Encoding|keyof typeof google.pubsub.v1.Encoding|null); + } + + /** Represents a SchemaSettings. */ + class SchemaSettings implements ISchemaSettings { + + /** + * Constructs a new SchemaSettings. + * @param [properties] Properties to set + */ + constructor(properties?: google.pubsub.v1.ISchemaSettings); + + /** SchemaSettings schema. */ + public schema: string; + + /** SchemaSettings encoding. */ + public encoding: (google.pubsub.v1.Encoding|keyof typeof google.pubsub.v1.Encoding); + + /** + * Creates a new SchemaSettings instance using the specified properties. + * @param [properties] Properties to set + * @returns SchemaSettings instance + */ + public static create(properties?: google.pubsub.v1.ISchemaSettings): google.pubsub.v1.SchemaSettings; + + /** + * Encodes the specified SchemaSettings message. Does not implicitly {@link google.pubsub.v1.SchemaSettings.verify|verify} messages. + * @param message SchemaSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.pubsub.v1.ISchemaSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SchemaSettings message, length delimited. Does not implicitly {@link google.pubsub.v1.SchemaSettings.verify|verify} messages. + * @param message SchemaSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.pubsub.v1.ISchemaSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SchemaSettings message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SchemaSettings + * @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.SchemaSettings; + + /** + * Decodes a SchemaSettings message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SchemaSettings + * @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.SchemaSettings; + + /** + * Verifies a SchemaSettings 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 SchemaSettings message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SchemaSettings + */ + public static fromObject(object: { [k: string]: any }): google.pubsub.v1.SchemaSettings; + + /** + * Creates a plain object from a SchemaSettings message. Also converts values to other types if specified. + * @param message SchemaSettings + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.pubsub.v1.SchemaSettings, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SchemaSettings to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + /** Properties of a Topic. */ interface ITopic { @@ -340,6 +436,12 @@ export namespace google { /** Topic kmsKeyName */ kmsKeyName?: (string|null); + + /** Topic schemaSettings */ + schemaSettings?: (google.pubsub.v1.ISchemaSettings|null); + + /** Topic satisfiesPzs */ + satisfiesPzs?: (boolean|null); } /** Represents a Topic. */ @@ -363,6 +465,12 @@ export namespace google { /** Topic kmsKeyName. */ public kmsKeyName: string; + /** Topic schemaSettings. */ + public schemaSettings?: (google.pubsub.v1.ISchemaSettings|null); + + /** Topic satisfiesPzs. */ + public satisfiesPzs: boolean; + /** * Creates a new Topic instance using the specified properties. * @param [properties] Properties to set @@ -4942,6 +5050,1155 @@ export namespace google { */ public toJSON(): { [k: string]: any }; } + + /** Represents a SchemaService */ + class SchemaService extends $protobuf.rpc.Service { + + /** + * Constructs a new SchemaService service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Creates new SchemaService service using the specified rpc implementation. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + * @returns RPC service. Useful where requests and/or responses are streamed. + */ + public static create(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): SchemaService; + + /** + * Calls CreateSchema. + * @param request CreateSchemaRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Schema + */ + public createSchema(request: google.pubsub.v1.ICreateSchemaRequest, callback: google.pubsub.v1.SchemaService.CreateSchemaCallback): void; + + /** + * Calls CreateSchema. + * @param request CreateSchemaRequest message or plain object + * @returns Promise + */ + public createSchema(request: google.pubsub.v1.ICreateSchemaRequest): Promise; + + /** + * Calls GetSchema. + * @param request GetSchemaRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Schema + */ + public getSchema(request: google.pubsub.v1.IGetSchemaRequest, callback: google.pubsub.v1.SchemaService.GetSchemaCallback): void; + + /** + * Calls GetSchema. + * @param request GetSchemaRequest message or plain object + * @returns Promise + */ + public getSchema(request: google.pubsub.v1.IGetSchemaRequest): Promise; + + /** + * Calls ListSchemas. + * @param request ListSchemasRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListSchemasResponse + */ + public listSchemas(request: google.pubsub.v1.IListSchemasRequest, callback: google.pubsub.v1.SchemaService.ListSchemasCallback): void; + + /** + * Calls ListSchemas. + * @param request ListSchemasRequest message or plain object + * @returns Promise + */ + public listSchemas(request: google.pubsub.v1.IListSchemasRequest): Promise; + + /** + * Calls DeleteSchema. + * @param request DeleteSchemaRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteSchema(request: google.pubsub.v1.IDeleteSchemaRequest, callback: google.pubsub.v1.SchemaService.DeleteSchemaCallback): void; + + /** + * Calls DeleteSchema. + * @param request DeleteSchemaRequest message or plain object + * @returns Promise + */ + public deleteSchema(request: google.pubsub.v1.IDeleteSchemaRequest): Promise; + + /** + * Calls ValidateSchema. + * @param request ValidateSchemaRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ValidateSchemaResponse + */ + public validateSchema(request: google.pubsub.v1.IValidateSchemaRequest, callback: google.pubsub.v1.SchemaService.ValidateSchemaCallback): void; + + /** + * Calls ValidateSchema. + * @param request ValidateSchemaRequest message or plain object + * @returns Promise + */ + public validateSchema(request: google.pubsub.v1.IValidateSchemaRequest): Promise; + + /** + * Calls ValidateMessage. + * @param request ValidateMessageRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ValidateMessageResponse + */ + public validateMessage(request: google.pubsub.v1.IValidateMessageRequest, callback: google.pubsub.v1.SchemaService.ValidateMessageCallback): void; + + /** + * Calls ValidateMessage. + * @param request ValidateMessageRequest message or plain object + * @returns Promise + */ + public validateMessage(request: google.pubsub.v1.IValidateMessageRequest): Promise; + } + + namespace SchemaService { + + /** + * Callback as used by {@link google.pubsub.v1.SchemaService#createSchema}. + * @param error Error, if any + * @param [response] Schema + */ + type CreateSchemaCallback = (error: (Error|null), response?: google.pubsub.v1.Schema) => void; + + /** + * Callback as used by {@link google.pubsub.v1.SchemaService#getSchema}. + * @param error Error, if any + * @param [response] Schema + */ + type GetSchemaCallback = (error: (Error|null), response?: google.pubsub.v1.Schema) => void; + + /** + * Callback as used by {@link google.pubsub.v1.SchemaService#listSchemas}. + * @param error Error, if any + * @param [response] ListSchemasResponse + */ + type ListSchemasCallback = (error: (Error|null), response?: google.pubsub.v1.ListSchemasResponse) => void; + + /** + * Callback as used by {@link google.pubsub.v1.SchemaService#deleteSchema}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteSchemaCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.pubsub.v1.SchemaService#validateSchema}. + * @param error Error, if any + * @param [response] ValidateSchemaResponse + */ + type ValidateSchemaCallback = (error: (Error|null), response?: google.pubsub.v1.ValidateSchemaResponse) => void; + + /** + * Callback as used by {@link google.pubsub.v1.SchemaService#validateMessage}. + * @param error Error, if any + * @param [response] ValidateMessageResponse + */ + type ValidateMessageCallback = (error: (Error|null), response?: google.pubsub.v1.ValidateMessageResponse) => void; + } + + /** Properties of a Schema. */ + interface ISchema { + + /** Schema name */ + name?: (string|null); + + /** Schema type */ + type?: (google.pubsub.v1.Schema.Type|keyof typeof google.pubsub.v1.Schema.Type|null); + + /** Schema definition */ + definition?: (string|null); + } + + /** Represents a Schema. */ + class Schema implements ISchema { + + /** + * Constructs a new Schema. + * @param [properties] Properties to set + */ + constructor(properties?: google.pubsub.v1.ISchema); + + /** Schema name. */ + public name: string; + + /** Schema type. */ + public type: (google.pubsub.v1.Schema.Type|keyof typeof google.pubsub.v1.Schema.Type); + + /** Schema definition. */ + public definition: string; + + /** + * Creates a new Schema instance using the specified properties. + * @param [properties] Properties to set + * @returns Schema instance + */ + public static create(properties?: google.pubsub.v1.ISchema): google.pubsub.v1.Schema; + + /** + * Encodes the specified Schema message. Does not implicitly {@link google.pubsub.v1.Schema.verify|verify} messages. + * @param message Schema message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.pubsub.v1.ISchema, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Schema message, length delimited. Does not implicitly {@link google.pubsub.v1.Schema.verify|verify} messages. + * @param message Schema message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.pubsub.v1.ISchema, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Schema message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Schema + * @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.Schema; + + /** + * Decodes a Schema message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Schema + * @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.Schema; + + /** + * Verifies a Schema 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 Schema message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Schema + */ + public static fromObject(object: { [k: string]: any }): google.pubsub.v1.Schema; + + /** + * Creates a plain object from a Schema message. Also converts values to other types if specified. + * @param message Schema + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.pubsub.v1.Schema, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Schema to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace Schema { + + /** Type enum. */ + enum Type { + TYPE_UNSPECIFIED = 0, + PROTOCOL_BUFFER = 1, + AVRO = 2 + } + } + + /** Properties of a CreateSchemaRequest. */ + interface ICreateSchemaRequest { + + /** CreateSchemaRequest parent */ + parent?: (string|null); + + /** CreateSchemaRequest schema */ + schema?: (google.pubsub.v1.ISchema|null); + + /** CreateSchemaRequest schemaId */ + schemaId?: (string|null); + } + + /** Represents a CreateSchemaRequest. */ + class CreateSchemaRequest implements ICreateSchemaRequest { + + /** + * Constructs a new CreateSchemaRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.pubsub.v1.ICreateSchemaRequest); + + /** CreateSchemaRequest parent. */ + public parent: string; + + /** CreateSchemaRequest schema. */ + public schema?: (google.pubsub.v1.ISchema|null); + + /** CreateSchemaRequest schemaId. */ + public schemaId: string; + + /** + * Creates a new CreateSchemaRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateSchemaRequest instance + */ + public static create(properties?: google.pubsub.v1.ICreateSchemaRequest): google.pubsub.v1.CreateSchemaRequest; + + /** + * Encodes the specified CreateSchemaRequest message. Does not implicitly {@link google.pubsub.v1.CreateSchemaRequest.verify|verify} messages. + * @param message CreateSchemaRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.pubsub.v1.ICreateSchemaRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateSchemaRequest message, length delimited. Does not implicitly {@link google.pubsub.v1.CreateSchemaRequest.verify|verify} messages. + * @param message CreateSchemaRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.pubsub.v1.ICreateSchemaRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateSchemaRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateSchemaRequest + * @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.CreateSchemaRequest; + + /** + * Decodes a CreateSchemaRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateSchemaRequest + * @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.CreateSchemaRequest; + + /** + * Verifies a CreateSchemaRequest 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 CreateSchemaRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateSchemaRequest + */ + public static fromObject(object: { [k: string]: any }): google.pubsub.v1.CreateSchemaRequest; + + /** + * Creates a plain object from a CreateSchemaRequest message. Also converts values to other types if specified. + * @param message CreateSchemaRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.pubsub.v1.CreateSchemaRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateSchemaRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** SchemaView enum. */ + enum SchemaView { + SCHEMA_VIEW_UNSPECIFIED = 0, + BASIC = 1, + FULL = 2 + } + + /** Properties of a GetSchemaRequest. */ + interface IGetSchemaRequest { + + /** GetSchemaRequest name */ + name?: (string|null); + + /** GetSchemaRequest view */ + view?: (google.pubsub.v1.SchemaView|keyof typeof google.pubsub.v1.SchemaView|null); + } + + /** Represents a GetSchemaRequest. */ + class GetSchemaRequest implements IGetSchemaRequest { + + /** + * Constructs a new GetSchemaRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.pubsub.v1.IGetSchemaRequest); + + /** GetSchemaRequest name. */ + public name: string; + + /** GetSchemaRequest view. */ + public view: (google.pubsub.v1.SchemaView|keyof typeof google.pubsub.v1.SchemaView); + + /** + * Creates a new GetSchemaRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetSchemaRequest instance + */ + public static create(properties?: google.pubsub.v1.IGetSchemaRequest): google.pubsub.v1.GetSchemaRequest; + + /** + * Encodes the specified GetSchemaRequest message. Does not implicitly {@link google.pubsub.v1.GetSchemaRequest.verify|verify} messages. + * @param message GetSchemaRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.pubsub.v1.IGetSchemaRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetSchemaRequest message, length delimited. Does not implicitly {@link google.pubsub.v1.GetSchemaRequest.verify|verify} messages. + * @param message GetSchemaRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.pubsub.v1.IGetSchemaRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetSchemaRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetSchemaRequest + * @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.GetSchemaRequest; + + /** + * Decodes a GetSchemaRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetSchemaRequest + * @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.GetSchemaRequest; + + /** + * Verifies a GetSchemaRequest 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 GetSchemaRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetSchemaRequest + */ + public static fromObject(object: { [k: string]: any }): google.pubsub.v1.GetSchemaRequest; + + /** + * Creates a plain object from a GetSchemaRequest message. Also converts values to other types if specified. + * @param message GetSchemaRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.pubsub.v1.GetSchemaRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetSchemaRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListSchemasRequest. */ + interface IListSchemasRequest { + + /** ListSchemasRequest parent */ + parent?: (string|null); + + /** ListSchemasRequest view */ + view?: (google.pubsub.v1.SchemaView|keyof typeof google.pubsub.v1.SchemaView|null); + + /** ListSchemasRequest pageSize */ + pageSize?: (number|null); + + /** ListSchemasRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListSchemasRequest. */ + class ListSchemasRequest implements IListSchemasRequest { + + /** + * Constructs a new ListSchemasRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.pubsub.v1.IListSchemasRequest); + + /** ListSchemasRequest parent. */ + public parent: string; + + /** ListSchemasRequest view. */ + public view: (google.pubsub.v1.SchemaView|keyof typeof google.pubsub.v1.SchemaView); + + /** ListSchemasRequest pageSize. */ + public pageSize: number; + + /** ListSchemasRequest pageToken. */ + public pageToken: string; + + /** + * Creates a new ListSchemasRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListSchemasRequest instance + */ + public static create(properties?: google.pubsub.v1.IListSchemasRequest): google.pubsub.v1.ListSchemasRequest; + + /** + * Encodes the specified ListSchemasRequest message. Does not implicitly {@link google.pubsub.v1.ListSchemasRequest.verify|verify} messages. + * @param message ListSchemasRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.pubsub.v1.IListSchemasRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListSchemasRequest message, length delimited. Does not implicitly {@link google.pubsub.v1.ListSchemasRequest.verify|verify} messages. + * @param message ListSchemasRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.pubsub.v1.IListSchemasRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListSchemasRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListSchemasRequest + * @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.ListSchemasRequest; + + /** + * Decodes a ListSchemasRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListSchemasRequest + * @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.ListSchemasRequest; + + /** + * Verifies a ListSchemasRequest 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 ListSchemasRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListSchemasRequest + */ + public static fromObject(object: { [k: string]: any }): google.pubsub.v1.ListSchemasRequest; + + /** + * Creates a plain object from a ListSchemasRequest message. Also converts values to other types if specified. + * @param message ListSchemasRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.pubsub.v1.ListSchemasRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListSchemasRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListSchemasResponse. */ + interface IListSchemasResponse { + + /** ListSchemasResponse schemas */ + schemas?: (google.pubsub.v1.ISchema[]|null); + + /** ListSchemasResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListSchemasResponse. */ + class ListSchemasResponse implements IListSchemasResponse { + + /** + * Constructs a new ListSchemasResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.pubsub.v1.IListSchemasResponse); + + /** ListSchemasResponse schemas. */ + public schemas: google.pubsub.v1.ISchema[]; + + /** ListSchemasResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListSchemasResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListSchemasResponse instance + */ + public static create(properties?: google.pubsub.v1.IListSchemasResponse): google.pubsub.v1.ListSchemasResponse; + + /** + * Encodes the specified ListSchemasResponse message. Does not implicitly {@link google.pubsub.v1.ListSchemasResponse.verify|verify} messages. + * @param message ListSchemasResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.pubsub.v1.IListSchemasResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListSchemasResponse message, length delimited. Does not implicitly {@link google.pubsub.v1.ListSchemasResponse.verify|verify} messages. + * @param message ListSchemasResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.pubsub.v1.IListSchemasResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListSchemasResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListSchemasResponse + * @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.ListSchemasResponse; + + /** + * Decodes a ListSchemasResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListSchemasResponse + * @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.ListSchemasResponse; + + /** + * Verifies a ListSchemasResponse 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 ListSchemasResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListSchemasResponse + */ + public static fromObject(object: { [k: string]: any }): google.pubsub.v1.ListSchemasResponse; + + /** + * Creates a plain object from a ListSchemasResponse message. Also converts values to other types if specified. + * @param message ListSchemasResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.pubsub.v1.ListSchemasResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListSchemasResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DeleteSchemaRequest. */ + interface IDeleteSchemaRequest { + + /** DeleteSchemaRequest name */ + name?: (string|null); + } + + /** Represents a DeleteSchemaRequest. */ + class DeleteSchemaRequest implements IDeleteSchemaRequest { + + /** + * Constructs a new DeleteSchemaRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.pubsub.v1.IDeleteSchemaRequest); + + /** DeleteSchemaRequest name. */ + public name: string; + + /** + * Creates a new DeleteSchemaRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteSchemaRequest instance + */ + public static create(properties?: google.pubsub.v1.IDeleteSchemaRequest): google.pubsub.v1.DeleteSchemaRequest; + + /** + * Encodes the specified DeleteSchemaRequest message. Does not implicitly {@link google.pubsub.v1.DeleteSchemaRequest.verify|verify} messages. + * @param message DeleteSchemaRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.pubsub.v1.IDeleteSchemaRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteSchemaRequest message, length delimited. Does not implicitly {@link google.pubsub.v1.DeleteSchemaRequest.verify|verify} messages. + * @param message DeleteSchemaRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.pubsub.v1.IDeleteSchemaRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteSchemaRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteSchemaRequest + * @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.DeleteSchemaRequest; + + /** + * Decodes a DeleteSchemaRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteSchemaRequest + * @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.DeleteSchemaRequest; + + /** + * Verifies a DeleteSchemaRequest 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 DeleteSchemaRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteSchemaRequest + */ + public static fromObject(object: { [k: string]: any }): google.pubsub.v1.DeleteSchemaRequest; + + /** + * Creates a plain object from a DeleteSchemaRequest message. Also converts values to other types if specified. + * @param message DeleteSchemaRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.pubsub.v1.DeleteSchemaRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteSchemaRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ValidateSchemaRequest. */ + interface IValidateSchemaRequest { + + /** ValidateSchemaRequest parent */ + parent?: (string|null); + + /** ValidateSchemaRequest schema */ + schema?: (google.pubsub.v1.ISchema|null); + } + + /** Represents a ValidateSchemaRequest. */ + class ValidateSchemaRequest implements IValidateSchemaRequest { + + /** + * Constructs a new ValidateSchemaRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.pubsub.v1.IValidateSchemaRequest); + + /** ValidateSchemaRequest parent. */ + public parent: string; + + /** ValidateSchemaRequest schema. */ + public schema?: (google.pubsub.v1.ISchema|null); + + /** + * Creates a new ValidateSchemaRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ValidateSchemaRequest instance + */ + public static create(properties?: google.pubsub.v1.IValidateSchemaRequest): google.pubsub.v1.ValidateSchemaRequest; + + /** + * Encodes the specified ValidateSchemaRequest message. Does not implicitly {@link google.pubsub.v1.ValidateSchemaRequest.verify|verify} messages. + * @param message ValidateSchemaRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.pubsub.v1.IValidateSchemaRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ValidateSchemaRequest message, length delimited. Does not implicitly {@link google.pubsub.v1.ValidateSchemaRequest.verify|verify} messages. + * @param message ValidateSchemaRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.pubsub.v1.IValidateSchemaRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ValidateSchemaRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ValidateSchemaRequest + * @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.ValidateSchemaRequest; + + /** + * Decodes a ValidateSchemaRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ValidateSchemaRequest + * @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.ValidateSchemaRequest; + + /** + * Verifies a ValidateSchemaRequest 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 ValidateSchemaRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ValidateSchemaRequest + */ + public static fromObject(object: { [k: string]: any }): google.pubsub.v1.ValidateSchemaRequest; + + /** + * Creates a plain object from a ValidateSchemaRequest message. Also converts values to other types if specified. + * @param message ValidateSchemaRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.pubsub.v1.ValidateSchemaRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ValidateSchemaRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ValidateSchemaResponse. */ + interface IValidateSchemaResponse { + } + + /** Represents a ValidateSchemaResponse. */ + class ValidateSchemaResponse implements IValidateSchemaResponse { + + /** + * Constructs a new ValidateSchemaResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.pubsub.v1.IValidateSchemaResponse); + + /** + * Creates a new ValidateSchemaResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ValidateSchemaResponse instance + */ + public static create(properties?: google.pubsub.v1.IValidateSchemaResponse): google.pubsub.v1.ValidateSchemaResponse; + + /** + * Encodes the specified ValidateSchemaResponse message. Does not implicitly {@link google.pubsub.v1.ValidateSchemaResponse.verify|verify} messages. + * @param message ValidateSchemaResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.pubsub.v1.IValidateSchemaResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ValidateSchemaResponse message, length delimited. Does not implicitly {@link google.pubsub.v1.ValidateSchemaResponse.verify|verify} messages. + * @param message ValidateSchemaResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.pubsub.v1.IValidateSchemaResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ValidateSchemaResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ValidateSchemaResponse + * @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.ValidateSchemaResponse; + + /** + * Decodes a ValidateSchemaResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ValidateSchemaResponse + * @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.ValidateSchemaResponse; + + /** + * Verifies a ValidateSchemaResponse 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 ValidateSchemaResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ValidateSchemaResponse + */ + public static fromObject(object: { [k: string]: any }): google.pubsub.v1.ValidateSchemaResponse; + + /** + * Creates a plain object from a ValidateSchemaResponse message. Also converts values to other types if specified. + * @param message ValidateSchemaResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.pubsub.v1.ValidateSchemaResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ValidateSchemaResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ValidateMessageRequest. */ + interface IValidateMessageRequest { + + /** ValidateMessageRequest parent */ + parent?: (string|null); + + /** ValidateMessageRequest name */ + name?: (string|null); + + /** ValidateMessageRequest schema */ + schema?: (google.pubsub.v1.ISchema|null); + + /** ValidateMessageRequest message */ + message?: (Uint8Array|string|null); + + /** ValidateMessageRequest encoding */ + encoding?: (google.pubsub.v1.Encoding|keyof typeof google.pubsub.v1.Encoding|null); + } + + /** Represents a ValidateMessageRequest. */ + class ValidateMessageRequest implements IValidateMessageRequest { + + /** + * Constructs a new ValidateMessageRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.pubsub.v1.IValidateMessageRequest); + + /** ValidateMessageRequest parent. */ + public parent: string; + + /** ValidateMessageRequest name. */ + public name: string; + + /** ValidateMessageRequest schema. */ + public schema?: (google.pubsub.v1.ISchema|null); + + /** ValidateMessageRequest message. */ + public message: (Uint8Array|string); + + /** ValidateMessageRequest encoding. */ + public encoding: (google.pubsub.v1.Encoding|keyof typeof google.pubsub.v1.Encoding); + + /** ValidateMessageRequest schemaSpec. */ + public schemaSpec?: ("name"|"schema"); + + /** + * Creates a new ValidateMessageRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ValidateMessageRequest instance + */ + public static create(properties?: google.pubsub.v1.IValidateMessageRequest): google.pubsub.v1.ValidateMessageRequest; + + /** + * Encodes the specified ValidateMessageRequest message. Does not implicitly {@link google.pubsub.v1.ValidateMessageRequest.verify|verify} messages. + * @param message ValidateMessageRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.pubsub.v1.IValidateMessageRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ValidateMessageRequest message, length delimited. Does not implicitly {@link google.pubsub.v1.ValidateMessageRequest.verify|verify} messages. + * @param message ValidateMessageRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.pubsub.v1.IValidateMessageRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ValidateMessageRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ValidateMessageRequest + * @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.ValidateMessageRequest; + + /** + * Decodes a ValidateMessageRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ValidateMessageRequest + * @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.ValidateMessageRequest; + + /** + * Verifies a ValidateMessageRequest 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 ValidateMessageRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ValidateMessageRequest + */ + public static fromObject(object: { [k: string]: any }): google.pubsub.v1.ValidateMessageRequest; + + /** + * Creates a plain object from a ValidateMessageRequest message. Also converts values to other types if specified. + * @param message ValidateMessageRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.pubsub.v1.ValidateMessageRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ValidateMessageRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ValidateMessageResponse. */ + interface IValidateMessageResponse { + } + + /** Represents a ValidateMessageResponse. */ + class ValidateMessageResponse implements IValidateMessageResponse { + + /** + * Constructs a new ValidateMessageResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.pubsub.v1.IValidateMessageResponse); + + /** + * Creates a new ValidateMessageResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ValidateMessageResponse instance + */ + public static create(properties?: google.pubsub.v1.IValidateMessageResponse): google.pubsub.v1.ValidateMessageResponse; + + /** + * Encodes the specified ValidateMessageResponse message. Does not implicitly {@link google.pubsub.v1.ValidateMessageResponse.verify|verify} messages. + * @param message ValidateMessageResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.pubsub.v1.IValidateMessageResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ValidateMessageResponse message, length delimited. Does not implicitly {@link google.pubsub.v1.ValidateMessageResponse.verify|verify} messages. + * @param message ValidateMessageResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.pubsub.v1.IValidateMessageResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ValidateMessageResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ValidateMessageResponse + * @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.ValidateMessageResponse; + + /** + * Decodes a ValidateMessageResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ValidateMessageResponse + * @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.ValidateMessageResponse; + + /** + * Verifies a ValidateMessageResponse 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 ValidateMessageResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ValidateMessageResponse + */ + public static fromObject(object: { [k: string]: any }): google.pubsub.v1.ValidateMessageResponse; + + /** + * Creates a plain object from a ValidateMessageResponse message. Also converts values to other types if specified. + * @param message ValidateMessageResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.pubsub.v1.ValidateMessageResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ValidateMessageResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Encoding enum. */ + enum Encoding { + ENCODING_UNSPECIFIED = 0, + JSON = 1, + BINARY = 2 + } } } diff --git a/protos/protos.js b/protos/protos.js index 95137e362..fe4e8f5c1 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -592,6 +592,234 @@ return MessageStoragePolicy; })(); + v1.SchemaSettings = (function() { + + /** + * Properties of a SchemaSettings. + * @memberof google.pubsub.v1 + * @interface ISchemaSettings + * @property {string|null} [schema] SchemaSettings schema + * @property {google.pubsub.v1.Encoding|null} [encoding] SchemaSettings encoding + */ + + /** + * Constructs a new SchemaSettings. + * @memberof google.pubsub.v1 + * @classdesc Represents a SchemaSettings. + * @implements ISchemaSettings + * @constructor + * @param {google.pubsub.v1.ISchemaSettings=} [properties] Properties to set + */ + function SchemaSettings(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]]; + } + + /** + * SchemaSettings schema. + * @member {string} schema + * @memberof google.pubsub.v1.SchemaSettings + * @instance + */ + SchemaSettings.prototype.schema = ""; + + /** + * SchemaSettings encoding. + * @member {google.pubsub.v1.Encoding} encoding + * @memberof google.pubsub.v1.SchemaSettings + * @instance + */ + SchemaSettings.prototype.encoding = 0; + + /** + * Creates a new SchemaSettings instance using the specified properties. + * @function create + * @memberof google.pubsub.v1.SchemaSettings + * @static + * @param {google.pubsub.v1.ISchemaSettings=} [properties] Properties to set + * @returns {google.pubsub.v1.SchemaSettings} SchemaSettings instance + */ + SchemaSettings.create = function create(properties) { + return new SchemaSettings(properties); + }; + + /** + * Encodes the specified SchemaSettings message. Does not implicitly {@link google.pubsub.v1.SchemaSettings.verify|verify} messages. + * @function encode + * @memberof google.pubsub.v1.SchemaSettings + * @static + * @param {google.pubsub.v1.ISchemaSettings} message SchemaSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SchemaSettings.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.schema != null && Object.hasOwnProperty.call(message, "schema")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.schema); + if (message.encoding != null && Object.hasOwnProperty.call(message, "encoding")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.encoding); + return writer; + }; + + /** + * Encodes the specified SchemaSettings message, length delimited. Does not implicitly {@link google.pubsub.v1.SchemaSettings.verify|verify} messages. + * @function encodeDelimited + * @memberof google.pubsub.v1.SchemaSettings + * @static + * @param {google.pubsub.v1.ISchemaSettings} message SchemaSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SchemaSettings.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SchemaSettings message from the specified reader or buffer. + * @function decode + * @memberof google.pubsub.v1.SchemaSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.pubsub.v1.SchemaSettings} SchemaSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SchemaSettings.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.SchemaSettings(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.schema = reader.string(); + break; + case 2: + message.encoding = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SchemaSettings message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.pubsub.v1.SchemaSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.pubsub.v1.SchemaSettings} SchemaSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SchemaSettings.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SchemaSettings message. + * @function verify + * @memberof google.pubsub.v1.SchemaSettings + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SchemaSettings.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.schema != null && message.hasOwnProperty("schema")) + if (!$util.isString(message.schema)) + return "schema: string expected"; + if (message.encoding != null && message.hasOwnProperty("encoding")) + switch (message.encoding) { + default: + return "encoding: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates a SchemaSettings message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.pubsub.v1.SchemaSettings + * @static + * @param {Object.} object Plain object + * @returns {google.pubsub.v1.SchemaSettings} SchemaSettings + */ + SchemaSettings.fromObject = function fromObject(object) { + if (object instanceof $root.google.pubsub.v1.SchemaSettings) + return object; + var message = new $root.google.pubsub.v1.SchemaSettings(); + if (object.schema != null) + message.schema = String(object.schema); + switch (object.encoding) { + case "ENCODING_UNSPECIFIED": + case 0: + message.encoding = 0; + break; + case "JSON": + case 1: + message.encoding = 1; + break; + case "BINARY": + case 2: + message.encoding = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from a SchemaSettings message. Also converts values to other types if specified. + * @function toObject + * @memberof google.pubsub.v1.SchemaSettings + * @static + * @param {google.pubsub.v1.SchemaSettings} message SchemaSettings + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SchemaSettings.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.schema = ""; + object.encoding = options.enums === String ? "ENCODING_UNSPECIFIED" : 0; + } + if (message.schema != null && message.hasOwnProperty("schema")) + object.schema = message.schema; + if (message.encoding != null && message.hasOwnProperty("encoding")) + object.encoding = options.enums === String ? $root.google.pubsub.v1.Encoding[message.encoding] : message.encoding; + return object; + }; + + /** + * Converts this SchemaSettings to JSON. + * @function toJSON + * @memberof google.pubsub.v1.SchemaSettings + * @instance + * @returns {Object.} JSON object + */ + SchemaSettings.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return SchemaSettings; + })(); + v1.Topic = (function() { /** @@ -602,6 +830,8 @@ * @property {Object.|null} [labels] Topic labels * @property {google.pubsub.v1.IMessageStoragePolicy|null} [messageStoragePolicy] Topic messageStoragePolicy * @property {string|null} [kmsKeyName] Topic kmsKeyName + * @property {google.pubsub.v1.ISchemaSettings|null} [schemaSettings] Topic schemaSettings + * @property {boolean|null} [satisfiesPzs] Topic satisfiesPzs */ /** @@ -652,6 +882,22 @@ */ Topic.prototype.kmsKeyName = ""; + /** + * Topic schemaSettings. + * @member {google.pubsub.v1.ISchemaSettings|null|undefined} schemaSettings + * @memberof google.pubsub.v1.Topic + * @instance + */ + Topic.prototype.schemaSettings = null; + + /** + * Topic satisfiesPzs. + * @member {boolean} satisfiesPzs + * @memberof google.pubsub.v1.Topic + * @instance + */ + Topic.prototype.satisfiesPzs = false; + /** * Creates a new Topic instance using the specified properties. * @function create @@ -685,6 +931,10 @@ $root.google.pubsub.v1.MessageStoragePolicy.encode(message.messageStoragePolicy, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); if (message.kmsKeyName != null && Object.hasOwnProperty.call(message, "kmsKeyName")) writer.uint32(/* id 5, wireType 2 =*/42).string(message.kmsKeyName); + if (message.schemaSettings != null && Object.hasOwnProperty.call(message, "schemaSettings")) + $root.google.pubsub.v1.SchemaSettings.encode(message.schemaSettings, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.satisfiesPzs != null && Object.hasOwnProperty.call(message, "satisfiesPzs")) + writer.uint32(/* id 7, wireType 0 =*/56).bool(message.satisfiesPzs); return writer; }; @@ -750,6 +1000,12 @@ case 5: message.kmsKeyName = reader.string(); break; + case 6: + message.schemaSettings = $root.google.pubsub.v1.SchemaSettings.decode(reader, reader.uint32()); + break; + case 7: + message.satisfiesPzs = reader.bool(); + break; default: reader.skipType(tag & 7); break; @@ -804,6 +1060,14 @@ if (message.kmsKeyName != null && message.hasOwnProperty("kmsKeyName")) if (!$util.isString(message.kmsKeyName)) return "kmsKeyName: string expected"; + if (message.schemaSettings != null && message.hasOwnProperty("schemaSettings")) { + var error = $root.google.pubsub.v1.SchemaSettings.verify(message.schemaSettings); + if (error) + return "schemaSettings." + error; + } + if (message.satisfiesPzs != null && message.hasOwnProperty("satisfiesPzs")) + if (typeof message.satisfiesPzs !== "boolean") + return "satisfiesPzs: boolean expected"; return null; }; @@ -835,6 +1099,13 @@ } if (object.kmsKeyName != null) message.kmsKeyName = String(object.kmsKeyName); + if (object.schemaSettings != null) { + if (typeof object.schemaSettings !== "object") + throw TypeError(".google.pubsub.v1.Topic.schemaSettings: object expected"); + message.schemaSettings = $root.google.pubsub.v1.SchemaSettings.fromObject(object.schemaSettings); + } + if (object.satisfiesPzs != null) + message.satisfiesPzs = Boolean(object.satisfiesPzs); return message; }; @@ -857,6 +1128,8 @@ object.name = ""; object.messageStoragePolicy = null; object.kmsKeyName = ""; + object.schemaSettings = null; + object.satisfiesPzs = false; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -870,6 +1143,10 @@ object.messageStoragePolicy = $root.google.pubsub.v1.MessageStoragePolicy.toObject(message.messageStoragePolicy, options); if (message.kmsKeyName != null && message.hasOwnProperty("kmsKeyName")) object.kmsKeyName = message.kmsKeyName; + if (message.schemaSettings != null && message.hasOwnProperty("schemaSettings")) + object.schemaSettings = $root.google.pubsub.v1.SchemaSettings.toObject(message.schemaSettings, options); + if (message.satisfiesPzs != null && message.hasOwnProperty("satisfiesPzs")) + object.satisfiesPzs = message.satisfiesPzs; return object; }; @@ -11269,6 +11546,2561 @@ return SeekResponse; })(); + v1.SchemaService = (function() { + + /** + * Constructs a new SchemaService service. + * @memberof google.pubsub.v1 + * @classdesc Represents a SchemaService + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function SchemaService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (SchemaService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = SchemaService; + + /** + * Creates new SchemaService service using the specified rpc implementation. + * @function create + * @memberof google.pubsub.v1.SchemaService + * @static + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + * @returns {SchemaService} RPC service. Useful where requests and/or responses are streamed. + */ + SchemaService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.pubsub.v1.SchemaService#createSchema}. + * @memberof google.pubsub.v1.SchemaService + * @typedef CreateSchemaCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.pubsub.v1.Schema} [response] Schema + */ + + /** + * Calls CreateSchema. + * @function createSchema + * @memberof google.pubsub.v1.SchemaService + * @instance + * @param {google.pubsub.v1.ICreateSchemaRequest} request CreateSchemaRequest message or plain object + * @param {google.pubsub.v1.SchemaService.CreateSchemaCallback} callback Node-style callback called with the error, if any, and Schema + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(SchemaService.prototype.createSchema = function createSchema(request, callback) { + return this.rpcCall(createSchema, $root.google.pubsub.v1.CreateSchemaRequest, $root.google.pubsub.v1.Schema, request, callback); + }, "name", { value: "CreateSchema" }); + + /** + * Calls CreateSchema. + * @function createSchema + * @memberof google.pubsub.v1.SchemaService + * @instance + * @param {google.pubsub.v1.ICreateSchemaRequest} request CreateSchemaRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.pubsub.v1.SchemaService#getSchema}. + * @memberof google.pubsub.v1.SchemaService + * @typedef GetSchemaCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.pubsub.v1.Schema} [response] Schema + */ + + /** + * Calls GetSchema. + * @function getSchema + * @memberof google.pubsub.v1.SchemaService + * @instance + * @param {google.pubsub.v1.IGetSchemaRequest} request GetSchemaRequest message or plain object + * @param {google.pubsub.v1.SchemaService.GetSchemaCallback} callback Node-style callback called with the error, if any, and Schema + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(SchemaService.prototype.getSchema = function getSchema(request, callback) { + return this.rpcCall(getSchema, $root.google.pubsub.v1.GetSchemaRequest, $root.google.pubsub.v1.Schema, request, callback); + }, "name", { value: "GetSchema" }); + + /** + * Calls GetSchema. + * @function getSchema + * @memberof google.pubsub.v1.SchemaService + * @instance + * @param {google.pubsub.v1.IGetSchemaRequest} request GetSchemaRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.pubsub.v1.SchemaService#listSchemas}. + * @memberof google.pubsub.v1.SchemaService + * @typedef ListSchemasCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.pubsub.v1.ListSchemasResponse} [response] ListSchemasResponse + */ + + /** + * Calls ListSchemas. + * @function listSchemas + * @memberof google.pubsub.v1.SchemaService + * @instance + * @param {google.pubsub.v1.IListSchemasRequest} request ListSchemasRequest message or plain object + * @param {google.pubsub.v1.SchemaService.ListSchemasCallback} callback Node-style callback called with the error, if any, and ListSchemasResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(SchemaService.prototype.listSchemas = function listSchemas(request, callback) { + return this.rpcCall(listSchemas, $root.google.pubsub.v1.ListSchemasRequest, $root.google.pubsub.v1.ListSchemasResponse, request, callback); + }, "name", { value: "ListSchemas" }); + + /** + * Calls ListSchemas. + * @function listSchemas + * @memberof google.pubsub.v1.SchemaService + * @instance + * @param {google.pubsub.v1.IListSchemasRequest} request ListSchemasRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.pubsub.v1.SchemaService#deleteSchema}. + * @memberof google.pubsub.v1.SchemaService + * @typedef DeleteSchemaCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteSchema. + * @function deleteSchema + * @memberof google.pubsub.v1.SchemaService + * @instance + * @param {google.pubsub.v1.IDeleteSchemaRequest} request DeleteSchemaRequest message or plain object + * @param {google.pubsub.v1.SchemaService.DeleteSchemaCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(SchemaService.prototype.deleteSchema = function deleteSchema(request, callback) { + return this.rpcCall(deleteSchema, $root.google.pubsub.v1.DeleteSchemaRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteSchema" }); + + /** + * Calls DeleteSchema. + * @function deleteSchema + * @memberof google.pubsub.v1.SchemaService + * @instance + * @param {google.pubsub.v1.IDeleteSchemaRequest} request DeleteSchemaRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.pubsub.v1.SchemaService#validateSchema}. + * @memberof google.pubsub.v1.SchemaService + * @typedef ValidateSchemaCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.pubsub.v1.ValidateSchemaResponse} [response] ValidateSchemaResponse + */ + + /** + * Calls ValidateSchema. + * @function validateSchema + * @memberof google.pubsub.v1.SchemaService + * @instance + * @param {google.pubsub.v1.IValidateSchemaRequest} request ValidateSchemaRequest message or plain object + * @param {google.pubsub.v1.SchemaService.ValidateSchemaCallback} callback Node-style callback called with the error, if any, and ValidateSchemaResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(SchemaService.prototype.validateSchema = function validateSchema(request, callback) { + return this.rpcCall(validateSchema, $root.google.pubsub.v1.ValidateSchemaRequest, $root.google.pubsub.v1.ValidateSchemaResponse, request, callback); + }, "name", { value: "ValidateSchema" }); + + /** + * Calls ValidateSchema. + * @function validateSchema + * @memberof google.pubsub.v1.SchemaService + * @instance + * @param {google.pubsub.v1.IValidateSchemaRequest} request ValidateSchemaRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.pubsub.v1.SchemaService#validateMessage}. + * @memberof google.pubsub.v1.SchemaService + * @typedef ValidateMessageCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.pubsub.v1.ValidateMessageResponse} [response] ValidateMessageResponse + */ + + /** + * Calls ValidateMessage. + * @function validateMessage + * @memberof google.pubsub.v1.SchemaService + * @instance + * @param {google.pubsub.v1.IValidateMessageRequest} request ValidateMessageRequest message or plain object + * @param {google.pubsub.v1.SchemaService.ValidateMessageCallback} callback Node-style callback called with the error, if any, and ValidateMessageResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(SchemaService.prototype.validateMessage = function validateMessage(request, callback) { + return this.rpcCall(validateMessage, $root.google.pubsub.v1.ValidateMessageRequest, $root.google.pubsub.v1.ValidateMessageResponse, request, callback); + }, "name", { value: "ValidateMessage" }); + + /** + * Calls ValidateMessage. + * @function validateMessage + * @memberof google.pubsub.v1.SchemaService + * @instance + * @param {google.pubsub.v1.IValidateMessageRequest} request ValidateMessageRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return SchemaService; + })(); + + v1.Schema = (function() { + + /** + * Properties of a Schema. + * @memberof google.pubsub.v1 + * @interface ISchema + * @property {string|null} [name] Schema name + * @property {google.pubsub.v1.Schema.Type|null} [type] Schema type + * @property {string|null} [definition] Schema definition + */ + + /** + * Constructs a new Schema. + * @memberof google.pubsub.v1 + * @classdesc Represents a Schema. + * @implements ISchema + * @constructor + * @param {google.pubsub.v1.ISchema=} [properties] Properties to set + */ + function Schema(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]]; + } + + /** + * Schema name. + * @member {string} name + * @memberof google.pubsub.v1.Schema + * @instance + */ + Schema.prototype.name = ""; + + /** + * Schema type. + * @member {google.pubsub.v1.Schema.Type} type + * @memberof google.pubsub.v1.Schema + * @instance + */ + Schema.prototype.type = 0; + + /** + * Schema definition. + * @member {string} definition + * @memberof google.pubsub.v1.Schema + * @instance + */ + Schema.prototype.definition = ""; + + /** + * Creates a new Schema instance using the specified properties. + * @function create + * @memberof google.pubsub.v1.Schema + * @static + * @param {google.pubsub.v1.ISchema=} [properties] Properties to set + * @returns {google.pubsub.v1.Schema} Schema instance + */ + Schema.create = function create(properties) { + return new Schema(properties); + }; + + /** + * Encodes the specified Schema message. Does not implicitly {@link google.pubsub.v1.Schema.verify|verify} messages. + * @function encode + * @memberof google.pubsub.v1.Schema + * @static + * @param {google.pubsub.v1.ISchema} message Schema message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Schema.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.type); + if (message.definition != null && Object.hasOwnProperty.call(message, "definition")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.definition); + return writer; + }; + + /** + * Encodes the specified Schema message, length delimited. Does not implicitly {@link google.pubsub.v1.Schema.verify|verify} messages. + * @function encodeDelimited + * @memberof google.pubsub.v1.Schema + * @static + * @param {google.pubsub.v1.ISchema} message Schema message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Schema.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Schema message from the specified reader or buffer. + * @function decode + * @memberof google.pubsub.v1.Schema + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.pubsub.v1.Schema} Schema + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Schema.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.Schema(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.type = reader.int32(); + break; + case 3: + message.definition = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Schema message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.pubsub.v1.Schema + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.pubsub.v1.Schema} Schema + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Schema.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Schema message. + * @function verify + * @memberof google.pubsub.v1.Schema + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Schema.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.type != null && message.hasOwnProperty("type")) + switch (message.type) { + default: + return "type: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.definition != null && message.hasOwnProperty("definition")) + if (!$util.isString(message.definition)) + return "definition: string expected"; + return null; + }; + + /** + * Creates a Schema message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.pubsub.v1.Schema + * @static + * @param {Object.} object Plain object + * @returns {google.pubsub.v1.Schema} Schema + */ + Schema.fromObject = function fromObject(object) { + if (object instanceof $root.google.pubsub.v1.Schema) + return object; + var message = new $root.google.pubsub.v1.Schema(); + if (object.name != null) + message.name = String(object.name); + switch (object.type) { + case "TYPE_UNSPECIFIED": + case 0: + message.type = 0; + break; + case "PROTOCOL_BUFFER": + case 1: + message.type = 1; + break; + case "AVRO": + case 2: + message.type = 2; + break; + } + if (object.definition != null) + message.definition = String(object.definition); + return message; + }; + + /** + * Creates a plain object from a Schema message. Also converts values to other types if specified. + * @function toObject + * @memberof google.pubsub.v1.Schema + * @static + * @param {google.pubsub.v1.Schema} message Schema + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Schema.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.type = options.enums === String ? "TYPE_UNSPECIFIED" : 0; + object.definition = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.google.pubsub.v1.Schema.Type[message.type] : message.type; + if (message.definition != null && message.hasOwnProperty("definition")) + object.definition = message.definition; + return object; + }; + + /** + * Converts this Schema to JSON. + * @function toJSON + * @memberof google.pubsub.v1.Schema + * @instance + * @returns {Object.} JSON object + */ + Schema.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Type enum. + * @name google.pubsub.v1.Schema.Type + * @enum {number} + * @property {number} TYPE_UNSPECIFIED=0 TYPE_UNSPECIFIED value + * @property {number} PROTOCOL_BUFFER=1 PROTOCOL_BUFFER value + * @property {number} AVRO=2 AVRO value + */ + Schema.Type = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "TYPE_UNSPECIFIED"] = 0; + values[valuesById[1] = "PROTOCOL_BUFFER"] = 1; + values[valuesById[2] = "AVRO"] = 2; + return values; + })(); + + return Schema; + })(); + + v1.CreateSchemaRequest = (function() { + + /** + * Properties of a CreateSchemaRequest. + * @memberof google.pubsub.v1 + * @interface ICreateSchemaRequest + * @property {string|null} [parent] CreateSchemaRequest parent + * @property {google.pubsub.v1.ISchema|null} [schema] CreateSchemaRequest schema + * @property {string|null} [schemaId] CreateSchemaRequest schemaId + */ + + /** + * Constructs a new CreateSchemaRequest. + * @memberof google.pubsub.v1 + * @classdesc Represents a CreateSchemaRequest. + * @implements ICreateSchemaRequest + * @constructor + * @param {google.pubsub.v1.ICreateSchemaRequest=} [properties] Properties to set + */ + function CreateSchemaRequest(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]]; + } + + /** + * CreateSchemaRequest parent. + * @member {string} parent + * @memberof google.pubsub.v1.CreateSchemaRequest + * @instance + */ + CreateSchemaRequest.prototype.parent = ""; + + /** + * CreateSchemaRequest schema. + * @member {google.pubsub.v1.ISchema|null|undefined} schema + * @memberof google.pubsub.v1.CreateSchemaRequest + * @instance + */ + CreateSchemaRequest.prototype.schema = null; + + /** + * CreateSchemaRequest schemaId. + * @member {string} schemaId + * @memberof google.pubsub.v1.CreateSchemaRequest + * @instance + */ + CreateSchemaRequest.prototype.schemaId = ""; + + /** + * Creates a new CreateSchemaRequest instance using the specified properties. + * @function create + * @memberof google.pubsub.v1.CreateSchemaRequest + * @static + * @param {google.pubsub.v1.ICreateSchemaRequest=} [properties] Properties to set + * @returns {google.pubsub.v1.CreateSchemaRequest} CreateSchemaRequest instance + */ + CreateSchemaRequest.create = function create(properties) { + return new CreateSchemaRequest(properties); + }; + + /** + * Encodes the specified CreateSchemaRequest message. Does not implicitly {@link google.pubsub.v1.CreateSchemaRequest.verify|verify} messages. + * @function encode + * @memberof google.pubsub.v1.CreateSchemaRequest + * @static + * @param {google.pubsub.v1.ICreateSchemaRequest} message CreateSchemaRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateSchemaRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.schema != null && Object.hasOwnProperty.call(message, "schema")) + $root.google.pubsub.v1.Schema.encode(message.schema, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.schemaId != null && Object.hasOwnProperty.call(message, "schemaId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.schemaId); + return writer; + }; + + /** + * Encodes the specified CreateSchemaRequest message, length delimited. Does not implicitly {@link google.pubsub.v1.CreateSchemaRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.pubsub.v1.CreateSchemaRequest + * @static + * @param {google.pubsub.v1.ICreateSchemaRequest} message CreateSchemaRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateSchemaRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateSchemaRequest message from the specified reader or buffer. + * @function decode + * @memberof google.pubsub.v1.CreateSchemaRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.pubsub.v1.CreateSchemaRequest} CreateSchemaRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateSchemaRequest.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.CreateSchemaRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.schema = $root.google.pubsub.v1.Schema.decode(reader, reader.uint32()); + break; + case 3: + message.schemaId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateSchemaRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.pubsub.v1.CreateSchemaRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.pubsub.v1.CreateSchemaRequest} CreateSchemaRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateSchemaRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateSchemaRequest message. + * @function verify + * @memberof google.pubsub.v1.CreateSchemaRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateSchemaRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.schema != null && message.hasOwnProperty("schema")) { + var error = $root.google.pubsub.v1.Schema.verify(message.schema); + if (error) + return "schema." + error; + } + if (message.schemaId != null && message.hasOwnProperty("schemaId")) + if (!$util.isString(message.schemaId)) + return "schemaId: string expected"; + return null; + }; + + /** + * Creates a CreateSchemaRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.pubsub.v1.CreateSchemaRequest + * @static + * @param {Object.} object Plain object + * @returns {google.pubsub.v1.CreateSchemaRequest} CreateSchemaRequest + */ + CreateSchemaRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.pubsub.v1.CreateSchemaRequest) + return object; + var message = new $root.google.pubsub.v1.CreateSchemaRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.schema != null) { + if (typeof object.schema !== "object") + throw TypeError(".google.pubsub.v1.CreateSchemaRequest.schema: object expected"); + message.schema = $root.google.pubsub.v1.Schema.fromObject(object.schema); + } + if (object.schemaId != null) + message.schemaId = String(object.schemaId); + return message; + }; + + /** + * Creates a plain object from a CreateSchemaRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.pubsub.v1.CreateSchemaRequest + * @static + * @param {google.pubsub.v1.CreateSchemaRequest} message CreateSchemaRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateSchemaRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.schema = null; + object.schemaId = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.schema != null && message.hasOwnProperty("schema")) + object.schema = $root.google.pubsub.v1.Schema.toObject(message.schema, options); + if (message.schemaId != null && message.hasOwnProperty("schemaId")) + object.schemaId = message.schemaId; + return object; + }; + + /** + * Converts this CreateSchemaRequest to JSON. + * @function toJSON + * @memberof google.pubsub.v1.CreateSchemaRequest + * @instance + * @returns {Object.} JSON object + */ + CreateSchemaRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CreateSchemaRequest; + })(); + + /** + * SchemaView enum. + * @name google.pubsub.v1.SchemaView + * @enum {number} + * @property {number} SCHEMA_VIEW_UNSPECIFIED=0 SCHEMA_VIEW_UNSPECIFIED value + * @property {number} BASIC=1 BASIC value + * @property {number} FULL=2 FULL value + */ + v1.SchemaView = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SCHEMA_VIEW_UNSPECIFIED"] = 0; + values[valuesById[1] = "BASIC"] = 1; + values[valuesById[2] = "FULL"] = 2; + return values; + })(); + + v1.GetSchemaRequest = (function() { + + /** + * Properties of a GetSchemaRequest. + * @memberof google.pubsub.v1 + * @interface IGetSchemaRequest + * @property {string|null} [name] GetSchemaRequest name + * @property {google.pubsub.v1.SchemaView|null} [view] GetSchemaRequest view + */ + + /** + * Constructs a new GetSchemaRequest. + * @memberof google.pubsub.v1 + * @classdesc Represents a GetSchemaRequest. + * @implements IGetSchemaRequest + * @constructor + * @param {google.pubsub.v1.IGetSchemaRequest=} [properties] Properties to set + */ + function GetSchemaRequest(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]]; + } + + /** + * GetSchemaRequest name. + * @member {string} name + * @memberof google.pubsub.v1.GetSchemaRequest + * @instance + */ + GetSchemaRequest.prototype.name = ""; + + /** + * GetSchemaRequest view. + * @member {google.pubsub.v1.SchemaView} view + * @memberof google.pubsub.v1.GetSchemaRequest + * @instance + */ + GetSchemaRequest.prototype.view = 0; + + /** + * Creates a new GetSchemaRequest instance using the specified properties. + * @function create + * @memberof google.pubsub.v1.GetSchemaRequest + * @static + * @param {google.pubsub.v1.IGetSchemaRequest=} [properties] Properties to set + * @returns {google.pubsub.v1.GetSchemaRequest} GetSchemaRequest instance + */ + GetSchemaRequest.create = function create(properties) { + return new GetSchemaRequest(properties); + }; + + /** + * Encodes the specified GetSchemaRequest message. Does not implicitly {@link google.pubsub.v1.GetSchemaRequest.verify|verify} messages. + * @function encode + * @memberof google.pubsub.v1.GetSchemaRequest + * @static + * @param {google.pubsub.v1.IGetSchemaRequest} message GetSchemaRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetSchemaRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.view != null && Object.hasOwnProperty.call(message, "view")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.view); + return writer; + }; + + /** + * Encodes the specified GetSchemaRequest message, length delimited. Does not implicitly {@link google.pubsub.v1.GetSchemaRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.pubsub.v1.GetSchemaRequest + * @static + * @param {google.pubsub.v1.IGetSchemaRequest} message GetSchemaRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetSchemaRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetSchemaRequest message from the specified reader or buffer. + * @function decode + * @memberof google.pubsub.v1.GetSchemaRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.pubsub.v1.GetSchemaRequest} GetSchemaRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetSchemaRequest.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.GetSchemaRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.view = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetSchemaRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.pubsub.v1.GetSchemaRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.pubsub.v1.GetSchemaRequest} GetSchemaRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetSchemaRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetSchemaRequest message. + * @function verify + * @memberof google.pubsub.v1.GetSchemaRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetSchemaRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.view != null && message.hasOwnProperty("view")) + switch (message.view) { + default: + return "view: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates a GetSchemaRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.pubsub.v1.GetSchemaRequest + * @static + * @param {Object.} object Plain object + * @returns {google.pubsub.v1.GetSchemaRequest} GetSchemaRequest + */ + GetSchemaRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.pubsub.v1.GetSchemaRequest) + return object; + var message = new $root.google.pubsub.v1.GetSchemaRequest(); + if (object.name != null) + message.name = String(object.name); + switch (object.view) { + case "SCHEMA_VIEW_UNSPECIFIED": + case 0: + message.view = 0; + break; + case "BASIC": + case 1: + message.view = 1; + break; + case "FULL": + case 2: + message.view = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from a GetSchemaRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.pubsub.v1.GetSchemaRequest + * @static + * @param {google.pubsub.v1.GetSchemaRequest} message GetSchemaRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetSchemaRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.view = options.enums === String ? "SCHEMA_VIEW_UNSPECIFIED" : 0; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.view != null && message.hasOwnProperty("view")) + object.view = options.enums === String ? $root.google.pubsub.v1.SchemaView[message.view] : message.view; + return object; + }; + + /** + * Converts this GetSchemaRequest to JSON. + * @function toJSON + * @memberof google.pubsub.v1.GetSchemaRequest + * @instance + * @returns {Object.} JSON object + */ + GetSchemaRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GetSchemaRequest; + })(); + + v1.ListSchemasRequest = (function() { + + /** + * Properties of a ListSchemasRequest. + * @memberof google.pubsub.v1 + * @interface IListSchemasRequest + * @property {string|null} [parent] ListSchemasRequest parent + * @property {google.pubsub.v1.SchemaView|null} [view] ListSchemasRequest view + * @property {number|null} [pageSize] ListSchemasRequest pageSize + * @property {string|null} [pageToken] ListSchemasRequest pageToken + */ + + /** + * Constructs a new ListSchemasRequest. + * @memberof google.pubsub.v1 + * @classdesc Represents a ListSchemasRequest. + * @implements IListSchemasRequest + * @constructor + * @param {google.pubsub.v1.IListSchemasRequest=} [properties] Properties to set + */ + function ListSchemasRequest(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]]; + } + + /** + * ListSchemasRequest parent. + * @member {string} parent + * @memberof google.pubsub.v1.ListSchemasRequest + * @instance + */ + ListSchemasRequest.prototype.parent = ""; + + /** + * ListSchemasRequest view. + * @member {google.pubsub.v1.SchemaView} view + * @memberof google.pubsub.v1.ListSchemasRequest + * @instance + */ + ListSchemasRequest.prototype.view = 0; + + /** + * ListSchemasRequest pageSize. + * @member {number} pageSize + * @memberof google.pubsub.v1.ListSchemasRequest + * @instance + */ + ListSchemasRequest.prototype.pageSize = 0; + + /** + * ListSchemasRequest pageToken. + * @member {string} pageToken + * @memberof google.pubsub.v1.ListSchemasRequest + * @instance + */ + ListSchemasRequest.prototype.pageToken = ""; + + /** + * Creates a new ListSchemasRequest instance using the specified properties. + * @function create + * @memberof google.pubsub.v1.ListSchemasRequest + * @static + * @param {google.pubsub.v1.IListSchemasRequest=} [properties] Properties to set + * @returns {google.pubsub.v1.ListSchemasRequest} ListSchemasRequest instance + */ + ListSchemasRequest.create = function create(properties) { + return new ListSchemasRequest(properties); + }; + + /** + * Encodes the specified ListSchemasRequest message. Does not implicitly {@link google.pubsub.v1.ListSchemasRequest.verify|verify} messages. + * @function encode + * @memberof google.pubsub.v1.ListSchemasRequest + * @static + * @param {google.pubsub.v1.IListSchemasRequest} message ListSchemasRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListSchemasRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.view != null && Object.hasOwnProperty.call(message, "view")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.view); + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.pageSize); + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.pageToken); + return writer; + }; + + /** + * Encodes the specified ListSchemasRequest message, length delimited. Does not implicitly {@link google.pubsub.v1.ListSchemasRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.pubsub.v1.ListSchemasRequest + * @static + * @param {google.pubsub.v1.IListSchemasRequest} message ListSchemasRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListSchemasRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListSchemasRequest message from the specified reader or buffer. + * @function decode + * @memberof google.pubsub.v1.ListSchemasRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.pubsub.v1.ListSchemasRequest} ListSchemasRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListSchemasRequest.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.ListSchemasRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.view = reader.int32(); + break; + case 3: + message.pageSize = reader.int32(); + break; + case 4: + message.pageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListSchemasRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.pubsub.v1.ListSchemasRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.pubsub.v1.ListSchemasRequest} ListSchemasRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListSchemasRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListSchemasRequest message. + * @function verify + * @memberof google.pubsub.v1.ListSchemasRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListSchemasRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.view != null && message.hasOwnProperty("view")) + switch (message.view) { + default: + return "view: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + if (!$util.isInteger(message.pageSize)) + return "pageSize: integer expected"; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + if (!$util.isString(message.pageToken)) + return "pageToken: string expected"; + return null; + }; + + /** + * Creates a ListSchemasRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.pubsub.v1.ListSchemasRequest + * @static + * @param {Object.} object Plain object + * @returns {google.pubsub.v1.ListSchemasRequest} ListSchemasRequest + */ + ListSchemasRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.pubsub.v1.ListSchemasRequest) + return object; + var message = new $root.google.pubsub.v1.ListSchemasRequest(); + if (object.parent != null) + message.parent = String(object.parent); + switch (object.view) { + case "SCHEMA_VIEW_UNSPECIFIED": + case 0: + message.view = 0; + break; + case "BASIC": + case 1: + message.view = 1; + break; + case "FULL": + case 2: + message.view = 2; + break; + } + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + return message; + }; + + /** + * Creates a plain object from a ListSchemasRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.pubsub.v1.ListSchemasRequest + * @static + * @param {google.pubsub.v1.ListSchemasRequest} message ListSchemasRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListSchemasRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.view = options.enums === String ? "SCHEMA_VIEW_UNSPECIFIED" : 0; + object.pageSize = 0; + object.pageToken = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.view != null && message.hasOwnProperty("view")) + object.view = options.enums === String ? $root.google.pubsub.v1.SchemaView[message.view] : message.view; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + return object; + }; + + /** + * Converts this ListSchemasRequest to JSON. + * @function toJSON + * @memberof google.pubsub.v1.ListSchemasRequest + * @instance + * @returns {Object.} JSON object + */ + ListSchemasRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListSchemasRequest; + })(); + + v1.ListSchemasResponse = (function() { + + /** + * Properties of a ListSchemasResponse. + * @memberof google.pubsub.v1 + * @interface IListSchemasResponse + * @property {Array.|null} [schemas] ListSchemasResponse schemas + * @property {string|null} [nextPageToken] ListSchemasResponse nextPageToken + */ + + /** + * Constructs a new ListSchemasResponse. + * @memberof google.pubsub.v1 + * @classdesc Represents a ListSchemasResponse. + * @implements IListSchemasResponse + * @constructor + * @param {google.pubsub.v1.IListSchemasResponse=} [properties] Properties to set + */ + function ListSchemasResponse(properties) { + this.schemas = []; + 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]]; + } + + /** + * ListSchemasResponse schemas. + * @member {Array.} schemas + * @memberof google.pubsub.v1.ListSchemasResponse + * @instance + */ + ListSchemasResponse.prototype.schemas = $util.emptyArray; + + /** + * ListSchemasResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.pubsub.v1.ListSchemasResponse + * @instance + */ + ListSchemasResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListSchemasResponse instance using the specified properties. + * @function create + * @memberof google.pubsub.v1.ListSchemasResponse + * @static + * @param {google.pubsub.v1.IListSchemasResponse=} [properties] Properties to set + * @returns {google.pubsub.v1.ListSchemasResponse} ListSchemasResponse instance + */ + ListSchemasResponse.create = function create(properties) { + return new ListSchemasResponse(properties); + }; + + /** + * Encodes the specified ListSchemasResponse message. Does not implicitly {@link google.pubsub.v1.ListSchemasResponse.verify|verify} messages. + * @function encode + * @memberof google.pubsub.v1.ListSchemasResponse + * @static + * @param {google.pubsub.v1.IListSchemasResponse} message ListSchemasResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListSchemasResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.schemas != null && message.schemas.length) + for (var i = 0; i < message.schemas.length; ++i) + $root.google.pubsub.v1.Schema.encode(message.schemas[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); + return writer; + }; + + /** + * Encodes the specified ListSchemasResponse message, length delimited. Does not implicitly {@link google.pubsub.v1.ListSchemasResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.pubsub.v1.ListSchemasResponse + * @static + * @param {google.pubsub.v1.IListSchemasResponse} message ListSchemasResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListSchemasResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListSchemasResponse message from the specified reader or buffer. + * @function decode + * @memberof google.pubsub.v1.ListSchemasResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.pubsub.v1.ListSchemasResponse} ListSchemasResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListSchemasResponse.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.ListSchemasResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.schemas && message.schemas.length)) + message.schemas = []; + message.schemas.push($root.google.pubsub.v1.Schema.decode(reader, reader.uint32())); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListSchemasResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.pubsub.v1.ListSchemasResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.pubsub.v1.ListSchemasResponse} ListSchemasResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListSchemasResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListSchemasResponse message. + * @function verify + * @memberof google.pubsub.v1.ListSchemasResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListSchemasResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.schemas != null && message.hasOwnProperty("schemas")) { + if (!Array.isArray(message.schemas)) + return "schemas: array expected"; + for (var i = 0; i < message.schemas.length; ++i) { + var error = $root.google.pubsub.v1.Schema.verify(message.schemas[i]); + if (error) + return "schemas." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListSchemasResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.pubsub.v1.ListSchemasResponse + * @static + * @param {Object.} object Plain object + * @returns {google.pubsub.v1.ListSchemasResponse} ListSchemasResponse + */ + ListSchemasResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.pubsub.v1.ListSchemasResponse) + return object; + var message = new $root.google.pubsub.v1.ListSchemasResponse(); + if (object.schemas) { + if (!Array.isArray(object.schemas)) + throw TypeError(".google.pubsub.v1.ListSchemasResponse.schemas: array expected"); + message.schemas = []; + for (var i = 0; i < object.schemas.length; ++i) { + if (typeof object.schemas[i] !== "object") + throw TypeError(".google.pubsub.v1.ListSchemasResponse.schemas: object expected"); + message.schemas[i] = $root.google.pubsub.v1.Schema.fromObject(object.schemas[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListSchemasResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.pubsub.v1.ListSchemasResponse + * @static + * @param {google.pubsub.v1.ListSchemasResponse} message ListSchemasResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListSchemasResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.schemas = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.schemas && message.schemas.length) { + object.schemas = []; + for (var j = 0; j < message.schemas.length; ++j) + object.schemas[j] = $root.google.pubsub.v1.Schema.toObject(message.schemas[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListSchemasResponse to JSON. + * @function toJSON + * @memberof google.pubsub.v1.ListSchemasResponse + * @instance + * @returns {Object.} JSON object + */ + ListSchemasResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListSchemasResponse; + })(); + + v1.DeleteSchemaRequest = (function() { + + /** + * Properties of a DeleteSchemaRequest. + * @memberof google.pubsub.v1 + * @interface IDeleteSchemaRequest + * @property {string|null} [name] DeleteSchemaRequest name + */ + + /** + * Constructs a new DeleteSchemaRequest. + * @memberof google.pubsub.v1 + * @classdesc Represents a DeleteSchemaRequest. + * @implements IDeleteSchemaRequest + * @constructor + * @param {google.pubsub.v1.IDeleteSchemaRequest=} [properties] Properties to set + */ + function DeleteSchemaRequest(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]]; + } + + /** + * DeleteSchemaRequest name. + * @member {string} name + * @memberof google.pubsub.v1.DeleteSchemaRequest + * @instance + */ + DeleteSchemaRequest.prototype.name = ""; + + /** + * Creates a new DeleteSchemaRequest instance using the specified properties. + * @function create + * @memberof google.pubsub.v1.DeleteSchemaRequest + * @static + * @param {google.pubsub.v1.IDeleteSchemaRequest=} [properties] Properties to set + * @returns {google.pubsub.v1.DeleteSchemaRequest} DeleteSchemaRequest instance + */ + DeleteSchemaRequest.create = function create(properties) { + return new DeleteSchemaRequest(properties); + }; + + /** + * Encodes the specified DeleteSchemaRequest message. Does not implicitly {@link google.pubsub.v1.DeleteSchemaRequest.verify|verify} messages. + * @function encode + * @memberof google.pubsub.v1.DeleteSchemaRequest + * @static + * @param {google.pubsub.v1.IDeleteSchemaRequest} message DeleteSchemaRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteSchemaRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + return writer; + }; + + /** + * Encodes the specified DeleteSchemaRequest message, length delimited. Does not implicitly {@link google.pubsub.v1.DeleteSchemaRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.pubsub.v1.DeleteSchemaRequest + * @static + * @param {google.pubsub.v1.IDeleteSchemaRequest} message DeleteSchemaRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteSchemaRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteSchemaRequest message from the specified reader or buffer. + * @function decode + * @memberof google.pubsub.v1.DeleteSchemaRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.pubsub.v1.DeleteSchemaRequest} DeleteSchemaRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteSchemaRequest.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.DeleteSchemaRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DeleteSchemaRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.pubsub.v1.DeleteSchemaRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.pubsub.v1.DeleteSchemaRequest} DeleteSchemaRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteSchemaRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteSchemaRequest message. + * @function verify + * @memberof google.pubsub.v1.DeleteSchemaRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteSchemaRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + return null; + }; + + /** + * Creates a DeleteSchemaRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.pubsub.v1.DeleteSchemaRequest + * @static + * @param {Object.} object Plain object + * @returns {google.pubsub.v1.DeleteSchemaRequest} DeleteSchemaRequest + */ + DeleteSchemaRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.pubsub.v1.DeleteSchemaRequest) + return object; + var message = new $root.google.pubsub.v1.DeleteSchemaRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a DeleteSchemaRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.pubsub.v1.DeleteSchemaRequest + * @static + * @param {google.pubsub.v1.DeleteSchemaRequest} message DeleteSchemaRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteSchemaRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this DeleteSchemaRequest to JSON. + * @function toJSON + * @memberof google.pubsub.v1.DeleteSchemaRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteSchemaRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DeleteSchemaRequest; + })(); + + v1.ValidateSchemaRequest = (function() { + + /** + * Properties of a ValidateSchemaRequest. + * @memberof google.pubsub.v1 + * @interface IValidateSchemaRequest + * @property {string|null} [parent] ValidateSchemaRequest parent + * @property {google.pubsub.v1.ISchema|null} [schema] ValidateSchemaRequest schema + */ + + /** + * Constructs a new ValidateSchemaRequest. + * @memberof google.pubsub.v1 + * @classdesc Represents a ValidateSchemaRequest. + * @implements IValidateSchemaRequest + * @constructor + * @param {google.pubsub.v1.IValidateSchemaRequest=} [properties] Properties to set + */ + function ValidateSchemaRequest(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]]; + } + + /** + * ValidateSchemaRequest parent. + * @member {string} parent + * @memberof google.pubsub.v1.ValidateSchemaRequest + * @instance + */ + ValidateSchemaRequest.prototype.parent = ""; + + /** + * ValidateSchemaRequest schema. + * @member {google.pubsub.v1.ISchema|null|undefined} schema + * @memberof google.pubsub.v1.ValidateSchemaRequest + * @instance + */ + ValidateSchemaRequest.prototype.schema = null; + + /** + * Creates a new ValidateSchemaRequest instance using the specified properties. + * @function create + * @memberof google.pubsub.v1.ValidateSchemaRequest + * @static + * @param {google.pubsub.v1.IValidateSchemaRequest=} [properties] Properties to set + * @returns {google.pubsub.v1.ValidateSchemaRequest} ValidateSchemaRequest instance + */ + ValidateSchemaRequest.create = function create(properties) { + return new ValidateSchemaRequest(properties); + }; + + /** + * Encodes the specified ValidateSchemaRequest message. Does not implicitly {@link google.pubsub.v1.ValidateSchemaRequest.verify|verify} messages. + * @function encode + * @memberof google.pubsub.v1.ValidateSchemaRequest + * @static + * @param {google.pubsub.v1.IValidateSchemaRequest} message ValidateSchemaRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ValidateSchemaRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.schema != null && Object.hasOwnProperty.call(message, "schema")) + $root.google.pubsub.v1.Schema.encode(message.schema, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ValidateSchemaRequest message, length delimited. Does not implicitly {@link google.pubsub.v1.ValidateSchemaRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.pubsub.v1.ValidateSchemaRequest + * @static + * @param {google.pubsub.v1.IValidateSchemaRequest} message ValidateSchemaRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ValidateSchemaRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ValidateSchemaRequest message from the specified reader or buffer. + * @function decode + * @memberof google.pubsub.v1.ValidateSchemaRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.pubsub.v1.ValidateSchemaRequest} ValidateSchemaRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ValidateSchemaRequest.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.ValidateSchemaRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.schema = $root.google.pubsub.v1.Schema.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ValidateSchemaRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.pubsub.v1.ValidateSchemaRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.pubsub.v1.ValidateSchemaRequest} ValidateSchemaRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ValidateSchemaRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ValidateSchemaRequest message. + * @function verify + * @memberof google.pubsub.v1.ValidateSchemaRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ValidateSchemaRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.schema != null && message.hasOwnProperty("schema")) { + var error = $root.google.pubsub.v1.Schema.verify(message.schema); + if (error) + return "schema." + error; + } + return null; + }; + + /** + * Creates a ValidateSchemaRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.pubsub.v1.ValidateSchemaRequest + * @static + * @param {Object.} object Plain object + * @returns {google.pubsub.v1.ValidateSchemaRequest} ValidateSchemaRequest + */ + ValidateSchemaRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.pubsub.v1.ValidateSchemaRequest) + return object; + var message = new $root.google.pubsub.v1.ValidateSchemaRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.schema != null) { + if (typeof object.schema !== "object") + throw TypeError(".google.pubsub.v1.ValidateSchemaRequest.schema: object expected"); + message.schema = $root.google.pubsub.v1.Schema.fromObject(object.schema); + } + return message; + }; + + /** + * Creates a plain object from a ValidateSchemaRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.pubsub.v1.ValidateSchemaRequest + * @static + * @param {google.pubsub.v1.ValidateSchemaRequest} message ValidateSchemaRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ValidateSchemaRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.schema = null; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.schema != null && message.hasOwnProperty("schema")) + object.schema = $root.google.pubsub.v1.Schema.toObject(message.schema, options); + return object; + }; + + /** + * Converts this ValidateSchemaRequest to JSON. + * @function toJSON + * @memberof google.pubsub.v1.ValidateSchemaRequest + * @instance + * @returns {Object.} JSON object + */ + ValidateSchemaRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ValidateSchemaRequest; + })(); + + v1.ValidateSchemaResponse = (function() { + + /** + * Properties of a ValidateSchemaResponse. + * @memberof google.pubsub.v1 + * @interface IValidateSchemaResponse + */ + + /** + * Constructs a new ValidateSchemaResponse. + * @memberof google.pubsub.v1 + * @classdesc Represents a ValidateSchemaResponse. + * @implements IValidateSchemaResponse + * @constructor + * @param {google.pubsub.v1.IValidateSchemaResponse=} [properties] Properties to set + */ + function ValidateSchemaResponse(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]]; + } + + /** + * Creates a new ValidateSchemaResponse instance using the specified properties. + * @function create + * @memberof google.pubsub.v1.ValidateSchemaResponse + * @static + * @param {google.pubsub.v1.IValidateSchemaResponse=} [properties] Properties to set + * @returns {google.pubsub.v1.ValidateSchemaResponse} ValidateSchemaResponse instance + */ + ValidateSchemaResponse.create = function create(properties) { + return new ValidateSchemaResponse(properties); + }; + + /** + * Encodes the specified ValidateSchemaResponse message. Does not implicitly {@link google.pubsub.v1.ValidateSchemaResponse.verify|verify} messages. + * @function encode + * @memberof google.pubsub.v1.ValidateSchemaResponse + * @static + * @param {google.pubsub.v1.IValidateSchemaResponse} message ValidateSchemaResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ValidateSchemaResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified ValidateSchemaResponse message, length delimited. Does not implicitly {@link google.pubsub.v1.ValidateSchemaResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.pubsub.v1.ValidateSchemaResponse + * @static + * @param {google.pubsub.v1.IValidateSchemaResponse} message ValidateSchemaResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ValidateSchemaResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ValidateSchemaResponse message from the specified reader or buffer. + * @function decode + * @memberof google.pubsub.v1.ValidateSchemaResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.pubsub.v1.ValidateSchemaResponse} ValidateSchemaResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ValidateSchemaResponse.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.ValidateSchemaResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ValidateSchemaResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.pubsub.v1.ValidateSchemaResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.pubsub.v1.ValidateSchemaResponse} ValidateSchemaResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ValidateSchemaResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ValidateSchemaResponse message. + * @function verify + * @memberof google.pubsub.v1.ValidateSchemaResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ValidateSchemaResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a ValidateSchemaResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.pubsub.v1.ValidateSchemaResponse + * @static + * @param {Object.} object Plain object + * @returns {google.pubsub.v1.ValidateSchemaResponse} ValidateSchemaResponse + */ + ValidateSchemaResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.pubsub.v1.ValidateSchemaResponse) + return object; + return new $root.google.pubsub.v1.ValidateSchemaResponse(); + }; + + /** + * Creates a plain object from a ValidateSchemaResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.pubsub.v1.ValidateSchemaResponse + * @static + * @param {google.pubsub.v1.ValidateSchemaResponse} message ValidateSchemaResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ValidateSchemaResponse.toObject = function toObject() { + return {}; + }; + + /** + * Converts this ValidateSchemaResponse to JSON. + * @function toJSON + * @memberof google.pubsub.v1.ValidateSchemaResponse + * @instance + * @returns {Object.} JSON object + */ + ValidateSchemaResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ValidateSchemaResponse; + })(); + + v1.ValidateMessageRequest = (function() { + + /** + * Properties of a ValidateMessageRequest. + * @memberof google.pubsub.v1 + * @interface IValidateMessageRequest + * @property {string|null} [parent] ValidateMessageRequest parent + * @property {string|null} [name] ValidateMessageRequest name + * @property {google.pubsub.v1.ISchema|null} [schema] ValidateMessageRequest schema + * @property {Uint8Array|null} [message] ValidateMessageRequest message + * @property {google.pubsub.v1.Encoding|null} [encoding] ValidateMessageRequest encoding + */ + + /** + * Constructs a new ValidateMessageRequest. + * @memberof google.pubsub.v1 + * @classdesc Represents a ValidateMessageRequest. + * @implements IValidateMessageRequest + * @constructor + * @param {google.pubsub.v1.IValidateMessageRequest=} [properties] Properties to set + */ + function ValidateMessageRequest(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]]; + } + + /** + * ValidateMessageRequest parent. + * @member {string} parent + * @memberof google.pubsub.v1.ValidateMessageRequest + * @instance + */ + ValidateMessageRequest.prototype.parent = ""; + + /** + * ValidateMessageRequest name. + * @member {string} name + * @memberof google.pubsub.v1.ValidateMessageRequest + * @instance + */ + ValidateMessageRequest.prototype.name = ""; + + /** + * ValidateMessageRequest schema. + * @member {google.pubsub.v1.ISchema|null|undefined} schema + * @memberof google.pubsub.v1.ValidateMessageRequest + * @instance + */ + ValidateMessageRequest.prototype.schema = null; + + /** + * ValidateMessageRequest message. + * @member {Uint8Array} message + * @memberof google.pubsub.v1.ValidateMessageRequest + * @instance + */ + ValidateMessageRequest.prototype.message = $util.newBuffer([]); + + /** + * ValidateMessageRequest encoding. + * @member {google.pubsub.v1.Encoding} encoding + * @memberof google.pubsub.v1.ValidateMessageRequest + * @instance + */ + ValidateMessageRequest.prototype.encoding = 0; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ValidateMessageRequest schemaSpec. + * @member {"name"|"schema"|undefined} schemaSpec + * @memberof google.pubsub.v1.ValidateMessageRequest + * @instance + */ + Object.defineProperty(ValidateMessageRequest.prototype, "schemaSpec", { + get: $util.oneOfGetter($oneOfFields = ["name", "schema"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new ValidateMessageRequest instance using the specified properties. + * @function create + * @memberof google.pubsub.v1.ValidateMessageRequest + * @static + * @param {google.pubsub.v1.IValidateMessageRequest=} [properties] Properties to set + * @returns {google.pubsub.v1.ValidateMessageRequest} ValidateMessageRequest instance + */ + ValidateMessageRequest.create = function create(properties) { + return new ValidateMessageRequest(properties); + }; + + /** + * Encodes the specified ValidateMessageRequest message. Does not implicitly {@link google.pubsub.v1.ValidateMessageRequest.verify|verify} messages. + * @function encode + * @memberof google.pubsub.v1.ValidateMessageRequest + * @static + * @param {google.pubsub.v1.IValidateMessageRequest} message ValidateMessageRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ValidateMessageRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.name); + if (message.schema != null && Object.hasOwnProperty.call(message, "schema")) + $root.google.pubsub.v1.Schema.encode(message.schema, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.message != null && Object.hasOwnProperty.call(message, "message")) + writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.message); + if (message.encoding != null && Object.hasOwnProperty.call(message, "encoding")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.encoding); + return writer; + }; + + /** + * Encodes the specified ValidateMessageRequest message, length delimited. Does not implicitly {@link google.pubsub.v1.ValidateMessageRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.pubsub.v1.ValidateMessageRequest + * @static + * @param {google.pubsub.v1.IValidateMessageRequest} message ValidateMessageRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ValidateMessageRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ValidateMessageRequest message from the specified reader or buffer. + * @function decode + * @memberof google.pubsub.v1.ValidateMessageRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.pubsub.v1.ValidateMessageRequest} ValidateMessageRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ValidateMessageRequest.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.ValidateMessageRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.name = reader.string(); + break; + case 3: + message.schema = $root.google.pubsub.v1.Schema.decode(reader, reader.uint32()); + break; + case 4: + message.message = reader.bytes(); + break; + case 5: + message.encoding = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ValidateMessageRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.pubsub.v1.ValidateMessageRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.pubsub.v1.ValidateMessageRequest} ValidateMessageRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ValidateMessageRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ValidateMessageRequest message. + * @function verify + * @memberof google.pubsub.v1.ValidateMessageRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ValidateMessageRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.name != null && message.hasOwnProperty("name")) { + properties.schemaSpec = 1; + if (!$util.isString(message.name)) + return "name: string expected"; + } + if (message.schema != null && message.hasOwnProperty("schema")) { + if (properties.schemaSpec === 1) + return "schemaSpec: multiple values"; + properties.schemaSpec = 1; + { + var error = $root.google.pubsub.v1.Schema.verify(message.schema); + if (error) + return "schema." + error; + } + } + if (message.message != null && message.hasOwnProperty("message")) + if (!(message.message && typeof message.message.length === "number" || $util.isString(message.message))) + return "message: buffer expected"; + if (message.encoding != null && message.hasOwnProperty("encoding")) + switch (message.encoding) { + default: + return "encoding: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates a ValidateMessageRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.pubsub.v1.ValidateMessageRequest + * @static + * @param {Object.} object Plain object + * @returns {google.pubsub.v1.ValidateMessageRequest} ValidateMessageRequest + */ + ValidateMessageRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.pubsub.v1.ValidateMessageRequest) + return object; + var message = new $root.google.pubsub.v1.ValidateMessageRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.name != null) + message.name = String(object.name); + if (object.schema != null) { + if (typeof object.schema !== "object") + throw TypeError(".google.pubsub.v1.ValidateMessageRequest.schema: object expected"); + message.schema = $root.google.pubsub.v1.Schema.fromObject(object.schema); + } + if (object.message != null) + if (typeof object.message === "string") + $util.base64.decode(object.message, message.message = $util.newBuffer($util.base64.length(object.message)), 0); + else if (object.message.length) + message.message = object.message; + switch (object.encoding) { + case "ENCODING_UNSPECIFIED": + case 0: + message.encoding = 0; + break; + case "JSON": + case 1: + message.encoding = 1; + break; + case "BINARY": + case 2: + message.encoding = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from a ValidateMessageRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.pubsub.v1.ValidateMessageRequest + * @static + * @param {google.pubsub.v1.ValidateMessageRequest} message ValidateMessageRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ValidateMessageRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + if (options.bytes === String) + object.message = ""; + else { + object.message = []; + if (options.bytes !== Array) + object.message = $util.newBuffer(object.message); + } + object.encoding = options.enums === String ? "ENCODING_UNSPECIFIED" : 0; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.name != null && message.hasOwnProperty("name")) { + object.name = message.name; + if (options.oneofs) + object.schemaSpec = "name"; + } + if (message.schema != null && message.hasOwnProperty("schema")) { + object.schema = $root.google.pubsub.v1.Schema.toObject(message.schema, options); + if (options.oneofs) + object.schemaSpec = "schema"; + } + if (message.message != null && message.hasOwnProperty("message")) + object.message = options.bytes === String ? $util.base64.encode(message.message, 0, message.message.length) : options.bytes === Array ? Array.prototype.slice.call(message.message) : message.message; + if (message.encoding != null && message.hasOwnProperty("encoding")) + object.encoding = options.enums === String ? $root.google.pubsub.v1.Encoding[message.encoding] : message.encoding; + return object; + }; + + /** + * Converts this ValidateMessageRequest to JSON. + * @function toJSON + * @memberof google.pubsub.v1.ValidateMessageRequest + * @instance + * @returns {Object.} JSON object + */ + ValidateMessageRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ValidateMessageRequest; + })(); + + v1.ValidateMessageResponse = (function() { + + /** + * Properties of a ValidateMessageResponse. + * @memberof google.pubsub.v1 + * @interface IValidateMessageResponse + */ + + /** + * Constructs a new ValidateMessageResponse. + * @memberof google.pubsub.v1 + * @classdesc Represents a ValidateMessageResponse. + * @implements IValidateMessageResponse + * @constructor + * @param {google.pubsub.v1.IValidateMessageResponse=} [properties] Properties to set + */ + function ValidateMessageResponse(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]]; + } + + /** + * Creates a new ValidateMessageResponse instance using the specified properties. + * @function create + * @memberof google.pubsub.v1.ValidateMessageResponse + * @static + * @param {google.pubsub.v1.IValidateMessageResponse=} [properties] Properties to set + * @returns {google.pubsub.v1.ValidateMessageResponse} ValidateMessageResponse instance + */ + ValidateMessageResponse.create = function create(properties) { + return new ValidateMessageResponse(properties); + }; + + /** + * Encodes the specified ValidateMessageResponse message. Does not implicitly {@link google.pubsub.v1.ValidateMessageResponse.verify|verify} messages. + * @function encode + * @memberof google.pubsub.v1.ValidateMessageResponse + * @static + * @param {google.pubsub.v1.IValidateMessageResponse} message ValidateMessageResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ValidateMessageResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified ValidateMessageResponse message, length delimited. Does not implicitly {@link google.pubsub.v1.ValidateMessageResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.pubsub.v1.ValidateMessageResponse + * @static + * @param {google.pubsub.v1.IValidateMessageResponse} message ValidateMessageResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ValidateMessageResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ValidateMessageResponse message from the specified reader or buffer. + * @function decode + * @memberof google.pubsub.v1.ValidateMessageResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.pubsub.v1.ValidateMessageResponse} ValidateMessageResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ValidateMessageResponse.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.ValidateMessageResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ValidateMessageResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.pubsub.v1.ValidateMessageResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.pubsub.v1.ValidateMessageResponse} ValidateMessageResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ValidateMessageResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ValidateMessageResponse message. + * @function verify + * @memberof google.pubsub.v1.ValidateMessageResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ValidateMessageResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a ValidateMessageResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.pubsub.v1.ValidateMessageResponse + * @static + * @param {Object.} object Plain object + * @returns {google.pubsub.v1.ValidateMessageResponse} ValidateMessageResponse + */ + ValidateMessageResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.pubsub.v1.ValidateMessageResponse) + return object; + return new $root.google.pubsub.v1.ValidateMessageResponse(); + }; + + /** + * Creates a plain object from a ValidateMessageResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.pubsub.v1.ValidateMessageResponse + * @static + * @param {google.pubsub.v1.ValidateMessageResponse} message ValidateMessageResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ValidateMessageResponse.toObject = function toObject() { + return {}; + }; + + /** + * Converts this ValidateMessageResponse to JSON. + * @function toJSON + * @memberof google.pubsub.v1.ValidateMessageResponse + * @instance + * @returns {Object.} JSON object + */ + ValidateMessageResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ValidateMessageResponse; + })(); + + /** + * Encoding enum. + * @name google.pubsub.v1.Encoding + * @enum {number} + * @property {number} ENCODING_UNSPECIFIED=0 ENCODING_UNSPECIFIED value + * @property {number} JSON=1 JSON value + * @property {number} BINARY=2 BINARY value + */ + v1.Encoding = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ENCODING_UNSPECIFIED"] = 0; + values[valuesById[1] = "JSON"] = 1; + values[valuesById[2] = "BINARY"] = 2; + return values; + })(); + return v1; })(); diff --git a/protos/protos.json b/protos/protos.json index cb4b5356b..6a97de5b4 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -10,7 +10,7 @@ "csharp_namespace": "Google.Cloud.PubSub.V1", "go_package": "google.golang.org/genproto/googleapis/pubsub/v1;pubsub", "java_multiple_files": true, - "java_outer_classname": "PubsubProto", + "java_outer_classname": "SchemaProto", "java_package": "com.google.pubsub.v1", "php_namespace": "Google\\Cloud\\PubSub\\V1", "ruby_package": "Google::Cloud::PubSub::V1" @@ -193,6 +193,22 @@ } } }, + "SchemaSettings": { + "fields": { + "schema": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "pubsub.googleapis.com/Schema" + } + }, + "encoding": { + "type": "Encoding", + "id": 2 + } + } + }, "Topic": { "options": { "(google.api.resource).type": "pubsub.googleapis.com/Topic", @@ -218,6 +234,14 @@ "kmsKeyName": { "type": "string", "id": 5 + }, + "schemaSettings": { + "type": "SchemaSettings", + "id": 6 + }, + "satisfiesPzs": { + "type": "bool", + "id": 7 } } }, @@ -1271,6 +1295,322 @@ }, "SeekResponse": { "fields": {} + }, + "SchemaService": { + "options": { + "(google.api.default_host)": "pubsub.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/pubsub" + }, + "methods": { + "CreateSchema": { + "requestType": "CreateSchemaRequest", + "responseType": "Schema", + "options": { + "(google.api.http).post": "/v1/{parent=projects/*}/schemas", + "(google.api.http).body": "schema", + "(google.api.method_signature)": "parent,schema,schema_id" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{parent=projects/*}/schemas", + "body": "schema" + } + }, + { + "(google.api.method_signature)": "parent,schema,schema_id" + } + ] + }, + "GetSchema": { + "requestType": "GetSchemaRequest", + "responseType": "Schema", + "options": { + "(google.api.http).get": "/v1/{name=projects/*/schemas/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1/{name=projects/*/schemas/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ListSchemas": { + "requestType": "ListSchemasRequest", + "responseType": "ListSchemasResponse", + "options": { + "(google.api.http).get": "/v1/{parent=projects/*}/schemas", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1/{parent=projects/*}/schemas" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + }, + "DeleteSchema": { + "requestType": "DeleteSchemaRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v1/{name=projects/*/schemas/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v1/{name=projects/*/schemas/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ValidateSchema": { + "requestType": "ValidateSchemaRequest", + "responseType": "ValidateSchemaResponse", + "options": { + "(google.api.http).post": "/v1/{parent=projects/*}/schemas:validate", + "(google.api.http).body": "*", + "(google.api.method_signature)": "parent,schema" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{parent=projects/*}/schemas:validate", + "body": "*" + } + }, + { + "(google.api.method_signature)": "parent,schema" + } + ] + }, + "ValidateMessage": { + "requestType": "ValidateMessageRequest", + "responseType": "ValidateMessageResponse", + "options": { + "(google.api.http).post": "/v1/{parent=projects/*}/schemas:validateMessage", + "(google.api.http).body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{parent=projects/*}/schemas:validateMessage", + "body": "*" + } + } + ] + } + } + }, + "Schema": { + "options": { + "(google.api.resource).type": "pubsub.googleapis.com/Schema", + "(google.api.resource).pattern": "projects/{project}/schemas/{schema}" + }, + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "type": { + "type": "Type", + "id": 2 + }, + "definition": { + "type": "string", + "id": 3 + } + }, + "nested": { + "Type": { + "values": { + "TYPE_UNSPECIFIED": 0, + "PROTOCOL_BUFFER": 1, + "AVRO": 2 + } + } + } + }, + "CreateSchemaRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).child_type": "pubsub.googleapis.com/Schema" + } + }, + "schema": { + "type": "Schema", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "schemaId": { + "type": "string", + "id": 3 + } + } + }, + "SchemaView": { + "values": { + "SCHEMA_VIEW_UNSPECIFIED": 0, + "BASIC": 1, + "FULL": 2 + } + }, + "GetSchemaRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "pubsub.googleapis.com/Schema" + } + }, + "view": { + "type": "SchemaView", + "id": 2 + } + } + }, + "ListSchemasRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "cloudresourcemanager.googleapis.com/Project" + } + }, + "view": { + "type": "SchemaView", + "id": 2 + }, + "pageSize": { + "type": "int32", + "id": 3 + }, + "pageToken": { + "type": "string", + "id": 4 + } + } + }, + "ListSchemasResponse": { + "fields": { + "schemas": { + "rule": "repeated", + "type": "Schema", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "DeleteSchemaRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "pubsub.googleapis.com/Schema" + } + } + } + }, + "ValidateSchemaRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "cloudresourcemanager.googleapis.com/Project" + } + }, + "schema": { + "type": "Schema", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "ValidateSchemaResponse": { + "fields": {} + }, + "ValidateMessageRequest": { + "oneofs": { + "schemaSpec": { + "oneof": [ + "name", + "schema" + ] + } + }, + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "cloudresourcemanager.googleapis.com/Project" + } + }, + "name": { + "type": "string", + "id": 2, + "options": { + "(google.api.resource_reference).type": "pubsub.googleapis.com/Schema" + } + }, + "schema": { + "type": "Schema", + "id": 3 + }, + "message": { + "type": "bytes", + "id": 4 + }, + "encoding": { + "type": "Encoding", + "id": 5 + } + } + }, + "ValidateMessageResponse": { + "fields": {} + }, + "Encoding": { + "values": { + "ENCODING_UNSPECIFIED": 0, + "JSON": 1, + "BINARY": 2 + } } } } diff --git a/src/v1/index.ts b/src/v1/index.ts index 9b1a8d2eb..3eeadbcf0 100644 --- a/src/v1/index.ts +++ b/src/v1/index.ts @@ -17,4 +17,5 @@ // ** All changes to this file may be overwritten. ** export {PublisherClient} from './publisher_client'; +export {SchemaServiceClient} from './schema_service_client'; export {SubscriberClient} from './subscriber_client'; diff --git a/src/v1/publisher_client.ts b/src/v1/publisher_client.ts index a0527bc6e..97975ee5c 100644 --- a/src/v1/publisher_client.ts +++ b/src/v1/publisher_client.ts @@ -16,6 +16,7 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** +/* global window */ import * as gax from 'google-gax'; import { Callback, @@ -32,6 +33,11 @@ import * as path from 'path'; import {Transform} from 'stream'; import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; +/** + * Client JSON configuration object, loaded from + * `src/v1/publisher_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ import * as gapicConfig from './publisher_client_config.json'; const version = require('../../../package.json').version; @@ -64,8 +70,10 @@ export class PublisherClient { /** * Construct an instance of PublisherClient. * - * @param {object} [options] - The configuration object. See the subsequent - * parameters for more details. + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: * @param {object} [options.credentials] - Credentials object. * @param {string} [options.credentials.client_email] * @param {string} [options.credentials.private_key] @@ -85,42 +93,35 @@ export class PublisherClient { * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. */ - constructor(opts?: ClientOptions) { - // Ensure that options include the service address and port. + // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof PublisherClient; const servicePath = - opts && opts.servicePath - ? opts.servicePath - : opts && opts.apiEndpoint - ? opts.apiEndpoint - : staticMembers.servicePath; - const port = opts && opts.port ? opts.port : staticMembers.port; + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - if (!opts) { - opts = {servicePath, port}; + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; } - opts.servicePath = opts.servicePath || servicePath; - opts.port = opts.port || port; - // users can override the config from client side, like retry codes name. - // The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/master/src/gax.ts#L546 - // The way to override client config for Showcase API: - // - // const customConfig = {"interfaces": {"google.showcase.v1beta1.Echo": {"methods": {"Echo": {"retry_codes_name": "idempotent", "retry_params_name": "default"}}}}} - // const showcaseClient = new showcaseClient({ projectId, customConfig }); - opts.clientConfig = opts.clientConfig || {}; - - // If we're running in browser, it's OK to omit `fallback` since - // google-gax has `browser` field in its `package.json`. - // For Electron (which does not respect `browser` field), - // pass `{fallback: true}` to the PublisherClient constructor. + // Choose either gRPC or proto-over-HTTP implementation of google-gax. this._gaxModule = opts.fallback ? gax.fallback : gax; - // Create a `gaxGrpc` object, with any grpc-specific options - // sent to the client. - opts.scopes = (this.constructor as typeof PublisherClient).scopes; + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. this._gaxGrpc = new this._gaxModule.GrpcClient(opts); // Save options to use in initialize() method. @@ -128,6 +129,11 @@ export class PublisherClient { // Save the auth object to the client, for use by other methods. this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } this.iamClient = new IamClient(this._gaxGrpc, opts); // Determine the client header string. @@ -171,6 +177,9 @@ export class PublisherClient { projectTopicPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/topics/{topic}' ), + schemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/schemas/{schema}' + ), snapshotPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/snapshots/{snapshot}' ), @@ -313,6 +322,7 @@ export class PublisherClient { /** * The DNS address for this API service. + * @returns {string} The DNS address for this service. */ static get servicePath() { return 'pubsub.googleapis.com'; @@ -321,6 +331,7 @@ export class PublisherClient { /** * The DNS address for this API service - same as servicePath(), * exists for compatibility reasons. + * @returns {string} The DNS address for this service. */ static get apiEndpoint() { return 'pubsub.googleapis.com'; @@ -328,6 +339,7 @@ export class PublisherClient { /** * The port for this API service. + * @returns {number} The default port for this service. */ static get port() { return 443; @@ -336,6 +348,7 @@ export class PublisherClient { /** * The scopes needed to make gRPC calls for every method defined * in this service. + * @returns {string[]} List of default scopes. */ static get scopes() { return [ @@ -348,8 +361,7 @@ export class PublisherClient { getProjectId(callback: Callback): void; /** * Return the project ID used by this class. - * @param {function(Error, string)} callback - the callback to - * be called with the current project Id. + * @returns {Promise} A promise that resolves to string containing the project ID. */ getProjectId( callback?: Callback @@ -366,7 +378,7 @@ export class PublisherClient { // ------------------- createTopic( request: protos.google.pubsub.v1.ITopic, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.pubsub.v1.ITopic, @@ -376,7 +388,7 @@ export class PublisherClient { >; createTopic( request: protos.google.pubsub.v1.ITopic, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.pubsub.v1.ITopic, protos.google.pubsub.v1.ITopic | null | undefined, @@ -392,8 +404,8 @@ export class PublisherClient { > ): void; /** - * Creates the given topic with the given name. See the [resource name rules]( - * https://cloud.google.com/pubsub/docs/admin#resource_names). + * Creates the given topic with the given name. See the [resource name rules] + * (https://cloud.google.com/pubsub/docs/admin#resource_names). * * @param {Object} request * The request object that will be sent. @@ -416,16 +428,27 @@ export class PublisherClient { * 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. + * + * EXPERIMENTAL: Schema support is in development and may not work yet. + * @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 {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. * The first element of the array is an object representing [Topic]{@link google.pubsub.v1.Topic}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createTopic(request); */ createTopic( request: protos.google.pubsub.v1.ITopic, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.pubsub.v1.ITopic, protos.google.pubsub.v1.ITopic | null | undefined, @@ -444,12 +467,12 @@ export class PublisherClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -464,7 +487,7 @@ export class PublisherClient { } updateTopic( request: protos.google.pubsub.v1.IUpdateTopicRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.pubsub.v1.ITopic, @@ -474,7 +497,7 @@ export class PublisherClient { >; updateTopic( request: protos.google.pubsub.v1.IUpdateTopicRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.pubsub.v1.ITopic, protos.google.pubsub.v1.IUpdateTopicRequest | null | undefined, @@ -507,12 +530,16 @@ export class PublisherClient { * 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. * The first element of the array is an object representing [Topic]{@link google.pubsub.v1.Topic}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.updateTopic(request); */ updateTopic( request: protos.google.pubsub.v1.IUpdateTopicRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.pubsub.v1.ITopic, protos.google.pubsub.v1.IUpdateTopicRequest | null | undefined, @@ -531,12 +558,12 @@ export class PublisherClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -551,7 +578,7 @@ export class PublisherClient { } publish( request: protos.google.pubsub.v1.IPublishRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.pubsub.v1.IPublishResponse, @@ -561,7 +588,7 @@ export class PublisherClient { >; publish( request: protos.google.pubsub.v1.IPublishRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.pubsub.v1.IPublishResponse, protos.google.pubsub.v1.IPublishRequest | null | undefined, @@ -591,12 +618,16 @@ export class PublisherClient { * 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. * The first element of the array is an object representing [PublishResponse]{@link google.pubsub.v1.PublishResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.publish(request); */ publish( request: protos.google.pubsub.v1.IPublishRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.pubsub.v1.IPublishResponse, protos.google.pubsub.v1.IPublishRequest | null | undefined, @@ -615,12 +646,12 @@ export class PublisherClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -635,7 +666,7 @@ export class PublisherClient { } getTopic( request: protos.google.pubsub.v1.IGetTopicRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.pubsub.v1.ITopic, @@ -645,7 +676,7 @@ export class PublisherClient { >; getTopic( request: protos.google.pubsub.v1.IGetTopicRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.pubsub.v1.ITopic, protos.google.pubsub.v1.IGetTopicRequest | null | undefined, @@ -672,12 +703,16 @@ export class PublisherClient { * 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. * The first element of the array is an object representing [Topic]{@link google.pubsub.v1.Topic}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getTopic(request); */ getTopic( request: protos.google.pubsub.v1.IGetTopicRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.pubsub.v1.ITopic, protos.google.pubsub.v1.IGetTopicRequest | null | undefined, @@ -696,12 +731,12 @@ export class PublisherClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -716,7 +751,7 @@ export class PublisherClient { } deleteTopic( request: protos.google.pubsub.v1.IDeleteTopicRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.protobuf.IEmpty, @@ -726,7 +761,7 @@ export class PublisherClient { >; deleteTopic( request: protos.google.pubsub.v1.IDeleteTopicRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.protobuf.IEmpty, protos.google.pubsub.v1.IDeleteTopicRequest | null | undefined, @@ -757,12 +792,16 @@ export class PublisherClient { * 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. * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deleteTopic(request); */ deleteTopic( request: protos.google.pubsub.v1.IDeleteTopicRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.protobuf.IEmpty, protos.google.pubsub.v1.IDeleteTopicRequest | null | undefined, @@ -781,12 +820,12 @@ export class PublisherClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -801,7 +840,7 @@ export class PublisherClient { } detachSubscription( request: protos.google.pubsub.v1.IDetachSubscriptionRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.pubsub.v1.IDetachSubscriptionResponse, @@ -811,7 +850,7 @@ export class PublisherClient { >; detachSubscription( request: protos.google.pubsub.v1.IDetachSubscriptionRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.pubsub.v1.IDetachSubscriptionResponse, protos.google.pubsub.v1.IDetachSubscriptionRequest | null | undefined, @@ -841,12 +880,16 @@ export class PublisherClient { * 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. * The first element of the array is an object representing [DetachSubscriptionResponse]{@link google.pubsub.v1.DetachSubscriptionResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.detachSubscription(request); */ detachSubscription( request: protos.google.pubsub.v1.IDetachSubscriptionRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.pubsub.v1.IDetachSubscriptionResponse, protos.google.pubsub.v1.IDetachSubscriptionRequest | null | undefined, @@ -865,12 +908,12 @@ export class PublisherClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -886,7 +929,7 @@ export class PublisherClient { listTopics( request: protos.google.pubsub.v1.IListTopicsRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.pubsub.v1.ITopic[], @@ -896,7 +939,7 @@ export class PublisherClient { >; listTopics( request: protos.google.pubsub.v1.IListTopicsRequest, - options: gax.CallOptions, + options: CallOptions, callback: PaginationCallback< protos.google.pubsub.v1.IListTopicsRequest, protos.google.pubsub.v1.IListTopicsResponse | null | undefined, @@ -929,24 +972,19 @@ export class PublisherClient { * 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. * The first element of the array is Array of [Topic]{@link google.pubsub.v1.Topic}. - * The client library support auto-pagination by default: it will call the API as many + * The client library will perform auto-pagination by default: it will call the API as many * times as needed and will merge results from all the pages into this array. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [Topic]{@link google.pubsub.v1.Topic} that corresponds to - * the one page received from the API server. - * If the second element is not null it contains the request object of type [ListTopicsRequest]{@link google.pubsub.v1.ListTopicsRequest} - * that can be used to obtain the next page of the results. - * If it is null, the next page does not exist. - * The third element contains the raw response received from the API server. Its type is - * [ListTopicsResponse]{@link google.pubsub.v1.ListTopicsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. + * Note that it can affect your quota. + * We recommend using `listTopicsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listTopics( request: protos.google.pubsub.v1.IListTopicsRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | PaginationCallback< protos.google.pubsub.v1.IListTopicsRequest, protos.google.pubsub.v1.IListTopicsResponse | null | undefined, @@ -965,12 +1003,12 @@ export class PublisherClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -985,18 +1023,7 @@ export class PublisherClient { } /** - * Equivalent to {@link listTopics}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listTopics} continuously - * and invokes the callback registered for 'data' event for each element in the - * responses. - * - * The returned object has 'end' method when no more elements are required. - * - * autoPaginate option will be ignored. - * - * @see {@link https://nodejs.org/api/stream.html} - * + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. * @param {Object} request * The request object that will be sent. * @param {string} request.project @@ -1012,10 +1039,17 @@ export class PublisherClient { * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Stream} * An object stream which emits an object representing [Topic]{@link google.pubsub.v1.Topic} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listTopicsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listTopicsStream( request?: protos.google.pubsub.v1.IListTopicsRequest, - options?: gax.CallOptions + options?: CallOptions ): Transform { request = request || {}; options = options || {}; @@ -1036,10 +1070,9 @@ export class PublisherClient { } /** - * Equivalent to {@link listTopics}, but returns an iterable object. - * - * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * Equivalent to `listTopics`, but returns an iterable object. * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. * @param {Object} request * The request object that will be sent. * @param {string} request.project @@ -1054,11 +1087,22 @@ export class PublisherClient { * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Object} - * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Topic]{@link google.pubsub.v1.Topic}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listTopicsAsync(request); + * for await (const response of iterable) { + * // process response + * } */ listTopicsAsync( request?: protos.google.pubsub.v1.IListTopicsRequest, - options?: gax.CallOptions + options?: CallOptions ): AsyncIterable { request = request || {}; options = options || {}; @@ -1080,7 +1124,7 @@ export class PublisherClient { } listTopicSubscriptions( request: protos.google.pubsub.v1.IListTopicSubscriptionsRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ string[], @@ -1090,7 +1134,7 @@ export class PublisherClient { >; listTopicSubscriptions( request: protos.google.pubsub.v1.IListTopicSubscriptionsRequest, - options: gax.CallOptions, + options: CallOptions, callback: PaginationCallback< protos.google.pubsub.v1.IListTopicSubscriptionsRequest, | protos.google.pubsub.v1.IListTopicSubscriptionsResponse @@ -1127,24 +1171,19 @@ export class PublisherClient { * 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. * The first element of the array is Array of string. - * The client library support auto-pagination by default: it will call the API as many + * The client library will perform auto-pagination by default: it will call the API as many * times as needed and will merge results from all the pages into this array. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of string that corresponds to - * the one page received from the API server. - * If the second element is not null it contains the request object of type [ListTopicSubscriptionsRequest]{@link google.pubsub.v1.ListTopicSubscriptionsRequest} - * that can be used to obtain the next page of the results. - * If it is null, the next page does not exist. - * The third element contains the raw response received from the API server. Its type is - * [ListTopicSubscriptionsResponse]{@link google.pubsub.v1.ListTopicSubscriptionsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. + * Note that it can affect your quota. + * We recommend using `listTopicSubscriptionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listTopicSubscriptions( request: protos.google.pubsub.v1.IListTopicSubscriptionsRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | PaginationCallback< protos.google.pubsub.v1.IListTopicSubscriptionsRequest, | protos.google.pubsub.v1.IListTopicSubscriptionsResponse @@ -1167,12 +1206,12 @@ export class PublisherClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1191,18 +1230,7 @@ export class PublisherClient { } /** - * Equivalent to {@link listTopicSubscriptions}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listTopicSubscriptions} continuously - * and invokes the callback registered for 'data' event for each element in the - * responses. - * - * The returned object has 'end' method when no more elements are required. - * - * autoPaginate option will be ignored. - * - * @see {@link https://nodejs.org/api/stream.html} - * + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. * @param {Object} request * The request object that will be sent. * @param {string} request.topic @@ -1218,10 +1246,17 @@ export class PublisherClient { * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Stream} * An object stream which emits an object representing string on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listTopicSubscriptionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listTopicSubscriptionsStream( request?: protos.google.pubsub.v1.IListTopicSubscriptionsRequest, - options?: gax.CallOptions + options?: CallOptions ): Transform { request = request || {}; options = options || {}; @@ -1242,10 +1277,9 @@ export class PublisherClient { } /** - * Equivalent to {@link listTopicSubscriptions}, but returns an iterable object. - * - * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * Equivalent to `listTopicSubscriptions`, but returns an iterable object. * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. * @param {Object} request * The request object that will be sent. * @param {string} request.topic @@ -1260,11 +1294,22 @@ export class PublisherClient { * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Object} - * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * string. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listTopicSubscriptionsAsync(request); + * for await (const response of iterable) { + * // process response + * } */ listTopicSubscriptionsAsync( request?: protos.google.pubsub.v1.IListTopicSubscriptionsRequest, - options?: gax.CallOptions + options?: CallOptions ): AsyncIterable { request = request || {}; options = options || {}; @@ -1286,7 +1331,7 @@ export class PublisherClient { } listTopicSnapshots( request: protos.google.pubsub.v1.IListTopicSnapshotsRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ string[], @@ -1296,7 +1341,7 @@ export class PublisherClient { >; listTopicSnapshots( request: protos.google.pubsub.v1.IListTopicSnapshotsRequest, - options: gax.CallOptions, + options: CallOptions, callback: PaginationCallback< protos.google.pubsub.v1.IListTopicSnapshotsRequest, protos.google.pubsub.v1.IListTopicSnapshotsResponse | null | undefined, @@ -1333,24 +1378,19 @@ export class PublisherClient { * 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. * The first element of the array is Array of string. - * The client library support auto-pagination by default: it will call the API as many + * The client library will perform auto-pagination by default: it will call the API as many * times as needed and will merge results from all the pages into this array. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of string that corresponds to - * the one page received from the API server. - * If the second element is not null it contains the request object of type [ListTopicSnapshotsRequest]{@link google.pubsub.v1.ListTopicSnapshotsRequest} - * that can be used to obtain the next page of the results. - * If it is null, the next page does not exist. - * The third element contains the raw response received from the API server. Its type is - * [ListTopicSnapshotsResponse]{@link google.pubsub.v1.ListTopicSnapshotsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. + * Note that it can affect your quota. + * We recommend using `listTopicSnapshotsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listTopicSnapshots( request: protos.google.pubsub.v1.IListTopicSnapshotsRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | PaginationCallback< protos.google.pubsub.v1.IListTopicSnapshotsRequest, | protos.google.pubsub.v1.IListTopicSnapshotsResponse @@ -1371,12 +1411,12 @@ export class PublisherClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1391,18 +1431,7 @@ export class PublisherClient { } /** - * Equivalent to {@link listTopicSnapshots}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listTopicSnapshots} continuously - * and invokes the callback registered for 'data' event for each element in the - * responses. - * - * The returned object has 'end' method when no more elements are required. - * - * autoPaginate option will be ignored. - * - * @see {@link https://nodejs.org/api/stream.html} - * + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. * @param {Object} request * The request object that will be sent. * @param {string} request.topic @@ -1418,10 +1447,17 @@ export class PublisherClient { * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Stream} * An object stream which emits an object representing string on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listTopicSnapshotsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listTopicSnapshotsStream( request?: protos.google.pubsub.v1.IListTopicSnapshotsRequest, - options?: gax.CallOptions + options?: CallOptions ): Transform { request = request || {}; options = options || {}; @@ -1442,10 +1478,9 @@ export class PublisherClient { } /** - * Equivalent to {@link listTopicSnapshots}, but returns an iterable object. - * - * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * Equivalent to `listTopicSnapshots`, but returns an iterable object. * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. * @param {Object} request * The request object that will be sent. * @param {string} request.topic @@ -1460,11 +1495,22 @@ export class PublisherClient { * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Object} - * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * string. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listTopicSnapshotsAsync(request); + * for await (const response of iterable) { + * // process response + * } */ listTopicSnapshotsAsync( request?: protos.google.pubsub.v1.IListTopicSnapshotsRequest, - options?: gax.CallOptions + options?: CallOptions ): AsyncIterable { request = request || {}; options = options || {}; @@ -1689,6 +1735,42 @@ export class PublisherClient { .topic; } + /** + * Return a fully-qualified schema resource name string. + * + * @param {string} project + * @param {string} schema + * @returns {string} Resource name string. + */ + schemaPath(project: string, schema: string) { + return this.pathTemplates.schemaPathTemplate.render({ + project: project, + schema: schema, + }); + } + + /** + * Parse the project from Schema resource. + * + * @param {string} schemaName + * A fully-qualified path representing Schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromSchemaName(schemaName: string) { + return this.pathTemplates.schemaPathTemplate.match(schemaName).project; + } + + /** + * Parse the schema from Schema resource. + * + * @param {string} schemaName + * A fully-qualified path representing Schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromSchemaName(schemaName: string) { + return this.pathTemplates.schemaPathTemplate.match(schemaName).schema; + } + /** * Return a fully-qualified snapshot resource name string. * @@ -1764,9 +1846,10 @@ export class PublisherClient { } /** - * Terminate the GRPC channel and close the client. + * Terminate the gRPC channel and close the client. * * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. */ close(): Promise { this.initialize(); diff --git a/src/v1/publisher_proto_list.json b/src/v1/publisher_proto_list.json index 23484bf66..91011aec1 100644 --- a/src/v1/publisher_proto_list.json +++ b/src/v1/publisher_proto_list.json @@ -1,3 +1,4 @@ [ - "../../protos/google/pubsub/v1/pubsub.proto" + "../../protos/google/pubsub/v1/pubsub.proto", + "../../protos/google/pubsub/v1/schema.proto" ] diff --git a/src/v1/schema_service_client.ts b/src/v1/schema_service_client.ts new file mode 100644 index 000000000..d2df82460 --- /dev/null +++ b/src/v1/schema_service_client.ts @@ -0,0 +1,1328 @@ +// Copyright 2021 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 file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import { + Callback, + CallOptions, + Descriptors, + ClientOptions, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, +} from 'google-gax'; +import * as path from 'path'; + +import {Transform} from 'stream'; +import {RequestType} from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +/** + * Client JSON configuration object, loaded from + * `src/v1/schema_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './schema_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * @class + * @memberof v1 + */ +export class SchemaServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + innerApiCalls: {[name: string]: Function}; + iamClient: IamClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + schemaServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SchemaServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SchemaServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.iamClient = new IamClient(this._gaxGrpc, opts); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + + const nodejsProtoPath = path.join( + __dirname, + '..', + '..', + 'protos', + 'protos.json' + ); + this._protos = this._gaxGrpc.loadProto( + opts.fallback + ? // eslint-disable-next-line @typescript-eslint/no-var-requires + require('../../protos/protos.json') + : nodejsProtoPath + ); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + projectTopicPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/topics/{topic}' + ), + schemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/schemas/{schema}' + ), + snapshotPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/snapshots/{snapshot}' + ), + subscriptionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/subscriptions/{subscription}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listSchemas: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'schemas' + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.pubsub.v1.SchemaService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + {'x-goog-api-client': clientHeader.join(' ')} + ); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.schemaServiceStub) { + return this.schemaServiceStub; + } + + // Put together the "service stub" for + // google.pubsub.v1.SchemaService. + this.schemaServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.pubsub.v1.SchemaService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.pubsub.v1.SchemaService, + this._opts + ) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const schemaServiceStubMethods = [ + 'createSchema', + 'getSchema', + 'listSchemas', + 'deleteSchema', + 'validateSchema', + 'validateMessage', + ]; + for (const methodName of schemaServiceStubMethods) { + const callPromise = this.schemaServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { + throw err; + } + ); + + const descriptor = this.descriptors.page[methodName] || undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.schemaServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'pubsub.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'pubsub.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/pubsub', + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId( + callback?: Callback + ): Promise | void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + createSchema( + request: protos.google.pubsub.v1.ICreateSchemaRequest, + options?: CallOptions + ): Promise< + [ + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.ICreateSchemaRequest | undefined, + {} | undefined + ] + >; + createSchema( + request: protos.google.pubsub.v1.ICreateSchemaRequest, + options: CallOptions, + callback: Callback< + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.ICreateSchemaRequest | null | undefined, + {} | null | undefined + > + ): void; + createSchema( + request: protos.google.pubsub.v1.ICreateSchemaRequest, + callback: Callback< + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.ICreateSchemaRequest | null | undefined, + {} | null | undefined + > + ): void; + /** + * Creates a schema. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project in which to create the schema. + * Format is `projects/{project-id}`. + * @param {google.pubsub.v1.Schema} request.schema + * Required. The schema object to create. + * + * This schema's `name` parameter is ignored. The schema object returned + * by CreateSchema will have a `name` made using the given `parent` and + * `schema_id`. + * @param {string} request.schemaId + * 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. + * @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. + * The first element of the array is an object representing [Schema]{@link google.pubsub.v1.Schema}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createSchema(request); + */ + createSchema( + request: protos.google.pubsub.v1.ICreateSchemaRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.ICreateSchemaRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.ICreateSchemaRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.ICreateSchemaRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createSchema(request, options, callback); + } + getSchema( + request: protos.google.pubsub.v1.IGetSchemaRequest, + options?: CallOptions + ): Promise< + [ + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.IGetSchemaRequest | undefined, + {} | undefined + ] + >; + getSchema( + request: protos.google.pubsub.v1.IGetSchemaRequest, + options: CallOptions, + callback: Callback< + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.IGetSchemaRequest | null | undefined, + {} | null | undefined + > + ): void; + getSchema( + request: protos.google.pubsub.v1.IGetSchemaRequest, + callback: Callback< + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.IGetSchemaRequest | null | undefined, + {} | null | undefined + > + ): void; + /** + * Gets a schema. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the schema to get. + * Format is `projects/{project}/schemas/{schema}`. + * @param {google.pubsub.v1.SchemaView} request.view + * The set of fields to return in the response. If not set, returns a Schema + * with `name` and `type`, but not `definition`. Set to `FULL` to retrieve all + * fields. + * @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. + * The first element of the array is an object representing [Schema]{@link google.pubsub.v1.Schema}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getSchema(request); + */ + getSchema( + request: protos.google.pubsub.v1.IGetSchemaRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.IGetSchemaRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.IGetSchemaRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.IGetSchemaRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getSchema(request, options, callback); + } + deleteSchema( + request: protos.google.pubsub.v1.IDeleteSchemaRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.pubsub.v1.IDeleteSchemaRequest | undefined, + {} | undefined + ] + >; + deleteSchema( + request: protos.google.pubsub.v1.IDeleteSchemaRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.pubsub.v1.IDeleteSchemaRequest | null | undefined, + {} | null | undefined + > + ): void; + deleteSchema( + request: protos.google.pubsub.v1.IDeleteSchemaRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.pubsub.v1.IDeleteSchemaRequest | null | undefined, + {} | null | undefined + > + ): void; + /** + * Deletes a schema. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the schema to delete. + * Format is `projects/{project}/schemas/{schema}`. + * @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. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deleteSchema(request); + */ + deleteSchema( + request: protos.google.pubsub.v1.IDeleteSchemaRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.protobuf.IEmpty, + protos.google.pubsub.v1.IDeleteSchemaRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.pubsub.v1.IDeleteSchemaRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.pubsub.v1.IDeleteSchemaRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteSchema(request, options, callback); + } + validateSchema( + request: protos.google.pubsub.v1.IValidateSchemaRequest, + options?: CallOptions + ): Promise< + [ + protos.google.pubsub.v1.IValidateSchemaResponse, + protos.google.pubsub.v1.IValidateSchemaRequest | undefined, + {} | undefined + ] + >; + validateSchema( + request: protos.google.pubsub.v1.IValidateSchemaRequest, + options: CallOptions, + callback: Callback< + protos.google.pubsub.v1.IValidateSchemaResponse, + protos.google.pubsub.v1.IValidateSchemaRequest | null | undefined, + {} | null | undefined + > + ): void; + validateSchema( + request: protos.google.pubsub.v1.IValidateSchemaRequest, + callback: Callback< + protos.google.pubsub.v1.IValidateSchemaResponse, + protos.google.pubsub.v1.IValidateSchemaRequest | null | undefined, + {} | null | undefined + > + ): void; + /** + * Validates a schema. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project in which to validate schemas. + * Format is `projects/{project-id}`. + * @param {google.pubsub.v1.Schema} request.schema + * Required. The schema object to validate. + * @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. + * The first element of the array is an object representing [ValidateSchemaResponse]{@link google.pubsub.v1.ValidateSchemaResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.validateSchema(request); + */ + validateSchema( + request: protos.google.pubsub.v1.IValidateSchemaRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.pubsub.v1.IValidateSchemaResponse, + protos.google.pubsub.v1.IValidateSchemaRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.pubsub.v1.IValidateSchemaResponse, + protos.google.pubsub.v1.IValidateSchemaRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.pubsub.v1.IValidateSchemaResponse, + protos.google.pubsub.v1.IValidateSchemaRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.validateSchema(request, options, callback); + } + validateMessage( + request: protos.google.pubsub.v1.IValidateMessageRequest, + options?: CallOptions + ): Promise< + [ + protos.google.pubsub.v1.IValidateMessageResponse, + protos.google.pubsub.v1.IValidateMessageRequest | undefined, + {} | undefined + ] + >; + validateMessage( + request: protos.google.pubsub.v1.IValidateMessageRequest, + options: CallOptions, + callback: Callback< + protos.google.pubsub.v1.IValidateMessageResponse, + protos.google.pubsub.v1.IValidateMessageRequest | null | undefined, + {} | null | undefined + > + ): void; + validateMessage( + request: protos.google.pubsub.v1.IValidateMessageRequest, + callback: Callback< + protos.google.pubsub.v1.IValidateMessageResponse, + protos.google.pubsub.v1.IValidateMessageRequest | null | undefined, + {} | null | undefined + > + ): void; + /** + * Validates a message against a schema. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project in which to validate schemas. + * Format is `projects/{project-id}`. + * @param {string} request.name + * Name of the schema against which to validate. + * + * Format is `projects/{project}/schemas/{schema}`. + * @param {google.pubsub.v1.Schema} request.schema + * Ad-hoc schema against which to validate + * @param {Buffer} request.message + * Message to validate against the provided `schema_spec`. + * @param {google.pubsub.v1.Encoding} request.encoding + * The encoding expected for messages + * @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. + * The first element of the array is an object representing [ValidateMessageResponse]{@link google.pubsub.v1.ValidateMessageResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.validateMessage(request); + */ + validateMessage( + request: protos.google.pubsub.v1.IValidateMessageRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.pubsub.v1.IValidateMessageResponse, + protos.google.pubsub.v1.IValidateMessageRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.pubsub.v1.IValidateMessageResponse, + protos.google.pubsub.v1.IValidateMessageRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.pubsub.v1.IValidateMessageResponse, + protos.google.pubsub.v1.IValidateMessageRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.validateMessage(request, options, callback); + } + + listSchemas( + request: protos.google.pubsub.v1.IListSchemasRequest, + options?: CallOptions + ): Promise< + [ + protos.google.pubsub.v1.ISchema[], + protos.google.pubsub.v1.IListSchemasRequest | null, + protos.google.pubsub.v1.IListSchemasResponse + ] + >; + listSchemas( + request: protos.google.pubsub.v1.IListSchemasRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.pubsub.v1.IListSchemasRequest, + protos.google.pubsub.v1.IListSchemasResponse | null | undefined, + protos.google.pubsub.v1.ISchema + > + ): void; + listSchemas( + request: protos.google.pubsub.v1.IListSchemasRequest, + callback: PaginationCallback< + protos.google.pubsub.v1.IListSchemasRequest, + protos.google.pubsub.v1.IListSchemasResponse | null | undefined, + protos.google.pubsub.v1.ISchema + > + ): void; + /** + * Lists schemas in a project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project in which to list schemas. + * Format is `projects/{project-id}`. + * @param {google.pubsub.v1.SchemaView} request.view + * The set of Schema fields to return in the response. If not set, returns + * Schemas with `name` and `type`, but not `definition`. Set to `FULL` to + * retrieve all fields. + * @param {number} request.pageSize + * Maximum number of schemas to return. + * @param {string} request.pageToken + * The value returned by the last `ListSchemasResponse`; indicates that + * this is a continuation of a prior `ListSchemas` 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. + * The first element of the array is Array of [Schema]{@link google.pubsub.v1.Schema}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listSchemasAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listSchemas( + request: protos.google.pubsub.v1.IListSchemasRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.pubsub.v1.IListSchemasRequest, + protos.google.pubsub.v1.IListSchemasResponse | null | undefined, + protos.google.pubsub.v1.ISchema + >, + callback?: PaginationCallback< + protos.google.pubsub.v1.IListSchemasRequest, + protos.google.pubsub.v1.IListSchemasResponse | null | undefined, + protos.google.pubsub.v1.ISchema + > + ): Promise< + [ + protos.google.pubsub.v1.ISchema[], + protos.google.pubsub.v1.IListSchemasRequest | null, + protos.google.pubsub.v1.IListSchemasResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listSchemas(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project in which to list schemas. + * Format is `projects/{project-id}`. + * @param {google.pubsub.v1.SchemaView} request.view + * The set of Schema fields to return in the response. If not set, returns + * Schemas with `name` and `type`, but not `definition`. Set to `FULL` to + * retrieve all fields. + * @param {number} request.pageSize + * Maximum number of schemas to return. + * @param {string} request.pageToken + * The value returned by the last `ListSchemasResponse`; indicates that + * this is a continuation of a prior `ListSchemas` 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} + * An object stream which emits an object representing [Schema]{@link google.pubsub.v1.Schema} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listSchemasAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listSchemasStream( + request?: protos.google.pubsub.v1.IListSchemasRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listSchemas.createStream( + this.innerApiCalls.listSchemas as gax.GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listSchemas`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project in which to list schemas. + * Format is `projects/{project-id}`. + * @param {google.pubsub.v1.SchemaView} request.view + * The set of Schema fields to return in the response. If not set, returns + * Schemas with `name` and `type`, but not `definition`. Set to `FULL` to + * retrieve all fields. + * @param {number} request.pageSize + * Maximum number of schemas to return. + * @param {string} request.pageToken + * The value returned by the last `ListSchemasResponse`; indicates that + * this is a continuation of a prior `ListSchemas` 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} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Schema]{@link google.pubsub.v1.Schema}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listSchemasAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listSchemasAsync( + request?: protos.google.pubsub.v1.IListSchemasRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listSchemas.asyncIterate( + this.innerApiCalls['listSchemas'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as [GetPolicyOptions]{@link google.iam.v1.GetPolicyOptions} + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [Policy]{@link google.iam.v1.Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getIamPolicy( + request: IamProtos.google.iam.v1.GetIamPolicyRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ): Promise { + return this.iamClient.getIamPolicy(request, options, callback); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + setIamPolicy( + request: IamProtos.google.iam.v1.SetIamPolicyRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ): Promise { + return this.iamClient.setIamPolicy(request, options, callback); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ + testIamPermissions( + request: IamProtos.google.iam.v1.TestIamPermissionsRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + ): Promise { + return this.iamClient.testIamPermissions(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project: string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified projectTopic resource name string. + * + * @param {string} project + * @param {string} topic + * @returns {string} Resource name string. + */ + projectTopicPath(project: string, topic: string) { + return this.pathTemplates.projectTopicPathTemplate.render({ + project: project, + topic: topic, + }); + } + + /** + * Parse the project from ProjectTopic resource. + * + * @param {string} projectTopicName + * A fully-qualified path representing project_topic resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectTopicName(projectTopicName: string) { + return this.pathTemplates.projectTopicPathTemplate.match(projectTopicName) + .project; + } + + /** + * Parse the topic from ProjectTopic resource. + * + * @param {string} projectTopicName + * A fully-qualified path representing project_topic resource. + * @returns {string} A string representing the topic. + */ + matchTopicFromProjectTopicName(projectTopicName: string) { + return this.pathTemplates.projectTopicPathTemplate.match(projectTopicName) + .topic; + } + + /** + * Return a fully-qualified schema resource name string. + * + * @param {string} project + * @param {string} schema + * @returns {string} Resource name string. + */ + schemaPath(project: string, schema: string) { + return this.pathTemplates.schemaPathTemplate.render({ + project: project, + schema: schema, + }); + } + + /** + * Parse the project from Schema resource. + * + * @param {string} schemaName + * A fully-qualified path representing Schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromSchemaName(schemaName: string) { + return this.pathTemplates.schemaPathTemplate.match(schemaName).project; + } + + /** + * Parse the schema from Schema resource. + * + * @param {string} schemaName + * A fully-qualified path representing Schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromSchemaName(schemaName: string) { + return this.pathTemplates.schemaPathTemplate.match(schemaName).schema; + } + + /** + * Return a fully-qualified snapshot resource name string. + * + * @param {string} project + * @param {string} snapshot + * @returns {string} Resource name string. + */ + snapshotPath(project: string, snapshot: string) { + return this.pathTemplates.snapshotPathTemplate.render({ + project: project, + snapshot: snapshot, + }); + } + + /** + * Parse the project from Snapshot resource. + * + * @param {string} snapshotName + * A fully-qualified path representing Snapshot resource. + * @returns {string} A string representing the project. + */ + matchProjectFromSnapshotName(snapshotName: string) { + return this.pathTemplates.snapshotPathTemplate.match(snapshotName).project; + } + + /** + * Parse the snapshot from Snapshot resource. + * + * @param {string} snapshotName + * A fully-qualified path representing Snapshot resource. + * @returns {string} A string representing the snapshot. + */ + matchSnapshotFromSnapshotName(snapshotName: string) { + return this.pathTemplates.snapshotPathTemplate.match(snapshotName).snapshot; + } + + /** + * Return a fully-qualified subscription resource name string. + * + * @param {string} project + * @param {string} subscription + * @returns {string} Resource name string. + */ + subscriptionPath(project: string, subscription: string) { + return this.pathTemplates.subscriptionPathTemplate.render({ + project: project, + subscription: subscription, + }); + } + + /** + * Parse the project from Subscription resource. + * + * @param {string} subscriptionName + * A fully-qualified path representing Subscription resource. + * @returns {string} A string representing the project. + */ + matchProjectFromSubscriptionName(subscriptionName: string) { + return this.pathTemplates.subscriptionPathTemplate.match(subscriptionName) + .project; + } + + /** + * Parse the subscription from Subscription resource. + * + * @param {string} subscriptionName + * A fully-qualified path representing Subscription resource. + * @returns {string} A string representing the subscription. + */ + matchSubscriptionFromSubscriptionName(subscriptionName: string) { + return this.pathTemplates.subscriptionPathTemplate.match(subscriptionName) + .subscription; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + this.initialize(); + if (!this._terminated) { + return this.schemaServiceStub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/src/v1/schema_service_client_config.json b/src/v1/schema_service_client_config.json new file mode 100644 index 000000000..8928eccdf --- /dev/null +++ b/src/v1/schema_service_client_config.json @@ -0,0 +1,50 @@ +{ + "interfaces": { + "google.pubsub.v1.SchemaService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateSchema": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetSchema": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListSchemas": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteSchema": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ValidateSchema": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ValidateMessage": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/src/v1/schema_service_proto_list.json b/src/v1/schema_service_proto_list.json new file mode 100644 index 000000000..91011aec1 --- /dev/null +++ b/src/v1/schema_service_proto_list.json @@ -0,0 +1,4 @@ +[ + "../../protos/google/pubsub/v1/pubsub.proto", + "../../protos/google/pubsub/v1/schema.proto" +] diff --git a/src/v1/subscriber_client.ts b/src/v1/subscriber_client.ts index 790489db5..4b8845544 100644 --- a/src/v1/subscriber_client.ts +++ b/src/v1/subscriber_client.ts @@ -16,6 +16,7 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** +/* global window */ import * as gax from 'google-gax'; import { Callback, @@ -32,6 +33,11 @@ import * as path from 'path'; import {Transform} from 'stream'; import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; +/** + * Client JSON configuration object, loaded from + * `src/v1/subscriber_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ import * as gapicConfig from './subscriber_client_config.json'; const version = require('../../../package.json').version; @@ -65,8 +71,10 @@ export class SubscriberClient { /** * Construct an instance of SubscriberClient. * - * @param {object} [options] - The configuration object. See the subsequent - * parameters for more details. + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: * @param {object} [options.credentials] - Credentials object. * @param {string} [options.credentials.client_email] * @param {string} [options.credentials.private_key] @@ -86,42 +94,35 @@ export class SubscriberClient { * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. */ - constructor(opts?: ClientOptions) { - // Ensure that options include the service address and port. + // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof SubscriberClient; const servicePath = - opts && opts.servicePath - ? opts.servicePath - : opts && opts.apiEndpoint - ? opts.apiEndpoint - : staticMembers.servicePath; - const port = opts && opts.port ? opts.port : staticMembers.port; + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - if (!opts) { - opts = {servicePath, port}; + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; } - opts.servicePath = opts.servicePath || servicePath; - opts.port = opts.port || port; - // users can override the config from client side, like retry codes name. - // The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/master/src/gax.ts#L546 - // The way to override client config for Showcase API: - // - // const customConfig = {"interfaces": {"google.showcase.v1beta1.Echo": {"methods": {"Echo": {"retry_codes_name": "idempotent", "retry_params_name": "default"}}}}} - // const showcaseClient = new showcaseClient({ projectId, customConfig }); - opts.clientConfig = opts.clientConfig || {}; - - // If we're running in browser, it's OK to omit `fallback` since - // google-gax has `browser` field in its `package.json`. - // For Electron (which does not respect `browser` field), - // pass `{fallback: true}` to the SubscriberClient constructor. + // Choose either gRPC or proto-over-HTTP implementation of google-gax. this._gaxModule = opts.fallback ? gax.fallback : gax; - // Create a `gaxGrpc` object, with any grpc-specific options - // sent to the client. - opts.scopes = (this.constructor as typeof SubscriberClient).scopes; + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. this._gaxGrpc = new this._gaxModule.GrpcClient(opts); // Save options to use in initialize() method. @@ -129,6 +130,11 @@ export class SubscriberClient { // Save the auth object to the client, for use by other methods. this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } this.iamClient = new IamClient(this._gaxGrpc, opts); // Determine the client header string. @@ -172,6 +178,9 @@ export class SubscriberClient { projectTopicPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/topics/{topic}' ), + schemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/schemas/{schema}' + ), snapshotPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/snapshots/{snapshot}' ), @@ -299,6 +308,7 @@ export class SubscriberClient { /** * The DNS address for this API service. + * @returns {string} The DNS address for this service. */ static get servicePath() { return 'pubsub.googleapis.com'; @@ -307,6 +317,7 @@ export class SubscriberClient { /** * The DNS address for this API service - same as servicePath(), * exists for compatibility reasons. + * @returns {string} The DNS address for this service. */ static get apiEndpoint() { return 'pubsub.googleapis.com'; @@ -314,6 +325,7 @@ export class SubscriberClient { /** * The port for this API service. + * @returns {number} The default port for this service. */ static get port() { return 443; @@ -322,6 +334,7 @@ export class SubscriberClient { /** * The scopes needed to make gRPC calls for every method defined * in this service. + * @returns {string[]} List of default scopes. */ static get scopes() { return [ @@ -334,8 +347,7 @@ export class SubscriberClient { getProjectId(callback: Callback): void; /** * Return the project ID used by this class. - * @param {function(Error, string)} callback - the callback to - * be called with the current project Id. + * @returns {Promise} A promise that resolves to string containing the project ID. */ getProjectId( callback?: Callback @@ -352,7 +364,7 @@ export class SubscriberClient { // ------------------- createSubscription( request: protos.google.pubsub.v1.ISubscription, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.pubsub.v1.ISubscription, @@ -362,7 +374,7 @@ export class SubscriberClient { >; createSubscription( request: protos.google.pubsub.v1.ISubscription, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.pubsub.v1.ISubscription, protos.google.pubsub.v1.ISubscription | null | undefined, @@ -489,12 +501,16 @@ export class SubscriberClient { * 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. * The first element of the array is an object representing [Subscription]{@link google.pubsub.v1.Subscription}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createSubscription(request); */ createSubscription( request: protos.google.pubsub.v1.ISubscription, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.pubsub.v1.ISubscription, protos.google.pubsub.v1.ISubscription | null | undefined, @@ -513,12 +529,12 @@ export class SubscriberClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -533,7 +549,7 @@ export class SubscriberClient { } getSubscription( request: protos.google.pubsub.v1.IGetSubscriptionRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.pubsub.v1.ISubscription, @@ -543,7 +559,7 @@ export class SubscriberClient { >; getSubscription( request: protos.google.pubsub.v1.IGetSubscriptionRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.pubsub.v1.ISubscription, protos.google.pubsub.v1.IGetSubscriptionRequest | null | undefined, @@ -570,12 +586,16 @@ export class SubscriberClient { * 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. * The first element of the array is an object representing [Subscription]{@link google.pubsub.v1.Subscription}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getSubscription(request); */ getSubscription( request: protos.google.pubsub.v1.IGetSubscriptionRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.pubsub.v1.ISubscription, protos.google.pubsub.v1.IGetSubscriptionRequest | null | undefined, @@ -594,12 +614,12 @@ export class SubscriberClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -614,7 +634,7 @@ export class SubscriberClient { } updateSubscription( request: protos.google.pubsub.v1.IUpdateSubscriptionRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.pubsub.v1.ISubscription, @@ -624,7 +644,7 @@ export class SubscriberClient { >; updateSubscription( request: protos.google.pubsub.v1.IUpdateSubscriptionRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.pubsub.v1.ISubscription, protos.google.pubsub.v1.IUpdateSubscriptionRequest | null | undefined, @@ -654,12 +674,16 @@ export class SubscriberClient { * 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. * The first element of the array is an object representing [Subscription]{@link google.pubsub.v1.Subscription}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.updateSubscription(request); */ updateSubscription( request: protos.google.pubsub.v1.IUpdateSubscriptionRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.pubsub.v1.ISubscription, protos.google.pubsub.v1.IUpdateSubscriptionRequest | null | undefined, @@ -678,12 +702,12 @@ export class SubscriberClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -698,7 +722,7 @@ export class SubscriberClient { } deleteSubscription( request: protos.google.pubsub.v1.IDeleteSubscriptionRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.protobuf.IEmpty, @@ -708,7 +732,7 @@ export class SubscriberClient { >; deleteSubscription( request: protos.google.pubsub.v1.IDeleteSubscriptionRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.protobuf.IEmpty, protos.google.pubsub.v1.IDeleteSubscriptionRequest | null | undefined, @@ -739,12 +763,16 @@ export class SubscriberClient { * 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. * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deleteSubscription(request); */ deleteSubscription( request: protos.google.pubsub.v1.IDeleteSubscriptionRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.protobuf.IEmpty, protos.google.pubsub.v1.IDeleteSubscriptionRequest | null | undefined, @@ -763,12 +791,12 @@ export class SubscriberClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -783,7 +811,7 @@ export class SubscriberClient { } modifyAckDeadline( request: protos.google.pubsub.v1.IModifyAckDeadlineRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.protobuf.IEmpty, @@ -793,7 +821,7 @@ export class SubscriberClient { >; modifyAckDeadline( request: protos.google.pubsub.v1.IModifyAckDeadlineRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.protobuf.IEmpty, protos.google.pubsub.v1.IModifyAckDeadlineRequest | null | undefined, @@ -835,12 +863,16 @@ export class SubscriberClient { * 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. * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.modifyAckDeadline(request); */ modifyAckDeadline( request: protos.google.pubsub.v1.IModifyAckDeadlineRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.protobuf.IEmpty, protos.google.pubsub.v1.IModifyAckDeadlineRequest | null | undefined, @@ -859,12 +891,12 @@ export class SubscriberClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -879,7 +911,7 @@ export class SubscriberClient { } acknowledge( request: protos.google.pubsub.v1.IAcknowledgeRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.protobuf.IEmpty, @@ -889,7 +921,7 @@ export class SubscriberClient { >; acknowledge( request: protos.google.pubsub.v1.IAcknowledgeRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.protobuf.IEmpty, protos.google.pubsub.v1.IAcknowledgeRequest | null | undefined, @@ -926,12 +958,16 @@ export class SubscriberClient { * 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. * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.acknowledge(request); */ acknowledge( request: protos.google.pubsub.v1.IAcknowledgeRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.protobuf.IEmpty, protos.google.pubsub.v1.IAcknowledgeRequest | null | undefined, @@ -950,12 +986,12 @@ export class SubscriberClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -970,7 +1006,7 @@ export class SubscriberClient { } pull( request: protos.google.pubsub.v1.IPullRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.pubsub.v1.IPullResponse, @@ -980,7 +1016,7 @@ export class SubscriberClient { >; pull( request: protos.google.pubsub.v1.IPullRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.pubsub.v1.IPullResponse, protos.google.pubsub.v1.IPullRequest | null | undefined, @@ -1021,12 +1057,16 @@ export class SubscriberClient { * 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. * The first element of the array is an object representing [PullResponse]{@link google.pubsub.v1.PullResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.pull(request); */ pull( request: protos.google.pubsub.v1.IPullRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.pubsub.v1.IPullResponse, protos.google.pubsub.v1.IPullRequest | null | undefined, @@ -1045,12 +1085,12 @@ export class SubscriberClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1065,7 +1105,7 @@ export class SubscriberClient { } modifyPushConfig( request: protos.google.pubsub.v1.IModifyPushConfigRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.protobuf.IEmpty, @@ -1075,7 +1115,7 @@ export class SubscriberClient { >; modifyPushConfig( request: protos.google.pubsub.v1.IModifyPushConfigRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.protobuf.IEmpty, protos.google.pubsub.v1.IModifyPushConfigRequest | null | undefined, @@ -1114,12 +1154,16 @@ export class SubscriberClient { * 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. * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.modifyPushConfig(request); */ modifyPushConfig( request: protos.google.pubsub.v1.IModifyPushConfigRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.protobuf.IEmpty, protos.google.pubsub.v1.IModifyPushConfigRequest | null | undefined, @@ -1138,12 +1182,12 @@ export class SubscriberClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1158,7 +1202,7 @@ export class SubscriberClient { } getSnapshot( request: protos.google.pubsub.v1.IGetSnapshotRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.pubsub.v1.ISnapshot, @@ -1168,7 +1212,7 @@ export class SubscriberClient { >; getSnapshot( request: protos.google.pubsub.v1.IGetSnapshotRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.pubsub.v1.ISnapshot, protos.google.pubsub.v1.IGetSnapshotRequest | null | undefined, @@ -1199,12 +1243,16 @@ export class SubscriberClient { * 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. * The first element of the array is an object representing [Snapshot]{@link google.pubsub.v1.Snapshot}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getSnapshot(request); */ getSnapshot( request: protos.google.pubsub.v1.IGetSnapshotRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.pubsub.v1.ISnapshot, protos.google.pubsub.v1.IGetSnapshotRequest | null | undefined, @@ -1223,12 +1271,12 @@ export class SubscriberClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1243,7 +1291,7 @@ export class SubscriberClient { } createSnapshot( request: protos.google.pubsub.v1.ICreateSnapshotRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.pubsub.v1.ISnapshot, @@ -1253,7 +1301,7 @@ export class SubscriberClient { >; createSnapshot( request: protos.google.pubsub.v1.ICreateSnapshotRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.pubsub.v1.ISnapshot, protos.google.pubsub.v1.ICreateSnapshotRequest | null | undefined, @@ -1312,12 +1360,16 @@ export class SubscriberClient { * 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. * The first element of the array is an object representing [Snapshot]{@link google.pubsub.v1.Snapshot}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createSnapshot(request); */ createSnapshot( request: protos.google.pubsub.v1.ICreateSnapshotRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.pubsub.v1.ISnapshot, protos.google.pubsub.v1.ICreateSnapshotRequest | null | undefined, @@ -1336,12 +1388,12 @@ export class SubscriberClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1356,7 +1408,7 @@ export class SubscriberClient { } updateSnapshot( request: protos.google.pubsub.v1.IUpdateSnapshotRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.pubsub.v1.ISnapshot, @@ -1366,7 +1418,7 @@ export class SubscriberClient { >; updateSnapshot( request: protos.google.pubsub.v1.IUpdateSnapshotRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.pubsub.v1.ISnapshot, protos.google.pubsub.v1.IUpdateSnapshotRequest | null | undefined, @@ -1400,12 +1452,16 @@ export class SubscriberClient { * 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. * The first element of the array is an object representing [Snapshot]{@link google.pubsub.v1.Snapshot}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.updateSnapshot(request); */ updateSnapshot( request: protos.google.pubsub.v1.IUpdateSnapshotRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.pubsub.v1.ISnapshot, protos.google.pubsub.v1.IUpdateSnapshotRequest | null | undefined, @@ -1424,12 +1480,12 @@ export class SubscriberClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1444,7 +1500,7 @@ export class SubscriberClient { } deleteSnapshot( request: protos.google.pubsub.v1.IDeleteSnapshotRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.protobuf.IEmpty, @@ -1454,7 +1510,7 @@ export class SubscriberClient { >; deleteSnapshot( request: protos.google.pubsub.v1.IDeleteSnapshotRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.protobuf.IEmpty, protos.google.pubsub.v1.IDeleteSnapshotRequest | null | undefined, @@ -1489,12 +1545,16 @@ export class SubscriberClient { * 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. * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deleteSnapshot(request); */ deleteSnapshot( request: protos.google.pubsub.v1.IDeleteSnapshotRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.protobuf.IEmpty, protos.google.pubsub.v1.IDeleteSnapshotRequest | null | undefined, @@ -1513,12 +1573,12 @@ export class SubscriberClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1533,7 +1593,7 @@ export class SubscriberClient { } seek( request: protos.google.pubsub.v1.ISeekRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.pubsub.v1.ISeekResponse, @@ -1543,7 +1603,7 @@ export class SubscriberClient { >; seek( request: protos.google.pubsub.v1.ISeekRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.pubsub.v1.ISeekResponse, protos.google.pubsub.v1.ISeekRequest | null | undefined, @@ -1560,8 +1620,8 @@ export class SubscriberClient { ): void; /** * Seeks an existing subscription to a point in time or to a given snapshot, - * whichever is provided in the request. Snapshots are used in [Seek]( - * https://cloud.google.com/pubsub/docs/replay-overview) operations, which + * whichever is provided in the request. 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 * state captured by a snapshot. Note that both the subscription and the @@ -1591,12 +1651,16 @@ export class SubscriberClient { * 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. * The first element of the array is an object representing [SeekResponse]{@link google.pubsub.v1.SeekResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.seek(request); */ seek( request: protos.google.pubsub.v1.ISeekRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.pubsub.v1.ISeekResponse, protos.google.pubsub.v1.ISeekRequest | null | undefined, @@ -1615,12 +1679,12 @@ export class SubscriberClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1649,15 +1713,24 @@ export class SubscriberClient { * An object stream which is both readable and writable. It accepts objects * representing [StreamingPullRequest]{@link google.pubsub.v1.StreamingPullRequest} for write() method, and * will emit objects representing [StreamingPullResponse]{@link google.pubsub.v1.StreamingPullResponse} on 'data' event asynchronously. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) + * for more details and examples. + * @example + * const stream = client.streamingPull(); + * stream.on('data', (response) => { ... }); + * stream.on('end', () => { ... }); + * stream.write(request); + * stream.end(); */ - streamingPull(options?: gax.CallOptions): gax.CancellableStream { + streamingPull(options?: CallOptions): gax.CancellableStream { this.initialize(); return this.innerApiCalls.streamingPull(options); } listSubscriptions( request: protos.google.pubsub.v1.IListSubscriptionsRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.pubsub.v1.ISubscription[], @@ -1667,7 +1740,7 @@ export class SubscriberClient { >; listSubscriptions( request: protos.google.pubsub.v1.IListSubscriptionsRequest, - options: gax.CallOptions, + options: CallOptions, callback: PaginationCallback< protos.google.pubsub.v1.IListSubscriptionsRequest, protos.google.pubsub.v1.IListSubscriptionsResponse | null | undefined, @@ -1700,24 +1773,19 @@ export class SubscriberClient { * 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. * The first element of the array is Array of [Subscription]{@link google.pubsub.v1.Subscription}. - * The client library support auto-pagination by default: it will call the API as many + * The client library will perform auto-pagination by default: it will call the API as many * times as needed and will merge results from all the pages into this array. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [Subscription]{@link google.pubsub.v1.Subscription} that corresponds to - * the one page received from the API server. - * If the second element is not null it contains the request object of type [ListSubscriptionsRequest]{@link google.pubsub.v1.ListSubscriptionsRequest} - * that can be used to obtain the next page of the results. - * If it is null, the next page does not exist. - * The third element contains the raw response received from the API server. Its type is - * [ListSubscriptionsResponse]{@link google.pubsub.v1.ListSubscriptionsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. + * Note that it can affect your quota. + * We recommend using `listSubscriptionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listSubscriptions( request: protos.google.pubsub.v1.IListSubscriptionsRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | PaginationCallback< protos.google.pubsub.v1.IListSubscriptionsRequest, protos.google.pubsub.v1.IListSubscriptionsResponse | null | undefined, @@ -1736,12 +1804,12 @@ export class SubscriberClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1756,18 +1824,7 @@ export class SubscriberClient { } /** - * Equivalent to {@link listSubscriptions}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listSubscriptions} continuously - * and invokes the callback registered for 'data' event for each element in the - * responses. - * - * The returned object has 'end' method when no more elements are required. - * - * autoPaginate option will be ignored. - * - * @see {@link https://nodejs.org/api/stream.html} - * + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. * @param {Object} request * The request object that will be sent. * @param {string} request.project @@ -1783,10 +1840,17 @@ export class SubscriberClient { * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Stream} * An object stream which emits an object representing [Subscription]{@link google.pubsub.v1.Subscription} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listSubscriptionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listSubscriptionsStream( request?: protos.google.pubsub.v1.IListSubscriptionsRequest, - options?: gax.CallOptions + options?: CallOptions ): Transform { request = request || {}; options = options || {}; @@ -1807,10 +1871,9 @@ export class SubscriberClient { } /** - * Equivalent to {@link listSubscriptions}, but returns an iterable object. - * - * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * Equivalent to `listSubscriptions`, but returns an iterable object. * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. * @param {Object} request * The request object that will be sent. * @param {string} request.project @@ -1825,11 +1888,22 @@ export class SubscriberClient { * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Object} - * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Subscription]{@link google.pubsub.v1.Subscription}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listSubscriptionsAsync(request); + * for await (const response of iterable) { + * // process response + * } */ listSubscriptionsAsync( request?: protos.google.pubsub.v1.IListSubscriptionsRequest, - options?: gax.CallOptions + options?: CallOptions ): AsyncIterable { request = request || {}; options = options || {}; @@ -1851,7 +1925,7 @@ export class SubscriberClient { } listSnapshots( request: protos.google.pubsub.v1.IListSnapshotsRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.pubsub.v1.ISnapshot[], @@ -1861,7 +1935,7 @@ export class SubscriberClient { >; listSnapshots( request: protos.google.pubsub.v1.IListSnapshotsRequest, - options: gax.CallOptions, + options: CallOptions, callback: PaginationCallback< protos.google.pubsub.v1.IListSnapshotsRequest, protos.google.pubsub.v1.IListSnapshotsResponse | null | undefined, @@ -1898,24 +1972,19 @@ export class SubscriberClient { * 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. * The first element of the array is Array of [Snapshot]{@link google.pubsub.v1.Snapshot}. - * The client library support auto-pagination by default: it will call the API as many + * The client library will perform auto-pagination by default: it will call the API as many * times as needed and will merge results from all the pages into this array. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [Snapshot]{@link google.pubsub.v1.Snapshot} that corresponds to - * the one page received from the API server. - * If the second element is not null it contains the request object of type [ListSnapshotsRequest]{@link google.pubsub.v1.ListSnapshotsRequest} - * that can be used to obtain the next page of the results. - * If it is null, the next page does not exist. - * The third element contains the raw response received from the API server. Its type is - * [ListSnapshotsResponse]{@link google.pubsub.v1.ListSnapshotsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. + * Note that it can affect your quota. + * We recommend using `listSnapshotsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listSnapshots( request: protos.google.pubsub.v1.IListSnapshotsRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | PaginationCallback< protos.google.pubsub.v1.IListSnapshotsRequest, protos.google.pubsub.v1.IListSnapshotsResponse | null | undefined, @@ -1934,12 +2003,12 @@ export class SubscriberClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1954,18 +2023,7 @@ export class SubscriberClient { } /** - * Equivalent to {@link listSnapshots}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listSnapshots} continuously - * and invokes the callback registered for 'data' event for each element in the - * responses. - * - * The returned object has 'end' method when no more elements are required. - * - * autoPaginate option will be ignored. - * - * @see {@link https://nodejs.org/api/stream.html} - * + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. * @param {Object} request * The request object that will be sent. * @param {string} request.project @@ -1981,10 +2039,17 @@ export class SubscriberClient { * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Stream} * An object stream which emits an object representing [Snapshot]{@link google.pubsub.v1.Snapshot} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listSnapshotsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listSnapshotsStream( request?: protos.google.pubsub.v1.IListSnapshotsRequest, - options?: gax.CallOptions + options?: CallOptions ): Transform { request = request || {}; options = options || {}; @@ -2005,10 +2070,9 @@ export class SubscriberClient { } /** - * Equivalent to {@link listSnapshots}, but returns an iterable object. - * - * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * Equivalent to `listSnapshots`, but returns an iterable object. * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. * @param {Object} request * The request object that will be sent. * @param {string} request.project @@ -2023,11 +2087,22 @@ export class SubscriberClient { * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Object} - * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Snapshot]{@link google.pubsub.v1.Snapshot}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listSnapshotsAsync(request); + * for await (const response of iterable) { + * // process response + * } */ listSnapshotsAsync( request?: protos.google.pubsub.v1.IListSnapshotsRequest, - options?: gax.CallOptions + options?: CallOptions ): AsyncIterable { request = request || {}; options = options || {}; @@ -2252,6 +2327,42 @@ export class SubscriberClient { .topic; } + /** + * Return a fully-qualified schema resource name string. + * + * @param {string} project + * @param {string} schema + * @returns {string} Resource name string. + */ + schemaPath(project: string, schema: string) { + return this.pathTemplates.schemaPathTemplate.render({ + project: project, + schema: schema, + }); + } + + /** + * Parse the project from Schema resource. + * + * @param {string} schemaName + * A fully-qualified path representing Schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromSchemaName(schemaName: string) { + return this.pathTemplates.schemaPathTemplate.match(schemaName).project; + } + + /** + * Parse the schema from Schema resource. + * + * @param {string} schemaName + * A fully-qualified path representing Schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromSchemaName(schemaName: string) { + return this.pathTemplates.schemaPathTemplate.match(schemaName).schema; + } + /** * Return a fully-qualified snapshot resource name string. * @@ -2327,9 +2438,10 @@ export class SubscriberClient { } /** - * Terminate the GRPC channel and close the client. + * Terminate the gRPC channel and close the client. * * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. */ close(): Promise { this.initialize(); diff --git a/src/v1/subscriber_proto_list.json b/src/v1/subscriber_proto_list.json index 23484bf66..91011aec1 100644 --- a/src/v1/subscriber_proto_list.json +++ b/src/v1/subscriber_proto_list.json @@ -1,3 +1,4 @@ [ - "../../protos/google/pubsub/v1/pubsub.proto" + "../../protos/google/pubsub/v1/pubsub.proto", + "../../protos/google/pubsub/v1/schema.proto" ] diff --git a/synth.metadata b/synth.metadata index 61e7c5b30..7b1f90e8f 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "4004f5e26358d3bcce180a2f9c15e890971fa2f3", - "internalRef": "337386065" + "sha": "41d8fbfec9d4bc4a8859f78185713950913b4bf3", + "internalRef": "348038736" } }, { diff --git a/test/gapic_publisher_v1.ts b/test/gapic_publisher_v1.ts index 868d224b0..29e25905d 100644 --- a/test/gapic_publisher_v1.ts +++ b/test/gapic_publisher_v1.ts @@ -2098,6 +2098,55 @@ describe('v1.PublisherClient', () => { }); }); + describe('schema', () => { + const fakePath = '/rendered/path/schema'; + const expectedParameters = { + project: 'projectValue', + schema: 'schemaValue', + }; + const client = new publisherModule.v1.PublisherClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.schemaPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.schemaPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('schemaPath', () => { + const result = client.schemaPath('projectValue', 'schemaValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.schemaPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromSchemaName', () => { + const result = client.matchProjectFromSchemaName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.schemaPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchSchemaFromSchemaName', () => { + const result = client.matchSchemaFromSchemaName(fakePath); + assert.strictEqual(result, 'schemaValue'); + assert( + (client.pathTemplates.schemaPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + describe('snapshot', () => { const fakePath = '/rendered/path/snapshot'; const expectedParameters = { diff --git a/test/gapic_schema_service_v1.ts b/test/gapic_schema_service_v1.ts new file mode 100644 index 000000000..9fb79f071 --- /dev/null +++ b/test/gapic_schema_service_v1.ts @@ -0,0 +1,1598 @@ +// Copyright 2021 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 file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as schemaserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, IamProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message).toObject( + instance as protobuf.Message, + {defaults: true} + ); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); + } + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.SchemaServiceClient', () => { + it('has servicePath', () => { + const servicePath = schemaserviceModule.v1.SchemaServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = schemaserviceModule.v1.SchemaServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = schemaserviceModule.v1.SchemaServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new schemaserviceModule.v1.SchemaServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.schemaServiceStub, undefined); + await client.initialize(); + assert(client.schemaServiceStub); + }); + + it('has close method', () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createSchema', () => { + it('invokes createSchema without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.CreateSchemaRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.pubsub.v1.Schema() + ); + client.innerApiCalls.createSchema = stubSimpleCall(expectedResponse); + const [response] = await client.createSchema(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createSchema as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createSchema without error using callback', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.CreateSchemaRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.pubsub.v1.Schema() + ); + client.innerApiCalls.createSchema = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.createSchema( + request, + ( + err?: Error | null, + result?: protos.google.pubsub.v1.ISchema | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createSchema as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes createSchema with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.CreateSchemaRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createSchema = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.createSchema(request), expectedError); + assert( + (client.innerApiCalls.createSchema as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('getSchema', () => { + it('invokes getSchema without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.GetSchemaRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.pubsub.v1.Schema() + ); + client.innerApiCalls.getSchema = stubSimpleCall(expectedResponse); + const [response] = await client.getSchema(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getSchema as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getSchema without error using callback', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.GetSchemaRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.pubsub.v1.Schema() + ); + client.innerApiCalls.getSchema = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.getSchema( + request, + ( + err?: Error | null, + result?: protos.google.pubsub.v1.ISchema | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getSchema as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes getSchema with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.GetSchemaRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getSchema = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getSchema(request), expectedError); + assert( + (client.innerApiCalls.getSchema as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('deleteSchema', () => { + it('invokes deleteSchema without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.DeleteSchemaRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteSchema = stubSimpleCall(expectedResponse); + const [response] = await client.deleteSchema(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteSchema as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes deleteSchema without error using callback', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.DeleteSchemaRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteSchema = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.deleteSchema( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteSchema as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes deleteSchema with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.DeleteSchemaRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSchema = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteSchema(request), expectedError); + assert( + (client.innerApiCalls.deleteSchema as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('validateSchema', () => { + it('invokes validateSchema without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.ValidateSchemaRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.pubsub.v1.ValidateSchemaResponse() + ); + client.innerApiCalls.validateSchema = stubSimpleCall(expectedResponse); + const [response] = await client.validateSchema(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.validateSchema as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes validateSchema without error using callback', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.ValidateSchemaRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.pubsub.v1.ValidateSchemaResponse() + ); + client.innerApiCalls.validateSchema = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.validateSchema( + request, + ( + err?: Error | null, + result?: protos.google.pubsub.v1.IValidateSchemaResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.validateSchema as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes validateSchema with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.ValidateSchemaRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.validateSchema = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.validateSchema(request), expectedError); + assert( + (client.innerApiCalls.validateSchema as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('validateMessage', () => { + it('invokes validateMessage without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.ValidateMessageRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.pubsub.v1.ValidateMessageResponse() + ); + client.innerApiCalls.validateMessage = stubSimpleCall(expectedResponse); + const [response] = await client.validateMessage(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.validateMessage as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes validateMessage without error using callback', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.ValidateMessageRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.pubsub.v1.ValidateMessageResponse() + ); + client.innerApiCalls.validateMessage = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.validateMessage( + request, + ( + err?: Error | null, + result?: protos.google.pubsub.v1.IValidateMessageResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.validateMessage as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes validateMessage with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.ValidateMessageRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.validateMessage = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.validateMessage(request), expectedError); + assert( + (client.innerApiCalls.validateMessage as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('listSchemas', () => { + it('invokes listSchemas without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.ListSchemasRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.pubsub.v1.Schema()), + generateSampleMessage(new protos.google.pubsub.v1.Schema()), + generateSampleMessage(new protos.google.pubsub.v1.Schema()), + ]; + client.innerApiCalls.listSchemas = stubSimpleCall(expectedResponse); + const [response] = await client.listSchemas(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listSchemas as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listSchemas without error using callback', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.ListSchemasRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.pubsub.v1.Schema()), + generateSampleMessage(new protos.google.pubsub.v1.Schema()), + generateSampleMessage(new protos.google.pubsub.v1.Schema()), + ]; + client.innerApiCalls.listSchemas = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listSchemas( + request, + ( + err?: Error | null, + result?: protos.google.pubsub.v1.ISchema[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listSchemas as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listSchemas with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.ListSchemasRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listSchemas = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listSchemas(request), expectedError); + assert( + (client.innerApiCalls.listSchemas as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listSchemasStream without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.ListSchemasRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.pubsub.v1.Schema()), + generateSampleMessage(new protos.google.pubsub.v1.Schema()), + generateSampleMessage(new protos.google.pubsub.v1.Schema()), + ]; + client.descriptors.page.listSchemas.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listSchemasStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.pubsub.v1.Schema[] = []; + stream.on('data', (response: protos.google.pubsub.v1.Schema) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listSchemas.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listSchemas, request) + ); + assert.strictEqual( + (client.descriptors.page.listSchemas.createStream as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listSchemasStream with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.ListSchemasRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listSchemas.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listSchemasStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.pubsub.v1.Schema[] = []; + stream.on('data', (response: protos.google.pubsub.v1.Schema) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listSchemas.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listSchemas, request) + ); + assert.strictEqual( + (client.descriptors.page.listSchemas.createStream as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listSchemas without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.ListSchemasRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.pubsub.v1.Schema()), + generateSampleMessage(new protos.google.pubsub.v1.Schema()), + generateSampleMessage(new protos.google.pubsub.v1.Schema()), + ]; + client.descriptors.page.listSchemas.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.pubsub.v1.ISchema[] = []; + const iterable = client.listSchemasAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listSchemas.asyncIterate as SinonStub).getCall( + 0 + ).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listSchemas.asyncIterate as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listSchemas with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.pubsub.v1.ListSchemasRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listSchemas.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listSchemasAsync(request); + await assert.rejects(async () => { + const responses: protos.google.pubsub.v1.ISchema[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listSchemas.asyncIterate as SinonStub).getCall( + 0 + ).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listSchemas.asyncIterate as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); + }); + it('invokes getIamPolicy with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); + }); + it('invokes setIamPolicy with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('Path templates', () => { + describe('project', () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('projectTopic', () => { + const fakePath = '/rendered/path/projectTopic'; + const expectedParameters = { + project: 'projectValue', + topic: 'topicValue', + }; + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectTopicPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectTopicPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectTopicPath', () => { + const result = client.projectTopicPath('projectValue', 'topicValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectTopicPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectTopicName', () => { + const result = client.matchProjectFromProjectTopicName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectTopicPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchTopicFromProjectTopicName', () => { + const result = client.matchTopicFromProjectTopicName(fakePath); + assert.strictEqual(result, 'topicValue'); + assert( + (client.pathTemplates.projectTopicPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('schema', () => { + const fakePath = '/rendered/path/schema'; + const expectedParameters = { + project: 'projectValue', + schema: 'schemaValue', + }; + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.schemaPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.schemaPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('schemaPath', () => { + const result = client.schemaPath('projectValue', 'schemaValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.schemaPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromSchemaName', () => { + const result = client.matchProjectFromSchemaName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.schemaPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchSchemaFromSchemaName', () => { + const result = client.matchSchemaFromSchemaName(fakePath); + assert.strictEqual(result, 'schemaValue'); + assert( + (client.pathTemplates.schemaPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('snapshot', () => { + const fakePath = '/rendered/path/snapshot'; + const expectedParameters = { + project: 'projectValue', + snapshot: 'snapshotValue', + }; + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.snapshotPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.snapshotPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('snapshotPath', () => { + const result = client.snapshotPath('projectValue', 'snapshotValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.snapshotPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromSnapshotName', () => { + const result = client.matchProjectFromSnapshotName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.snapshotPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchSnapshotFromSnapshotName', () => { + const result = client.matchSnapshotFromSnapshotName(fakePath); + assert.strictEqual(result, 'snapshotValue'); + assert( + (client.pathTemplates.snapshotPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('subscription', () => { + const fakePath = '/rendered/path/subscription'; + const expectedParameters = { + project: 'projectValue', + subscription: 'subscriptionValue', + }; + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.subscriptionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.subscriptionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('subscriptionPath', () => { + const result = client.subscriptionPath( + 'projectValue', + 'subscriptionValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.subscriptionPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromSubscriptionName', () => { + const result = client.matchProjectFromSubscriptionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.subscriptionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchSubscriptionFromSubscriptionName', () => { + const result = client.matchSubscriptionFromSubscriptionName(fakePath); + assert.strictEqual(result, 'subscriptionValue'); + assert( + (client.pathTemplates.subscriptionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/test/gapic_subscriber_v1.ts b/test/gapic_subscriber_v1.ts index 86d84260d..1ead2c3c3 100644 --- a/test/gapic_subscriber_v1.ts +++ b/test/gapic_subscriber_v1.ts @@ -2734,6 +2734,55 @@ describe('v1.SubscriberClient', () => { }); }); + describe('schema', () => { + const fakePath = '/rendered/path/schema'; + const expectedParameters = { + project: 'projectValue', + schema: 'schemaValue', + }; + const client = new subscriberModule.v1.SubscriberClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.schemaPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.schemaPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('schemaPath', () => { + const result = client.schemaPath('projectValue', 'schemaValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.schemaPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromSchemaName', () => { + const result = client.matchProjectFromSchemaName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.schemaPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchSchemaFromSchemaName', () => { + const result = client.matchSchemaFromSchemaName(fakePath); + assert.strictEqual(result, 'schemaValue'); + assert( + (client.pathTemplates.schemaPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + describe('snapshot', () => { const fakePath = '/rendered/path/snapshot'; const expectedParameters = {