diff --git a/.jsdoc.js b/.jsdoc.js index a3991a63f..6618d0cc4 100644 --- a/.jsdoc.js +++ b/.jsdoc.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ module.exports = { includePattern: '\\.js$' }, templates: { - copyright: 'Copyright 2022 Google LLC', + copyright: 'Copyright 2023 Google LLC', includeDate: false, sourceFiles: false, systemName: '@google-cloud/pubsub', diff --git a/protos/google/pubsub/v1/pubsub.proto b/protos/google/pubsub/v1/pubsub.proto index aa65f9db0..661633b61 100644 --- a/protos/google/pubsub/v1/pubsub.proto +++ b/protos/google/pubsub/v1/pubsub.proto @@ -157,6 +157,16 @@ message SchemaSettings { // The encoding of messages validated against `schema`. Encoding encoding = 2; + + // The minimum (inclusive) revision allowed for validating messages. If empty + // or not present, allow any revision to be validated against last_revision or + // any revision created before. + string first_revision_id = 3; + + // The maximum (inclusive) revision allowed for validating messages. If empty + // or not present, allow any revision to be validated against first_revision + // or any revision created after. + string last_revision_id = 4; } // A topic resource. diff --git a/protos/google/pubsub/v1/schema.proto b/protos/google/pubsub/v1/schema.proto index 3cdf10d93..1b1483b87 100644 --- a/protos/google/pubsub/v1/schema.proto +++ b/protos/google/pubsub/v1/schema.proto @@ -1,4 +1,4 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import "google/api/client.proto"; import "google/api/field_behavior.proto"; import "google/api/resource.proto"; import "google/protobuf/empty.proto"; +import "google/protobuf/timestamp.proto"; option cc_enable_arenas = true; option csharp_namespace = "Google.Cloud.PubSub.V1"; @@ -63,6 +64,41 @@ service SchemaService { option (google.api.method_signature) = "parent"; } + // Lists all schema revisions for the named schema. + rpc ListSchemaRevisions(ListSchemaRevisionsRequest) + returns (ListSchemaRevisionsResponse) { + option (google.api.http) = { + get: "/v1/{name=projects/*/schemas/*}:listRevisions" + }; + option (google.api.method_signature) = "name"; + } + + // Commits a new schema revision to an existing schema. + rpc CommitSchema(CommitSchemaRequest) returns (Schema) { + option (google.api.http) = { + post: "/v1/{name=projects/*/schemas/*}:commit" + body: "*" + }; + option (google.api.method_signature) = "name,schema"; + } + + // Creates a new schema revision that is a copy of the provided revision_id. + rpc RollbackSchema(RollbackSchemaRequest) returns (Schema) { + option (google.api.http) = { + post: "/v1/{name=projects/*/schemas/*}:rollback" + body: "*" + }; + option (google.api.method_signature) = "name,revision_id"; + } + + // Deletes a specific schema revision. + rpc DeleteSchemaRevision(DeleteSchemaRevisionRequest) returns (Schema) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/schemas/*}:deleteRevision" + }; + option (google.api.method_signature) = "name,revision_id"; + } + // Deletes a schema. rpc DeleteSchema(DeleteSchemaRequest) returns (google.protobuf.Empty) { option (google.api.http) = { @@ -120,6 +156,29 @@ message Schema { // the full definition of the schema that is a valid schema definition of // the type specified in `type`. string definition = 3; + + // Output only. Immutable. The revision ID of the schema. + string revision_id = 4 [ + (google.api.field_behavior) = IMMUTABLE, + (google.api.field_behavior) = OUTPUT_ONLY + ]; + + // Output only. The timestamp that the revision was created. + google.protobuf.Timestamp revision_create_time = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// 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 CreateSchema method. @@ -148,19 +207,6 @@ message CreateSchemaRequest { 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. @@ -171,8 +217,7 @@ message GetSchemaRequest { ]; // 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. + // with all fields filled out. Set to `BASIC` to omit the `definition`. SchemaView view = 2; } @@ -211,6 +256,83 @@ message ListSchemasResponse { string next_page_token = 2; } +// Request for the `ListSchemaRevisions` method. +message ListSchemaRevisionsRequest { + // Required. The name of the schema to list revisions for. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "pubsub.googleapis.com/Schema" } + ]; + + // 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; + + // The maximum number of revisions to return per page. + int32 page_size = 3; + + // The page token, received from a previous ListSchemaRevisions call. + // Provide this to retrieve the subsequent page. + string page_token = 4; +} + +// Response for the `ListSchemaRevisions` method. +message ListSchemaRevisionsResponse { + // The revisions of the schema. + repeated Schema schemas = 1; + + // A token that can be sent as `page_token` to retrieve the next page. + // If this field is empty, there are no subsequent pages. + string next_page_token = 2; +} + +// Request for CommitSchema method. +message CommitSchemaRequest { + // Required. The name of the schema we are revising. + // Format is `projects/{project}/schemas/{schema}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "pubsub.googleapis.com/Schema" } + ]; + + // Required. The schema revision to commit. + Schema schema = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for the `RollbackSchema` method. +message RollbackSchemaRequest { + // Required. The schema being rolled back with revision id. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "pubsub.googleapis.com/Schema" } + ]; + + // Required. The revision ID to roll back to. + // It must be a revision of the same schema. + // + // Example: c7cfa2a8 + string revision_id = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for the `DeleteSchemaRevision` method. +message DeleteSchemaRevisionRequest { + // Required. The name of the schema revision to be deleted, with a revision ID + // explicitly included. + // + // Example: projects/123/schemas/my-schema@c7cfa2a8 + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "pubsub.googleapis.com/Schema" } + ]; + + // Required. The revision ID to roll back to. + // It must be a revision of the same schema. + // + // Example: c7cfa2a8 + string revision_id = 2 [(google.api.field_behavior) = REQUIRED]; +} + // Request for the `DeleteSchema` method. message DeleteSchemaRequest { // Required. Name of the schema to delete. diff --git a/protos/protos.d.ts b/protos/protos.d.ts index 15cf6b1b0..e40d0e65e 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -341,6 +341,12 @@ export namespace google { /** SchemaSettings encoding */ encoding?: (google.pubsub.v1.Encoding|keyof typeof google.pubsub.v1.Encoding|null); + + /** SchemaSettings firstRevisionId */ + firstRevisionId?: (string|null); + + /** SchemaSettings lastRevisionId */ + lastRevisionId?: (string|null); } /** Represents a SchemaSettings. */ @@ -358,6 +364,12 @@ export namespace google { /** SchemaSettings encoding. */ public encoding: (google.pubsub.v1.Encoding|keyof typeof google.pubsub.v1.Encoding); + /** SchemaSettings firstRevisionId. */ + public firstRevisionId: string; + + /** SchemaSettings lastRevisionId. */ + public lastRevisionId: string; + /** * Creates a new SchemaSettings instance using the specified properties. * @param [properties] Properties to set @@ -5937,6 +5949,62 @@ export namespace google { */ public listSchemas(request: google.pubsub.v1.IListSchemasRequest): Promise; + /** + * Calls ListSchemaRevisions. + * @param request ListSchemaRevisionsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListSchemaRevisionsResponse + */ + public listSchemaRevisions(request: google.pubsub.v1.IListSchemaRevisionsRequest, callback: google.pubsub.v1.SchemaService.ListSchemaRevisionsCallback): void; + + /** + * Calls ListSchemaRevisions. + * @param request ListSchemaRevisionsRequest message or plain object + * @returns Promise + */ + public listSchemaRevisions(request: google.pubsub.v1.IListSchemaRevisionsRequest): Promise; + + /** + * Calls CommitSchema. + * @param request CommitSchemaRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Schema + */ + public commitSchema(request: google.pubsub.v1.ICommitSchemaRequest, callback: google.pubsub.v1.SchemaService.CommitSchemaCallback): void; + + /** + * Calls CommitSchema. + * @param request CommitSchemaRequest message or plain object + * @returns Promise + */ + public commitSchema(request: google.pubsub.v1.ICommitSchemaRequest): Promise; + + /** + * Calls RollbackSchema. + * @param request RollbackSchemaRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Schema + */ + public rollbackSchema(request: google.pubsub.v1.IRollbackSchemaRequest, callback: google.pubsub.v1.SchemaService.RollbackSchemaCallback): void; + + /** + * Calls RollbackSchema. + * @param request RollbackSchemaRequest message or plain object + * @returns Promise + */ + public rollbackSchema(request: google.pubsub.v1.IRollbackSchemaRequest): Promise; + + /** + * Calls DeleteSchemaRevision. + * @param request DeleteSchemaRevisionRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Schema + */ + public deleteSchemaRevision(request: google.pubsub.v1.IDeleteSchemaRevisionRequest, callback: google.pubsub.v1.SchemaService.DeleteSchemaRevisionCallback): void; + + /** + * Calls DeleteSchemaRevision. + * @param request DeleteSchemaRevisionRequest message or plain object + * @returns Promise + */ + public deleteSchemaRevision(request: google.pubsub.v1.IDeleteSchemaRevisionRequest): Promise; + /** * Calls DeleteSchema. * @param request DeleteSchemaRequest message or plain object @@ -6003,6 +6071,34 @@ export namespace google { */ type ListSchemasCallback = (error: (Error|null), response?: google.pubsub.v1.ListSchemasResponse) => void; + /** + * Callback as used by {@link google.pubsub.v1.SchemaService|listSchemaRevisions}. + * @param error Error, if any + * @param [response] ListSchemaRevisionsResponse + */ + type ListSchemaRevisionsCallback = (error: (Error|null), response?: google.pubsub.v1.ListSchemaRevisionsResponse) => void; + + /** + * Callback as used by {@link google.pubsub.v1.SchemaService|commitSchema}. + * @param error Error, if any + * @param [response] Schema + */ + type CommitSchemaCallback = (error: (Error|null), response?: google.pubsub.v1.Schema) => void; + + /** + * Callback as used by {@link google.pubsub.v1.SchemaService|rollbackSchema}. + * @param error Error, if any + * @param [response] Schema + */ + type RollbackSchemaCallback = (error: (Error|null), response?: google.pubsub.v1.Schema) => void; + + /** + * Callback as used by {@link google.pubsub.v1.SchemaService|deleteSchemaRevision}. + * @param error Error, if any + * @param [response] Schema + */ + type DeleteSchemaRevisionCallback = (error: (Error|null), response?: google.pubsub.v1.Schema) => void; + /** * Callback as used by {@link google.pubsub.v1.SchemaService|deleteSchema}. * @param error Error, if any @@ -6036,6 +6132,12 @@ export namespace google { /** Schema definition */ definition?: (string|null); + + /** Schema revisionId */ + revisionId?: (string|null); + + /** Schema revisionCreateTime */ + revisionCreateTime?: (google.protobuf.ITimestamp|null); } /** Represents a Schema. */ @@ -6056,6 +6158,12 @@ export namespace google { /** Schema definition. */ public definition: string; + /** Schema revisionId. */ + public revisionId: string; + + /** Schema revisionCreateTime. */ + public revisionCreateTime?: (google.protobuf.ITimestamp|null); + /** * Creates a new Schema instance using the specified properties. * @param [properties] Properties to set @@ -6144,6 +6252,13 @@ export namespace google { } } + /** SchemaView enum. */ + enum SchemaView { + SCHEMA_VIEW_UNSPECIFIED = 0, + BASIC = 1, + FULL = 2 + } + /** Properties of a CreateSchemaRequest. */ interface ICreateSchemaRequest { @@ -6253,13 +6368,6 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } - /** SchemaView enum. */ - enum SchemaView { - SCHEMA_VIEW_UNSPECIFIED = 0, - BASIC = 1, - FULL = 2 - } - /** Properties of a GetSchemaRequest. */ interface IGetSchemaRequest { @@ -6581,6 +6689,533 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of a ListSchemaRevisionsRequest. */ + interface IListSchemaRevisionsRequest { + + /** ListSchemaRevisionsRequest name */ + name?: (string|null); + + /** ListSchemaRevisionsRequest view */ + view?: (google.pubsub.v1.SchemaView|keyof typeof google.pubsub.v1.SchemaView|null); + + /** ListSchemaRevisionsRequest pageSize */ + pageSize?: (number|null); + + /** ListSchemaRevisionsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListSchemaRevisionsRequest. */ + class ListSchemaRevisionsRequest implements IListSchemaRevisionsRequest { + + /** + * Constructs a new ListSchemaRevisionsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.pubsub.v1.IListSchemaRevisionsRequest); + + /** ListSchemaRevisionsRequest name. */ + public name: string; + + /** ListSchemaRevisionsRequest view. */ + public view: (google.pubsub.v1.SchemaView|keyof typeof google.pubsub.v1.SchemaView); + + /** ListSchemaRevisionsRequest pageSize. */ + public pageSize: number; + + /** ListSchemaRevisionsRequest pageToken. */ + public pageToken: string; + + /** + * Creates a new ListSchemaRevisionsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListSchemaRevisionsRequest instance + */ + public static create(properties?: google.pubsub.v1.IListSchemaRevisionsRequest): google.pubsub.v1.ListSchemaRevisionsRequest; + + /** + * Encodes the specified ListSchemaRevisionsRequest message. Does not implicitly {@link google.pubsub.v1.ListSchemaRevisionsRequest.verify|verify} messages. + * @param message ListSchemaRevisionsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.pubsub.v1.IListSchemaRevisionsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListSchemaRevisionsRequest message, length delimited. Does not implicitly {@link google.pubsub.v1.ListSchemaRevisionsRequest.verify|verify} messages. + * @param message ListSchemaRevisionsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.pubsub.v1.IListSchemaRevisionsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListSchemaRevisionsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListSchemaRevisionsRequest + * @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.ListSchemaRevisionsRequest; + + /** + * Decodes a ListSchemaRevisionsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListSchemaRevisionsRequest + * @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.ListSchemaRevisionsRequest; + + /** + * Verifies a ListSchemaRevisionsRequest 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 ListSchemaRevisionsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListSchemaRevisionsRequest + */ + public static fromObject(object: { [k: string]: any }): google.pubsub.v1.ListSchemaRevisionsRequest; + + /** + * Creates a plain object from a ListSchemaRevisionsRequest message. Also converts values to other types if specified. + * @param message ListSchemaRevisionsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.pubsub.v1.ListSchemaRevisionsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListSchemaRevisionsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListSchemaRevisionsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListSchemaRevisionsResponse. */ + interface IListSchemaRevisionsResponse { + + /** ListSchemaRevisionsResponse schemas */ + schemas?: (google.pubsub.v1.ISchema[]|null); + + /** ListSchemaRevisionsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListSchemaRevisionsResponse. */ + class ListSchemaRevisionsResponse implements IListSchemaRevisionsResponse { + + /** + * Constructs a new ListSchemaRevisionsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.pubsub.v1.IListSchemaRevisionsResponse); + + /** ListSchemaRevisionsResponse schemas. */ + public schemas: google.pubsub.v1.ISchema[]; + + /** ListSchemaRevisionsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListSchemaRevisionsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListSchemaRevisionsResponse instance + */ + public static create(properties?: google.pubsub.v1.IListSchemaRevisionsResponse): google.pubsub.v1.ListSchemaRevisionsResponse; + + /** + * Encodes the specified ListSchemaRevisionsResponse message. Does not implicitly {@link google.pubsub.v1.ListSchemaRevisionsResponse.verify|verify} messages. + * @param message ListSchemaRevisionsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.pubsub.v1.IListSchemaRevisionsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListSchemaRevisionsResponse message, length delimited. Does not implicitly {@link google.pubsub.v1.ListSchemaRevisionsResponse.verify|verify} messages. + * @param message ListSchemaRevisionsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.pubsub.v1.IListSchemaRevisionsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListSchemaRevisionsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListSchemaRevisionsResponse + * @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.ListSchemaRevisionsResponse; + + /** + * Decodes a ListSchemaRevisionsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListSchemaRevisionsResponse + * @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.ListSchemaRevisionsResponse; + + /** + * Verifies a ListSchemaRevisionsResponse 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 ListSchemaRevisionsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListSchemaRevisionsResponse + */ + public static fromObject(object: { [k: string]: any }): google.pubsub.v1.ListSchemaRevisionsResponse; + + /** + * Creates a plain object from a ListSchemaRevisionsResponse message. Also converts values to other types if specified. + * @param message ListSchemaRevisionsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.pubsub.v1.ListSchemaRevisionsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListSchemaRevisionsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListSchemaRevisionsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CommitSchemaRequest. */ + interface ICommitSchemaRequest { + + /** CommitSchemaRequest name */ + name?: (string|null); + + /** CommitSchemaRequest schema */ + schema?: (google.pubsub.v1.ISchema|null); + } + + /** Represents a CommitSchemaRequest. */ + class CommitSchemaRequest implements ICommitSchemaRequest { + + /** + * Constructs a new CommitSchemaRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.pubsub.v1.ICommitSchemaRequest); + + /** CommitSchemaRequest name. */ + public name: string; + + /** CommitSchemaRequest schema. */ + public schema?: (google.pubsub.v1.ISchema|null); + + /** + * Creates a new CommitSchemaRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CommitSchemaRequest instance + */ + public static create(properties?: google.pubsub.v1.ICommitSchemaRequest): google.pubsub.v1.CommitSchemaRequest; + + /** + * Encodes the specified CommitSchemaRequest message. Does not implicitly {@link google.pubsub.v1.CommitSchemaRequest.verify|verify} messages. + * @param message CommitSchemaRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.pubsub.v1.ICommitSchemaRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CommitSchemaRequest message, length delimited. Does not implicitly {@link google.pubsub.v1.CommitSchemaRequest.verify|verify} messages. + * @param message CommitSchemaRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.pubsub.v1.ICommitSchemaRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CommitSchemaRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CommitSchemaRequest + * @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.CommitSchemaRequest; + + /** + * Decodes a CommitSchemaRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CommitSchemaRequest + * @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.CommitSchemaRequest; + + /** + * Verifies a CommitSchemaRequest 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 CommitSchemaRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CommitSchemaRequest + */ + public static fromObject(object: { [k: string]: any }): google.pubsub.v1.CommitSchemaRequest; + + /** + * Creates a plain object from a CommitSchemaRequest message. Also converts values to other types if specified. + * @param message CommitSchemaRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.pubsub.v1.CommitSchemaRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CommitSchemaRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CommitSchemaRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RollbackSchemaRequest. */ + interface IRollbackSchemaRequest { + + /** RollbackSchemaRequest name */ + name?: (string|null); + + /** RollbackSchemaRequest revisionId */ + revisionId?: (string|null); + } + + /** Represents a RollbackSchemaRequest. */ + class RollbackSchemaRequest implements IRollbackSchemaRequest { + + /** + * Constructs a new RollbackSchemaRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.pubsub.v1.IRollbackSchemaRequest); + + /** RollbackSchemaRequest name. */ + public name: string; + + /** RollbackSchemaRequest revisionId. */ + public revisionId: string; + + /** + * Creates a new RollbackSchemaRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RollbackSchemaRequest instance + */ + public static create(properties?: google.pubsub.v1.IRollbackSchemaRequest): google.pubsub.v1.RollbackSchemaRequest; + + /** + * Encodes the specified RollbackSchemaRequest message. Does not implicitly {@link google.pubsub.v1.RollbackSchemaRequest.verify|verify} messages. + * @param message RollbackSchemaRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.pubsub.v1.IRollbackSchemaRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RollbackSchemaRequest message, length delimited. Does not implicitly {@link google.pubsub.v1.RollbackSchemaRequest.verify|verify} messages. + * @param message RollbackSchemaRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.pubsub.v1.IRollbackSchemaRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RollbackSchemaRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RollbackSchemaRequest + * @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.RollbackSchemaRequest; + + /** + * Decodes a RollbackSchemaRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RollbackSchemaRequest + * @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.RollbackSchemaRequest; + + /** + * Verifies a RollbackSchemaRequest 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 RollbackSchemaRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RollbackSchemaRequest + */ + public static fromObject(object: { [k: string]: any }): google.pubsub.v1.RollbackSchemaRequest; + + /** + * Creates a plain object from a RollbackSchemaRequest message. Also converts values to other types if specified. + * @param message RollbackSchemaRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.pubsub.v1.RollbackSchemaRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RollbackSchemaRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RollbackSchemaRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DeleteSchemaRevisionRequest. */ + interface IDeleteSchemaRevisionRequest { + + /** DeleteSchemaRevisionRequest name */ + name?: (string|null); + + /** DeleteSchemaRevisionRequest revisionId */ + revisionId?: (string|null); + } + + /** Represents a DeleteSchemaRevisionRequest. */ + class DeleteSchemaRevisionRequest implements IDeleteSchemaRevisionRequest { + + /** + * Constructs a new DeleteSchemaRevisionRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.pubsub.v1.IDeleteSchemaRevisionRequest); + + /** DeleteSchemaRevisionRequest name. */ + public name: string; + + /** DeleteSchemaRevisionRequest revisionId. */ + public revisionId: string; + + /** + * Creates a new DeleteSchemaRevisionRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteSchemaRevisionRequest instance + */ + public static create(properties?: google.pubsub.v1.IDeleteSchemaRevisionRequest): google.pubsub.v1.DeleteSchemaRevisionRequest; + + /** + * Encodes the specified DeleteSchemaRevisionRequest message. Does not implicitly {@link google.pubsub.v1.DeleteSchemaRevisionRequest.verify|verify} messages. + * @param message DeleteSchemaRevisionRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.pubsub.v1.IDeleteSchemaRevisionRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteSchemaRevisionRequest message, length delimited. Does not implicitly {@link google.pubsub.v1.DeleteSchemaRevisionRequest.verify|verify} messages. + * @param message DeleteSchemaRevisionRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.pubsub.v1.IDeleteSchemaRevisionRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteSchemaRevisionRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteSchemaRevisionRequest + * @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.DeleteSchemaRevisionRequest; + + /** + * Decodes a DeleteSchemaRevisionRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteSchemaRevisionRequest + * @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.DeleteSchemaRevisionRequest; + + /** + * Verifies a DeleteSchemaRevisionRequest 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 DeleteSchemaRevisionRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteSchemaRevisionRequest + */ + public static fromObject(object: { [k: string]: any }): google.pubsub.v1.DeleteSchemaRevisionRequest; + + /** + * Creates a plain object from a DeleteSchemaRevisionRequest message. Also converts values to other types if specified. + * @param message DeleteSchemaRevisionRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.pubsub.v1.DeleteSchemaRevisionRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteSchemaRevisionRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeleteSchemaRevisionRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of a DeleteSchemaRequest. */ interface IDeleteSchemaRequest { diff --git a/protos/protos.js b/protos/protos.js index f8f80dba5..fc79a0564 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -616,6 +616,8 @@ * @interface ISchemaSettings * @property {string|null} [schema] SchemaSettings schema * @property {google.pubsub.v1.Encoding|null} [encoding] SchemaSettings encoding + * @property {string|null} [firstRevisionId] SchemaSettings firstRevisionId + * @property {string|null} [lastRevisionId] SchemaSettings lastRevisionId */ /** @@ -649,6 +651,22 @@ */ SchemaSettings.prototype.encoding = 0; + /** + * SchemaSettings firstRevisionId. + * @member {string} firstRevisionId + * @memberof google.pubsub.v1.SchemaSettings + * @instance + */ + SchemaSettings.prototype.firstRevisionId = ""; + + /** + * SchemaSettings lastRevisionId. + * @member {string} lastRevisionId + * @memberof google.pubsub.v1.SchemaSettings + * @instance + */ + SchemaSettings.prototype.lastRevisionId = ""; + /** * Creates a new SchemaSettings instance using the specified properties. * @function create @@ -677,6 +695,10 @@ 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); + if (message.firstRevisionId != null && Object.hasOwnProperty.call(message, "firstRevisionId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.firstRevisionId); + if (message.lastRevisionId != null && Object.hasOwnProperty.call(message, "lastRevisionId")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.lastRevisionId); return writer; }; @@ -719,6 +741,14 @@ message.encoding = reader.int32(); break; } + case 3: { + message.firstRevisionId = reader.string(); + break; + } + case 4: { + message.lastRevisionId = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -766,6 +796,12 @@ case 2: break; } + if (message.firstRevisionId != null && message.hasOwnProperty("firstRevisionId")) + if (!$util.isString(message.firstRevisionId)) + return "firstRevisionId: string expected"; + if (message.lastRevisionId != null && message.hasOwnProperty("lastRevisionId")) + if (!$util.isString(message.lastRevisionId)) + return "lastRevisionId: string expected"; return null; }; @@ -803,6 +839,10 @@ message.encoding = 2; break; } + if (object.firstRevisionId != null) + message.firstRevisionId = String(object.firstRevisionId); + if (object.lastRevisionId != null) + message.lastRevisionId = String(object.lastRevisionId); return message; }; @@ -822,11 +862,17 @@ if (options.defaults) { object.schema = ""; object.encoding = options.enums === String ? "ENCODING_UNSPECIFIED" : 0; + object.firstRevisionId = ""; + object.lastRevisionId = ""; } 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] === undefined ? message.encoding : $root.google.pubsub.v1.Encoding[message.encoding] : message.encoding; + if (message.firstRevisionId != null && message.hasOwnProperty("firstRevisionId")) + object.firstRevisionId = message.firstRevisionId; + if (message.lastRevisionId != null && message.hasOwnProperty("lastRevisionId")) + object.lastRevisionId = message.lastRevisionId; return object; }; @@ -13859,6 +13905,138 @@ * @variation 2 */ + /** + * Callback as used by {@link google.pubsub.v1.SchemaService|listSchemaRevisions}. + * @memberof google.pubsub.v1.SchemaService + * @typedef ListSchemaRevisionsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.pubsub.v1.ListSchemaRevisionsResponse} [response] ListSchemaRevisionsResponse + */ + + /** + * Calls ListSchemaRevisions. + * @function listSchemaRevisions + * @memberof google.pubsub.v1.SchemaService + * @instance + * @param {google.pubsub.v1.IListSchemaRevisionsRequest} request ListSchemaRevisionsRequest message or plain object + * @param {google.pubsub.v1.SchemaService.ListSchemaRevisionsCallback} callback Node-style callback called with the error, if any, and ListSchemaRevisionsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(SchemaService.prototype.listSchemaRevisions = function listSchemaRevisions(request, callback) { + return this.rpcCall(listSchemaRevisions, $root.google.pubsub.v1.ListSchemaRevisionsRequest, $root.google.pubsub.v1.ListSchemaRevisionsResponse, request, callback); + }, "name", { value: "ListSchemaRevisions" }); + + /** + * Calls ListSchemaRevisions. + * @function listSchemaRevisions + * @memberof google.pubsub.v1.SchemaService + * @instance + * @param {google.pubsub.v1.IListSchemaRevisionsRequest} request ListSchemaRevisionsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.pubsub.v1.SchemaService|commitSchema}. + * @memberof google.pubsub.v1.SchemaService + * @typedef CommitSchemaCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.pubsub.v1.Schema} [response] Schema + */ + + /** + * Calls CommitSchema. + * @function commitSchema + * @memberof google.pubsub.v1.SchemaService + * @instance + * @param {google.pubsub.v1.ICommitSchemaRequest} request CommitSchemaRequest message or plain object + * @param {google.pubsub.v1.SchemaService.CommitSchemaCallback} callback Node-style callback called with the error, if any, and Schema + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(SchemaService.prototype.commitSchema = function commitSchema(request, callback) { + return this.rpcCall(commitSchema, $root.google.pubsub.v1.CommitSchemaRequest, $root.google.pubsub.v1.Schema, request, callback); + }, "name", { value: "CommitSchema" }); + + /** + * Calls CommitSchema. + * @function commitSchema + * @memberof google.pubsub.v1.SchemaService + * @instance + * @param {google.pubsub.v1.ICommitSchemaRequest} request CommitSchemaRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.pubsub.v1.SchemaService|rollbackSchema}. + * @memberof google.pubsub.v1.SchemaService + * @typedef RollbackSchemaCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.pubsub.v1.Schema} [response] Schema + */ + + /** + * Calls RollbackSchema. + * @function rollbackSchema + * @memberof google.pubsub.v1.SchemaService + * @instance + * @param {google.pubsub.v1.IRollbackSchemaRequest} request RollbackSchemaRequest message or plain object + * @param {google.pubsub.v1.SchemaService.RollbackSchemaCallback} callback Node-style callback called with the error, if any, and Schema + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(SchemaService.prototype.rollbackSchema = function rollbackSchema(request, callback) { + return this.rpcCall(rollbackSchema, $root.google.pubsub.v1.RollbackSchemaRequest, $root.google.pubsub.v1.Schema, request, callback); + }, "name", { value: "RollbackSchema" }); + + /** + * Calls RollbackSchema. + * @function rollbackSchema + * @memberof google.pubsub.v1.SchemaService + * @instance + * @param {google.pubsub.v1.IRollbackSchemaRequest} request RollbackSchemaRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.pubsub.v1.SchemaService|deleteSchemaRevision}. + * @memberof google.pubsub.v1.SchemaService + * @typedef DeleteSchemaRevisionCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.pubsub.v1.Schema} [response] Schema + */ + + /** + * Calls DeleteSchemaRevision. + * @function deleteSchemaRevision + * @memberof google.pubsub.v1.SchemaService + * @instance + * @param {google.pubsub.v1.IDeleteSchemaRevisionRequest} request DeleteSchemaRevisionRequest message or plain object + * @param {google.pubsub.v1.SchemaService.DeleteSchemaRevisionCallback} callback Node-style callback called with the error, if any, and Schema + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(SchemaService.prototype.deleteSchemaRevision = function deleteSchemaRevision(request, callback) { + return this.rpcCall(deleteSchemaRevision, $root.google.pubsub.v1.DeleteSchemaRevisionRequest, $root.google.pubsub.v1.Schema, request, callback); + }, "name", { value: "DeleteSchemaRevision" }); + + /** + * Calls DeleteSchemaRevision. + * @function deleteSchemaRevision + * @memberof google.pubsub.v1.SchemaService + * @instance + * @param {google.pubsub.v1.IDeleteSchemaRevisionRequest} request DeleteSchemaRevisionRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + /** * Callback as used by {@link google.pubsub.v1.SchemaService|deleteSchema}. * @memberof google.pubsub.v1.SchemaService @@ -13970,6 +14148,8 @@ * @property {string|null} [name] Schema name * @property {google.pubsub.v1.Schema.Type|null} [type] Schema type * @property {string|null} [definition] Schema definition + * @property {string|null} [revisionId] Schema revisionId + * @property {google.protobuf.ITimestamp|null} [revisionCreateTime] Schema revisionCreateTime */ /** @@ -14011,6 +14191,22 @@ */ Schema.prototype.definition = ""; + /** + * Schema revisionId. + * @member {string} revisionId + * @memberof google.pubsub.v1.Schema + * @instance + */ + Schema.prototype.revisionId = ""; + + /** + * Schema revisionCreateTime. + * @member {google.protobuf.ITimestamp|null|undefined} revisionCreateTime + * @memberof google.pubsub.v1.Schema + * @instance + */ + Schema.prototype.revisionCreateTime = null; + /** * Creates a new Schema instance using the specified properties. * @function create @@ -14041,6 +14237,10 @@ 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); + if (message.revisionId != null && Object.hasOwnProperty.call(message, "revisionId")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.revisionId); + if (message.revisionCreateTime != null && Object.hasOwnProperty.call(message, "revisionCreateTime")) + $root.google.protobuf.Timestamp.encode(message.revisionCreateTime, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); return writer; }; @@ -14087,6 +14287,14 @@ message.definition = reader.string(); break; } + case 4: { + message.revisionId = reader.string(); + break; + } + case 6: { + message.revisionCreateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -14137,6 +14345,14 @@ if (message.definition != null && message.hasOwnProperty("definition")) if (!$util.isString(message.definition)) return "definition: string expected"; + if (message.revisionId != null && message.hasOwnProperty("revisionId")) + if (!$util.isString(message.revisionId)) + return "revisionId: string expected"; + if (message.revisionCreateTime != null && message.hasOwnProperty("revisionCreateTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.revisionCreateTime); + if (error) + return "revisionCreateTime." + error; + } return null; }; @@ -14176,6 +14392,13 @@ } if (object.definition != null) message.definition = String(object.definition); + if (object.revisionId != null) + message.revisionId = String(object.revisionId); + if (object.revisionCreateTime != null) { + if (typeof object.revisionCreateTime !== "object") + throw TypeError(".google.pubsub.v1.Schema.revisionCreateTime: object expected"); + message.revisionCreateTime = $root.google.protobuf.Timestamp.fromObject(object.revisionCreateTime); + } return message; }; @@ -14196,6 +14419,8 @@ object.name = ""; object.type = options.enums === String ? "TYPE_UNSPECIFIED" : 0; object.definition = ""; + object.revisionId = ""; + object.revisionCreateTime = null; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -14203,6 +14428,10 @@ object.type = options.enums === String ? $root.google.pubsub.v1.Schema.Type[message.type] === undefined ? message.type : $root.google.pubsub.v1.Schema.Type[message.type] : message.type; if (message.definition != null && message.hasOwnProperty("definition")) object.definition = message.definition; + if (message.revisionId != null && message.hasOwnProperty("revisionId")) + object.revisionId = message.revisionId; + if (message.revisionCreateTime != null && message.hasOwnProperty("revisionCreateTime")) + object.revisionCreateTime = $root.google.protobuf.Timestamp.toObject(message.revisionCreateTime, options); return object; }; @@ -14251,6 +14480,22 @@ return Schema; })(); + /** + * 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.CreateSchemaRequest = (function() { /** @@ -14506,22 +14751,6 @@ 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() { /** @@ -15318,6 +15547,1237 @@ return ListSchemasResponse; })(); + v1.ListSchemaRevisionsRequest = (function() { + + /** + * Properties of a ListSchemaRevisionsRequest. + * @memberof google.pubsub.v1 + * @interface IListSchemaRevisionsRequest + * @property {string|null} [name] ListSchemaRevisionsRequest name + * @property {google.pubsub.v1.SchemaView|null} [view] ListSchemaRevisionsRequest view + * @property {number|null} [pageSize] ListSchemaRevisionsRequest pageSize + * @property {string|null} [pageToken] ListSchemaRevisionsRequest pageToken + */ + + /** + * Constructs a new ListSchemaRevisionsRequest. + * @memberof google.pubsub.v1 + * @classdesc Represents a ListSchemaRevisionsRequest. + * @implements IListSchemaRevisionsRequest + * @constructor + * @param {google.pubsub.v1.IListSchemaRevisionsRequest=} [properties] Properties to set + */ + function ListSchemaRevisionsRequest(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]]; + } + + /** + * ListSchemaRevisionsRequest name. + * @member {string} name + * @memberof google.pubsub.v1.ListSchemaRevisionsRequest + * @instance + */ + ListSchemaRevisionsRequest.prototype.name = ""; + + /** + * ListSchemaRevisionsRequest view. + * @member {google.pubsub.v1.SchemaView} view + * @memberof google.pubsub.v1.ListSchemaRevisionsRequest + * @instance + */ + ListSchemaRevisionsRequest.prototype.view = 0; + + /** + * ListSchemaRevisionsRequest pageSize. + * @member {number} pageSize + * @memberof google.pubsub.v1.ListSchemaRevisionsRequest + * @instance + */ + ListSchemaRevisionsRequest.prototype.pageSize = 0; + + /** + * ListSchemaRevisionsRequest pageToken. + * @member {string} pageToken + * @memberof google.pubsub.v1.ListSchemaRevisionsRequest + * @instance + */ + ListSchemaRevisionsRequest.prototype.pageToken = ""; + + /** + * Creates a new ListSchemaRevisionsRequest instance using the specified properties. + * @function create + * @memberof google.pubsub.v1.ListSchemaRevisionsRequest + * @static + * @param {google.pubsub.v1.IListSchemaRevisionsRequest=} [properties] Properties to set + * @returns {google.pubsub.v1.ListSchemaRevisionsRequest} ListSchemaRevisionsRequest instance + */ + ListSchemaRevisionsRequest.create = function create(properties) { + return new ListSchemaRevisionsRequest(properties); + }; + + /** + * Encodes the specified ListSchemaRevisionsRequest message. Does not implicitly {@link google.pubsub.v1.ListSchemaRevisionsRequest.verify|verify} messages. + * @function encode + * @memberof google.pubsub.v1.ListSchemaRevisionsRequest + * @static + * @param {google.pubsub.v1.IListSchemaRevisionsRequest} message ListSchemaRevisionsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListSchemaRevisionsRequest.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); + 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 ListSchemaRevisionsRequest message, length delimited. Does not implicitly {@link google.pubsub.v1.ListSchemaRevisionsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.pubsub.v1.ListSchemaRevisionsRequest + * @static + * @param {google.pubsub.v1.IListSchemaRevisionsRequest} message ListSchemaRevisionsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListSchemaRevisionsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListSchemaRevisionsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.pubsub.v1.ListSchemaRevisionsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.pubsub.v1.ListSchemaRevisionsRequest} ListSchemaRevisionsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListSchemaRevisionsRequest.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.ListSchemaRevisionsRequest(); + 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; + } + case 3: { + message.pageSize = reader.int32(); + break; + } + case 4: { + message.pageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListSchemaRevisionsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.pubsub.v1.ListSchemaRevisionsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.pubsub.v1.ListSchemaRevisionsRequest} ListSchemaRevisionsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListSchemaRevisionsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListSchemaRevisionsRequest message. + * @function verify + * @memberof google.pubsub.v1.ListSchemaRevisionsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListSchemaRevisionsRequest.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; + } + 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 ListSchemaRevisionsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.pubsub.v1.ListSchemaRevisionsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.pubsub.v1.ListSchemaRevisionsRequest} ListSchemaRevisionsRequest + */ + ListSchemaRevisionsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.pubsub.v1.ListSchemaRevisionsRequest) + return object; + var message = new $root.google.pubsub.v1.ListSchemaRevisionsRequest(); + if (object.name != null) + message.name = String(object.name); + switch (object.view) { + default: + if (typeof object.view === "number") { + message.view = object.view; + break; + } + break; + 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 ListSchemaRevisionsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.pubsub.v1.ListSchemaRevisionsRequest + * @static + * @param {google.pubsub.v1.ListSchemaRevisionsRequest} message ListSchemaRevisionsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListSchemaRevisionsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.view = options.enums === String ? "SCHEMA_VIEW_UNSPECIFIED" : 0; + object.pageSize = 0; + object.pageToken = ""; + } + 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] === undefined ? message.view : $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 ListSchemaRevisionsRequest to JSON. + * @function toJSON + * @memberof google.pubsub.v1.ListSchemaRevisionsRequest + * @instance + * @returns {Object.} JSON object + */ + ListSchemaRevisionsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListSchemaRevisionsRequest + * @function getTypeUrl + * @memberof google.pubsub.v1.ListSchemaRevisionsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListSchemaRevisionsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.pubsub.v1.ListSchemaRevisionsRequest"; + }; + + return ListSchemaRevisionsRequest; + })(); + + v1.ListSchemaRevisionsResponse = (function() { + + /** + * Properties of a ListSchemaRevisionsResponse. + * @memberof google.pubsub.v1 + * @interface IListSchemaRevisionsResponse + * @property {Array.|null} [schemas] ListSchemaRevisionsResponse schemas + * @property {string|null} [nextPageToken] ListSchemaRevisionsResponse nextPageToken + */ + + /** + * Constructs a new ListSchemaRevisionsResponse. + * @memberof google.pubsub.v1 + * @classdesc Represents a ListSchemaRevisionsResponse. + * @implements IListSchemaRevisionsResponse + * @constructor + * @param {google.pubsub.v1.IListSchemaRevisionsResponse=} [properties] Properties to set + */ + function ListSchemaRevisionsResponse(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]]; + } + + /** + * ListSchemaRevisionsResponse schemas. + * @member {Array.} schemas + * @memberof google.pubsub.v1.ListSchemaRevisionsResponse + * @instance + */ + ListSchemaRevisionsResponse.prototype.schemas = $util.emptyArray; + + /** + * ListSchemaRevisionsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.pubsub.v1.ListSchemaRevisionsResponse + * @instance + */ + ListSchemaRevisionsResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListSchemaRevisionsResponse instance using the specified properties. + * @function create + * @memberof google.pubsub.v1.ListSchemaRevisionsResponse + * @static + * @param {google.pubsub.v1.IListSchemaRevisionsResponse=} [properties] Properties to set + * @returns {google.pubsub.v1.ListSchemaRevisionsResponse} ListSchemaRevisionsResponse instance + */ + ListSchemaRevisionsResponse.create = function create(properties) { + return new ListSchemaRevisionsResponse(properties); + }; + + /** + * Encodes the specified ListSchemaRevisionsResponse message. Does not implicitly {@link google.pubsub.v1.ListSchemaRevisionsResponse.verify|verify} messages. + * @function encode + * @memberof google.pubsub.v1.ListSchemaRevisionsResponse + * @static + * @param {google.pubsub.v1.IListSchemaRevisionsResponse} message ListSchemaRevisionsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListSchemaRevisionsResponse.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 ListSchemaRevisionsResponse message, length delimited. Does not implicitly {@link google.pubsub.v1.ListSchemaRevisionsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.pubsub.v1.ListSchemaRevisionsResponse + * @static + * @param {google.pubsub.v1.IListSchemaRevisionsResponse} message ListSchemaRevisionsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListSchemaRevisionsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListSchemaRevisionsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.pubsub.v1.ListSchemaRevisionsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.pubsub.v1.ListSchemaRevisionsResponse} ListSchemaRevisionsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListSchemaRevisionsResponse.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.ListSchemaRevisionsResponse(); + 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 ListSchemaRevisionsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.pubsub.v1.ListSchemaRevisionsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.pubsub.v1.ListSchemaRevisionsResponse} ListSchemaRevisionsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListSchemaRevisionsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListSchemaRevisionsResponse message. + * @function verify + * @memberof google.pubsub.v1.ListSchemaRevisionsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListSchemaRevisionsResponse.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 ListSchemaRevisionsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.pubsub.v1.ListSchemaRevisionsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.pubsub.v1.ListSchemaRevisionsResponse} ListSchemaRevisionsResponse + */ + ListSchemaRevisionsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.pubsub.v1.ListSchemaRevisionsResponse) + return object; + var message = new $root.google.pubsub.v1.ListSchemaRevisionsResponse(); + if (object.schemas) { + if (!Array.isArray(object.schemas)) + throw TypeError(".google.pubsub.v1.ListSchemaRevisionsResponse.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.ListSchemaRevisionsResponse.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 ListSchemaRevisionsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.pubsub.v1.ListSchemaRevisionsResponse + * @static + * @param {google.pubsub.v1.ListSchemaRevisionsResponse} message ListSchemaRevisionsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListSchemaRevisionsResponse.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 ListSchemaRevisionsResponse to JSON. + * @function toJSON + * @memberof google.pubsub.v1.ListSchemaRevisionsResponse + * @instance + * @returns {Object.} JSON object + */ + ListSchemaRevisionsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListSchemaRevisionsResponse + * @function getTypeUrl + * @memberof google.pubsub.v1.ListSchemaRevisionsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListSchemaRevisionsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.pubsub.v1.ListSchemaRevisionsResponse"; + }; + + return ListSchemaRevisionsResponse; + })(); + + v1.CommitSchemaRequest = (function() { + + /** + * Properties of a CommitSchemaRequest. + * @memberof google.pubsub.v1 + * @interface ICommitSchemaRequest + * @property {string|null} [name] CommitSchemaRequest name + * @property {google.pubsub.v1.ISchema|null} [schema] CommitSchemaRequest schema + */ + + /** + * Constructs a new CommitSchemaRequest. + * @memberof google.pubsub.v1 + * @classdesc Represents a CommitSchemaRequest. + * @implements ICommitSchemaRequest + * @constructor + * @param {google.pubsub.v1.ICommitSchemaRequest=} [properties] Properties to set + */ + function CommitSchemaRequest(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]]; + } + + /** + * CommitSchemaRequest name. + * @member {string} name + * @memberof google.pubsub.v1.CommitSchemaRequest + * @instance + */ + CommitSchemaRequest.prototype.name = ""; + + /** + * CommitSchemaRequest schema. + * @member {google.pubsub.v1.ISchema|null|undefined} schema + * @memberof google.pubsub.v1.CommitSchemaRequest + * @instance + */ + CommitSchemaRequest.prototype.schema = null; + + /** + * Creates a new CommitSchemaRequest instance using the specified properties. + * @function create + * @memberof google.pubsub.v1.CommitSchemaRequest + * @static + * @param {google.pubsub.v1.ICommitSchemaRequest=} [properties] Properties to set + * @returns {google.pubsub.v1.CommitSchemaRequest} CommitSchemaRequest instance + */ + CommitSchemaRequest.create = function create(properties) { + return new CommitSchemaRequest(properties); + }; + + /** + * Encodes the specified CommitSchemaRequest message. Does not implicitly {@link google.pubsub.v1.CommitSchemaRequest.verify|verify} messages. + * @function encode + * @memberof google.pubsub.v1.CommitSchemaRequest + * @static + * @param {google.pubsub.v1.ICommitSchemaRequest} message CommitSchemaRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CommitSchemaRequest.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.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 CommitSchemaRequest message, length delimited. Does not implicitly {@link google.pubsub.v1.CommitSchemaRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.pubsub.v1.CommitSchemaRequest + * @static + * @param {google.pubsub.v1.ICommitSchemaRequest} message CommitSchemaRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CommitSchemaRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CommitSchemaRequest message from the specified reader or buffer. + * @function decode + * @memberof google.pubsub.v1.CommitSchemaRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.pubsub.v1.CommitSchemaRequest} CommitSchemaRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CommitSchemaRequest.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.CommitSchemaRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = 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 CommitSchemaRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.pubsub.v1.CommitSchemaRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.pubsub.v1.CommitSchemaRequest} CommitSchemaRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CommitSchemaRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CommitSchemaRequest message. + * @function verify + * @memberof google.pubsub.v1.CommitSchemaRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CommitSchemaRequest.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.schema != null && message.hasOwnProperty("schema")) { + var error = $root.google.pubsub.v1.Schema.verify(message.schema); + if (error) + return "schema." + error; + } + return null; + }; + + /** + * Creates a CommitSchemaRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.pubsub.v1.CommitSchemaRequest + * @static + * @param {Object.} object Plain object + * @returns {google.pubsub.v1.CommitSchemaRequest} CommitSchemaRequest + */ + CommitSchemaRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.pubsub.v1.CommitSchemaRequest) + return object; + var message = new $root.google.pubsub.v1.CommitSchemaRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.schema != null) { + if (typeof object.schema !== "object") + throw TypeError(".google.pubsub.v1.CommitSchemaRequest.schema: object expected"); + message.schema = $root.google.pubsub.v1.Schema.fromObject(object.schema); + } + return message; + }; + + /** + * Creates a plain object from a CommitSchemaRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.pubsub.v1.CommitSchemaRequest + * @static + * @param {google.pubsub.v1.CommitSchemaRequest} message CommitSchemaRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CommitSchemaRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.schema = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.schema != null && message.hasOwnProperty("schema")) + object.schema = $root.google.pubsub.v1.Schema.toObject(message.schema, options); + return object; + }; + + /** + * Converts this CommitSchemaRequest to JSON. + * @function toJSON + * @memberof google.pubsub.v1.CommitSchemaRequest + * @instance + * @returns {Object.} JSON object + */ + CommitSchemaRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CommitSchemaRequest + * @function getTypeUrl + * @memberof google.pubsub.v1.CommitSchemaRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CommitSchemaRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.pubsub.v1.CommitSchemaRequest"; + }; + + return CommitSchemaRequest; + })(); + + v1.RollbackSchemaRequest = (function() { + + /** + * Properties of a RollbackSchemaRequest. + * @memberof google.pubsub.v1 + * @interface IRollbackSchemaRequest + * @property {string|null} [name] RollbackSchemaRequest name + * @property {string|null} [revisionId] RollbackSchemaRequest revisionId + */ + + /** + * Constructs a new RollbackSchemaRequest. + * @memberof google.pubsub.v1 + * @classdesc Represents a RollbackSchemaRequest. + * @implements IRollbackSchemaRequest + * @constructor + * @param {google.pubsub.v1.IRollbackSchemaRequest=} [properties] Properties to set + */ + function RollbackSchemaRequest(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]]; + } + + /** + * RollbackSchemaRequest name. + * @member {string} name + * @memberof google.pubsub.v1.RollbackSchemaRequest + * @instance + */ + RollbackSchemaRequest.prototype.name = ""; + + /** + * RollbackSchemaRequest revisionId. + * @member {string} revisionId + * @memberof google.pubsub.v1.RollbackSchemaRequest + * @instance + */ + RollbackSchemaRequest.prototype.revisionId = ""; + + /** + * Creates a new RollbackSchemaRequest instance using the specified properties. + * @function create + * @memberof google.pubsub.v1.RollbackSchemaRequest + * @static + * @param {google.pubsub.v1.IRollbackSchemaRequest=} [properties] Properties to set + * @returns {google.pubsub.v1.RollbackSchemaRequest} RollbackSchemaRequest instance + */ + RollbackSchemaRequest.create = function create(properties) { + return new RollbackSchemaRequest(properties); + }; + + /** + * Encodes the specified RollbackSchemaRequest message. Does not implicitly {@link google.pubsub.v1.RollbackSchemaRequest.verify|verify} messages. + * @function encode + * @memberof google.pubsub.v1.RollbackSchemaRequest + * @static + * @param {google.pubsub.v1.IRollbackSchemaRequest} message RollbackSchemaRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RollbackSchemaRequest.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.revisionId != null && Object.hasOwnProperty.call(message, "revisionId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.revisionId); + return writer; + }; + + /** + * Encodes the specified RollbackSchemaRequest message, length delimited. Does not implicitly {@link google.pubsub.v1.RollbackSchemaRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.pubsub.v1.RollbackSchemaRequest + * @static + * @param {google.pubsub.v1.IRollbackSchemaRequest} message RollbackSchemaRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RollbackSchemaRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RollbackSchemaRequest message from the specified reader or buffer. + * @function decode + * @memberof google.pubsub.v1.RollbackSchemaRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.pubsub.v1.RollbackSchemaRequest} RollbackSchemaRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RollbackSchemaRequest.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.RollbackSchemaRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.revisionId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RollbackSchemaRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.pubsub.v1.RollbackSchemaRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.pubsub.v1.RollbackSchemaRequest} RollbackSchemaRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RollbackSchemaRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RollbackSchemaRequest message. + * @function verify + * @memberof google.pubsub.v1.RollbackSchemaRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RollbackSchemaRequest.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.revisionId != null && message.hasOwnProperty("revisionId")) + if (!$util.isString(message.revisionId)) + return "revisionId: string expected"; + return null; + }; + + /** + * Creates a RollbackSchemaRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.pubsub.v1.RollbackSchemaRequest + * @static + * @param {Object.} object Plain object + * @returns {google.pubsub.v1.RollbackSchemaRequest} RollbackSchemaRequest + */ + RollbackSchemaRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.pubsub.v1.RollbackSchemaRequest) + return object; + var message = new $root.google.pubsub.v1.RollbackSchemaRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.revisionId != null) + message.revisionId = String(object.revisionId); + return message; + }; + + /** + * Creates a plain object from a RollbackSchemaRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.pubsub.v1.RollbackSchemaRequest + * @static + * @param {google.pubsub.v1.RollbackSchemaRequest} message RollbackSchemaRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RollbackSchemaRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.revisionId = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.revisionId != null && message.hasOwnProperty("revisionId")) + object.revisionId = message.revisionId; + return object; + }; + + /** + * Converts this RollbackSchemaRequest to JSON. + * @function toJSON + * @memberof google.pubsub.v1.RollbackSchemaRequest + * @instance + * @returns {Object.} JSON object + */ + RollbackSchemaRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RollbackSchemaRequest + * @function getTypeUrl + * @memberof google.pubsub.v1.RollbackSchemaRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RollbackSchemaRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.pubsub.v1.RollbackSchemaRequest"; + }; + + return RollbackSchemaRequest; + })(); + + v1.DeleteSchemaRevisionRequest = (function() { + + /** + * Properties of a DeleteSchemaRevisionRequest. + * @memberof google.pubsub.v1 + * @interface IDeleteSchemaRevisionRequest + * @property {string|null} [name] DeleteSchemaRevisionRequest name + * @property {string|null} [revisionId] DeleteSchemaRevisionRequest revisionId + */ + + /** + * Constructs a new DeleteSchemaRevisionRequest. + * @memberof google.pubsub.v1 + * @classdesc Represents a DeleteSchemaRevisionRequest. + * @implements IDeleteSchemaRevisionRequest + * @constructor + * @param {google.pubsub.v1.IDeleteSchemaRevisionRequest=} [properties] Properties to set + */ + function DeleteSchemaRevisionRequest(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]]; + } + + /** + * DeleteSchemaRevisionRequest name. + * @member {string} name + * @memberof google.pubsub.v1.DeleteSchemaRevisionRequest + * @instance + */ + DeleteSchemaRevisionRequest.prototype.name = ""; + + /** + * DeleteSchemaRevisionRequest revisionId. + * @member {string} revisionId + * @memberof google.pubsub.v1.DeleteSchemaRevisionRequest + * @instance + */ + DeleteSchemaRevisionRequest.prototype.revisionId = ""; + + /** + * Creates a new DeleteSchemaRevisionRequest instance using the specified properties. + * @function create + * @memberof google.pubsub.v1.DeleteSchemaRevisionRequest + * @static + * @param {google.pubsub.v1.IDeleteSchemaRevisionRequest=} [properties] Properties to set + * @returns {google.pubsub.v1.DeleteSchemaRevisionRequest} DeleteSchemaRevisionRequest instance + */ + DeleteSchemaRevisionRequest.create = function create(properties) { + return new DeleteSchemaRevisionRequest(properties); + }; + + /** + * Encodes the specified DeleteSchemaRevisionRequest message. Does not implicitly {@link google.pubsub.v1.DeleteSchemaRevisionRequest.verify|verify} messages. + * @function encode + * @memberof google.pubsub.v1.DeleteSchemaRevisionRequest + * @static + * @param {google.pubsub.v1.IDeleteSchemaRevisionRequest} message DeleteSchemaRevisionRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteSchemaRevisionRequest.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.revisionId != null && Object.hasOwnProperty.call(message, "revisionId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.revisionId); + return writer; + }; + + /** + * Encodes the specified DeleteSchemaRevisionRequest message, length delimited. Does not implicitly {@link google.pubsub.v1.DeleteSchemaRevisionRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.pubsub.v1.DeleteSchemaRevisionRequest + * @static + * @param {google.pubsub.v1.IDeleteSchemaRevisionRequest} message DeleteSchemaRevisionRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteSchemaRevisionRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteSchemaRevisionRequest message from the specified reader or buffer. + * @function decode + * @memberof google.pubsub.v1.DeleteSchemaRevisionRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.pubsub.v1.DeleteSchemaRevisionRequest} DeleteSchemaRevisionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteSchemaRevisionRequest.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.DeleteSchemaRevisionRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.revisionId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DeleteSchemaRevisionRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.pubsub.v1.DeleteSchemaRevisionRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.pubsub.v1.DeleteSchemaRevisionRequest} DeleteSchemaRevisionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteSchemaRevisionRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteSchemaRevisionRequest message. + * @function verify + * @memberof google.pubsub.v1.DeleteSchemaRevisionRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteSchemaRevisionRequest.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.revisionId != null && message.hasOwnProperty("revisionId")) + if (!$util.isString(message.revisionId)) + return "revisionId: string expected"; + return null; + }; + + /** + * Creates a DeleteSchemaRevisionRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.pubsub.v1.DeleteSchemaRevisionRequest + * @static + * @param {Object.} object Plain object + * @returns {google.pubsub.v1.DeleteSchemaRevisionRequest} DeleteSchemaRevisionRequest + */ + DeleteSchemaRevisionRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.pubsub.v1.DeleteSchemaRevisionRequest) + return object; + var message = new $root.google.pubsub.v1.DeleteSchemaRevisionRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.revisionId != null) + message.revisionId = String(object.revisionId); + return message; + }; + + /** + * Creates a plain object from a DeleteSchemaRevisionRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.pubsub.v1.DeleteSchemaRevisionRequest + * @static + * @param {google.pubsub.v1.DeleteSchemaRevisionRequest} message DeleteSchemaRevisionRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteSchemaRevisionRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.revisionId = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.revisionId != null && message.hasOwnProperty("revisionId")) + object.revisionId = message.revisionId; + return object; + }; + + /** + * Converts this DeleteSchemaRevisionRequest to JSON. + * @function toJSON + * @memberof google.pubsub.v1.DeleteSchemaRevisionRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteSchemaRevisionRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeleteSchemaRevisionRequest + * @function getTypeUrl + * @memberof google.pubsub.v1.DeleteSchemaRevisionRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteSchemaRevisionRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.pubsub.v1.DeleteSchemaRevisionRequest"; + }; + + return DeleteSchemaRevisionRequest; + })(); + v1.DeleteSchemaRequest = (function() { /** diff --git a/protos/protos.json b/protos/protos.json index 7cac400a2..2d55ee337 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -206,6 +206,14 @@ "encoding": { "type": "Encoding", "id": 2 + }, + "firstRevisionId": { + "type": "string", + "id": 3 + }, + "lastRevisionId": { + "type": "string", + "id": 4 } } }, @@ -1499,6 +1507,82 @@ } ] }, + "ListSchemaRevisions": { + "requestType": "ListSchemaRevisionsRequest", + "responseType": "ListSchemaRevisionsResponse", + "options": { + "(google.api.http).get": "/v1/{name=projects/*/schemas/*}:listRevisions", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1/{name=projects/*/schemas/*}:listRevisions" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "CommitSchema": { + "requestType": "CommitSchemaRequest", + "responseType": "Schema", + "options": { + "(google.api.http).post": "/v1/{name=projects/*/schemas/*}:commit", + "(google.api.http).body": "*", + "(google.api.method_signature)": "name,schema" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{name=projects/*/schemas/*}:commit", + "body": "*" + } + }, + { + "(google.api.method_signature)": "name,schema" + } + ] + }, + "RollbackSchema": { + "requestType": "RollbackSchemaRequest", + "responseType": "Schema", + "options": { + "(google.api.http).post": "/v1/{name=projects/*/schemas/*}:rollback", + "(google.api.http).body": "*", + "(google.api.method_signature)": "name,revision_id" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{name=projects/*/schemas/*}:rollback", + "body": "*" + } + }, + { + "(google.api.method_signature)": "name,revision_id" + } + ] + }, + "DeleteSchemaRevision": { + "requestType": "DeleteSchemaRevisionRequest", + "responseType": "Schema", + "options": { + "(google.api.http).delete": "/v1/{name=projects/*/schemas/*}:deleteRevision", + "(google.api.method_signature)": "name,revision_id" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v1/{name=projects/*/schemas/*}:deleteRevision" + } + }, + { + "(google.api.method_signature)": "name,revision_id" + } + ] + }, "DeleteSchema": { "requestType": "DeleteSchemaRequest", "responseType": "google.protobuf.Empty", @@ -1575,6 +1659,20 @@ "definition": { "type": "string", "id": 3 + }, + "revisionId": { + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "revisionCreateTime": { + "type": "google.protobuf.Timestamp", + "id": 6, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } } }, "nested": { @@ -1587,6 +1685,13 @@ } } }, + "SchemaView": { + "values": { + "SCHEMA_VIEW_UNSPECIFIED": 0, + "BASIC": 1, + "FULL": 2 + } + }, "CreateSchemaRequest": { "fields": { "parent": { @@ -1610,13 +1715,6 @@ } } }, - "SchemaView": { - "values": { - "SCHEMA_VIEW_UNSPECIFIED": 0, - "BASIC": 1, - "FULL": 2 - } - }, "GetSchemaRequest": { "fields": { "name": { @@ -1670,6 +1768,100 @@ } } }, + "ListSchemaRevisionsRequest": { + "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 + }, + "pageSize": { + "type": "int32", + "id": 3 + }, + "pageToken": { + "type": "string", + "id": 4 + } + } + }, + "ListSchemaRevisionsResponse": { + "fields": { + "schemas": { + "rule": "repeated", + "type": "Schema", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "CommitSchemaRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "pubsub.googleapis.com/Schema" + } + }, + "schema": { + "type": "Schema", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "RollbackSchemaRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "pubsub.googleapis.com/Schema" + } + }, + "revisionId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "DeleteSchemaRevisionRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "pubsub.googleapis.com/Schema" + } + }, + "revisionId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, "DeleteSchemaRequest": { "fields": { "name": { diff --git a/src/v1/index.ts b/src/v1/index.ts index 0d4bf1d45..8bcd06706 100644 --- a/src/v1/index.ts +++ b/src/v1/index.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/v1/publisher_client.ts b/src/v1/publisher_client.ts index 7398ca91c..27b0ee243 100644 --- a/src/v1/publisher_client.ts +++ b/src/v1/publisher_client.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/v1/schema_service_client.ts b/src/v1/schema_service_client.ts index dda22e59f..407534903 100644 --- a/src/v1/schema_service_client.ts +++ b/src/v1/schema_service_client.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -208,6 +208,11 @@ export class SchemaServiceClient { 'nextPageToken', 'schemas' ), + listSchemaRevisions: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'schemas' + ), }; // Put together the default options sent with requests. @@ -263,6 +268,10 @@ export class SchemaServiceClient { 'createSchema', 'getSchema', 'listSchemas', + 'listSchemaRevisions', + 'commitSchema', + 'rollbackSchema', + 'deleteSchemaRevision', 'deleteSchema', 'validateSchema', 'validateMessage', @@ -456,8 +465,7 @@ export class SchemaServiceClient { * 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. + * with all fields filled out. Set to `BASIC` to omit the `definition`. * @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. @@ -532,6 +540,267 @@ export class SchemaServiceClient { this.initialize(); return this.innerApiCalls.getSchema(request, options, callback); } + /** + * Commits a new schema revision to an existing schema. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the schema we are revising. + * Format is `projects/{project}/schemas/{schema}`. + * @param {google.pubsub.v1.Schema} request.schema + * Required. The schema revision to commit. + * @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. + */ + commitSchema( + request?: protos.google.pubsub.v1.ICommitSchemaRequest, + options?: CallOptions + ): Promise< + [ + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.ICommitSchemaRequest | undefined, + {} | undefined + ] + >; + commitSchema( + request: protos.google.pubsub.v1.ICommitSchemaRequest, + options: CallOptions, + callback: Callback< + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.ICommitSchemaRequest | null | undefined, + {} | null | undefined + > + ): void; + commitSchema( + request: protos.google.pubsub.v1.ICommitSchemaRequest, + callback: Callback< + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.ICommitSchemaRequest | null | undefined, + {} | null | undefined + > + ): void; + commitSchema( + request?: protos.google.pubsub.v1.ICommitSchemaRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.ICommitSchemaRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.ICommitSchemaRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.ICommitSchemaRequest | 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'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.commitSchema(request, options, callback); + } + /** + * Creates a new schema revision that is a copy of the provided revision_id. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The schema being rolled back with revision id. + * @param {string} request.revisionId + * Required. The revision ID to roll back to. + * It must be a revision of the same schema. + * + * Example: c7cfa2a8 + * @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. + */ + rollbackSchema( + request?: protos.google.pubsub.v1.IRollbackSchemaRequest, + options?: CallOptions + ): Promise< + [ + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.IRollbackSchemaRequest | undefined, + {} | undefined + ] + >; + rollbackSchema( + request: protos.google.pubsub.v1.IRollbackSchemaRequest, + options: CallOptions, + callback: Callback< + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.IRollbackSchemaRequest | null | undefined, + {} | null | undefined + > + ): void; + rollbackSchema( + request: protos.google.pubsub.v1.IRollbackSchemaRequest, + callback: Callback< + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.IRollbackSchemaRequest | null | undefined, + {} | null | undefined + > + ): void; + rollbackSchema( + request?: protos.google.pubsub.v1.IRollbackSchemaRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.IRollbackSchemaRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.IRollbackSchemaRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.IRollbackSchemaRequest | 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'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.rollbackSchema(request, options, callback); + } + /** + * Deletes a specific schema revision. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the schema revision to be deleted, with a revision ID + * explicitly included. + * + * Example: projects/123/schemas/my-schema@c7cfa2a8 + * @param {string} request.revisionId + * Required. The revision ID to roll back to. + * It must be a revision of the same schema. + * + * Example: c7cfa2a8 + * @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. + */ + deleteSchemaRevision( + request?: protos.google.pubsub.v1.IDeleteSchemaRevisionRequest, + options?: CallOptions + ): Promise< + [ + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.IDeleteSchemaRevisionRequest | undefined, + {} | undefined + ] + >; + deleteSchemaRevision( + request: protos.google.pubsub.v1.IDeleteSchemaRevisionRequest, + options: CallOptions, + callback: Callback< + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.IDeleteSchemaRevisionRequest | null | undefined, + {} | null | undefined + > + ): void; + deleteSchemaRevision( + request: protos.google.pubsub.v1.IDeleteSchemaRevisionRequest, + callback: Callback< + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.IDeleteSchemaRevisionRequest | null | undefined, + {} | null | undefined + > + ): void; + deleteSchemaRevision( + request?: protos.google.pubsub.v1.IDeleteSchemaRevisionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.pubsub.v1.ISchema, + | protos.google.pubsub.v1.IDeleteSchemaRevisionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.IDeleteSchemaRevisionRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.pubsub.v1.ISchema, + protos.google.pubsub.v1.IDeleteSchemaRevisionRequest | 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'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteSchemaRevision(request, options, callback); + } /** * Deletes a schema. * @@ -991,6 +1260,202 @@ export class SchemaServiceClient { callSettings ) as AsyncIterable; } + /** + * Lists all schema revisions for the named schema. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the schema to list revisions for. + * @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 + * The maximum number of revisions to return per page. + * @param {string} request.pageToken + * The page token, received from a previous ListSchemaRevisions call. + * Provide this to retrieve the subsequent page. + * @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 `listSchemaRevisionsAsync()` + * 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. + */ + listSchemaRevisions( + request?: protos.google.pubsub.v1.IListSchemaRevisionsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.pubsub.v1.ISchema[], + protos.google.pubsub.v1.IListSchemaRevisionsRequest | null, + protos.google.pubsub.v1.IListSchemaRevisionsResponse + ] + >; + listSchemaRevisions( + request: protos.google.pubsub.v1.IListSchemaRevisionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.pubsub.v1.IListSchemaRevisionsRequest, + protos.google.pubsub.v1.IListSchemaRevisionsResponse | null | undefined, + protos.google.pubsub.v1.ISchema + > + ): void; + listSchemaRevisions( + request: protos.google.pubsub.v1.IListSchemaRevisionsRequest, + callback: PaginationCallback< + protos.google.pubsub.v1.IListSchemaRevisionsRequest, + protos.google.pubsub.v1.IListSchemaRevisionsResponse | null | undefined, + protos.google.pubsub.v1.ISchema + > + ): void; + listSchemaRevisions( + request?: protos.google.pubsub.v1.IListSchemaRevisionsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.pubsub.v1.IListSchemaRevisionsRequest, + | protos.google.pubsub.v1.IListSchemaRevisionsResponse + | null + | undefined, + protos.google.pubsub.v1.ISchema + >, + callback?: PaginationCallback< + protos.google.pubsub.v1.IListSchemaRevisionsRequest, + protos.google.pubsub.v1.IListSchemaRevisionsResponse | null | undefined, + protos.google.pubsub.v1.ISchema + > + ): Promise< + [ + protos.google.pubsub.v1.ISchema[], + protos.google.pubsub.v1.IListSchemaRevisionsRequest | null, + protos.google.pubsub.v1.IListSchemaRevisionsResponse + ] + > | 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'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.listSchemaRevisions(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.name + * Required. The name of the schema to list revisions for. + * @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 + * The maximum number of revisions to return per page. + * @param {string} request.pageToken + * The page token, received from a previous ListSchemaRevisions call. + * Provide this to retrieve the subsequent page. + * @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 `listSchemaRevisionsAsync()` + * 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. + */ + listSchemaRevisionsStream( + request?: protos.google.pubsub.v1.IListSchemaRevisionsRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + const defaultCallSettings = this._defaults['listSchemaRevisions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listSchemaRevisions.createStream( + this.innerApiCalls.listSchemaRevisions as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listSchemaRevisions`, 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.name + * Required. The name of the schema to list revisions for. + * @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 + * The maximum number of revisions to return per page. + * @param {string} request.pageToken + * The page token, received from a previous ListSchemaRevisions call. + * Provide this to retrieve the subsequent page. + * @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. + */ + listSchemaRevisionsAsync( + request?: protos.google.pubsub.v1.IListSchemaRevisionsRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + const defaultCallSettings = this._defaults['listSchemaRevisions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listSchemaRevisions.asyncIterate( + this.innerApiCalls['listSchemaRevisions'] as GaxCall, + request as {}, + 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. diff --git a/src/v1/schema_service_client_config.json b/src/v1/schema_service_client_config.json index 8928eccdf..05ac8a991 100644 --- a/src/v1/schema_service_client_config.json +++ b/src/v1/schema_service_client_config.json @@ -32,6 +32,22 @@ "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, + "ListSchemaRevisions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CommitSchema": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RollbackSchema": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteSchemaRevision": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, "DeleteSchema": { "retry_codes_name": "non_idempotent", "retry_params_name": "default" diff --git a/src/v1/subscriber_client.ts b/src/v1/subscriber_client.ts index 8ec3ba231..4b007c86c 100644 --- a/src/v1/subscriber_client.ts +++ b/src/v1/subscriber_client.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/test/gapic_publisher_v1.ts b/test/gapic_publisher_v1.ts index f4554a459..8c868b8eb 100644 --- a/test/gapic_publisher_v1.ts +++ b/test/gapic_publisher_v1.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/test/gapic_schema_service_v1.ts b/test/gapic_schema_service_v1.ts index 611703825..3641e64c8 100644 --- a/test/gapic_schema_service_v1.ts +++ b/test/gapic_schema_service_v1.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -484,6 +484,397 @@ describe('v1.SchemaServiceClient', () => { }); }); + describe('commitSchema', () => { + it('invokes commitSchema 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.CommitSchemaRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.pubsub.v1.CommitSchemaRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.pubsub.v1.Schema() + ); + client.innerApiCalls.commitSchema = stubSimpleCall(expectedResponse); + const [response] = await client.commitSchema(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.commitSchema as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.commitSchema as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes commitSchema 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.CommitSchemaRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.pubsub.v1.CommitSchemaRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.pubsub.v1.Schema() + ); + client.innerApiCalls.commitSchema = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.commitSchema( + 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); + const actualRequest = ( + client.innerApiCalls.commitSchema as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.commitSchema as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes commitSchema 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.CommitSchemaRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.pubsub.v1.CommitSchemaRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.commitSchema = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.commitSchema(request), expectedError); + const actualRequest = ( + client.innerApiCalls.commitSchema as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.commitSchema as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes commitSchema with closed client', 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.CommitSchemaRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.pubsub.v1.CommitSchemaRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.commitSchema(request), expectedError); + }); + }); + + describe('rollbackSchema', () => { + it('invokes rollbackSchema 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.RollbackSchemaRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.pubsub.v1.RollbackSchemaRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.pubsub.v1.Schema() + ); + client.innerApiCalls.rollbackSchema = stubSimpleCall(expectedResponse); + const [response] = await client.rollbackSchema(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rollbackSchema as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rollbackSchema as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rollbackSchema 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.RollbackSchemaRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.pubsub.v1.RollbackSchemaRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.pubsub.v1.Schema() + ); + client.innerApiCalls.rollbackSchema = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rollbackSchema( + 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); + const actualRequest = ( + client.innerApiCalls.rollbackSchema as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rollbackSchema as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rollbackSchema 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.RollbackSchemaRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.pubsub.v1.RollbackSchemaRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rollbackSchema = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.rollbackSchema(request), expectedError); + const actualRequest = ( + client.innerApiCalls.rollbackSchema as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rollbackSchema as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rollbackSchema with closed client', 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.RollbackSchemaRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.pubsub.v1.RollbackSchemaRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.rollbackSchema(request), expectedError); + }); + }); + + describe('deleteSchemaRevision', () => { + it('invokes deleteSchemaRevision 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.DeleteSchemaRevisionRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.pubsub.v1.DeleteSchemaRevisionRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.pubsub.v1.Schema() + ); + client.innerApiCalls.deleteSchemaRevision = + stubSimpleCall(expectedResponse); + const [response] = await client.deleteSchemaRevision(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteSchemaRevision as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSchemaRevision as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSchemaRevision 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.DeleteSchemaRevisionRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.pubsub.v1.DeleteSchemaRevisionRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.pubsub.v1.Schema() + ); + client.innerApiCalls.deleteSchemaRevision = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteSchemaRevision( + 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); + const actualRequest = ( + client.innerApiCalls.deleteSchemaRevision as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSchemaRevision as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSchemaRevision 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.DeleteSchemaRevisionRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.pubsub.v1.DeleteSchemaRevisionRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSchemaRevision = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteSchemaRevision(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteSchemaRevision as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSchemaRevision as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSchemaRevision with closed client', 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.DeleteSchemaRevisionRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.pubsub.v1.DeleteSchemaRevisionRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteSchemaRevision(request), expectedError); + }); + }); + describe('deleteSchema', () => { it('invokes deleteSchema without error', async () => { const client = new schemaserviceModule.v1.SchemaServiceClient({ @@ -1172,6 +1563,302 @@ describe('v1.SchemaServiceClient', () => { ); }); }); + + describe('listSchemaRevisions', () => { + it('invokes listSchemaRevisions 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.ListSchemaRevisionsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.pubsub.v1.ListSchemaRevisionsRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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.listSchemaRevisions = + stubSimpleCall(expectedResponse); + const [response] = await client.listSchemaRevisions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listSchemaRevisions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSchemaRevisions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSchemaRevisions 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.ListSchemaRevisionsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.pubsub.v1.ListSchemaRevisionsRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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.listSchemaRevisions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listSchemaRevisions( + 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); + const actualRequest = ( + client.innerApiCalls.listSchemaRevisions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSchemaRevisions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSchemaRevisions 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.ListSchemaRevisionsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.pubsub.v1.ListSchemaRevisionsRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listSchemaRevisions = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listSchemaRevisions(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listSchemaRevisions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSchemaRevisions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSchemaRevisionsStream 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.ListSchemaRevisionsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.pubsub.v1.ListSchemaRevisionsRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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.listSchemaRevisions.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listSchemaRevisionsStream(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.listSchemaRevisions.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listSchemaRevisions, request) + ); + assert( + (client.descriptors.page.listSchemaRevisions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listSchemaRevisionsStream 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.ListSchemaRevisionsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.pubsub.v1.ListSchemaRevisionsRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSchemaRevisions.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listSchemaRevisionsStream(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.listSchemaRevisions.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listSchemaRevisions, request) + ); + assert( + (client.descriptors.page.listSchemaRevisions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listSchemaRevisions 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.ListSchemaRevisionsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.pubsub.v1.ListSchemaRevisionsRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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.listSchemaRevisions.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.pubsub.v1.ISchema[] = []; + const iterable = client.listSchemaRevisionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listSchemaRevisions.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listSchemaRevisions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listSchemaRevisions 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.ListSchemaRevisionsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.pubsub.v1.ListSchemaRevisionsRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSchemaRevisions.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listSchemaRevisionsAsync(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.listSchemaRevisions.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listSchemaRevisions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); describe('getIamPolicy', () => { it('invokes getIamPolicy without error', async () => { const client = new schemaserviceModule.v1.SchemaServiceClient({ diff --git a/test/gapic_subscriber_v1.ts b/test/gapic_subscriber_v1.ts index 1fae03939..719092899 100644 --- a/test/gapic_subscriber_v1.ts +++ b/test/gapic_subscriber_v1.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License.