From 764faca7cad111d0fea1cb26678b4139e861f5ae Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 21 Mar 2023 13:21:58 -0700 Subject: [PATCH] feat: [documentai] Add ImportProcessorVersion in v1beta3 (#4109) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Add ImportProcessorVersion in v1beta3 PiperOrigin-RevId: 517997886 Source-Link: https://github.com/googleapis/googleapis/commit/ae3e6130091c0a9887d13d3b7261e2cfc15c466f Source-Link: https://github.com/googleapis/googleapis-gen/commit/a9e1daab141f302a3320478d22c07aa65b80d8eb Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRvY3VtZW50YWkvLk93bEJvdC55YW1sIiwiaCI6ImE5ZTFkYWFiMTQxZjMwMmEzMzIwNDc4ZDIyYzA3YWE2NWI4MGQ4ZWIifQ== * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot --- packages/google-cloud-documentai/README.md | 1 + .../v1beta3/document_processor_service.proto | 58 ++ .../protos/protos.d.ts | 321 ++++++++ .../google-cloud-documentai/protos/protos.js | 689 ++++++++++++++++++ .../protos/protos.json | 73 ++ .../google-cloud-documentai/samples/README.md | 18 + ...cessor_service.import_processor_version.js | 68 ++ ...adata.google.cloud.documentai.v1beta3.json | 44 ++ .../document_processor_service_client.ts | 162 ++++ ...ument_processor_service_client_config.json | 4 + .../src/v1beta3/gapic_metadata.json | 10 + ...apic_document_processor_service_v1beta3.ts | 215 ++++++ 12 files changed, 1663 insertions(+) create mode 100644 packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.import_processor_version.js diff --git a/packages/google-cloud-documentai/README.md b/packages/google-cloud-documentai/README.md index af2c6184620..c64b8ae20a6 100644 --- a/packages/google-cloud-documentai/README.md +++ b/packages/google-cloud-documentai/README.md @@ -173,6 +173,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/google-cloud-node/ | Document_processor_service.get_processor | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.get_processor.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.get_processor.js,samples/README.md) | | Document_processor_service.get_processor_type | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.get_processor_type.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.get_processor_type.js,samples/README.md) | | Document_processor_service.get_processor_version | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.get_processor_version.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.get_processor_version.js,samples/README.md) | +| Document_processor_service.import_processor_version | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.import_processor_version.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.import_processor_version.js,samples/README.md) | | Document_processor_service.list_evaluations | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.list_evaluations.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.list_evaluations.js,samples/README.md) | | Document_processor_service.list_processor_types | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.list_processor_types.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.list_processor_types.js,samples/README.md) | | Document_processor_service.list_processor_versions | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.list_processor_versions.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.list_processor_versions.js,samples/README.md) | diff --git a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document_processor_service.proto b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document_processor_service.proto index 689ce0674de..885bdffd861 100644 --- a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document_processor_service.proto +++ b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document_processor_service.proto @@ -321,6 +321,20 @@ service DocumentProcessorService { }; option (google.api.method_signature) = "parent"; } + + // Imports a processor version from source processor version. + rpc ImportProcessorVersion(ImportProcessorVersionRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta3/{parent=projects/*/locations/*/processors/*}/processorVersions:importProcessorVersion" + body: "*" + }; + option (google.api.method_signature) = "parent"; + option (google.longrunning.operation_info) = { + response_type: "ImportProcessorVersionResponse" + metadata_type: "ImportProcessorVersionMetadata" + }; + } } // Options for Process API @@ -1121,3 +1135,47 @@ message ListEvaluationsResponse { // If this field is omitted, there are no subsequent pages. string next_page_token = 2; } + +// The request message for the ImportProcessorVersion method. +// This method requires Document AI Service Agent of the destination project in +// the source project's IAM with [Document AI Editor +// role](https://cloud.google.com/document-ai/docs/access-control/iam-roles). +// +// The destination project is specified as part of the `parent` field. +// The source project is specified as part of `source` field. +// +// The Service Agent for Document AI can be found in +// https://cloud.google.com/iam/docs/service-agents. +message ImportProcessorVersionRequest { + oneof source { + // The source processor version to import from. + string processor_version_source = 2 [(google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + }]; + } + + // Required. The destination processor name to create the processor version + // in. Format: + // `projects/{project}/locations/{location}/processors/{processor}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "documentai.googleapis.com/ProcessorVersion" + } + ]; +} + +// The response message for the ImportProcessorVersion method. +message ImportProcessorVersionResponse { + // The destination processor version name. + string processor_version = 1 [(google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + }]; +} + +// The long running operation metadata for the ImportProcessorVersion +// method. +message ImportProcessorVersionMetadata { + // The basic metadata for the long running operation. + CommonOperationMetadata common_metadata = 1; +} diff --git a/packages/google-cloud-documentai/protos/protos.d.ts b/packages/google-cloud-documentai/protos/protos.d.ts index d92f7a763d6..ece5bc5559f 100644 --- a/packages/google-cloud-documentai/protos/protos.d.ts +++ b/packages/google-cloud-documentai/protos/protos.d.ts @@ -29087,6 +29087,20 @@ export namespace google { * @returns Promise */ public listEvaluations(request: google.cloud.documentai.v1beta3.IListEvaluationsRequest): Promise; + + /** + * Calls ImportProcessorVersion. + * @param request ImportProcessorVersionRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public importProcessorVersion(request: google.cloud.documentai.v1beta3.IImportProcessorVersionRequest, callback: google.cloud.documentai.v1beta3.DocumentProcessorService.ImportProcessorVersionCallback): void; + + /** + * Calls ImportProcessorVersion. + * @param request ImportProcessorVersionRequest message or plain object + * @returns Promise + */ + public importProcessorVersion(request: google.cloud.documentai.v1beta3.IImportProcessorVersionRequest): Promise; } namespace DocumentProcessorService { @@ -29244,6 +29258,13 @@ export namespace google { * @param [response] ListEvaluationsResponse */ type ListEvaluationsCallback = (error: (Error|null), response?: google.cloud.documentai.v1beta3.ListEvaluationsResponse) => void; + + /** + * Callback as used by {@link google.cloud.documentai.v1beta3.DocumentProcessorService|importProcessorVersion}. + * @param error Error, if any + * @param [response] Operation + */ + type ImportProcessorVersionCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; } /** Properties of a ProcessOptions. */ @@ -34990,6 +35011,306 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of an ImportProcessorVersionRequest. */ + interface IImportProcessorVersionRequest { + + /** ImportProcessorVersionRequest processorVersionSource */ + processorVersionSource?: (string|null); + + /** ImportProcessorVersionRequest parent */ + parent?: (string|null); + } + + /** Represents an ImportProcessorVersionRequest. */ + class ImportProcessorVersionRequest implements IImportProcessorVersionRequest { + + /** + * Constructs a new ImportProcessorVersionRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.IImportProcessorVersionRequest); + + /** ImportProcessorVersionRequest processorVersionSource. */ + public processorVersionSource?: (string|null); + + /** ImportProcessorVersionRequest parent. */ + public parent: string; + + /** ImportProcessorVersionRequest source. */ + public source?: "processorVersionSource"; + + /** + * Creates a new ImportProcessorVersionRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportProcessorVersionRequest instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.IImportProcessorVersionRequest): google.cloud.documentai.v1beta3.ImportProcessorVersionRequest; + + /** + * Encodes the specified ImportProcessorVersionRequest message. Does not implicitly {@link google.cloud.documentai.v1beta3.ImportProcessorVersionRequest.verify|verify} messages. + * @param message ImportProcessorVersionRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.IImportProcessorVersionRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportProcessorVersionRequest message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ImportProcessorVersionRequest.verify|verify} messages. + * @param message ImportProcessorVersionRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.IImportProcessorVersionRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportProcessorVersionRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportProcessorVersionRequest + * @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.cloud.documentai.v1beta3.ImportProcessorVersionRequest; + + /** + * Decodes an ImportProcessorVersionRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportProcessorVersionRequest + * @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.cloud.documentai.v1beta3.ImportProcessorVersionRequest; + + /** + * Verifies an ImportProcessorVersionRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ImportProcessorVersionRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportProcessorVersionRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.ImportProcessorVersionRequest; + + /** + * Creates a plain object from an ImportProcessorVersionRequest message. Also converts values to other types if specified. + * @param message ImportProcessorVersionRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.ImportProcessorVersionRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportProcessorVersionRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportProcessorVersionRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportProcessorVersionResponse. */ + interface IImportProcessorVersionResponse { + + /** ImportProcessorVersionResponse processorVersion */ + processorVersion?: (string|null); + } + + /** Represents an ImportProcessorVersionResponse. */ + class ImportProcessorVersionResponse implements IImportProcessorVersionResponse { + + /** + * Constructs a new ImportProcessorVersionResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.IImportProcessorVersionResponse); + + /** ImportProcessorVersionResponse processorVersion. */ + public processorVersion: string; + + /** + * Creates a new ImportProcessorVersionResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportProcessorVersionResponse instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.IImportProcessorVersionResponse): google.cloud.documentai.v1beta3.ImportProcessorVersionResponse; + + /** + * Encodes the specified ImportProcessorVersionResponse message. Does not implicitly {@link google.cloud.documentai.v1beta3.ImportProcessorVersionResponse.verify|verify} messages. + * @param message ImportProcessorVersionResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.IImportProcessorVersionResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportProcessorVersionResponse message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ImportProcessorVersionResponse.verify|verify} messages. + * @param message ImportProcessorVersionResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.IImportProcessorVersionResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportProcessorVersionResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportProcessorVersionResponse + * @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.cloud.documentai.v1beta3.ImportProcessorVersionResponse; + + /** + * Decodes an ImportProcessorVersionResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportProcessorVersionResponse + * @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.cloud.documentai.v1beta3.ImportProcessorVersionResponse; + + /** + * Verifies an ImportProcessorVersionResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ImportProcessorVersionResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportProcessorVersionResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.ImportProcessorVersionResponse; + + /** + * Creates a plain object from an ImportProcessorVersionResponse message. Also converts values to other types if specified. + * @param message ImportProcessorVersionResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.ImportProcessorVersionResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportProcessorVersionResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportProcessorVersionResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportProcessorVersionMetadata. */ + interface IImportProcessorVersionMetadata { + + /** ImportProcessorVersionMetadata commonMetadata */ + commonMetadata?: (google.cloud.documentai.v1beta3.ICommonOperationMetadata|null); + } + + /** Represents an ImportProcessorVersionMetadata. */ + class ImportProcessorVersionMetadata implements IImportProcessorVersionMetadata { + + /** + * Constructs a new ImportProcessorVersionMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.IImportProcessorVersionMetadata); + + /** ImportProcessorVersionMetadata commonMetadata. */ + public commonMetadata?: (google.cloud.documentai.v1beta3.ICommonOperationMetadata|null); + + /** + * Creates a new ImportProcessorVersionMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportProcessorVersionMetadata instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.IImportProcessorVersionMetadata): google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata; + + /** + * Encodes the specified ImportProcessorVersionMetadata message. Does not implicitly {@link google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata.verify|verify} messages. + * @param message ImportProcessorVersionMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.IImportProcessorVersionMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportProcessorVersionMetadata message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata.verify|verify} messages. + * @param message ImportProcessorVersionMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.IImportProcessorVersionMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportProcessorVersionMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportProcessorVersionMetadata + * @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.cloud.documentai.v1beta3.ImportProcessorVersionMetadata; + + /** + * Decodes an ImportProcessorVersionMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportProcessorVersionMetadata + * @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.cloud.documentai.v1beta3.ImportProcessorVersionMetadata; + + /** + * Verifies an ImportProcessorVersionMetadata message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ImportProcessorVersionMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportProcessorVersionMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata; + + /** + * Creates a plain object from an ImportProcessorVersionMetadata message. Also converts values to other types if specified. + * @param message ImportProcessorVersionMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportProcessorVersionMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportProcessorVersionMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of a DocumentSchema. */ interface IDocumentSchema { diff --git a/packages/google-cloud-documentai/protos/protos.js b/packages/google-cloud-documentai/protos/protos.js index f57dd5cc2c4..c90616ef955 100644 --- a/packages/google-cloud-documentai/protos/protos.js +++ b/packages/google-cloud-documentai/protos/protos.js @@ -72571,6 +72571,39 @@ * @variation 2 */ + /** + * Callback as used by {@link google.cloud.documentai.v1beta3.DocumentProcessorService|importProcessorVersion}. + * @memberof google.cloud.documentai.v1beta3.DocumentProcessorService + * @typedef ImportProcessorVersionCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls ImportProcessorVersion. + * @function importProcessorVersion + * @memberof google.cloud.documentai.v1beta3.DocumentProcessorService + * @instance + * @param {google.cloud.documentai.v1beta3.IImportProcessorVersionRequest} request ImportProcessorVersionRequest message or plain object + * @param {google.cloud.documentai.v1beta3.DocumentProcessorService.ImportProcessorVersionCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(DocumentProcessorService.prototype.importProcessorVersion = function importProcessorVersion(request, callback) { + return this.rpcCall(importProcessorVersion, $root.google.cloud.documentai.v1beta3.ImportProcessorVersionRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "ImportProcessorVersion" }); + + /** + * Calls ImportProcessorVersion. + * @function importProcessorVersion + * @memberof google.cloud.documentai.v1beta3.DocumentProcessorService + * @instance + * @param {google.cloud.documentai.v1beta3.IImportProcessorVersionRequest} request ImportProcessorVersionRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + return DocumentProcessorService; })(); @@ -85718,6 +85751,662 @@ return ListEvaluationsResponse; })(); + v1beta3.ImportProcessorVersionRequest = (function() { + + /** + * Properties of an ImportProcessorVersionRequest. + * @memberof google.cloud.documentai.v1beta3 + * @interface IImportProcessorVersionRequest + * @property {string|null} [processorVersionSource] ImportProcessorVersionRequest processorVersionSource + * @property {string|null} [parent] ImportProcessorVersionRequest parent + */ + + /** + * Constructs a new ImportProcessorVersionRequest. + * @memberof google.cloud.documentai.v1beta3 + * @classdesc Represents an ImportProcessorVersionRequest. + * @implements IImportProcessorVersionRequest + * @constructor + * @param {google.cloud.documentai.v1beta3.IImportProcessorVersionRequest=} [properties] Properties to set + */ + function ImportProcessorVersionRequest(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]]; + } + + /** + * ImportProcessorVersionRequest processorVersionSource. + * @member {string|null|undefined} processorVersionSource + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionRequest + * @instance + */ + ImportProcessorVersionRequest.prototype.processorVersionSource = null; + + /** + * ImportProcessorVersionRequest parent. + * @member {string} parent + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionRequest + * @instance + */ + ImportProcessorVersionRequest.prototype.parent = ""; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ImportProcessorVersionRequest source. + * @member {"processorVersionSource"|undefined} source + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionRequest + * @instance + */ + Object.defineProperty(ImportProcessorVersionRequest.prototype, "source", { + get: $util.oneOfGetter($oneOfFields = ["processorVersionSource"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new ImportProcessorVersionRequest instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionRequest + * @static + * @param {google.cloud.documentai.v1beta3.IImportProcessorVersionRequest=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.ImportProcessorVersionRequest} ImportProcessorVersionRequest instance + */ + ImportProcessorVersionRequest.create = function create(properties) { + return new ImportProcessorVersionRequest(properties); + }; + + /** + * Encodes the specified ImportProcessorVersionRequest message. Does not implicitly {@link google.cloud.documentai.v1beta3.ImportProcessorVersionRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionRequest + * @static + * @param {google.cloud.documentai.v1beta3.IImportProcessorVersionRequest} message ImportProcessorVersionRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportProcessorVersionRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.processorVersionSource != null && Object.hasOwnProperty.call(message, "processorVersionSource")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.processorVersionSource); + return writer; + }; + + /** + * Encodes the specified ImportProcessorVersionRequest message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ImportProcessorVersionRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionRequest + * @static + * @param {google.cloud.documentai.v1beta3.IImportProcessorVersionRequest} message ImportProcessorVersionRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportProcessorVersionRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportProcessorVersionRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.ImportProcessorVersionRequest} ImportProcessorVersionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportProcessorVersionRequest.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.cloud.documentai.v1beta3.ImportProcessorVersionRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + message.processorVersionSource = reader.string(); + break; + } + case 1: { + message.parent = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportProcessorVersionRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.ImportProcessorVersionRequest} ImportProcessorVersionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportProcessorVersionRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportProcessorVersionRequest message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportProcessorVersionRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.processorVersionSource != null && message.hasOwnProperty("processorVersionSource")) { + properties.source = 1; + if (!$util.isString(message.processorVersionSource)) + return "processorVersionSource: string expected"; + } + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + return null; + }; + + /** + * Creates an ImportProcessorVersionRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.ImportProcessorVersionRequest} ImportProcessorVersionRequest + */ + ImportProcessorVersionRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.ImportProcessorVersionRequest) + return object; + var message = new $root.google.cloud.documentai.v1beta3.ImportProcessorVersionRequest(); + if (object.processorVersionSource != null) + message.processorVersionSource = String(object.processorVersionSource); + if (object.parent != null) + message.parent = String(object.parent); + return message; + }; + + /** + * Creates a plain object from an ImportProcessorVersionRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionRequest + * @static + * @param {google.cloud.documentai.v1beta3.ImportProcessorVersionRequest} message ImportProcessorVersionRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportProcessorVersionRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.parent = ""; + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.processorVersionSource != null && message.hasOwnProperty("processorVersionSource")) { + object.processorVersionSource = message.processorVersionSource; + if (options.oneofs) + object.source = "processorVersionSource"; + } + return object; + }; + + /** + * Converts this ImportProcessorVersionRequest to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionRequest + * @instance + * @returns {Object.} JSON object + */ + ImportProcessorVersionRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportProcessorVersionRequest + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportProcessorVersionRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.ImportProcessorVersionRequest"; + }; + + return ImportProcessorVersionRequest; + })(); + + v1beta3.ImportProcessorVersionResponse = (function() { + + /** + * Properties of an ImportProcessorVersionResponse. + * @memberof google.cloud.documentai.v1beta3 + * @interface IImportProcessorVersionResponse + * @property {string|null} [processorVersion] ImportProcessorVersionResponse processorVersion + */ + + /** + * Constructs a new ImportProcessorVersionResponse. + * @memberof google.cloud.documentai.v1beta3 + * @classdesc Represents an ImportProcessorVersionResponse. + * @implements IImportProcessorVersionResponse + * @constructor + * @param {google.cloud.documentai.v1beta3.IImportProcessorVersionResponse=} [properties] Properties to set + */ + function ImportProcessorVersionResponse(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]]; + } + + /** + * ImportProcessorVersionResponse processorVersion. + * @member {string} processorVersion + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionResponse + * @instance + */ + ImportProcessorVersionResponse.prototype.processorVersion = ""; + + /** + * Creates a new ImportProcessorVersionResponse instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionResponse + * @static + * @param {google.cloud.documentai.v1beta3.IImportProcessorVersionResponse=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.ImportProcessorVersionResponse} ImportProcessorVersionResponse instance + */ + ImportProcessorVersionResponse.create = function create(properties) { + return new ImportProcessorVersionResponse(properties); + }; + + /** + * Encodes the specified ImportProcessorVersionResponse message. Does not implicitly {@link google.cloud.documentai.v1beta3.ImportProcessorVersionResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionResponse + * @static + * @param {google.cloud.documentai.v1beta3.IImportProcessorVersionResponse} message ImportProcessorVersionResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportProcessorVersionResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.processorVersion != null && Object.hasOwnProperty.call(message, "processorVersion")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.processorVersion); + return writer; + }; + + /** + * Encodes the specified ImportProcessorVersionResponse message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ImportProcessorVersionResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionResponse + * @static + * @param {google.cloud.documentai.v1beta3.IImportProcessorVersionResponse} message ImportProcessorVersionResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportProcessorVersionResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportProcessorVersionResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.ImportProcessorVersionResponse} ImportProcessorVersionResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportProcessorVersionResponse.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.cloud.documentai.v1beta3.ImportProcessorVersionResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.processorVersion = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportProcessorVersionResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.ImportProcessorVersionResponse} ImportProcessorVersionResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportProcessorVersionResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportProcessorVersionResponse message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportProcessorVersionResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.processorVersion != null && message.hasOwnProperty("processorVersion")) + if (!$util.isString(message.processorVersion)) + return "processorVersion: string expected"; + return null; + }; + + /** + * Creates an ImportProcessorVersionResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.ImportProcessorVersionResponse} ImportProcessorVersionResponse + */ + ImportProcessorVersionResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.ImportProcessorVersionResponse) + return object; + var message = new $root.google.cloud.documentai.v1beta3.ImportProcessorVersionResponse(); + if (object.processorVersion != null) + message.processorVersion = String(object.processorVersion); + return message; + }; + + /** + * Creates a plain object from an ImportProcessorVersionResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionResponse + * @static + * @param {google.cloud.documentai.v1beta3.ImportProcessorVersionResponse} message ImportProcessorVersionResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportProcessorVersionResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.processorVersion = ""; + if (message.processorVersion != null && message.hasOwnProperty("processorVersion")) + object.processorVersion = message.processorVersion; + return object; + }; + + /** + * Converts this ImportProcessorVersionResponse to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionResponse + * @instance + * @returns {Object.} JSON object + */ + ImportProcessorVersionResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportProcessorVersionResponse + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportProcessorVersionResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.ImportProcessorVersionResponse"; + }; + + return ImportProcessorVersionResponse; + })(); + + v1beta3.ImportProcessorVersionMetadata = (function() { + + /** + * Properties of an ImportProcessorVersionMetadata. + * @memberof google.cloud.documentai.v1beta3 + * @interface IImportProcessorVersionMetadata + * @property {google.cloud.documentai.v1beta3.ICommonOperationMetadata|null} [commonMetadata] ImportProcessorVersionMetadata commonMetadata + */ + + /** + * Constructs a new ImportProcessorVersionMetadata. + * @memberof google.cloud.documentai.v1beta3 + * @classdesc Represents an ImportProcessorVersionMetadata. + * @implements IImportProcessorVersionMetadata + * @constructor + * @param {google.cloud.documentai.v1beta3.IImportProcessorVersionMetadata=} [properties] Properties to set + */ + function ImportProcessorVersionMetadata(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]]; + } + + /** + * ImportProcessorVersionMetadata commonMetadata. + * @member {google.cloud.documentai.v1beta3.ICommonOperationMetadata|null|undefined} commonMetadata + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata + * @instance + */ + ImportProcessorVersionMetadata.prototype.commonMetadata = null; + + /** + * Creates a new ImportProcessorVersionMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata + * @static + * @param {google.cloud.documentai.v1beta3.IImportProcessorVersionMetadata=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata} ImportProcessorVersionMetadata instance + */ + ImportProcessorVersionMetadata.create = function create(properties) { + return new ImportProcessorVersionMetadata(properties); + }; + + /** + * Encodes the specified ImportProcessorVersionMetadata message. Does not implicitly {@link google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata + * @static + * @param {google.cloud.documentai.v1beta3.IImportProcessorVersionMetadata} message ImportProcessorVersionMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportProcessorVersionMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.commonMetadata != null && Object.hasOwnProperty.call(message, "commonMetadata")) + $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.encode(message.commonMetadata, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ImportProcessorVersionMetadata message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata + * @static + * @param {google.cloud.documentai.v1beta3.IImportProcessorVersionMetadata} message ImportProcessorVersionMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportProcessorVersionMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportProcessorVersionMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata} ImportProcessorVersionMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportProcessorVersionMetadata.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.cloud.documentai.v1beta3.ImportProcessorVersionMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.commonMetadata = $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportProcessorVersionMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata} ImportProcessorVersionMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportProcessorVersionMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportProcessorVersionMetadata message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportProcessorVersionMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.commonMetadata != null && message.hasOwnProperty("commonMetadata")) { + var error = $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.verify(message.commonMetadata); + if (error) + return "commonMetadata." + error; + } + return null; + }; + + /** + * Creates an ImportProcessorVersionMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata} ImportProcessorVersionMetadata + */ + ImportProcessorVersionMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata) + return object; + var message = new $root.google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata(); + if (object.commonMetadata != null) { + if (typeof object.commonMetadata !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata.commonMetadata: object expected"); + message.commonMetadata = $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.fromObject(object.commonMetadata); + } + return message; + }; + + /** + * Creates a plain object from an ImportProcessorVersionMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata + * @static + * @param {google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata} message ImportProcessorVersionMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportProcessorVersionMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.commonMetadata = null; + if (message.commonMetadata != null && message.hasOwnProperty("commonMetadata")) + object.commonMetadata = $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.toObject(message.commonMetadata, options); + return object; + }; + + /** + * Converts this ImportProcessorVersionMetadata to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata + * @instance + * @returns {Object.} JSON object + */ + ImportProcessorVersionMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportProcessorVersionMetadata + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportProcessorVersionMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata"; + }; + + return ImportProcessorVersionMetadata; + })(); + v1beta3.DocumentSchema = (function() { /** diff --git a/packages/google-cloud-documentai/protos/protos.json b/packages/google-cloud-documentai/protos/protos.json index c357d936791..97dd1d876fc 100644 --- a/packages/google-cloud-documentai/protos/protos.json +++ b/packages/google-cloud-documentai/protos/protos.json @@ -6520,6 +6520,34 @@ "(google.api.method_signature)": "parent" } ] + }, + "ImportProcessorVersion": { + "requestType": "ImportProcessorVersionRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v1beta3/{parent=projects/*/locations/*/processors/*}/processorVersions:importProcessorVersion", + "(google.api.http).body": "*", + "(google.api.method_signature)": "parent", + "(google.longrunning.operation_info).response_type": "ImportProcessorVersionResponse", + "(google.longrunning.operation_info).metadata_type": "ImportProcessorVersionMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1beta3/{parent=projects/*/locations/*/processors/*}/processorVersions:importProcessorVersion", + "body": "*" + } + }, + { + "(google.api.method_signature)": "parent" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "ImportProcessorVersionResponse", + "metadata_type": "ImportProcessorVersionMetadata" + } + } + ] } } }, @@ -7398,6 +7426,51 @@ } } }, + "ImportProcessorVersionRequest": { + "oneofs": { + "source": { + "oneof": [ + "processorVersionSource" + ] + } + }, + "fields": { + "processorVersionSource": { + "type": "string", + "id": 2, + "options": { + "(google.api.resource_reference).type": "documentai.googleapis.com/ProcessorVersion" + } + }, + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).child_type": "documentai.googleapis.com/ProcessorVersion" + } + } + } + }, + "ImportProcessorVersionResponse": { + "fields": { + "processorVersion": { + "type": "string", + "id": 1, + "options": { + "(google.api.resource_reference).type": "documentai.googleapis.com/ProcessorVersion" + } + } + } + }, + "ImportProcessorVersionMetadata": { + "fields": { + "commonMetadata": { + "type": "CommonOperationMetadata", + "id": 1 + } + } + }, "DocumentSchema": { "fields": { "displayName": { diff --git a/packages/google-cloud-documentai/samples/README.md b/packages/google-cloud-documentai/samples/README.md index f35373f3178..e6960c83ff5 100644 --- a/packages/google-cloud-documentai/samples/README.md +++ b/packages/google-cloud-documentai/samples/README.md @@ -50,6 +50,7 @@ * [Document_processor_service.get_processor](#document_processor_service.get_processor) * [Document_processor_service.get_processor_type](#document_processor_service.get_processor_type) * [Document_processor_service.get_processor_version](#document_processor_service.get_processor_version) + * [Document_processor_service.import_processor_version](#document_processor_service.import_processor_version) * [Document_processor_service.list_evaluations](#document_processor_service.list_evaluations) * [Document_processor_service.list_processor_types](#document_processor_service.list_processor_types) * [Document_processor_service.list_processor_versions](#document_processor_service.list_processor_versions) @@ -723,6 +724,23 @@ __Usage:__ +### Document_processor_service.import_processor_version + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.import_processor_version.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.import_processor_version.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.import_processor_version.js` + + +----- + + + + ### Document_processor_service.list_evaluations View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.list_evaluations.js). diff --git a/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.import_processor_version.js b/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.import_processor_version.js new file mode 100644 index 00000000000..e9342a566b6 --- /dev/null +++ b/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.import_processor_version.js @@ -0,0 +1,68 @@ +// 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. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START documentai_v1beta3_generated_DocumentProcessorService_ImportProcessorVersion_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * The source processor version to import from. + */ + // const processorVersionSource = 'abc123' + /** + * Required. The destination processor name to create the processor version + * in. Format: + * `projects/{project}/locations/{location}/processors/{processor}` + */ + // const parent = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callImportProcessorVersion() { + // Construct request + const request = { + parent, + }; + + // Run request + const [operation] = await documentaiClient.importProcessorVersion(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProcessorVersion(); + // [END documentai_v1beta3_generated_DocumentProcessorService_ImportProcessorVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-documentai/samples/generated/v1beta3/snippet_metadata.google.cloud.documentai.v1beta3.json b/packages/google-cloud-documentai/samples/generated/v1beta3/snippet_metadata.google.cloud.documentai.v1beta3.json index 6482c58a9ea..1f61f47a850 100644 --- a/packages/google-cloud-documentai/samples/generated/v1beta3/snippet_metadata.google.cloud.documentai.v1beta3.json +++ b/packages/google-cloud-documentai/samples/generated/v1beta3/snippet_metadata.google.cloud.documentai.v1beta3.json @@ -1018,6 +1018,50 @@ } } } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_ImportProcessorVersion_async", + "title": "DocumentProcessorService importProcessorVersion Sample", + "origin": "API_DEFINITION", + "description": " Imports a processor version from source processor version.", + "canonical": true, + "file": "document_processor_service.import_processor_version.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProcessorVersion", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ImportProcessorVersion", + "async": true, + "parameters": [ + { + "name": "processor_version_source", + "type": "TYPE_STRING" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "ImportProcessorVersion", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ImportProcessorVersion", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } } ] } \ No newline at end of file diff --git a/packages/google-cloud-documentai/src/v1beta3/document_processor_service_client.ts b/packages/google-cloud-documentai/src/v1beta3/document_processor_service_client.ts index f66ead29606..34e15465d3a 100644 --- a/packages/google-cloud-documentai/src/v1beta3/document_processor_service_client.ts +++ b/packages/google-cloud-documentai/src/v1beta3/document_processor_service_client.ts @@ -360,6 +360,12 @@ export class DocumentProcessorServiceClient { const evaluateProcessorVersionMetadata = protoFilesRoot.lookup( '.google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata' ) as gax.protobuf.Type; + const importProcessorVersionResponse = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.ImportProcessorVersionResponse' + ) as gax.protobuf.Type; + const importProcessorVersionMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata' + ) as gax.protobuf.Type; this.descriptors.longrunning = { batchProcessDocuments: new this._gaxModule.LongrunningDescriptor( @@ -441,6 +447,15 @@ export class DocumentProcessorServiceClient { evaluateProcessorVersionMetadata ) ), + importProcessorVersion: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProcessorVersionResponse.decode.bind( + importProcessorVersionResponse + ), + importProcessorVersionMetadata.decode.bind( + importProcessorVersionMetadata + ) + ), }; // Put together the default options sent with requests. @@ -516,6 +531,7 @@ export class DocumentProcessorServiceClient { 'evaluateProcessorVersion', 'getEvaluation', 'listEvaluations', + 'importProcessorVersion', ]; for (const methodName of documentProcessorServiceStubMethods) { const callPromise = this.documentProcessorServiceStub.then( @@ -2896,6 +2912,152 @@ export class DocumentProcessorServiceClient { protos.google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata >; } + /** + * Imports a processor version from source processor version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.processorVersionSource + * The source processor version to import from. + * @param {string} request.parent + * Required. The destination processor name to create the processor version + * in. Format: + * `projects/{project}/locations/{location}/processors/{processor}` + * @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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.import_processor_version.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_ImportProcessorVersion_async + */ + importProcessorVersion( + request?: protos.google.cloud.documentai.v1beta3.IImportProcessorVersionRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.documentai.v1beta3.IImportProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.IImportProcessorVersionMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + importProcessorVersion( + request: protos.google.cloud.documentai.v1beta3.IImportProcessorVersionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.documentai.v1beta3.IImportProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.IImportProcessorVersionMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + importProcessorVersion( + request: protos.google.cloud.documentai.v1beta3.IImportProcessorVersionRequest, + callback: Callback< + LROperation< + protos.google.cloud.documentai.v1beta3.IImportProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.IImportProcessorVersionMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + importProcessorVersion( + request?: protos.google.cloud.documentai.v1beta3.IImportProcessorVersionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.documentai.v1beta3.IImportProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.IImportProcessorVersionMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.documentai.v1beta3.IImportProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.IImportProcessorVersionMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.documentai.v1beta3.IImportProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.IImportProcessorVersionMetadata + >, + protos.google.longrunning.IOperation | 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({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.importProcessorVersion( + request, + options, + callback + ); + } + /** + * Check the status of the long running operation returned by `importProcessorVersion()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.import_processor_version.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_ImportProcessorVersion_async + */ + async checkImportProcessorVersionProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.documentai.v1beta3.ImportProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata + > + > { + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.importProcessorVersion, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.documentai.v1beta3.ImportProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.ImportProcessorVersionMetadata + >; + } /** * Lists the processor types that exist. * diff --git a/packages/google-cloud-documentai/src/v1beta3/document_processor_service_client_config.json b/packages/google-cloud-documentai/src/v1beta3/document_processor_service_client_config.json index dc88ecae57b..5bd71049a27 100644 --- a/packages/google-cloud-documentai/src/v1beta3/document_processor_service_client_config.json +++ b/packages/google-cloud-documentai/src/v1beta3/document_processor_service_client_config.json @@ -110,6 +110,10 @@ "ListEvaluations": { "retry_codes_name": "non_idempotent", "retry_params_name": "default" + }, + "ImportProcessorVersion": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" } } } diff --git a/packages/google-cloud-documentai/src/v1beta3/gapic_metadata.json b/packages/google-cloud-documentai/src/v1beta3/gapic_metadata.json index f90e7da1cf8..1b5e866fb3f 100644 --- a/packages/google-cloud-documentai/src/v1beta3/gapic_metadata.json +++ b/packages/google-cloud-documentai/src/v1beta3/gapic_metadata.json @@ -100,6 +100,11 @@ "evaluateProcessorVersion" ] }, + "ImportProcessorVersion": { + "methods": [ + "importProcessorVersion" + ] + }, "ListProcessorTypes": { "methods": [ "listProcessorTypes", @@ -223,6 +228,11 @@ "evaluateProcessorVersion" ] }, + "ImportProcessorVersion": { + "methods": [ + "importProcessorVersion" + ] + }, "ListProcessorTypes": { "methods": [ "listProcessorTypes", diff --git a/packages/google-cloud-documentai/test/gapic_document_processor_service_v1beta3.ts b/packages/google-cloud-documentai/test/gapic_document_processor_service_v1beta3.ts index 2b6d287f374..b0242a3e01f 100644 --- a/packages/google-cloud-documentai/test/gapic_document_processor_service_v1beta3.ts +++ b/packages/google-cloud-documentai/test/gapic_document_processor_service_v1beta3.ts @@ -3639,6 +3639,221 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { }); }); + describe('importProcessorVersion', () => { + it('invokes importProcessorVersion without error', async () => { + const client = + new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.ImportProcessorVersionRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.ImportProcessorVersionRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importProcessorVersion = + stubLongRunningCall(expectedResponse); + const [operation] = await client.importProcessorVersion(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importProcessorVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProcessorVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProcessorVersion without error using callback', async () => { + const client = + new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.ImportProcessorVersionRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.ImportProcessorVersionRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importProcessorVersion = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProcessorVersion( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.documentai.v1beta3.IImportProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.IImportProcessorVersionMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.documentai.v1beta3.IImportProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.IImportProcessorVersionMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importProcessorVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProcessorVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProcessorVersion with call error', async () => { + const client = + new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.ImportProcessorVersionRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.ImportProcessorVersionRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProcessorVersion = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects( + client.importProcessorVersion(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.importProcessorVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProcessorVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProcessorVersion with LRO error', async () => { + const client = + new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.ImportProcessorVersionRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.ImportProcessorVersionRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProcessorVersion = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.importProcessorVersion(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.importProcessorVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProcessorVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportProcessorVersionProgress without error', async () => { + const client = + new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportProcessorVersionProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProcessorVersionProgress with error', async () => { + const client = + new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkImportProcessorVersionProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + describe('listProcessorTypes', () => { it('invokes listProcessorTypes without error', async () => { const client =