From 6d20071f3eb73faadfb7b69424dad6f96bd7178c Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot <44816363+yoshi-automation@users.noreply.github.com> Date: Thu, 9 May 2019 10:43:38 -0700 Subject: [PATCH] feat: image annotation batching (#375) --- .../google/cloud/vision/v1/geometry.proto | 2 +- .../cloud/vision/v1/image_annotator.proto | 173 ++- .../cloud/vision/v1/product_search.proto | 13 +- .../vision/v1/product_search_service.proto | 21 +- .../cloud/vision/v1/text_annotation.proto | 2 +- .../cloud/vision/v1/web_detection.proto | 24 +- .../cloud/vision/v1/doc_image_annotator.js | 151 ++- .../cloud/vision/v1/doc_product_search.js | 11 +- .../vision/v1/doc_product_search_service.js | 3 +- .../cloud/vision/v1/doc_web_detection.js | 38 +- .../src/v1/image_annotator_client.js | 195 ++++ .../src/v1/image_annotator_client_config.json | 11 +- packages/google-cloud-vision/src/v1/index.js | 4 +- .../src/v1/product_search_client.js | 750 +++++++------ .../src/v1/product_search_client_config.json | 37 +- .../image_annotator_client_config.json | 1 - .../image_annotator_client_config.json | 1 - .../image_annotator_client_config.json | 1 - .../product_search_client_config.json | 1 - .../image_annotator_client_config.json | 1 - .../product_search_client_config.json | 1 - packages/google-cloud-vision/synth.metadata | 12 +- packages/google-cloud-vision/test/gapic-v1.js | 983 ++++++++++-------- 23 files changed, 1498 insertions(+), 938 deletions(-) diff --git a/packages/google-cloud-vision/protos/google/cloud/vision/v1/geometry.proto b/packages/google-cloud-vision/protos/google/cloud/vision/v1/geometry.proto index f3ba8b773f5..881c8f84ede 100644 --- a/packages/google-cloud-vision/protos/google/cloud/vision/v1/geometry.proto +++ b/packages/google-cloud-vision/protos/google/cloud/vision/v1/geometry.proto @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC. +// Copyright 2019 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/packages/google-cloud-vision/protos/google/cloud/vision/v1/image_annotator.proto b/packages/google-cloud-vision/protos/google/cloud/vision/v1/image_annotator.proto index abaf1bd756a..ad9087213ac 100644 --- a/packages/google-cloud-vision/protos/google/cloud/vision/v1/image_annotator.proto +++ b/packages/google-cloud-vision/protos/google/cloud/vision/v1/image_annotator.proto @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC. +// Copyright 2019 Google LLC. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -49,6 +49,38 @@ service ImageAnnotator { }; } + // Service that performs image detection and annotation for a batch of files. + // Now only "application/pdf", "image/tiff" and "image/gif" are supported. + // + // This service will extract at most 5 (customers can specify which 5 in + // AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each + // file provided and perform detection and annotation for each image + // extracted. + rpc BatchAnnotateFiles(BatchAnnotateFilesRequest) + returns (BatchAnnotateFilesResponse) { + option (google.api.http) = { + post: "/v1/files:annotate" + body: "*" + }; + } + + // Run asynchronous image detection and annotation for a list of images. + // + // Progress and results can be retrieved through the + // `google.longrunning.Operations` interface. + // `Operation.metadata` contains `OperationMetadata` (metadata). + // `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). + // + // This service will write image annotation outputs to json files in customer + // GCS bucket, each json file containing BatchAnnotateImagesResponse proto. + rpc AsyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/images:asyncBatchAnnotate" + body: "*" + }; + } + // Run asynchronous image detection and annotation for a list of generic // files, such as PDF files, which may contain multiple pages and multiple // images per page. Progress and results can be retrieved through the @@ -128,6 +160,28 @@ message Feature { string model = 3; } +// A bucketized representation of likelihood, which is intended to give clients +// highly stable results across model upgrades. +enum Likelihood { + // Unknown likelihood. + UNKNOWN = 0; + + // It is very unlikely that the image belongs to the specified vertical. + VERY_UNLIKELY = 1; + + // It is unlikely that the image belongs to the specified vertical. + UNLIKELY = 2; + + // It is possible that the image belongs to the specified vertical. + POSSIBLE = 3; + + // It is likely that the image belongs to the specified vertical. + LIKELY = 4; + + // It is very likely that the image belongs to the specified vertical. + VERY_LIKELY = 5; +} + // External image source (Google Cloud Storage or web URL image location). message ImageSource { // **Use `image_uri` instead.** @@ -294,7 +348,7 @@ message FaceAnnotation { } // The bounding polygon around the face. The coordinates of the bounding box - // are in the original image's scale, as returned in `ImageParams`. + // are in the original image's scale. // The bounding box is computed to "frame" the face in accordance with human // expectations. It is based on the landmarker results. // Note that one or more x and/or y coordinates may not be generated in the @@ -505,7 +559,7 @@ message ImageProperties { // Single crop hint that is used to generate a new crop when serving an image. message CropHint { // The bounding polygon for the crop region. The coordinates of the bounding - // box are in the original image's scale, as returned in `ImageParams`. + // box are in the original image's scale. BoundingPoly bounding_poly = 1; // Confidence of this being a salient region. Range [0, 1]. @@ -565,7 +619,7 @@ message ImageContext { } // Request for performing Google Cloud Vision API tasks over a user-provided -// image, with user-requested features. +// image, with user-requested features, and with context information. message AnnotateImageRequest { // The image to be processed. Image image = 1; @@ -648,6 +702,9 @@ message AnnotateFileResponse { // Individual responses to images found within the file. repeated AnnotateImageResponse responses = 2; + + // This field gives the total number of pages in the file. + int32 total_pages = 3; } // Multiple image annotation requests are batched into a single service call. @@ -662,6 +719,48 @@ message BatchAnnotateImagesResponse { repeated AnnotateImageResponse responses = 1; } +// A request to annotate one single file, e.g. a PDF, TIFF or GIF file. +message AnnotateFileRequest { + // Required. Information about the input file. + InputConfig input_config = 1; + + // Required. Requested features. + repeated Feature features = 2; + + // Additional context that may accompany the image(s) in the file. + ImageContext image_context = 3; + + // Pages of the file to perform image annotation. + // + // Pages starts from 1, we assume the first page of the file is page 1. + // At most 5 pages are supported per request. Pages can be negative. + // + // Page 1 means the first page. + // Page 2 means the second page. + // Page -1 means the last page. + // Page -2 means the second to the last page. + // + // If the file is GIF instead of PDF or TIFF, page refers to GIF frames. + // + // If this field is empty, by default the service performs image annotation + // for the first 5 pages of the file. + repeated int32 pages = 4; +} + +// A list of requests to annotate files using the BatchAnnotateFiles API. +message BatchAnnotateFilesRequest { + // The list of file annotation requests. Right now we support only one + // AnnotateFileRequest in BatchAnnotateFilesRequest. + repeated AnnotateFileRequest requests = 1; +} + +// A list of file annotation responses. +message BatchAnnotateFilesResponse { + // The list of file annotation responses, each response corresponding to each + // AnnotateFileRequest in BatchAnnotateFilesRequest. + repeated AnnotateFileResponse responses = 1; +} + // An offline file annotation request. message AsyncAnnotateFileRequest { // Required. Information about the input file. @@ -683,6 +782,21 @@ message AsyncAnnotateFileResponse { OutputConfig output_config = 1; } +// Request for async image annotation for a list of images. +message AsyncBatchAnnotateImagesRequest { + // Individual image annotation requests for this batch. + repeated AnnotateImageRequest requests = 1; + + // Required. The desired output location and metadata (e.g. format). + OutputConfig output_config = 2; +} + +// Response to an async batch image annotation request. +message AsyncBatchAnnotateImagesResponse { + // The output location and metadata from AsyncBatchAnnotateImagesRequest. + OutputConfig output_config = 1; +} + // Multiple async file annotation requests are batched into a single service // call. message AsyncBatchAnnotateFilesRequest { @@ -702,6 +816,14 @@ message InputConfig { // The Google Cloud Storage location to read the input from. GcsSource gcs_source = 1; + // File content, represented as a stream of bytes. + // Note: As with all `bytes` fields, protobuffers use a pure binary + // representation, whereas JSON representations use base64. + // + // Currently, this field only works for BatchAnnotateFiles requests. It does + // not work for AsyncBatchAnnotateFiles requests. + bytes content = 3; + // The type of the file. Currently only "application/pdf" and "image/tiff" // are supported. Wildcards are not supported. string mime_type = 2; @@ -735,16 +857,23 @@ message GcsSource { // The Google Cloud Storage location where the output will be written to. message GcsDestination { - // Google Cloud Storage URI where the results will be stored. Results will - // be in JSON format and preceded by its corresponding input URI. This field - // can either represent a single file, or a prefix for multiple outputs. - // Prefixes must end in a `/`. + // Google Cloud Storage URI prefix where the results will be stored. Results + // will be in JSON format and preceded by its corresponding input URI prefix. + // This field can either represent a gcs file prefix or gcs directory. In + // either case, the uri should be unique because in order to get all of the + // output files, you will need to do a wildcard gcs search on the uri prefix + // you provide. // // Examples: // - // * File: gs://bucket-name/filename.json - // * Prefix: gs://bucket-name/prefix/here/ - // * File: gs://bucket-name/prefix/here + // * File Prefix: gs://bucket-name/here/filenameprefix The output files + // will be created in gs://bucket-name/here/ and the names of the + // output files will begin with "filenameprefix". + // + // * Directory Prefix: gs://bucket-name/some/location/ The output files + // will be created in gs://bucket-name/some/location/ and the names of the + // output files could be anything because there was no filename prefix + // specified. // // If multiple outputs, each response is still AnnotateFileResponse, each of // which contains some subset of the full list of AnnotateImageResponse. @@ -782,25 +911,3 @@ message OperationMetadata { // The time when the operation result was last updated. google.protobuf.Timestamp update_time = 6; } - -// A bucketized representation of likelihood, which is intended to give clients -// highly stable results across model upgrades. -enum Likelihood { - // Unknown likelihood. - UNKNOWN = 0; - - // It is very unlikely that the image belongs to the specified vertical. - VERY_UNLIKELY = 1; - - // It is unlikely that the image belongs to the specified vertical. - UNLIKELY = 2; - - // It is possible that the image belongs to the specified vertical. - POSSIBLE = 3; - - // It is likely that the image belongs to the specified vertical. - LIKELY = 4; - - // It is very likely that the image belongs to the specified vertical. - VERY_LIKELY = 5; -} diff --git a/packages/google-cloud-vision/protos/google/cloud/vision/v1/product_search.proto b/packages/google-cloud-vision/protos/google/cloud/vision/v1/product_search.proto index 2b895bdbdac..74c0b188a6f 100644 --- a/packages/google-cloud-vision/protos/google/cloud/vision/v1/product_search.proto +++ b/packages/google-cloud-vision/protos/google/cloud/vision/v1/product_search.proto @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC. +// Copyright 2019 Google LLC. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -49,10 +49,12 @@ message ProductSearchParams { // The filtering expression. This can be used to restrict search results based // on Product labels. We currently support an AND of OR of key-value - // expressions, where each expression within an OR must have the same key. + // expressions, where each expression within an OR must have the same key. An + // '=' should be used to connect the key and value. // // For example, "(color = red OR color = blue) AND brand = Google" is - // acceptable, but not "(color = red OR brand = Google)" or "color: red". + // acceptable, but "(color = red OR brand = Google)" is not acceptable. + // "color: red" is not acceptable because it uses a ':' instead of an '='. string filter = 8; } @@ -82,8 +84,9 @@ message ProductSearchResults { repeated Result results = 2; } - // Timestamp of the index which provided these results. Changes made after - // this time are not reflected in the current results. + // Timestamp of the index which provided these results. Products added to the + // product set and products removed from the product set after this time are + // not reflected in the current results. google.protobuf.Timestamp index_time = 2; // List of results, one for each product match. diff --git a/packages/google-cloud-vision/protos/google/cloud/vision/v1/product_search_service.proto b/packages/google-cloud-vision/protos/google/cloud/vision/v1/product_search_service.proto index 5bbfebfb56f..9b62fac228f 100644 --- a/packages/google-cloud-vision/protos/google/cloud/vision/v1/product_search_service.proto +++ b/packages/google-cloud-vision/protos/google/cloud/vision/v1/product_search_service.proto @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC. +// Copyright 2019 Google LLC. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -105,10 +105,6 @@ service ProductSearch { // ProductSet are not deleted. // // The actual image files are not deleted from Google Cloud Storage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the ProductSet does not exist. rpc DeleteProductSet(DeleteProductSetRequest) returns (google.protobuf.Empty) { option (google.api.http) = { @@ -180,10 +176,6 @@ service ProductSearch { // Metadata of the product and all its images will be deleted right away, but // search queries against ProductSets containing the product may still work // until all related caches are refreshed. - // - // Possible errors: - // - // * Returns NOT_FOUND if the product does not exist. rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { option (google.api.http) = { delete: "/v1/{name=projects/*/locations/*/products/*}" @@ -224,10 +216,6 @@ service ProductSearch { // caches are refreshed. // // The actual image files are not deleted from Google Cloud Storage. - // - // Possible errors: - // - // * Returns NOT_FOUND if the reference image does not exist. rpc DeleteReferenceImage(DeleteReferenceImageRequest) returns (google.protobuf.Empty) { option (google.api.http) = { @@ -277,10 +265,6 @@ service ProductSearch { } // Removes a Product from the specified ProductSet. - // - // Possible errors: - // - // * Returns NOT_FOUND If the Product is not found under the ProductSet. rpc RemoveProductFromProductSet(RemoveProductFromProductSetRequest) returns (google.protobuf.Empty) { option (google.api.http) = { @@ -388,7 +372,8 @@ message ProductSet { // Output only. The time at which this ProductSet was last indexed. Query // results will reflect all updates before this time. If this ProductSet has - // never been indexed, this field is 0. + // never been indexed, this timestamp is the default value + // "1970-01-01T00:00:00Z". // // This field is ignored when creating a ProductSet. google.protobuf.Timestamp index_time = 3; diff --git a/packages/google-cloud-vision/protos/google/cloud/vision/v1/text_annotation.proto b/packages/google-cloud-vision/protos/google/cloud/vision/v1/text_annotation.proto index 417e4f514f8..afbebea5142 100644 --- a/packages/google-cloud-vision/protos/google/cloud/vision/v1/text_annotation.proto +++ b/packages/google-cloud-vision/protos/google/cloud/vision/v1/text_annotation.proto @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC. +// Copyright 2019 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/packages/google-cloud-vision/protos/google/cloud/vision/v1/web_detection.proto b/packages/google-cloud-vision/protos/google/cloud/vision/v1/web_detection.proto index 2d3c4a86a8e..f4a22019c65 100644 --- a/packages/google-cloud-vision/protos/google/cloud/vision/v1/web_detection.proto +++ b/packages/google-cloud-vision/protos/google/cloud/vision/v1/web_detection.proto @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC. +// Copyright 2019 Google LLC. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -50,6 +50,17 @@ message WebDetection { float score = 2; } + // Label to provide extra metadata for the web detection. + message WebLabel { + // Label for extra metadata. + string label = 1; + + // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; + } + // Metadata for web pages. message WebPage { // The result web page URL. @@ -72,17 +83,6 @@ message WebDetection { repeated WebImage partial_matching_images = 5; } - // Label to provide extra metadata for the web detection. - message WebLabel { - // Label for extra metadata. - string label = 1; - - // The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; - } - // Deduced entities from similar images on the Internet. repeated WebEntity web_entities = 1; diff --git a/packages/google-cloud-vision/src/v1/doc/google/cloud/vision/v1/doc_image_annotator.js b/packages/google-cloud-vision/src/v1/doc/google/cloud/vision/v1/doc_image_annotator.js index ebe621c9904..bac94aee7f8 100644 --- a/packages/google-cloud-vision/src/v1/doc/google/cloud/vision/v1/doc_image_annotator.js +++ b/packages/google-cloud-vision/src/v1/doc/google/cloud/vision/v1/doc_image_annotator.js @@ -187,7 +187,7 @@ const Image = { * * @property {Object} boundingPoly * The bounding polygon around the face. The coordinates of the bounding box - * are in the original image's scale, as returned in `ImageParams`. + * are in the original image's scale. * The bounding box is computed to "frame" the face in accordance with human * expectations. It is based on the landmarker results. * Note that one or more x and/or y coordinates may not be generated in the @@ -736,7 +736,7 @@ const ImageProperties = { * * @property {Object} boundingPoly * The bounding polygon for the crop region. The coordinates of the bounding - * box are in the original image's scale, as returned in `ImageParams`. + * box are in the original image's scale. * * This object should have the same structure as [BoundingPoly]{@link google.cloud.vision.v1.BoundingPoly} * @@ -847,7 +847,7 @@ const ImageContext = { /** * Request for performing Google Cloud Vision API tasks over a user-provided - * image, with user-requested features. + * image, with user-requested features, and with context information. * * @property {Object} image * The image to be processed. @@ -993,6 +993,9 @@ const AnnotateImageResponse = { * * This object should have the same structure as [AnnotateImageResponse]{@link google.cloud.vision.v1.AnnotateImageResponse} * + * @property {number} totalPages + * This field gives the total number of pages in the file. + * * @typedef AnnotateFileResponse * @memberof google.cloud.vision.v1 * @see [google.cloud.vision.v1.AnnotateFileResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/vision/v1/image_annotator.proto} @@ -1033,6 +1036,82 @@ const BatchAnnotateImagesResponse = { // This is for documentation. Actual contents will be loaded by gRPC. }; +/** + * A request to annotate one single file, e.g. a PDF, TIFF or GIF file. + * + * @property {Object} inputConfig + * Required. Information about the input file. + * + * This object should have the same structure as [InputConfig]{@link google.cloud.vision.v1.InputConfig} + * + * @property {Object[]} features + * Required. Requested features. + * + * This object should have the same structure as [Feature]{@link google.cloud.vision.v1.Feature} + * + * @property {Object} imageContext + * Additional context that may accompany the image(s) in the file. + * + * This object should have the same structure as [ImageContext]{@link google.cloud.vision.v1.ImageContext} + * + * @property {number[]} pages + * Pages of the file to perform image annotation. + * + * Pages starts from 1, we assume the first page of the file is page 1. + * At most 5 pages are supported per request. Pages can be negative. + * + * Page 1 means the first page. + * Page 2 means the second page. + * Page -1 means the last page. + * Page -2 means the second to the last page. + * + * If the file is GIF instead of PDF or TIFF, page refers to GIF frames. + * + * If this field is empty, by default the service performs image annotation + * for the first 5 pages of the file. + * + * @typedef AnnotateFileRequest + * @memberof google.cloud.vision.v1 + * @see [google.cloud.vision.v1.AnnotateFileRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/vision/v1/image_annotator.proto} + */ +const AnnotateFileRequest = { + // This is for documentation. Actual contents will be loaded by gRPC. +}; + +/** + * A list of requests to annotate files using the BatchAnnotateFiles API. + * + * @property {Object[]} requests + * The list of file annotation requests. Right now we support only one + * AnnotateFileRequest in BatchAnnotateFilesRequest. + * + * This object should have the same structure as [AnnotateFileRequest]{@link google.cloud.vision.v1.AnnotateFileRequest} + * + * @typedef BatchAnnotateFilesRequest + * @memberof google.cloud.vision.v1 + * @see [google.cloud.vision.v1.BatchAnnotateFilesRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/vision/v1/image_annotator.proto} + */ +const BatchAnnotateFilesRequest = { + // This is for documentation. Actual contents will be loaded by gRPC. +}; + +/** + * A list of file annotation responses. + * + * @property {Object[]} responses + * The list of file annotation responses, each response corresponding to each + * AnnotateFileRequest in BatchAnnotateFilesRequest. + * + * This object should have the same structure as [AnnotateFileResponse]{@link google.cloud.vision.v1.AnnotateFileResponse} + * + * @typedef BatchAnnotateFilesResponse + * @memberof google.cloud.vision.v1 + * @see [google.cloud.vision.v1.BatchAnnotateFilesResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/vision/v1/image_annotator.proto} + */ +const BatchAnnotateFilesResponse = { + // This is for documentation. Actual contents will be loaded by gRPC. +}; + /** * An offline file annotation request. * @@ -1080,6 +1159,43 @@ const AsyncAnnotateFileResponse = { // This is for documentation. Actual contents will be loaded by gRPC. }; +/** + * Request for async image annotation for a list of images. + * + * @property {Object[]} requests + * Individual image annotation requests for this batch. + * + * This object should have the same structure as [AnnotateImageRequest]{@link google.cloud.vision.v1.AnnotateImageRequest} + * + * @property {Object} outputConfig + * Required. The desired output location and metadata (e.g. format). + * + * This object should have the same structure as [OutputConfig]{@link google.cloud.vision.v1.OutputConfig} + * + * @typedef AsyncBatchAnnotateImagesRequest + * @memberof google.cloud.vision.v1 + * @see [google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/vision/v1/image_annotator.proto} + */ +const AsyncBatchAnnotateImagesRequest = { + // This is for documentation. Actual contents will be loaded by gRPC. +}; + +/** + * Response to an async batch image annotation request. + * + * @property {Object} outputConfig + * The output location and metadata from AsyncBatchAnnotateImagesRequest. + * + * This object should have the same structure as [OutputConfig]{@link google.cloud.vision.v1.OutputConfig} + * + * @typedef AsyncBatchAnnotateImagesResponse + * @memberof google.cloud.vision.v1 + * @see [google.cloud.vision.v1.AsyncBatchAnnotateImagesResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/vision/v1/image_annotator.proto} + */ +const AsyncBatchAnnotateImagesResponse = { + // This is for documentation. Actual contents will be loaded by gRPC. +}; + /** * Multiple async file annotation requests are batched into a single service * call. @@ -1122,6 +1238,14 @@ const AsyncBatchAnnotateFilesResponse = { * * This object should have the same structure as [GcsSource]{@link google.cloud.vision.v1.GcsSource} * + * @property {string} content + * File content, represented as a stream of bytes. + * Note: As with all `bytes` fields, protobuffers use a pure binary + * representation, whereas JSON representations use base64. + * + * Currently, this field only works for BatchAnnotateFiles requests. It does + * not work for AsyncBatchAnnotateFiles requests. + * * @property {string} mimeType * The type of the file. Currently only "application/pdf" and "image/tiff" * are supported. Wildcards are not supported. @@ -1182,16 +1306,23 @@ const GcsSource = { * The Google Cloud Storage location where the output will be written to. * * @property {string} uri - * Google Cloud Storage URI where the results will be stored. Results will - * be in JSON format and preceded by its corresponding input URI. This field - * can either represent a single file, or a prefix for multiple outputs. - * Prefixes must end in a `/`. + * Google Cloud Storage URI prefix where the results will be stored. Results + * will be in JSON format and preceded by its corresponding input URI prefix. + * This field can either represent a gcs file prefix or gcs directory. In + * either case, the uri should be unique because in order to get all of the + * output files, you will need to do a wildcard gcs search on the uri prefix + * you provide. * * Examples: * - * * File: gs://bucket-name/filename.json - * * Prefix: gs://bucket-name/prefix/here/ - * * File: gs://bucket-name/prefix/here + * * File Prefix: gs://bucket-name/here/filenameprefix The output files + * will be created in gs://bucket-name/here/ and the names of the + * output files will begin with "filenameprefix". + * + * * Directory Prefix: gs://bucket-name/some/location/ The output files + * will be created in gs://bucket-name/some/location/ and the names of the + * output files could be anything because there was no filename prefix + * specified. * * If multiple outputs, each response is still AnnotateFileResponse, each of * which contains some subset of the full list of AnnotateImageResponse. diff --git a/packages/google-cloud-vision/src/v1/doc/google/cloud/vision/v1/doc_product_search.js b/packages/google-cloud-vision/src/v1/doc/google/cloud/vision/v1/doc_product_search.js index 2f5a97805bf..a260ff45d80 100644 --- a/packages/google-cloud-vision/src/v1/doc/google/cloud/vision/v1/doc_product_search.js +++ b/packages/google-cloud-vision/src/v1/doc/google/cloud/vision/v1/doc_product_search.js @@ -39,10 +39,12 @@ * @property {string} filter * The filtering expression. This can be used to restrict search results based * on Product labels. We currently support an AND of OR of key-value - * expressions, where each expression within an OR must have the same key. + * expressions, where each expression within an OR must have the same key. An + * '=' should be used to connect the key and value. * * For example, "(color = red OR color = blue) AND brand = Google" is - * acceptable, but not "(color = red OR brand = Google)" or "color: red". + * acceptable, but "(color = red OR brand = Google)" is not acceptable. + * "color: red" is not acceptable because it uses a ':' instead of an '='. * * @typedef ProductSearchParams * @memberof google.cloud.vision.v1 @@ -56,8 +58,9 @@ const ProductSearchParams = { * Results for a product search request. * * @property {Object} indexTime - * Timestamp of the index which provided these results. Changes made after - * this time are not reflected in the current results. + * Timestamp of the index which provided these results. Products added to the + * product set and products removed from the product set after this time are + * not reflected in the current results. * * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} * diff --git a/packages/google-cloud-vision/src/v1/doc/google/cloud/vision/v1/doc_product_search_service.js b/packages/google-cloud-vision/src/v1/doc/google/cloud/vision/v1/doc_product_search_service.js index 2fa7846d1a7..c446ce5d250 100644 --- a/packages/google-cloud-vision/src/v1/doc/google/cloud/vision/v1/doc_product_search_service.js +++ b/packages/google-cloud-vision/src/v1/doc/google/cloud/vision/v1/doc_product_search_service.js @@ -100,7 +100,8 @@ const Product = { * @property {Object} indexTime * Output only. The time at which this ProductSet was last indexed. Query * results will reflect all updates before this time. If this ProductSet has - * never been indexed, this field is 0. + * never been indexed, this timestamp is the default value + * "1970-01-01T00:00:00Z". * * This field is ignored when creating a ProductSet. * diff --git a/packages/google-cloud-vision/src/v1/doc/google/cloud/vision/v1/doc_web_detection.js b/packages/google-cloud-vision/src/v1/doc/google/cloud/vision/v1/doc_web_detection.js index 883ee78f57d..afb4f6fc32a 100644 --- a/packages/google-cloud-vision/src/v1/doc/google/cloud/vision/v1/doc_web_detection.js +++ b/packages/google-cloud-vision/src/v1/doc/google/cloud/vision/v1/doc_web_detection.js @@ -97,6 +97,25 @@ const WebDetection = { // This is for documentation. Actual contents will be loaded by gRPC. }, + /** + * Label to provide extra metadata for the web detection. + * + * @property {string} label + * Label for extra metadata. + * + * @property {string} languageCode + * The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". + * For more information, see + * http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + * + * @typedef WebLabel + * @memberof google.cloud.vision.v1 + * @see [google.cloud.vision.v1.WebDetection.WebLabel definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/vision/v1/web_detection.proto} + */ + WebLabel: { + // This is for documentation. Actual contents will be loaded by gRPC. + }, + /** * Metadata for web pages. * @@ -129,24 +148,5 @@ const WebDetection = { */ WebPage: { // This is for documentation. Actual contents will be loaded by gRPC. - }, - - /** - * Label to provide extra metadata for the web detection. - * - * @property {string} label - * Label for extra metadata. - * - * @property {string} languageCode - * The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". - * For more information, see - * http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - * - * @typedef WebLabel - * @memberof google.cloud.vision.v1 - * @see [google.cloud.vision.v1.WebDetection.WebLabel definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/vision/v1/web_detection.proto} - */ - WebLabel: { - // This is for documentation. Actual contents will be loaded by gRPC. } }; \ No newline at end of file diff --git a/packages/google-cloud-vision/src/v1/image_annotator_client.js b/packages/google-cloud-vision/src/v1/image_annotator_client.js index a1868f3a315..c9bf6690c69 100644 --- a/packages/google-cloud-vision/src/v1/image_annotator_client.js +++ b/packages/google-cloud-vision/src/v1/image_annotator_client.js @@ -118,6 +118,12 @@ class ImageAnnotatorClient { grpc: gaxGrpc.grpc, }).operationsClient(opts); + const asyncBatchAnnotateImagesResponse = protoFilesRoot.lookup( + 'google.cloud.vision.v1.AsyncBatchAnnotateImagesResponse' + ); + const asyncBatchAnnotateImagesMetadata = protoFilesRoot.lookup( + 'google.cloud.vision.v1.OperationMetadata' + ); const asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup( 'google.cloud.vision.v1.AsyncBatchAnnotateFilesResponse' ); @@ -126,6 +132,15 @@ class ImageAnnotatorClient { ); this._descriptors.longrunning = { + asyncBatchAnnotateImages: new gax.LongrunningDescriptor( + this.operationsClient, + asyncBatchAnnotateImagesResponse.decode.bind( + asyncBatchAnnotateImagesResponse + ), + asyncBatchAnnotateImagesMetadata.decode.bind( + asyncBatchAnnotateImagesMetadata + ) + ), asyncBatchAnnotateFiles: new gax.LongrunningDescriptor( this.operationsClient, asyncBatchAnnotateFilesResponse.decode.bind( @@ -161,6 +176,8 @@ class ImageAnnotatorClient { // and create an API call method for each. const imageAnnotatorStubMethods = [ 'batchAnnotateImages', + 'batchAnnotateFiles', + 'asyncBatchAnnotateImages', 'asyncBatchAnnotateFiles', ]; for (const methodName of imageAnnotatorStubMethods) { @@ -268,6 +285,184 @@ class ImageAnnotatorClient { return this._innerApiCalls.batchAnnotateImages(request, options, callback); } + /** + * Service that performs image detection and annotation for a batch of files. + * Now only "application/pdf", "image/tiff" and "image/gif" are supported. + * + * This service will extract at most 5 (customers can specify which 5 in + * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each + * file provided and perform detection and annotation for each image + * extracted. + * + * @param {Object} request + * The request object that will be sent. + * @param {Object[]} request.requests + * The list of file annotation requests. Right now we support only one + * AnnotateFileRequest in BatchAnnotateFilesRequest. + * + * This object should have the same structure as [AnnotateFileRequest]{@link google.cloud.vision.v1.AnnotateFileRequest} + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [BatchAnnotateFilesResponse]{@link google.cloud.vision.v1.BatchAnnotateFilesResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchAnnotateFilesResponse]{@link google.cloud.vision.v1.BatchAnnotateFilesResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * + * const vision = require('@google-cloud/vision'); + * + * const client = new vision.v1.ImageAnnotatorClient({ + * // optional auth parameters. + * }); + * + * const requests = []; + * client.batchAnnotateFiles({requests: requests}) + * .then(responses => { + * const response = responses[0]; + * // doThingsWith(response) + * }) + * .catch(err => { + * console.error(err); + * }); + */ + batchAnnotateFiles(request, options, callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + + return this._innerApiCalls.batchAnnotateFiles(request, options, callback); + } + + /** + * Run asynchronous image detection and annotation for a list of images. + * + * Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). + * + * This service will write image annotation outputs to json files in customer + * GCS bucket, each json file containing BatchAnnotateImagesResponse proto. + * + * @param {Object} request + * The request object that will be sent. + * @param {Object[]} request.requests + * Individual image annotation requests for this batch. + * + * This object should have the same structure as [AnnotateImageRequest]{@link google.cloud.vision.v1.AnnotateImageRequest} + * @param {Object} request.outputConfig + * Required. The desired output location and metadata (e.g. format). + * + * This object should have the same structure as [OutputConfig]{@link google.cloud.vision.v1.OutputConfig} + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is a [gax.Operation]{@link https://googleapis.github.io/gax-nodejs/Operation} object. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is a [gax.Operation]{@link https://googleapis.github.io/gax-nodejs/Operation} object. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * + * const vision = require('@google-cloud/vision'); + * + * const client = new vision.v1.ImageAnnotatorClient({ + * // optional auth parameters. + * }); + * + * const requests = []; + * const outputConfig = {}; + * const request = { + * requests: requests, + * outputConfig: outputConfig, + * }; + * + * // Handle the operation using the promise pattern. + * client.asyncBatchAnnotateImages(request) + * .then(responses => { + * const [operation, initialApiResponse] = responses; + * + * // Operation#promise starts polling for the completion of the LRO. + * return operation.promise(); + * }) + * .then(responses => { + * const result = responses[0]; + * const metadata = responses[1]; + * const finalApiResponse = responses[2]; + * }) + * .catch(err => { + * console.error(err); + * }); + * + * const requests = []; + * const outputConfig = {}; + * const request = { + * requests: requests, + * outputConfig: outputConfig, + * }; + * + * // Handle the operation using the event emitter pattern. + * client.asyncBatchAnnotateImages(request) + * .then(responses => { + * const [operation, initialApiResponse] = responses; + * + * // Adding a listener for the "complete" event starts polling for the + * // completion of the operation. + * operation.on('complete', (result, metadata, finalApiResponse) => { + * // doSomethingWith(result); + * }); + * + * // Adding a listener for the "progress" event causes the callback to be + * // called on any change in metadata when the operation is polled. + * operation.on('progress', (metadata, apiResponse) => { + * // doSomethingWith(metadata) + * }); + * + * // Adding a listener for the "error" event handles any errors found during polling. + * operation.on('error', err => { + * // throw(err); + * }); + * }) + * .catch(err => { + * console.error(err); + * }); + * + * const requests = []; + * const outputConfig = {}; + * const request = { + * requests: requests, + * outputConfig: outputConfig, + * }; + * + * // Handle the operation using the await pattern. + * const [operation] = await client.asyncBatchAnnotateImages(request); + * + * const [response] = await operation.promise(); + */ + asyncBatchAnnotateImages(request, options, callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + + return this._innerApiCalls.asyncBatchAnnotateImages( + request, + options, + callback + ); + } + /** * Run asynchronous image detection and annotation for a list of generic * files, such as PDF files, which may contain multiple pages and multiple diff --git a/packages/google-cloud-vision/src/v1/image_annotator_client_config.json b/packages/google-cloud-vision/src/v1/image_annotator_client_config.json index bd8d8371dee..32cc73d4e0d 100644 --- a/packages/google-cloud-vision/src/v1/image_annotator_client_config.json +++ b/packages/google-cloud-vision/src/v1/image_annotator_client_config.json @@ -3,7 +3,6 @@ "google.cloud.vision.v1.ImageAnnotator": { "retry_codes": { "idempotent": [ - "DEADLINE_EXCEEDED", "UNAVAILABLE" ], "non_idempotent": [] @@ -25,6 +24,16 @@ "retry_codes_name": "idempotent", "retry_params_name": "default" }, + "BatchAnnotateFiles": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AsyncBatchAnnotateImages": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, "AsyncBatchAnnotateFiles": { "timeout_millis": 60000, "retry_codes_name": "idempotent", diff --git a/packages/google-cloud-vision/src/v1/index.js b/packages/google-cloud-vision/src/v1/index.js index 8a46227b562..c361ba2863d 100644 --- a/packages/google-cloud-vision/src/v1/index.js +++ b/packages/google-cloud-vision/src/v1/index.js @@ -14,8 +14,8 @@ 'use strict'; -const ProductSearchClient = require('./product_search_client'); const ImageAnnotatorClient = require('./image_annotator_client'); +const ProductSearchClient = require('./product_search_client'); -module.exports.ProductSearchClient = ProductSearchClient; module.exports.ImageAnnotatorClient = ImageAnnotatorClient; +module.exports.ProductSearchClient = ProductSearchClient; diff --git a/packages/google-cloud-vision/src/v1/product_search_client.js b/packages/google-cloud-vision/src/v1/product_search_client.js index a236a03b27f..559567bdd05 100644 --- a/packages/google-cloud-vision/src/v1/product_search_client.js +++ b/packages/google-cloud-vision/src/v1/product_search_client.js @@ -134,6 +134,11 @@ class ProductSearchClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this._descriptors.page = { + listProductSets: new gax.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'productSets' + ), listProducts: new gax.PageDescriptor( 'pageToken', 'nextPageToken', @@ -144,11 +149,6 @@ class ProductSearchClient { 'nextPageToken', 'referenceImages' ), - listProductSets: new gax.PageDescriptor( - 'pageToken', - 'nextPageToken', - 'productSets' - ), listProductsInProductSet: new gax.PageDescriptor( 'pageToken', 'nextPageToken', @@ -213,20 +213,20 @@ class ProductSearchClient { // Iterate over each of the methods that the service provides // and create an API call method for each. const productSearchStubMethods = [ + 'createProductSet', + 'listProductSets', + 'getProductSet', + 'updateProductSet', + 'deleteProductSet', 'createProduct', 'listProducts', 'getProduct', 'updateProduct', 'deleteProduct', + 'createReferenceImage', + 'deleteReferenceImage', 'listReferenceImages', 'getReferenceImage', - 'deleteReferenceImage', - 'createReferenceImage', - 'createProductSet', - 'listProductSets', - 'getProductSet', - 'updateProductSet', - 'deleteProductSet', 'addProductToProductSet', 'removeProductFromProductSet', 'listProductsInProductSet', @@ -291,28 +291,25 @@ class ProductSearchClient { // ------------------- /** - * Creates and returns a new product resource. + * Creates and returns a new ProductSet resource. * * Possible errors: * - * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is missing or invalid. + * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + * 4096 characters. * * @param {Object} request * The request object that will be sent. * @param {string} request.parent - * The project in which the Product should be created. + * The project in which the ProductSet should be created. * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID`. - * @param {Object} request.product - * The product to create. + * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * @param {Object} request.productSet + * The ProductSet to create. * - * This object should have the same structure as [Product]{@link google.cloud.vision.v1.Product} - * @param {string} [request.productId] - * A user-supplied resource id for this Product. If set, the server will + * This object should have the same structure as [ProductSet]{@link google.cloud.vision.v1.ProductSet} + * @param {string} [request.productSetId] + * A user-supplied resource id for this ProductSet. If set, the server will * attempt to use this value as the resource id. If it is already in use, an * error is returned with code ALREADY_EXISTS. Must be at most 128 characters * long. It cannot contain the character `/`. @@ -322,9 +319,9 @@ class ProductSearchClient { * @param {function(?Error, ?Object)} [callback] * The function which will be called with the result of the API call. * - * The second parameter to the callback is an object representing [Product]{@link google.cloud.vision.v1.Product}. + * The second parameter to the callback is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. * The promise has a method named "cancel" which cancels the ongoing API call. * * @example @@ -336,12 +333,12 @@ class ProductSearchClient { * }); * * const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); - * const product = {}; + * const productSet = {}; * const request = { * parent: formattedParent, - * product: product, + * productSet: productSet, * }; - * client.createProduct(request) + * client.createProductSet(request) * .then(responses => { * const response = responses[0]; * // doThingsWith(response) @@ -350,7 +347,7 @@ class ProductSearchClient { * console.error(err); * }); */ - createProduct(request, options, callback) { + createProductSet(request, options, callback) { if (options instanceof Function && callback === undefined) { callback = options; options = {}; @@ -364,23 +361,23 @@ class ProductSearchClient { parent: request.parent, }); - return this._innerApiCalls.createProduct(request, options, callback); + return this._innerApiCalls.createProductSet(request, options, callback); } /** - * Lists products in an unspecified order. + * Lists ProductSets in an unspecified order. * * Possible errors: * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + * than 1. * * @param {Object} request * The request object that will be sent. * @param {string} request.parent - * The project OR ProductSet from which Products should be listed. + * The project from which ProductSets should be listed. * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` + * Format is `projects/PROJECT_ID/locations/LOC_ID`. * @param {number} [request.pageSize] * The maximum number of resources contained in the underlying API * response. If page streaming is performed per-resource, this @@ -393,20 +390,20 @@ class ProductSearchClient { * @param {function(?Error, ?Array, ?Object, ?Object)} [callback] * The function which will be called with the result of the API call. * - * The second parameter to the callback is Array of [Product]{@link google.cloud.vision.v1.Product}. + * The second parameter to the callback is Array of [ProductSet]{@link google.cloud.vision.v1.ProductSet}. * * When autoPaginate: false is specified through options, it contains the result * in a single response. If the response indicates the next page exists, the third * parameter is set to be used for the next request object. The fourth parameter keeps - * the raw response object of an object representing [ListProductsResponse]{@link google.cloud.vision.v1.ListProductsResponse}. + * the raw response object of an object representing [ListProductSetsResponse]{@link google.cloud.vision.v1.ListProductSetsResponse}. * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Product]{@link google.cloud.vision.v1.Product}. + * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1.ProductSet}. * * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [Product]{@link google.cloud.vision.v1.Product} in a single response. + * The first element is Array of [ProductSet]{@link google.cloud.vision.v1.ProductSet} in a single response. * The second element is the next request object if the response * indicates the next page exists, or null. The third element is - * an object representing [ListProductsResponse]{@link google.cloud.vision.v1.ListProductsResponse}. + * an object representing [ListProductSetsResponse]{@link google.cloud.vision.v1.ListProductSetsResponse}. * * The promise has a method named "cancel" which cancels the ongoing API call. * @@ -421,7 +418,7 @@ class ProductSearchClient { * // Iterate over all elements. * const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); * - * client.listProducts({parent: formattedParent}) + * client.listProductSets({parent: formattedParent}) * .then(responses => { * const resources = responses[0]; * for (const resource of resources) { @@ -449,16 +446,16 @@ class ProductSearchClient { * } * if (nextRequest) { * // Fetch the next page. - * return client.listProducts(nextRequest, options).then(callback); + * return client.listProductSets(nextRequest, options).then(callback); * } * } - * client.listProducts({parent: formattedParent}, options) + * client.listProductSets({parent: formattedParent}, options) * .then(callback) * .catch(err => { * console.error(err); * }); */ - listProducts(request, options, callback) { + listProductSets(request, options, callback) { if (options instanceof Function && callback === undefined) { callback = options; options = {}; @@ -472,13 +469,13 @@ class ProductSearchClient { parent: request.parent, }); - return this._innerApiCalls.listProducts(request, options, callback); + return this._innerApiCalls.listProductSets(request, options, callback); } /** - * Equivalent to {@link listProducts}, but returns a NodeJS Stream object. + * Equivalent to {@link listProductSets}, but returns a NodeJS Stream object. * - * This fetches the paged responses for {@link listProducts} continuously + * This fetches the paged responses for {@link listProductSets} continuously * and invokes the callback registered for 'data' event for each element in the * responses. * @@ -491,10 +488,9 @@ class ProductSearchClient { * @param {Object} request * The request object that will be sent. * @param {string} request.parent - * The project OR ProductSet from which Products should be listed. + * The project from which ProductSets should be listed. * - * Format: - * `projects/PROJECT_ID/locations/LOC_ID` + * Format is `projects/PROJECT_ID/locations/LOC_ID`. * @param {number} [request.pageSize] * The maximum number of resources contained in the underlying API * response. If page streaming is performed per-resource, this @@ -505,7 +501,7 @@ class ProductSearchClient { * Optional parameters. You can override the default settings for this call, e.g, timeout, * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. * @returns {Stream} - * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1.Product} on 'data' event. + * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet} on 'data' event. * * @example * @@ -516,46 +512,46 @@ class ProductSearchClient { * }); * * const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); - * client.listProductsStream({parent: formattedParent}) + * client.listProductSetsStream({parent: formattedParent}) * .on('data', element => { * // doThingsWith(element) * }).on('error', err => { * console.log(err); * }); */ - listProductsStream(request, options) { + listProductSetsStream(request, options) { options = options || {}; - return this._descriptors.page.listProducts.createStream( - this._innerApiCalls.listProducts, + return this._descriptors.page.listProductSets.createStream( + this._innerApiCalls.listProductSets, request, options ); } /** - * Gets information associated with a Product. + * Gets information associated with a ProductSet. * * Possible errors: * - * * Returns NOT_FOUND if the Product does not exist. + * * Returns NOT_FOUND if the ProductSet does not exist. * * @param {Object} request * The request object that will be sent. * @param {string} request.name - * Resource name of the Product to get. + * Resource name of the ProductSet to get. * * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * `projects/PROJECT_ID/locations/LOG_ID/productSets/PRODUCT_SET_ID` * @param {Object} [options] * Optional parameters. You can override the default settings for this call, e.g, timeout, * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. * @param {function(?Error, ?Object)} [callback] * The function which will be called with the result of the API call. * - * The second parameter to the callback is an object representing [Product]{@link google.cloud.vision.v1.Product}. + * The second parameter to the callback is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. * The promise has a method named "cancel" which cancels the ongoing API call. * * @example @@ -566,8 +562,8 @@ class ProductSearchClient { * // optional auth parameters. * }); * - * const formattedName = client.productPath('[PROJECT]', '[LOCATION]', '[PRODUCT]'); - * client.getProduct({name: formattedName}) + * const formattedName = client.productSetPath('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]'); + * client.getProductSet({name: formattedName}) * .then(responses => { * const response = responses[0]; * // doThingsWith(response) @@ -576,7 +572,7 @@ class ProductSearchClient { * console.error(err); * }); */ - getProduct(request, options, callback) { + getProductSet(request, options, callback) { if (options instanceof Function && callback === undefined) { callback = options; options = {}; @@ -590,39 +586,30 @@ class ProductSearchClient { name: request.name, }); - return this._innerApiCalls.getProduct(request, options, callback); + return this._innerApiCalls.getProductSet(request, options, callback); } /** - * Makes changes to a Product resource. - * Only the `display_name`, `description`, and `labels` fields can be updated - * right now. - * - * If labels are updated, the change will not be reflected in queries until - * the next index time. + * Makes changes to a ProductSet resource. + * Only display_name can be updated currently. * * Possible errors: * - * * Returns NOT_FOUND if the Product does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + * * Returns NOT_FOUND if the ProductSet does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but * missing from the request or longer than 4096 characters. - * * Returns INVALID_ARGUMENT if description is present in update_mask but is - * longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is present in update_mask. * * @param {Object} request * The request object that will be sent. - * @param {Object} request.product - * The Product resource which replaces the one on the server. - * product.name is immutable. + * @param {Object} request.productSet + * The ProductSet resource which replaces the one on the server. * - * This object should have the same structure as [Product]{@link google.cloud.vision.v1.Product} + * This object should have the same structure as [ProductSet]{@link google.cloud.vision.v1.ProductSet} * @param {Object} [request.updateMask] - * The FieldMask that specifies which fields - * to update. + * The FieldMask that specifies which fields to + * update. * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask paths include `product_labels`, `display_name`, and - * `description`. + * Valid mask path is `display_name`. * * This object should have the same structure as [FieldMask]{@link google.protobuf.FieldMask} * @param {Object} [options] @@ -631,9 +618,9 @@ class ProductSearchClient { * @param {function(?Error, ?Object)} [callback] * The function which will be called with the result of the API call. * - * The second parameter to the callback is an object representing [Product]{@link google.cloud.vision.v1.Product}. + * The second parameter to the callback is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. + * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. * The promise has a method named "cancel" which cancels the ongoing API call. * * @example @@ -644,8 +631,8 @@ class ProductSearchClient { * // optional auth parameters. * }); * - * const product = {}; - * client.updateProduct({product: product}) + * const productSet = {}; + * client.updateProductSet({productSet: productSet}) * .then(responses => { * const response = responses[0]; * // doThingsWith(response) @@ -654,7 +641,7 @@ class ProductSearchClient { * console.error(err); * }); */ - updateProduct(request, options, callback) { + updateProductSet(request, options, callback) { if (options instanceof Function && callback === undefined) { callback = options; options = {}; @@ -665,30 +652,25 @@ class ProductSearchClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'product.name': request.product.name, + 'product_set.name': request.productSet.name, }); - return this._innerApiCalls.updateProduct(request, options, callback); + return this._innerApiCalls.updateProductSet(request, options, callback); } /** - * Permanently deletes a product and its reference images. - * - * Metadata of the product and all its images will be deleted right away, but - * search queries against ProductSets containing the product may still work - * until all related caches are refreshed. - * - * Possible errors: + * Permanently deletes a ProductSet. Products and ReferenceImages in the + * ProductSet are not deleted. * - * * Returns NOT_FOUND if the product does not exist. + * The actual image files are not deleted from Google Cloud Storage. * * @param {Object} request * The request object that will be sent. * @param {string} request.name - * Resource name of product to delete. + * Resource name of the ProductSet to delete. * * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` * @param {Object} [options] * Optional parameters. You can override the default settings for this call, e.g, timeout, * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. @@ -705,12 +687,12 @@ class ProductSearchClient { * // optional auth parameters. * }); * - * const formattedName = client.productPath('[PROJECT]', '[LOCATION]', '[PRODUCT]'); - * client.deleteProduct({name: formattedName}).catch(err => { + * const formattedName = client.productSetPath('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]'); + * client.deleteProductSet({name: formattedName}).catch(err => { * console.error(err); * }); */ - deleteProduct(request, options, callback) { + deleteProductSet(request, options, callback) { if (options instanceof Function && callback === undefined) { callback = options; options = {}; @@ -724,52 +706,44 @@ class ProductSearchClient { name: request.name, }); - return this._innerApiCalls.deleteProduct(request, options, callback); + return this._innerApiCalls.deleteProductSet(request, options, callback); } /** - * Lists reference images. + * Creates and returns a new product resource. * * Possible errors: * - * * Returns NOT_FOUND if the parent product does not exist. - * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - * than 1. + * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is missing or invalid. * * @param {Object} request * The request object that will be sent. * @param {string} request.parent - * Resource name of the product containing the reference images. + * The project in which the Product should be created. * * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. - * @param {number} [request.pageSize] - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. + * `projects/PROJECT_ID/locations/LOC_ID`. + * @param {Object} request.product + * The product to create. + * + * This object should have the same structure as [Product]{@link google.cloud.vision.v1.Product} + * @param {string} [request.productId] + * A user-supplied resource id for this Product. If set, the server will + * attempt to use this value as the resource id. If it is already in use, an + * error is returned with code ALREADY_EXISTS. Must be at most 128 characters + * long. It cannot contain the character `/`. * @param {Object} [options] * Optional parameters. You can override the default settings for this call, e.g, timeout, * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. - * @param {function(?Error, ?Array, ?Object, ?Object)} [callback] + * @param {function(?Error, ?Object)} [callback] * The function which will be called with the result of the API call. * - * The second parameter to the callback is Array of [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. - * - * When autoPaginate: false is specified through options, it contains the result - * in a single response. If the response indicates the next page exists, the third - * parameter is set to be used for the next request object. The fourth parameter keeps - * the raw response object of an object representing [ListReferenceImagesResponse]{@link google.cloud.vision.v1.ListReferenceImagesResponse}. + * The second parameter to the callback is an object representing [Product]{@link google.cloud.vision.v1.Product}. * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage} in a single response. - * The second element is the next request object if the response - * indicates the next page exists, or null. The third element is - * an object representing [ListReferenceImagesResponse]{@link google.cloud.vision.v1.ListReferenceImagesResponse}. - * + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. * The promise has a method named "cancel" which cancels the ongoing API call. * * @example @@ -780,22 +754,105 @@ class ProductSearchClient { * // optional auth parameters. * }); * - * // Iterate over all elements. - * const formattedParent = client.productPath('[PROJECT]', '[LOCATION]', '[PRODUCT]'); - * - * client.listReferenceImages({parent: formattedParent}) + * const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); + * const product = {}; + * const request = { + * parent: formattedParent, + * product: product, + * }; + * client.createProduct(request) * .then(responses => { - * const resources = responses[0]; - * for (const resource of resources) { - * // doThingsWith(resource) - * } + * const response = responses[0]; + * // doThingsWith(response) + * }) + * .catch(err => { + * console.error(err); + * }); + */ + createProduct(request, options, callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent, + }); + + return this._innerApiCalls.createProduct(request, options, callback); + } + + /** + * Lists products in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The project OR ProductSet from which Products should be listed. + * + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` + * @param {number} [request.pageSize] + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error, ?Array, ?Object, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is Array of [Product]{@link google.cloud.vision.v1.Product}. + * + * When autoPaginate: false is specified through options, it contains the result + * in a single response. If the response indicates the next page exists, the third + * parameter is set to be used for the next request object. The fourth parameter keeps + * the raw response object of an object representing [ListProductsResponse]{@link google.cloud.vision.v1.ListProductsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Product]{@link google.cloud.vision.v1.Product}. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [Product]{@link google.cloud.vision.v1.Product} in a single response. + * The second element is the next request object if the response + * indicates the next page exists, or null. The third element is + * an object representing [ListProductsResponse]{@link google.cloud.vision.v1.ListProductsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * + * const vision = require('@google-cloud/vision'); + * + * const client = new vision.v1.ProductSearchClient({ + * // optional auth parameters. + * }); + * + * // Iterate over all elements. + * const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); + * + * client.listProducts({parent: formattedParent}) + * .then(responses => { + * const resources = responses[0]; + * for (const resource of resources) { + * // doThingsWith(resource) + * } * }) * .catch(err => { * console.error(err); * }); * * // Or obtain the paged response. - * const formattedParent = client.productPath('[PROJECT]', '[LOCATION]', '[PRODUCT]'); + * const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); * * * const options = {autoPaginate: false}; @@ -811,16 +868,16 @@ class ProductSearchClient { * } * if (nextRequest) { * // Fetch the next page. - * return client.listReferenceImages(nextRequest, options).then(callback); + * return client.listProducts(nextRequest, options).then(callback); * } * } - * client.listReferenceImages({parent: formattedParent}, options) + * client.listProducts({parent: formattedParent}, options) * .then(callback) * .catch(err => { * console.error(err); * }); */ - listReferenceImages(request, options, callback) { + listProducts(request, options, callback) { if (options instanceof Function && callback === undefined) { callback = options; options = {}; @@ -834,13 +891,13 @@ class ProductSearchClient { parent: request.parent, }); - return this._innerApiCalls.listReferenceImages(request, options, callback); + return this._innerApiCalls.listProducts(request, options, callback); } /** - * Equivalent to {@link listReferenceImages}, but returns a NodeJS Stream object. + * Equivalent to {@link listProducts}, but returns a NodeJS Stream object. * - * This fetches the paged responses for {@link listReferenceImages} continuously + * This fetches the paged responses for {@link listProducts} continuously * and invokes the callback registered for 'data' event for each element in the * responses. * @@ -853,10 +910,10 @@ class ProductSearchClient { * @param {Object} request * The request object that will be sent. * @param {string} request.parent - * Resource name of the product containing the reference images. + * The project OR ProductSet from which Products should be listed. * - * Format is - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. + * Format: + * `projects/PROJECT_ID/locations/LOC_ID` * @param {number} [request.pageSize] * The maximum number of resources contained in the underlying API * response. If page streaming is performed per-resource, this @@ -867,7 +924,7 @@ class ProductSearchClient { * Optional parameters. You can override the default settings for this call, e.g, timeout, * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. * @returns {Stream} - * An object stream which emits an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage} on 'data' event. + * An object stream which emits an object representing [Product]{@link google.cloud.vision.v1.Product} on 'data' event. * * @example * @@ -877,48 +934,47 @@ class ProductSearchClient { * // optional auth parameters. * }); * - * const formattedParent = client.productPath('[PROJECT]', '[LOCATION]', '[PRODUCT]'); - * client.listReferenceImagesStream({parent: formattedParent}) + * const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); + * client.listProductsStream({parent: formattedParent}) * .on('data', element => { * // doThingsWith(element) * }).on('error', err => { * console.log(err); * }); */ - listReferenceImagesStream(request, options) { + listProductsStream(request, options) { options = options || {}; - return this._descriptors.page.listReferenceImages.createStream( - this._innerApiCalls.listReferenceImages, + return this._descriptors.page.listProducts.createStream( + this._innerApiCalls.listProducts, request, options ); } /** - * Gets information associated with a ReferenceImage. + * Gets information associated with a Product. * * Possible errors: * - * * Returns NOT_FOUND if the specified image does not exist. + * * Returns NOT_FOUND if the Product does not exist. * * @param {Object} request * The request object that will be sent. * @param {string} request.name - * The resource name of the ReferenceImage to get. + * Resource name of the Product to get. * * Format is: - * - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` * @param {Object} [options] * Optional parameters. You can override the default settings for this call, e.g, timeout, * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. * @param {function(?Error, ?Object)} [callback] * The function which will be called with the result of the API call. * - * The second parameter to the callback is an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. + * The second parameter to the callback is an object representing [Product]{@link google.cloud.vision.v1.Product}. * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. * The promise has a method named "cancel" which cancels the ongoing API call. * * @example @@ -929,8 +985,8 @@ class ProductSearchClient { * // optional auth parameters. * }); * - * const formattedName = client.referenceImagePath('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[REFERENCE_IMAGE]'); - * client.getReferenceImage({name: formattedName}) + * const formattedName = client.productPath('[PROJECT]', '[LOCATION]', '[PRODUCT]'); + * client.getProduct({name: formattedName}) * .then(responses => { * const response = responses[0]; * // doThingsWith(response) @@ -939,7 +995,7 @@ class ProductSearchClient { * console.error(err); * }); */ - getReferenceImage(request, options, callback) { + getProduct(request, options, callback) { if (options instanceof Function && callback === undefined) { callback = options; options = {}; @@ -953,30 +1009,101 @@ class ProductSearchClient { name: request.name, }); - return this._innerApiCalls.getReferenceImage(request, options, callback); + return this._innerApiCalls.getProduct(request, options, callback); } /** - * Permanently deletes a reference image. - * - * The image metadata will be deleted right away, but search queries - * against ProductSets containing the image may still work until all related - * caches are refreshed. + * Makes changes to a Product resource. + * Only the `display_name`, `description`, and `labels` fields can be updated + * right now. * - * The actual image files are not deleted from Google Cloud Storage. + * If labels are updated, the change will not be reflected in queries until + * the next index time. * * Possible errors: * - * * Returns NOT_FOUND if the reference image does not exist. + * * Returns NOT_FOUND if the Product does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + * missing from the request or longer than 4096 characters. + * * Returns INVALID_ARGUMENT if description is present in update_mask but is + * longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is present in update_mask. + * + * @param {Object} request + * The request object that will be sent. + * @param {Object} request.product + * The Product resource which replaces the one on the server. + * product.name is immutable. + * + * This object should have the same structure as [Product]{@link google.cloud.vision.v1.Product} + * @param {Object} [request.updateMask] + * The FieldMask that specifies which fields + * to update. + * If update_mask isn't specified, all mutable fields are to be updated. + * Valid mask paths include `product_labels`, `display_name`, and + * `description`. + * + * This object should have the same structure as [FieldMask]{@link google.protobuf.FieldMask} + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [Product]{@link google.cloud.vision.v1.Product}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Product]{@link google.cloud.vision.v1.Product}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * + * const vision = require('@google-cloud/vision'); + * + * const client = new vision.v1.ProductSearchClient({ + * // optional auth parameters. + * }); + * + * const product = {}; + * client.updateProduct({product: product}) + * .then(responses => { + * const response = responses[0]; + * // doThingsWith(response) + * }) + * .catch(err => { + * console.error(err); + * }); + */ + updateProduct(request, options, callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'product.name': request.product.name, + }); + + return this._innerApiCalls.updateProduct(request, options, callback); + } + + /** + * Permanently deletes a product and its reference images. + * + * Metadata of the product and all its images will be deleted right away, but + * search queries against ProductSets containing the product may still work + * until all related caches are refreshed. * * @param {Object} request * The request object that will be sent. * @param {string} request.name - * The resource name of the reference image to delete. + * Resource name of product to delete. * * Format is: - * - * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` * @param {Object} [options] * Optional parameters. You can override the default settings for this call, e.g, timeout, * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. @@ -993,12 +1120,12 @@ class ProductSearchClient { * // optional auth parameters. * }); * - * const formattedName = client.referenceImagePath('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[REFERENCE_IMAGE]'); - * client.deleteReferenceImage({name: formattedName}).catch(err => { + * const formattedName = client.productPath('[PROJECT]', '[LOCATION]', '[PRODUCT]'); + * client.deleteProduct({name: formattedName}).catch(err => { * console.error(err); * }); */ - deleteReferenceImage(request, options, callback) { + deleteProduct(request, options, callback) { if (options instanceof Function && callback === undefined) { callback = options; options = {}; @@ -1012,7 +1139,7 @@ class ProductSearchClient { name: request.name, }); - return this._innerApiCalls.deleteReferenceImage(request, options, callback); + return this._innerApiCalls.deleteProduct(request, options, callback); } /** @@ -1105,37 +1232,28 @@ class ProductSearchClient { } /** - * Creates and returns a new ProductSet resource. + * Permanently deletes a reference image. * - * Possible errors: + * The image metadata will be deleted right away, but search queries + * against ProductSets containing the image may still work until all related + * caches are refreshed. * - * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - * 4096 characters. + * The actual image files are not deleted from Google Cloud Storage. * * @param {Object} request * The request object that will be sent. - * @param {string} request.parent - * The project in which the ProductSet should be created. + * @param {string} request.name + * The resource name of the reference image to delete. * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. - * @param {Object} request.productSet - * The ProductSet to create. + * Format is: * - * This object should have the same structure as [ProductSet]{@link google.cloud.vision.v1.ProductSet} - * @param {string} [request.productSetId] - * A user-supplied resource id for this ProductSet. If set, the server will - * attempt to use this value as the resource id. If it is already in use, an - * error is returned with code ALREADY_EXISTS. Must be at most 128 characters - * long. It cannot contain the character `/`. + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` * @param {Object} [options] * Optional parameters. You can override the default settings for this call, e.g, timeout, * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] + * @param {function(?Error)} [callback] * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. + * @returns {Promise} - The promise which resolves when API call finishes. * The promise has a method named "cancel" which cancels the ongoing API call. * * @example @@ -1146,22 +1264,12 @@ class ProductSearchClient { * // optional auth parameters. * }); * - * const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); - * const productSet = {}; - * const request = { - * parent: formattedParent, - * productSet: productSet, - * }; - * client.createProductSet(request) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); + * const formattedName = client.referenceImagePath('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[REFERENCE_IMAGE]'); + * client.deleteReferenceImage({name: formattedName}).catch(err => { + * console.error(err); + * }); */ - createProductSet(request, options, callback) { + deleteReferenceImage(request, options, callback) { if (options instanceof Function && callback === undefined) { callback = options; options = {}; @@ -1172,26 +1280,28 @@ class ProductSearchClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - parent: request.parent, + name: request.name, }); - return this._innerApiCalls.createProductSet(request, options, callback); + return this._innerApiCalls.deleteReferenceImage(request, options, callback); } /** - * Lists ProductSets in an unspecified order. + * Lists reference images. * * Possible errors: * - * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + * * Returns NOT_FOUND if the parent product does not exist. + * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less * than 1. * * @param {Object} request * The request object that will be sent. * @param {string} request.parent - * The project from which ProductSets should be listed. + * Resource name of the product containing the reference images. * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. * @param {number} [request.pageSize] * The maximum number of resources contained in the underlying API * response. If page streaming is performed per-resource, this @@ -1204,20 +1314,20 @@ class ProductSearchClient { * @param {function(?Error, ?Array, ?Object, ?Object)} [callback] * The function which will be called with the result of the API call. * - * The second parameter to the callback is Array of [ProductSet]{@link google.cloud.vision.v1.ProductSet}. + * The second parameter to the callback is Array of [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. * * When autoPaginate: false is specified through options, it contains the result * in a single response. If the response indicates the next page exists, the third * parameter is set to be used for the next request object. The fourth parameter keeps - * the raw response object of an object representing [ListProductSetsResponse]{@link google.cloud.vision.v1.ListProductSetsResponse}. + * the raw response object of an object representing [ListReferenceImagesResponse]{@link google.cloud.vision.v1.ListReferenceImagesResponse}. * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [ProductSet]{@link google.cloud.vision.v1.ProductSet}. + * The first element of the array is Array of [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. * * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [ProductSet]{@link google.cloud.vision.v1.ProductSet} in a single response. + * The first element is Array of [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage} in a single response. * The second element is the next request object if the response * indicates the next page exists, or null. The third element is - * an object representing [ListProductSetsResponse]{@link google.cloud.vision.v1.ListProductSetsResponse}. + * an object representing [ListReferenceImagesResponse]{@link google.cloud.vision.v1.ListReferenceImagesResponse}. * * The promise has a method named "cancel" which cancels the ongoing API call. * @@ -1230,9 +1340,9 @@ class ProductSearchClient { * }); * * // Iterate over all elements. - * const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); + * const formattedParent = client.productPath('[PROJECT]', '[LOCATION]', '[PRODUCT]'); * - * client.listProductSets({parent: formattedParent}) + * client.listReferenceImages({parent: formattedParent}) * .then(responses => { * const resources = responses[0]; * for (const resource of resources) { @@ -1244,7 +1354,7 @@ class ProductSearchClient { * }); * * // Or obtain the paged response. - * const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); + * const formattedParent = client.productPath('[PROJECT]', '[LOCATION]', '[PRODUCT]'); * * * const options = {autoPaginate: false}; @@ -1260,16 +1370,16 @@ class ProductSearchClient { * } * if (nextRequest) { * // Fetch the next page. - * return client.listProductSets(nextRequest, options).then(callback); + * return client.listReferenceImages(nextRequest, options).then(callback); * } * } - * client.listProductSets({parent: formattedParent}, options) + * client.listReferenceImages({parent: formattedParent}, options) * .then(callback) * .catch(err => { * console.error(err); * }); */ - listProductSets(request, options, callback) { + listReferenceImages(request, options, callback) { if (options instanceof Function && callback === undefined) { callback = options; options = {}; @@ -1283,13 +1393,13 @@ class ProductSearchClient { parent: request.parent, }); - return this._innerApiCalls.listProductSets(request, options, callback); + return this._innerApiCalls.listReferenceImages(request, options, callback); } /** - * Equivalent to {@link listProductSets}, but returns a NodeJS Stream object. + * Equivalent to {@link listReferenceImages}, but returns a NodeJS Stream object. * - * This fetches the paged responses for {@link listProductSets} continuously + * This fetches the paged responses for {@link listReferenceImages} continuously * and invokes the callback registered for 'data' event for each element in the * responses. * @@ -1302,9 +1412,10 @@ class ProductSearchClient { * @param {Object} request * The request object that will be sent. * @param {string} request.parent - * The project from which ProductSets should be listed. + * Resource name of the product containing the reference images. * - * Format is `projects/PROJECT_ID/locations/LOC_ID`. + * Format is + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. * @param {number} [request.pageSize] * The maximum number of resources contained in the underlying API * response. If page streaming is performed per-resource, this @@ -1315,7 +1426,7 @@ class ProductSearchClient { * Optional parameters. You can override the default settings for this call, e.g, timeout, * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. * @returns {Stream} - * An object stream which emits an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet} on 'data' event. + * An object stream which emits an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage} on 'data' event. * * @example * @@ -1325,116 +1436,48 @@ class ProductSearchClient { * // optional auth parameters. * }); * - * const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); - * client.listProductSetsStream({parent: formattedParent}) + * const formattedParent = client.productPath('[PROJECT]', '[LOCATION]', '[PRODUCT]'); + * client.listReferenceImagesStream({parent: formattedParent}) * .on('data', element => { * // doThingsWith(element) * }).on('error', err => { * console.log(err); * }); */ - listProductSetsStream(request, options) { + listReferenceImagesStream(request, options) { options = options || {}; - return this._descriptors.page.listProductSets.createStream( - this._innerApiCalls.listProductSets, + return this._descriptors.page.listReferenceImages.createStream( + this._innerApiCalls.listReferenceImages, request, options ); } /** - * Gets information associated with a ProductSet. + * Gets information associated with a ReferenceImage. * * Possible errors: * - * * Returns NOT_FOUND if the ProductSet does not exist. + * * Returns NOT_FOUND if the specified image does not exist. * * @param {Object} request * The request object that will be sent. * @param {string} request.name - * Resource name of the ProductSet to get. + * The resource name of the ReferenceImage to get. * * Format is: - * `projects/PROJECT_ID/locations/LOG_ID/productSets/PRODUCT_SET_ID` - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. - * The promise has a method named "cancel" which cancels the ongoing API call. * - * @example - * - * const vision = require('@google-cloud/vision'); - * - * const client = new vision.v1.ProductSearchClient({ - * // optional auth parameters. - * }); - * - * const formattedName = client.productSetPath('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]'); - * client.getProductSet({name: formattedName}) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - getProductSet(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - options = {}; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - name: request.name, - }); - - return this._innerApiCalls.getProductSet(request, options, callback); - } - - /** - * Makes changes to a ProductSet resource. - * Only display_name can be updated currently. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but - * missing from the request or longer than 4096 characters. - * - * @param {Object} request - * The request object that will be sent. - * @param {Object} request.productSet - * The ProductSet resource which replaces the one on the server. - * - * This object should have the same structure as [ProductSet]{@link google.cloud.vision.v1.ProductSet} - * @param {Object} [request.updateMask] - * The FieldMask that specifies which fields to - * update. - * If update_mask isn't specified, all mutable fields are to be updated. - * Valid mask path is `display_name`. - * - * This object should have the same structure as [FieldMask]{@link google.protobuf.FieldMask} + * `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. * @param {Object} [options] * Optional parameters. You can override the default settings for this call, e.g, timeout, * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. * @param {function(?Error, ?Object)} [callback] * The function which will be called with the result of the API call. * - * The second parameter to the callback is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. + * The second parameter to the callback is an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProductSet]{@link google.cloud.vision.v1.ProductSet}. + * The first element of the array is an object representing [ReferenceImage]{@link google.cloud.vision.v1.ReferenceImage}. * The promise has a method named "cancel" which cancels the ongoing API call. * * @example @@ -1445,8 +1488,8 @@ class ProductSearchClient { * // optional auth parameters. * }); * - * const productSet = {}; - * client.updateProductSet({productSet: productSet}) + * const formattedName = client.referenceImagePath('[PROJECT]', '[LOCATION]', '[PRODUCT]', '[REFERENCE_IMAGE]'); + * client.getReferenceImage({name: formattedName}) * .then(responses => { * const response = responses[0]; * // doThingsWith(response) @@ -1455,62 +1498,7 @@ class ProductSearchClient { * console.error(err); * }); */ - updateProductSet(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - options = {}; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'product_set.name': request.productSet.name, - }); - - return this._innerApiCalls.updateProductSet(request, options, callback); - } - - /** - * Permanently deletes a ProductSet. Products and ReferenceImages in the - * ProductSet are not deleted. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name of the ProductSet to delete. - * - * Format is: - * `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. - * @param {function(?Error)} [callback] - * The function which will be called with the result of the API call. - * @returns {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const vision = require('@google-cloud/vision'); - * - * const client = new vision.v1.ProductSearchClient({ - * // optional auth parameters. - * }); - * - * const formattedName = client.productSetPath('[PROJECT]', '[LOCATION]', '[PRODUCT_SET]'); - * client.deleteProductSet({name: formattedName}).catch(err => { - * console.error(err); - * }); - */ - deleteProductSet(request, options, callback) { + getReferenceImage(request, options, callback) { if (options instanceof Function && callback === undefined) { callback = options; options = {}; @@ -1524,7 +1512,7 @@ class ProductSearchClient { name: request.name, }); - return this._innerApiCalls.deleteProductSet(request, options, callback); + return this._innerApiCalls.getReferenceImage(request, options, callback); } /** @@ -1599,10 +1587,6 @@ class ProductSearchClient { /** * Removes a Product from the specified ProductSet. * - * Possible errors: - * - * * Returns NOT_FOUND If the Product is not found under the ProductSet. - * * @param {Object} request * The request object that will be sent. * @param {string} request.name diff --git a/packages/google-cloud-vision/src/v1/product_search_client_config.json b/packages/google-cloud-vision/src/v1/product_search_client_config.json index 77e2a4fe331..c08955ff25c 100644 --- a/packages/google-cloud-vision/src/v1/product_search_client_config.json +++ b/packages/google-cloud-vision/src/v1/product_search_client_config.json @@ -3,7 +3,6 @@ "google.cloud.vision.v1.ProductSearch": { "retry_codes": { "idempotent": [ - "DEADLINE_EXCEEDED", "UNAVAILABLE" ], "non_idempotent": [] @@ -20,72 +19,72 @@ } }, "methods": { - "CreateProduct": { + "CreateProductSet": { "timeout_millis": 60000, "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, - "ListProducts": { + "ListProductSets": { "timeout_millis": 60000, "retry_codes_name": "idempotent", "retry_params_name": "default" }, - "GetProduct": { + "GetProductSet": { "timeout_millis": 60000, "retry_codes_name": "idempotent", "retry_params_name": "default" }, - "UpdateProduct": { + "UpdateProductSet": { "timeout_millis": 60000, "retry_codes_name": "idempotent", "retry_params_name": "default" }, - "DeleteProduct": { + "DeleteProductSet": { "timeout_millis": 60000, "retry_codes_name": "idempotent", "retry_params_name": "default" }, - "ListReferenceImages": { + "CreateProduct": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, - "GetReferenceImage": { + "ListProducts": { "timeout_millis": 60000, "retry_codes_name": "idempotent", "retry_params_name": "default" }, - "DeleteReferenceImage": { + "GetProduct": { "timeout_millis": 60000, "retry_codes_name": "idempotent", "retry_params_name": "default" }, - "CreateReferenceImage": { + "UpdateProduct": { "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", + "retry_codes_name": "idempotent", "retry_params_name": "default" }, - "CreateProductSet": { + "DeleteProduct": { "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", + "retry_codes_name": "idempotent", "retry_params_name": "default" }, - "ListProductSets": { + "CreateReferenceImage": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, - "GetProductSet": { + "DeleteReferenceImage": { "timeout_millis": 60000, "retry_codes_name": "idempotent", "retry_params_name": "default" }, - "UpdateProductSet": { + "ListReferenceImages": { "timeout_millis": 60000, "retry_codes_name": "idempotent", "retry_params_name": "default" }, - "DeleteProductSet": { + "GetReferenceImage": { "timeout_millis": 60000, "retry_codes_name": "idempotent", "retry_params_name": "default" diff --git a/packages/google-cloud-vision/src/v1p1beta1/image_annotator_client_config.json b/packages/google-cloud-vision/src/v1p1beta1/image_annotator_client_config.json index 55c365e3f80..91455d317ab 100644 --- a/packages/google-cloud-vision/src/v1p1beta1/image_annotator_client_config.json +++ b/packages/google-cloud-vision/src/v1p1beta1/image_annotator_client_config.json @@ -3,7 +3,6 @@ "google.cloud.vision.v1p1beta1.ImageAnnotator": { "retry_codes": { "idempotent": [ - "DEADLINE_EXCEEDED", "UNAVAILABLE" ], "non_idempotent": [] diff --git a/packages/google-cloud-vision/src/v1p2beta1/image_annotator_client_config.json b/packages/google-cloud-vision/src/v1p2beta1/image_annotator_client_config.json index 72dc25aa596..5e567cd375a 100644 --- a/packages/google-cloud-vision/src/v1p2beta1/image_annotator_client_config.json +++ b/packages/google-cloud-vision/src/v1p2beta1/image_annotator_client_config.json @@ -3,7 +3,6 @@ "google.cloud.vision.v1p2beta1.ImageAnnotator": { "retry_codes": { "idempotent": [ - "DEADLINE_EXCEEDED", "UNAVAILABLE" ], "non_idempotent": [] diff --git a/packages/google-cloud-vision/src/v1p3beta1/image_annotator_client_config.json b/packages/google-cloud-vision/src/v1p3beta1/image_annotator_client_config.json index 23e23cdf3d7..a9bcd1924dc 100644 --- a/packages/google-cloud-vision/src/v1p3beta1/image_annotator_client_config.json +++ b/packages/google-cloud-vision/src/v1p3beta1/image_annotator_client_config.json @@ -3,7 +3,6 @@ "google.cloud.vision.v1p3beta1.ImageAnnotator": { "retry_codes": { "idempotent": [ - "DEADLINE_EXCEEDED", "UNAVAILABLE" ], "non_idempotent": [] diff --git a/packages/google-cloud-vision/src/v1p3beta1/product_search_client_config.json b/packages/google-cloud-vision/src/v1p3beta1/product_search_client_config.json index 03793ddd14c..9bf6874e6c6 100644 --- a/packages/google-cloud-vision/src/v1p3beta1/product_search_client_config.json +++ b/packages/google-cloud-vision/src/v1p3beta1/product_search_client_config.json @@ -3,7 +3,6 @@ "google.cloud.vision.v1p3beta1.ProductSearch": { "retry_codes": { "idempotent": [ - "DEADLINE_EXCEEDED", "UNAVAILABLE" ], "non_idempotent": [] diff --git a/packages/google-cloud-vision/src/v1p4beta1/image_annotator_client_config.json b/packages/google-cloud-vision/src/v1p4beta1/image_annotator_client_config.json index 9666bd1f923..f0487937113 100644 --- a/packages/google-cloud-vision/src/v1p4beta1/image_annotator_client_config.json +++ b/packages/google-cloud-vision/src/v1p4beta1/image_annotator_client_config.json @@ -3,7 +3,6 @@ "google.cloud.vision.v1p4beta1.ImageAnnotator": { "retry_codes": { "idempotent": [ - "DEADLINE_EXCEEDED", "UNAVAILABLE" ], "non_idempotent": [] diff --git a/packages/google-cloud-vision/src/v1p4beta1/product_search_client_config.json b/packages/google-cloud-vision/src/v1p4beta1/product_search_client_config.json index 37cb6d2a79a..bd8ea9ad253 100644 --- a/packages/google-cloud-vision/src/v1p4beta1/product_search_client_config.json +++ b/packages/google-cloud-vision/src/v1p4beta1/product_search_client_config.json @@ -3,7 +3,6 @@ "google.cloud.vision.v1p4beta1.ProductSearch": { "retry_codes": { "idempotent": [ - "DEADLINE_EXCEEDED", "UNAVAILABLE" ], "non_idempotent": [] diff --git a/packages/google-cloud-vision/synth.metadata b/packages/google-cloud-vision/synth.metadata index 5f3a5bbafb3..4ba6b44ade1 100644 --- a/packages/google-cloud-vision/synth.metadata +++ b/packages/google-cloud-vision/synth.metadata @@ -1,26 +1,26 @@ { - "updateTime": "2019-04-27T11:22:48.245286Z", + "updateTime": "2019-05-08T12:13:36.416401Z", "sources": [ { "generator": { "name": "artman", - "version": "0.17.1", - "dockerImage": "googleapis/artman@sha256:a40ca4dd4ef031c0ded4df4909ffdf7b3f20d29b23e682ef991eb60ba0ca6025" + "version": "0.19.0", + "dockerImage": "googleapis/artman@sha256:d3df563538225ac6caac45d8ad86499500211d1bcb2536955a6dbda15e1b368e" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "808110e242c682d7ac2bab6d9c49fc3bf72d7604", - "internalRef": "245313728" + "sha": "51145ff7812d2bb44c1219d0b76dac92a8bd94b2", + "internalRef": "247143125" } }, { "template": { "name": "node_library", "origin": "synthtool.gcp", - "version": "2019.4.10" + "version": "2019.5.2" } } ], diff --git a/packages/google-cloud-vision/test/gapic-v1.js b/packages/google-cloud-vision/test/gapic-v1.js index 0112f2ba084..cb49a4fbb4a 100644 --- a/packages/google-cloud-vision/test/gapic-v1.js +++ b/packages/google-cloud-vision/test/gapic-v1.js @@ -22,9 +22,304 @@ const FAKE_STATUS_CODE = 1; const error = new Error(); error.code = FAKE_STATUS_CODE; +describe('ImageAnnotatorClient', () => { + describe('batchAnnotateImages', () => { + it('invokes batchAnnotateImages without error', done => { + const client = new visionModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + + // Mock request + const requests = []; + const request = { + requests: requests, + }; + + // Mock response + const expectedResponse = {}; + + // Mock Grpc layer + client._innerApiCalls.batchAnnotateImages = mockSimpleGrpcMethod( + request, + expectedResponse + ); + + client.batchAnnotateImages(request, (err, response) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes batchAnnotateImages with error', done => { + const client = new visionModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + + // Mock request + const requests = []; + const request = { + requests: requests, + }; + + // Mock Grpc layer + client._innerApiCalls.batchAnnotateImages = mockSimpleGrpcMethod( + request, + null, + error + ); + + client.batchAnnotateImages(request, (err, response) => { + assert(err instanceof Error); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }); + }); + }); + + describe('batchAnnotateFiles', () => { + it('invokes batchAnnotateFiles without error', done => { + const client = new visionModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + + // Mock request + const requests = []; + const request = { + requests: requests, + }; + + // Mock response + const expectedResponse = {}; + + // Mock Grpc layer + client._innerApiCalls.batchAnnotateFiles = mockSimpleGrpcMethod( + request, + expectedResponse + ); + + client.batchAnnotateFiles(request, (err, response) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes batchAnnotateFiles with error', done => { + const client = new visionModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + + // Mock request + const requests = []; + const request = { + requests: requests, + }; + + // Mock Grpc layer + client._innerApiCalls.batchAnnotateFiles = mockSimpleGrpcMethod( + request, + null, + error + ); + + client.batchAnnotateFiles(request, (err, response) => { + assert(err instanceof Error); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }); + }); + }); + + describe('asyncBatchAnnotateImages', function() { + it('invokes asyncBatchAnnotateImages without error', done => { + const client = new visionModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + + // Mock request + const requests = []; + const outputConfig = {}; + const request = { + requests: requests, + outputConfig: outputConfig, + }; + + // Mock response + const expectedResponse = {}; + + // Mock Grpc layer + client._innerApiCalls.asyncBatchAnnotateImages = mockLongRunningGrpcMethod( + request, + expectedResponse + ); + + client + .asyncBatchAnnotateImages(request) + .then(responses => { + const operation = responses[0]; + return operation.promise(); + }) + .then(responses => { + assert.deepStrictEqual(responses[0], expectedResponse); + done(); + }) + .catch(err => { + done(err); + }); + }); + + it('invokes asyncBatchAnnotateImages with error', done => { + const client = new visionModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + + // Mock request + const requests = []; + const outputConfig = {}; + const request = { + requests: requests, + outputConfig: outputConfig, + }; + + // Mock Grpc layer + client._innerApiCalls.asyncBatchAnnotateImages = mockLongRunningGrpcMethod( + request, + null, + error + ); + + client + .asyncBatchAnnotateImages(request) + .then(responses => { + const operation = responses[0]; + return operation.promise(); + }) + .then(() => { + assert.fail(); + }) + .catch(err => { + assert(err instanceof Error); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + done(); + }); + }); + + it('has longrunning decoder functions', () => { + const client = new visionModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert( + client._descriptors.longrunning.asyncBatchAnnotateImages + .responseDecoder instanceof Function + ); + assert( + client._descriptors.longrunning.asyncBatchAnnotateImages + .metadataDecoder instanceof Function + ); + }); + }); + + describe('asyncBatchAnnotateFiles', function() { + it('invokes asyncBatchAnnotateFiles without error', done => { + const client = new visionModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + + // Mock request + const requests = []; + const request = { + requests: requests, + }; + + // Mock response + const expectedResponse = {}; + + // Mock Grpc layer + client._innerApiCalls.asyncBatchAnnotateFiles = mockLongRunningGrpcMethod( + request, + expectedResponse + ); + + client + .asyncBatchAnnotateFiles(request) + .then(responses => { + const operation = responses[0]; + return operation.promise(); + }) + .then(responses => { + assert.deepStrictEqual(responses[0], expectedResponse); + done(); + }) + .catch(err => { + done(err); + }); + }); + + it('invokes asyncBatchAnnotateFiles with error', done => { + const client = new visionModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + + // Mock request + const requests = []; + const request = { + requests: requests, + }; + + // Mock Grpc layer + client._innerApiCalls.asyncBatchAnnotateFiles = mockLongRunningGrpcMethod( + request, + null, + error + ); + + client + .asyncBatchAnnotateFiles(request) + .then(responses => { + const operation = responses[0]; + return operation.promise(); + }) + .then(() => { + assert.fail(); + }) + .catch(err => { + assert(err instanceof Error); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + done(); + }); + }); + + it('has longrunning decoder functions', () => { + const client = new visionModule.v1.ImageAnnotatorClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert( + client._descriptors.longrunning.asyncBatchAnnotateFiles + .responseDecoder instanceof Function + ); + assert( + client._descriptors.longrunning.asyncBatchAnnotateFiles + .metadataDecoder instanceof Function + ); + }); + }); +}); describe('ProductSearchClient', () => { - describe('createProduct', () => { - it('invokes createProduct without error', done => { + describe('createProductSet', () => { + it('invokes createProductSet without error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -32,38 +327,34 @@ describe('ProductSearchClient', () => { // Mock request const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); - const product = {}; + const productSet = {}; const request = { parent: formattedParent, - product: product, + productSet: productSet, }; // Mock response const name = 'name3373707'; const displayName = 'displayName1615086568'; - const description = 'description-1724546052'; - const productCategory = 'productCategory-1607451058'; const expectedResponse = { name: name, displayName: displayName, - description: description, - productCategory: productCategory, }; // Mock Grpc layer - client._innerApiCalls.createProduct = mockSimpleGrpcMethod( + client._innerApiCalls.createProductSet = mockSimpleGrpcMethod( request, expectedResponse ); - client.createProduct(request, (err, response) => { + client.createProductSet(request, (err, response) => { assert.ifError(err); assert.deepStrictEqual(response, expectedResponse); done(); }); }); - it('invokes createProduct with error', done => { + it('invokes createProductSet with error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -71,20 +362,20 @@ describe('ProductSearchClient', () => { // Mock request const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); - const product = {}; + const productSet = {}; const request = { parent: formattedParent, - product: product, + productSet: productSet, }; // Mock Grpc layer - client._innerApiCalls.createProduct = mockSimpleGrpcMethod( + client._innerApiCalls.createProductSet = mockSimpleGrpcMethod( request, null, error ); - client.createProduct(request, (err, response) => { + client.createProductSet(request, (err, response) => { assert(err instanceof Error); assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); @@ -93,8 +384,8 @@ describe('ProductSearchClient', () => { }); }); - describe('listProducts', () => { - it('invokes listProducts without error', done => { + describe('listProductSets', () => { + it('invokes listProductSets without error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -108,31 +399,31 @@ describe('ProductSearchClient', () => { // Mock response const nextPageToken = ''; - const productsElement = {}; - const products = [productsElement]; + const productSetsElement = {}; + const productSets = [productSetsElement]; const expectedResponse = { nextPageToken: nextPageToken, - products: products, + productSets: productSets, }; // Mock Grpc layer - client._innerApiCalls.listProducts = ( + client._innerApiCalls.listProductSets = ( actualRequest, options, callback ) => { assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse.products); + callback(null, expectedResponse.productSets); }; - client.listProducts(request, (err, response) => { + client.listProductSets(request, (err, response) => { assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse.products); + assert.deepStrictEqual(response, expectedResponse.productSets); done(); }); }); - it('invokes listProducts with error', done => { + it('invokes listProductSets with error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -145,13 +436,13 @@ describe('ProductSearchClient', () => { }; // Mock Grpc layer - client._innerApiCalls.listProducts = mockSimpleGrpcMethod( + client._innerApiCalls.listProductSets = mockSimpleGrpcMethod( request, null, error ); - client.listProducts(request, (err, response) => { + client.listProductSets(request, (err, response) => { assert(err instanceof Error); assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); @@ -160,18 +451,18 @@ describe('ProductSearchClient', () => { }); }); - describe('getProduct', () => { - it('invokes getProduct without error', done => { + describe('getProductSet', () => { + it('invokes getProductSet without error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const formattedName = client.productPath( + const formattedName = client.productSetPath( '[PROJECT]', '[LOCATION]', - '[PRODUCT]' + '[PRODUCT_SET]' ); const request = { name: formattedName, @@ -180,52 +471,48 @@ describe('ProductSearchClient', () => { // Mock response const name2 = 'name2-1052831874'; const displayName = 'displayName1615086568'; - const description = 'description-1724546052'; - const productCategory = 'productCategory-1607451058'; const expectedResponse = { name: name2, displayName: displayName, - description: description, - productCategory: productCategory, }; // Mock Grpc layer - client._innerApiCalls.getProduct = mockSimpleGrpcMethod( + client._innerApiCalls.getProductSet = mockSimpleGrpcMethod( request, expectedResponse ); - client.getProduct(request, (err, response) => { + client.getProductSet(request, (err, response) => { assert.ifError(err); assert.deepStrictEqual(response, expectedResponse); done(); }); }); - it('invokes getProduct with error', done => { + it('invokes getProductSet with error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const formattedName = client.productPath( + const formattedName = client.productSetPath( '[PROJECT]', '[LOCATION]', - '[PRODUCT]' + '[PRODUCT_SET]' ); const request = { name: formattedName, }; // Mock Grpc layer - client._innerApiCalls.getProduct = mockSimpleGrpcMethod( + client._innerApiCalls.getProductSet = mockSimpleGrpcMethod( request, null, error ); - client.getProduct(request, (err, response) => { + client.getProductSet(request, (err, response) => { assert(err instanceof Error); assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); @@ -234,64 +521,60 @@ describe('ProductSearchClient', () => { }); }); - describe('updateProduct', () => { - it('invokes updateProduct without error', done => { + describe('updateProductSet', () => { + it('invokes updateProductSet without error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const product = {}; + const productSet = {}; const request = { - product: product, + productSet: productSet, }; // Mock response const name = 'name3373707'; const displayName = 'displayName1615086568'; - const description = 'description-1724546052'; - const productCategory = 'productCategory-1607451058'; const expectedResponse = { name: name, displayName: displayName, - description: description, - productCategory: productCategory, }; // Mock Grpc layer - client._innerApiCalls.updateProduct = mockSimpleGrpcMethod( + client._innerApiCalls.updateProductSet = mockSimpleGrpcMethod( request, expectedResponse ); - client.updateProduct(request, (err, response) => { + client.updateProductSet(request, (err, response) => { assert.ifError(err); assert.deepStrictEqual(response, expectedResponse); done(); }); }); - it('invokes updateProduct with error', done => { + it('invokes updateProductSet with error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const product = {}; + const productSet = {}; const request = { - product: product, + productSet: productSet, }; // Mock Grpc layer - client._innerApiCalls.updateProduct = mockSimpleGrpcMethod( + client._innerApiCalls.updateProductSet = mockSimpleGrpcMethod( request, null, error ); - client.updateProduct(request, (err, response) => { + client.updateProductSet(request, (err, response) => { assert(err instanceof Error); assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); @@ -300,56 +583,56 @@ describe('ProductSearchClient', () => { }); }); - describe('deleteProduct', () => { - it('invokes deleteProduct without error', done => { + describe('deleteProductSet', () => { + it('invokes deleteProductSet without error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const formattedName = client.productPath( + const formattedName = client.productSetPath( '[PROJECT]', '[LOCATION]', - '[PRODUCT]' + '[PRODUCT_SET]' ); const request = { name: formattedName, }; // Mock Grpc layer - client._innerApiCalls.deleteProduct = mockSimpleGrpcMethod(request); + client._innerApiCalls.deleteProductSet = mockSimpleGrpcMethod(request); - client.deleteProduct(request, err => { + client.deleteProductSet(request, err => { assert.ifError(err); done(); }); }); - it('invokes deleteProduct with error', done => { + it('invokes deleteProductSet with error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const formattedName = client.productPath( + const formattedName = client.productSetPath( '[PROJECT]', '[LOCATION]', - '[PRODUCT]' + '[PRODUCT_SET]' ); const request = { name: formattedName, }; // Mock Grpc layer - client._innerApiCalls.deleteProduct = mockSimpleGrpcMethod( + client._innerApiCalls.deleteProductSet = mockSimpleGrpcMethod( request, null, error ); - client.deleteProduct(request, err => { + client.deleteProductSet(request, err => { assert(err instanceof Error); assert.strictEqual(err.code, FAKE_STATUS_CODE); done(); @@ -357,75 +640,68 @@ describe('ProductSearchClient', () => { }); }); - describe('listReferenceImages', () => { - it('invokes listReferenceImages without error', done => { + describe('createProduct', () => { + it('invokes createProduct without error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const formattedParent = client.productPath( - '[PROJECT]', - '[LOCATION]', - '[PRODUCT]' - ); + const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); + const product = {}; const request = { parent: formattedParent, + product: product, }; // Mock response - const pageSize = 883849137; - const nextPageToken = ''; - const referenceImagesElement = {}; - const referenceImages = [referenceImagesElement]; + const name = 'name3373707'; + const displayName = 'displayName1615086568'; + const description = 'description-1724546052'; + const productCategory = 'productCategory-1607451058'; const expectedResponse = { - pageSize: pageSize, - nextPageToken: nextPageToken, - referenceImages: referenceImages, + name: name, + displayName: displayName, + description: description, + productCategory: productCategory, }; // Mock Grpc layer - client._innerApiCalls.listReferenceImages = ( - actualRequest, - options, - callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse.referenceImages); - }; + client._innerApiCalls.createProduct = mockSimpleGrpcMethod( + request, + expectedResponse + ); - client.listReferenceImages(request, (err, response) => { + client.createProduct(request, (err, response) => { assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse.referenceImages); + assert.deepStrictEqual(response, expectedResponse); done(); }); }); - it('invokes listReferenceImages with error', done => { + it('invokes createProduct with error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const formattedParent = client.productPath( - '[PROJECT]', - '[LOCATION]', - '[PRODUCT]' - ); + const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); + const product = {}; const request = { parent: formattedParent, + product: product, }; // Mock Grpc layer - client._innerApiCalls.listReferenceImages = mockSimpleGrpcMethod( + client._innerApiCalls.createProduct = mockSimpleGrpcMethod( request, null, error ); - client.listReferenceImages(request, (err, response) => { + client.createProduct(request, (err, response) => { assert(err instanceof Error); assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); @@ -434,70 +710,65 @@ describe('ProductSearchClient', () => { }); }); - describe('getReferenceImage', () => { - it('invokes getReferenceImage without error', done => { + describe('listProducts', () => { + it('invokes listProducts without error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const formattedName = client.referenceImagePath( - '[PROJECT]', - '[LOCATION]', - '[PRODUCT]', - '[REFERENCE_IMAGE]' - ); + const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); const request = { - name: formattedName, + parent: formattedParent, }; // Mock response - const name2 = 'name2-1052831874'; - const uri = 'uri116076'; + const nextPageToken = ''; + const productsElement = {}; + const products = [productsElement]; const expectedResponse = { - name: name2, - uri: uri, + nextPageToken: nextPageToken, + products: products, }; // Mock Grpc layer - client._innerApiCalls.getReferenceImage = mockSimpleGrpcMethod( - request, - expectedResponse - ); + client._innerApiCalls.listProducts = ( + actualRequest, + options, + callback + ) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse.products); + }; - client.getReferenceImage(request, (err, response) => { + client.listProducts(request, (err, response) => { assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); + assert.deepStrictEqual(response, expectedResponse.products); done(); }); }); - it('invokes getReferenceImage with error', done => { + it('invokes listProducts with error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const formattedName = client.referenceImagePath( - '[PROJECT]', - '[LOCATION]', - '[PRODUCT]', - '[REFERENCE_IMAGE]' - ); + const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); const request = { - name: formattedName, + parent: formattedParent, }; // Mock Grpc layer - client._innerApiCalls.getReferenceImage = mockSimpleGrpcMethod( + client._innerApiCalls.listProducts = mockSimpleGrpcMethod( request, null, error ); - client.getReferenceImage(request, (err, response) => { + client.listProducts(request, (err, response) => { assert(err instanceof Error); assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); @@ -506,133 +777,138 @@ describe('ProductSearchClient', () => { }); }); - describe('deleteReferenceImage', () => { - it('invokes deleteReferenceImage without error', done => { + describe('getProduct', () => { + it('invokes getProduct without error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const formattedName = client.referenceImagePath( + const formattedName = client.productPath( '[PROJECT]', '[LOCATION]', - '[PRODUCT]', - '[REFERENCE_IMAGE]' + '[PRODUCT]' ); const request = { name: formattedName, }; + // Mock response + const name2 = 'name2-1052831874'; + const displayName = 'displayName1615086568'; + const description = 'description-1724546052'; + const productCategory = 'productCategory-1607451058'; + const expectedResponse = { + name: name2, + displayName: displayName, + description: description, + productCategory: productCategory, + }; + // Mock Grpc layer - client._innerApiCalls.deleteReferenceImage = mockSimpleGrpcMethod( - request + client._innerApiCalls.getProduct = mockSimpleGrpcMethod( + request, + expectedResponse ); - client.deleteReferenceImage(request, err => { + client.getProduct(request, (err, response) => { assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); done(); }); }); - it('invokes deleteReferenceImage with error', done => { + it('invokes getProduct with error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const formattedName = client.referenceImagePath( + const formattedName = client.productPath( '[PROJECT]', '[LOCATION]', - '[PRODUCT]', - '[REFERENCE_IMAGE]' + '[PRODUCT]' ); const request = { name: formattedName, }; // Mock Grpc layer - client._innerApiCalls.deleteReferenceImage = mockSimpleGrpcMethod( + client._innerApiCalls.getProduct = mockSimpleGrpcMethod( request, null, error ); - client.deleteReferenceImage(request, err => { + client.getProduct(request, (err, response) => { assert(err instanceof Error); assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); done(); }); }); }); - describe('createReferenceImage', () => { - it('invokes createReferenceImage without error', done => { + describe('updateProduct', () => { + it('invokes updateProduct without error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const formattedParent = client.productPath( - '[PROJECT]', - '[LOCATION]', - '[PRODUCT]' - ); - const referenceImage = {}; + const product = {}; const request = { - parent: formattedParent, - referenceImage: referenceImage, + product: product, }; // Mock response const name = 'name3373707'; - const uri = 'uri116076'; + const displayName = 'displayName1615086568'; + const description = 'description-1724546052'; + const productCategory = 'productCategory-1607451058'; const expectedResponse = { name: name, - uri: uri, + displayName: displayName, + description: description, + productCategory: productCategory, }; // Mock Grpc layer - client._innerApiCalls.createReferenceImage = mockSimpleGrpcMethod( + client._innerApiCalls.updateProduct = mockSimpleGrpcMethod( request, expectedResponse ); - client.createReferenceImage(request, (err, response) => { + client.updateProduct(request, (err, response) => { assert.ifError(err); assert.deepStrictEqual(response, expectedResponse); done(); }); }); - it('invokes createReferenceImage with error', done => { + it('invokes updateProduct with error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const formattedParent = client.productPath( - '[PROJECT]', - '[LOCATION]', - '[PRODUCT]' - ); - const referenceImage = {}; + const product = {}; const request = { - parent: formattedParent, - referenceImage: referenceImage, + product: product, }; // Mock Grpc layer - client._innerApiCalls.createReferenceImage = mockSimpleGrpcMethod( + client._innerApiCalls.updateProduct = mockSimpleGrpcMethod( request, null, error ); - client.createReferenceImage(request, (err, response) => { + client.updateProduct(request, (err, response) => { assert(err instanceof Error); assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); @@ -641,131 +917,129 @@ describe('ProductSearchClient', () => { }); }); - describe('createProductSet', () => { - it('invokes createProductSet without error', done => { + describe('deleteProduct', () => { + it('invokes deleteProduct without error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); - const productSet = {}; + const formattedName = client.productPath( + '[PROJECT]', + '[LOCATION]', + '[PRODUCT]' + ); const request = { - parent: formattedParent, - productSet: productSet, - }; - - // Mock response - const name = 'name3373707'; - const displayName = 'displayName1615086568'; - const expectedResponse = { - name: name, - displayName: displayName, + name: formattedName, }; // Mock Grpc layer - client._innerApiCalls.createProductSet = mockSimpleGrpcMethod( - request, - expectedResponse - ); + client._innerApiCalls.deleteProduct = mockSimpleGrpcMethod(request); - client.createProductSet(request, (err, response) => { + client.deleteProduct(request, err => { assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); done(); }); }); - it('invokes createProductSet with error', done => { + it('invokes deleteProduct with error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); - const productSet = {}; + const formattedName = client.productPath( + '[PROJECT]', + '[LOCATION]', + '[PRODUCT]' + ); const request = { - parent: formattedParent, - productSet: productSet, + name: formattedName, }; // Mock Grpc layer - client._innerApiCalls.createProductSet = mockSimpleGrpcMethod( + client._innerApiCalls.deleteProduct = mockSimpleGrpcMethod( request, null, error ); - client.createProductSet(request, (err, response) => { + client.deleteProduct(request, err => { assert(err instanceof Error); assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); done(); }); }); }); - describe('listProductSets', () => { - it('invokes listProductSets without error', done => { + describe('createReferenceImage', () => { + it('invokes createReferenceImage without error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); + const formattedParent = client.productPath( + '[PROJECT]', + '[LOCATION]', + '[PRODUCT]' + ); + const referenceImage = {}; const request = { parent: formattedParent, + referenceImage: referenceImage, }; // Mock response - const nextPageToken = ''; - const productSetsElement = {}; - const productSets = [productSetsElement]; + const name = 'name3373707'; + const uri = 'uri116076'; const expectedResponse = { - nextPageToken: nextPageToken, - productSets: productSets, + name: name, + uri: uri, }; // Mock Grpc layer - client._innerApiCalls.listProductSets = ( - actualRequest, - options, - callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse.productSets); - }; + client._innerApiCalls.createReferenceImage = mockSimpleGrpcMethod( + request, + expectedResponse + ); - client.listProductSets(request, (err, response) => { + client.createReferenceImage(request, (err, response) => { assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse.productSets); + assert.deepStrictEqual(response, expectedResponse); done(); }); }); - it('invokes listProductSets with error', done => { + it('invokes createReferenceImage with error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); + const formattedParent = client.productPath( + '[PROJECT]', + '[LOCATION]', + '[PRODUCT]' + ); + const referenceImage = {}; const request = { parent: formattedParent, + referenceImage: referenceImage, }; // Mock Grpc layer - client._innerApiCalls.listProductSets = mockSimpleGrpcMethod( + client._innerApiCalls.createReferenceImage = mockSimpleGrpcMethod( request, null, error ); - client.listProductSets(request, (err, response) => { + client.createReferenceImage(request, (err, response) => { assert(err instanceof Error); assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); @@ -774,130 +1048,136 @@ describe('ProductSearchClient', () => { }); }); - describe('getProductSet', () => { - it('invokes getProductSet without error', done => { + describe('deleteReferenceImage', () => { + it('invokes deleteReferenceImage without error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const formattedName = client.productSetPath( + const formattedName = client.referenceImagePath( '[PROJECT]', '[LOCATION]', - '[PRODUCT_SET]' + '[PRODUCT]', + '[REFERENCE_IMAGE]' ); const request = { name: formattedName, }; - // Mock response - const name2 = 'name2-1052831874'; - const displayName = 'displayName1615086568'; - const expectedResponse = { - name: name2, - displayName: displayName, - }; - // Mock Grpc layer - client._innerApiCalls.getProductSet = mockSimpleGrpcMethod( - request, - expectedResponse + client._innerApiCalls.deleteReferenceImage = mockSimpleGrpcMethod( + request ); - client.getProductSet(request, (err, response) => { + client.deleteReferenceImage(request, err => { assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); done(); }); }); - it('invokes getProductSet with error', done => { + it('invokes deleteReferenceImage with error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const formattedName = client.productSetPath( + const formattedName = client.referenceImagePath( '[PROJECT]', '[LOCATION]', - '[PRODUCT_SET]' + '[PRODUCT]', + '[REFERENCE_IMAGE]' ); const request = { name: formattedName, }; // Mock Grpc layer - client._innerApiCalls.getProductSet = mockSimpleGrpcMethod( + client._innerApiCalls.deleteReferenceImage = mockSimpleGrpcMethod( request, null, error ); - client.getProductSet(request, (err, response) => { + client.deleteReferenceImage(request, err => { assert(err instanceof Error); assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); done(); }); }); }); - describe('updateProductSet', () => { - it('invokes updateProductSet without error', done => { + describe('listReferenceImages', () => { + it('invokes listReferenceImages without error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const productSet = {}; + const formattedParent = client.productPath( + '[PROJECT]', + '[LOCATION]', + '[PRODUCT]' + ); const request = { - productSet: productSet, + parent: formattedParent, }; // Mock response - const name = 'name3373707'; - const displayName = 'displayName1615086568'; + const pageSize = 883849137; + const nextPageToken = ''; + const referenceImagesElement = {}; + const referenceImages = [referenceImagesElement]; const expectedResponse = { - name: name, - displayName: displayName, + pageSize: pageSize, + nextPageToken: nextPageToken, + referenceImages: referenceImages, }; // Mock Grpc layer - client._innerApiCalls.updateProductSet = mockSimpleGrpcMethod( - request, - expectedResponse - ); + client._innerApiCalls.listReferenceImages = ( + actualRequest, + options, + callback + ) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse.referenceImages); + }; - client.updateProductSet(request, (err, response) => { + client.listReferenceImages(request, (err, response) => { assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); + assert.deepStrictEqual(response, expectedResponse.referenceImages); done(); }); }); - it('invokes updateProductSet with error', done => { + it('invokes listReferenceImages with error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const productSet = {}; + const formattedParent = client.productPath( + '[PROJECT]', + '[LOCATION]', + '[PRODUCT]' + ); const request = { - productSet: productSet, + parent: formattedParent, }; // Mock Grpc layer - client._innerApiCalls.updateProductSet = mockSimpleGrpcMethod( + client._innerApiCalls.listReferenceImages = mockSimpleGrpcMethod( request, null, error ); - client.updateProductSet(request, (err, response) => { + client.listReferenceImages(request, (err, response) => { assert(err instanceof Error); assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); @@ -906,58 +1186,73 @@ describe('ProductSearchClient', () => { }); }); - describe('deleteProductSet', () => { - it('invokes deleteProductSet without error', done => { + describe('getReferenceImage', () => { + it('invokes getReferenceImage without error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const formattedName = client.productSetPath( + const formattedName = client.referenceImagePath( '[PROJECT]', '[LOCATION]', - '[PRODUCT_SET]' + '[PRODUCT]', + '[REFERENCE_IMAGE]' ); const request = { name: formattedName, }; + // Mock response + const name2 = 'name2-1052831874'; + const uri = 'uri116076'; + const expectedResponse = { + name: name2, + uri: uri, + }; + // Mock Grpc layer - client._innerApiCalls.deleteProductSet = mockSimpleGrpcMethod(request); + client._innerApiCalls.getReferenceImage = mockSimpleGrpcMethod( + request, + expectedResponse + ); - client.deleteProductSet(request, err => { + client.getReferenceImage(request, (err, response) => { assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); done(); }); }); - it('invokes deleteProductSet with error', done => { + it('invokes getReferenceImage with error', done => { const client = new visionModule.v1.ProductSearchClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - const formattedName = client.productSetPath( + const formattedName = client.referenceImagePath( '[PROJECT]', '[LOCATION]', - '[PRODUCT_SET]' + '[PRODUCT]', + '[REFERENCE_IMAGE]' ); const request = { name: formattedName, }; // Mock Grpc layer - client._innerApiCalls.deleteProductSet = mockSimpleGrpcMethod( + client._innerApiCalls.getReferenceImage = mockSimpleGrpcMethod( request, null, error ); - client.deleteProductSet(request, err => { + client.getReferenceImage(request, (err, response) => { assert(err instanceof Error); assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); done(); }); }); @@ -1272,152 +1567,6 @@ describe('ProductSearchClient', () => { }); }); }); -describe('ImageAnnotatorClient', () => { - describe('batchAnnotateImages', () => { - it('invokes batchAnnotateImages without error', done => { - const client = new visionModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - - // Mock request - const requests = []; - const request = { - requests: requests, - }; - - // Mock response - const expectedResponse = {}; - - // Mock Grpc layer - client._innerApiCalls.batchAnnotateImages = mockSimpleGrpcMethod( - request, - expectedResponse - ); - - client.batchAnnotateImages(request, (err, response) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes batchAnnotateImages with error', done => { - const client = new visionModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - - // Mock request - const requests = []; - const request = { - requests: requests, - }; - - // Mock Grpc layer - client._innerApiCalls.batchAnnotateImages = mockSimpleGrpcMethod( - request, - null, - error - ); - - client.batchAnnotateImages(request, (err, response) => { - assert(err instanceof Error); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - - describe('asyncBatchAnnotateFiles', function() { - it('invokes asyncBatchAnnotateFiles without error', done => { - const client = new visionModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - - // Mock request - const requests = []; - const request = { - requests: requests, - }; - - // Mock response - const expectedResponse = {}; - - // Mock Grpc layer - client._innerApiCalls.asyncBatchAnnotateFiles = mockLongRunningGrpcMethod( - request, - expectedResponse - ); - - client - .asyncBatchAnnotateFiles(request) - .then(responses => { - const operation = responses[0]; - return operation.promise(); - }) - .then(responses => { - assert.deepStrictEqual(responses[0], expectedResponse); - done(); - }) - .catch(err => { - done(err); - }); - }); - - it('invokes asyncBatchAnnotateFiles with error', done => { - const client = new visionModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - - // Mock request - const requests = []; - const request = { - requests: requests, - }; - - // Mock Grpc layer - client._innerApiCalls.asyncBatchAnnotateFiles = mockLongRunningGrpcMethod( - request, - null, - error - ); - - client - .asyncBatchAnnotateFiles(request) - .then(responses => { - const operation = responses[0]; - return operation.promise(); - }) - .then(() => { - assert.fail(); - }) - .catch(err => { - assert(err instanceof Error); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - done(); - }); - }); - - it('has longrunning decoder functions', () => { - const client = new visionModule.v1.ImageAnnotatorClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert( - client._descriptors.longrunning.asyncBatchAnnotateFiles - .responseDecoder instanceof Function - ); - assert( - client._descriptors.longrunning.asyncBatchAnnotateFiles - .metadataDecoder instanceof Function - ); - }); - }); -}); function mockSimpleGrpcMethod(expectedRequest, response, error) { return function(actualRequest, options, callback) {