1 4
// Copyright 2020 Google LLC
2 4
//
3 4
// Licensed under the Apache License, Version 2.0 (the "License");
4 4
// you may not use this file except in compliance with the License.
5 4
// You may obtain a copy of the License at
6 4
//
7 4
//     https://www.apache.org/licenses/LICENSE-2.0
8 4
//
9 4
// Unless required by applicable law or agreed to in writing, software
10 4
// distributed under the License is distributed on an "AS IS" BASIS,
11 4
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 4
// See the License for the specific language governing permissions and
13 4
// limitations under the License.
14 4
//
15 4
// ** This file is automatically generated by gapic-generator-typescript. **
16 4
// ** https://github.com/googleapis/gapic-generator-typescript **
17 4
// ** All changes to this file may be overwritten. **
18 4

19 4
import * as gax from 'google-gax';
20 4
import {
21 4
  Callback,
22 4
  CallOptions,
23 4
  Descriptors,
24 4
  ClientOptions,
25 4
  LROperation,
26 4
} from 'google-gax';
27 4
import * as path from 'path';
28 4

29 4
import * as protos from '../../protos/protos';
30 4
import * as gapicConfig from './image_annotator_client_config.json';
31 4
import {operationsProtos} from 'google-gax';
32 4
const version = require('../../../package.json').version;
33 4

34 4
/**
35 4
 *  Service that performs Google Cloud Vision API detection tasks over client
36 4
 *  images, such as face, landmark, logo, label, and text detection. The
37 4
 *  ImageAnnotator service returns detected entities from the images.
38 4
 * @class
39 4
 * @memberof v1p2beta1
40 4
 */
41 4
export class ImageAnnotatorClient {
42 4
  private _terminated = false;
43 4
  private _opts: ClientOptions;
44 4
  private _gaxModule: typeof gax | typeof gax.fallback;
45 4
  private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient;
46 4
  private _protos: {};
47 4
  private _defaults: {[method: string]: gax.CallSettings};
48 4
  auth: gax.GoogleAuth;
49 4
  descriptors: Descriptors = {
50 4
    page: {},
51 4
    stream: {},
52 4
    longrunning: {},
53 4
    batching: {},
54 4
  };
55 4
  innerApiCalls: {[name: string]: Function};
56 4
  operationsClient: gax.OperationsClient;
57 4
  imageAnnotatorStub?: Promise<{[name: string]: Function}>;
58 4

59 4
  /**
60 4
   * Construct an instance of ImageAnnotatorClient.
61 4
   *
62 4
   * @param {object} [options] - The configuration object. See the subsequent
63 4
   *   parameters for more details.
64 4
   * @param {object} [options.credentials] - Credentials object.
65 4
   * @param {string} [options.credentials.client_email]
66 4
   * @param {string} [options.credentials.private_key]
67 4
   * @param {string} [options.email] - Account email address. Required when
68 4
   *     using a .pem or .p12 keyFilename.
69 4
   * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
70 4
   *     .p12 key downloaded from the Google Developers Console. If you provide
71 4
   *     a path to a JSON file, the projectId option below is not necessary.
72 4
   *     NOTE: .pem and .p12 require you to specify options.email as well.
73 4
   * @param {number} [options.port] - The port on which to connect to
74 4
   *     the remote host.
75 4
   * @param {string} [options.projectId] - The project ID from the Google
76 4
   *     Developer's Console, e.g. 'grape-spaceship-123'. We will also check
77 4
   *     the environment variable GCLOUD_PROJECT for your project ID. If your
78 4
   *     app is running in an environment which supports
79 4
   *     {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
80 4
   *     your project ID will be detected automatically.
81 4
   * @param {string} [options.apiEndpoint] - The domain name of the
82 4
   *     API remote host.
83 4
   */
84 4

85 4
  constructor(opts?: ClientOptions) {
86 4
    // Ensure that options include the service address and port.
87 4
    const staticMembers = this.constructor as typeof ImageAnnotatorClient;
88 4
    const servicePath =
89 4
      opts && opts.servicePath
90 4
        ? opts.servicePath
91 4
        : opts && opts.apiEndpoint
92 4
        ? opts.apiEndpoint
93 4
        : staticMembers.servicePath;
94 4
    const port = opts && opts.port ? opts.port : staticMembers.port;
95 4

96 4
    if (!opts) {
97 4
      opts = {servicePath, port};
98 4
    }
99 4
    opts.servicePath = opts.servicePath || servicePath;
100 4
    opts.port = opts.port || port;
101 4

102 4
    // users can override the config from client side, like retry codes name.
103 4
    // The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/master/src/gax.ts#L546
104 4
    // The way to override client config for Showcase API:
105 4
    //
106 4
    // const customConfig = {"interfaces": {"google.showcase.v1beta1.Echo": {"methods": {"Echo": {"retry_codes_name": "idempotent", "retry_params_name": "default"}}}}}
107 4
    // const showcaseClient = new showcaseClient({ projectId, customConfig });
108 4
    opts.clientConfig = opts.clientConfig || {};
109 4

110 4
    // If we're running in browser, it's OK to omit `fallback` since
111 4
    // google-gax has `browser` field in its `package.json`.
112 4
    // For Electron (which does not respect `browser` field),
113 4
    // pass `{fallback: true}` to the ImageAnnotatorClient constructor.
114 4
    this._gaxModule = opts.fallback ? gax.fallback : gax;
115 4

116 4
    // Create a `gaxGrpc` object, with any grpc-specific options
117 4
    // sent to the client.
118 4
    opts.scopes = (this.constructor as typeof ImageAnnotatorClient).scopes;
119 4
    this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
120 4

121 4
    // Save options to use in initialize() method.
122 4
    this._opts = opts;
123 4

124 4
    // Save the auth object to the client, for use by other methods.
125 4
    this.auth = this._gaxGrpc.auth as gax.GoogleAuth;
126 4

127 4
    // Determine the client header string.
128 4
    const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
129 4
    if (typeof process !== 'undefined' && 'versions' in process) {
130 4
      clientHeader.push(`gl-node/${process.versions.node}`);
131 4
    } else {
132 0
      clientHeader.push(`gl-web/${this._gaxModule.version}`);
133 0
    }
134 4
    if (!opts.fallback) {
135 4
      clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
136 4
    }
137 4
    if (opts.libName && opts.libVersion) {
138 0
      clientHeader.push(`${opts.libName}/${opts.libVersion}`);
139 0
    }
140 4
    // Load the applicable protos.
141 4
    // For Node.js, pass the path to JSON proto file.
142 4
    // For browsers, pass the JSON content.
143 4

144 4
    const nodejsProtoPath = path.join(
145 4
      __dirname,
146 4
      '..',
147 4
      '..',
148 4
      'protos',
149 4
      'protos.json'
150 4
    );
151 4
    this._protos = this._gaxGrpc.loadProto(
152 4
      opts.fallback
153 4
        ? // eslint-disable-next-line @typescript-eslint/no-var-requires
154 4
          require('../../protos/protos.json')
155 4
        : nodejsProtoPath
156 4
    );
157 4

158 4
    // This API contains "long-running operations", which return a
159 4
    // an Operation object that allows for tracking of the operation,
160 4
    // rather than holding a request open.
161 4
    const protoFilesRoot = opts.fallback
162 4
      ? this._gaxModule.protobuf.Root.fromJSON(
163 4
          // eslint-disable-next-line @typescript-eslint/no-var-requires
164 4
          require('../../protos/protos.json')
165 4
        )
166 4
      : this._gaxModule.protobuf.loadSync(nodejsProtoPath);
167 4

168 4
    this.operationsClient = this._gaxModule
169 4
      .lro({
170 4
        auth: this.auth,
171 4
        grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
172 4
      })
173 4
      .operationsClient(opts);
174 4
    const asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup(
175 4
      '.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesResponse'
176 4
    ) as gax.protobuf.Type;
177 4
    const asyncBatchAnnotateFilesMetadata = protoFilesRoot.lookup(
178 4
      '.google.cloud.vision.v1p2beta1.OperationMetadata'
179 4
    ) as gax.protobuf.Type;
180 4

181 4
    this.descriptors.longrunning = {
182 4
      asyncBatchAnnotateFiles: new this._gaxModule.LongrunningDescriptor(
183 4
        this.operationsClient,
184 4
        asyncBatchAnnotateFilesResponse.decode.bind(
185 4
          asyncBatchAnnotateFilesResponse
186 4
        ),
187 4
        asyncBatchAnnotateFilesMetadata.decode.bind(
188 4
          asyncBatchAnnotateFilesMetadata
189 4
        )
190 4
      ),
191 4
    };
192 4

193 4
    // Put together the default options sent with requests.
194 4
    this._defaults = this._gaxGrpc.constructSettings(
195 4
      'google.cloud.vision.v1p2beta1.ImageAnnotator',
196 4
      gapicConfig as gax.ClientConfig,
197 4
      opts.clientConfig || {},
198 4
      {'x-goog-api-client': clientHeader.join(' ')}
199 4
    );
200 4

201 4
    // Set up a dictionary of "inner API calls"; the core implementation
202 4
    // of calling the API is handled in `google-gax`, with this code
203 4
    // merely providing the destination and request information.
204 4
    this.innerApiCalls = {};
205 4
  }
206 4

207 4
  /**
208 4
   * Initialize the client.
209 4
   * Performs asynchronous operations (such as authentication) and prepares the client.
210 4
   * This function will be called automatically when any class method is called for the
211 4
   * first time, but if you need to initialize it before calling an actual method,
212 4
   * feel free to call initialize() directly.
213 4
   *
214 4
   * You can await on this method if you want to make sure the client is initialized.
215 4
   *
216 4
   * @returns {Promise} A promise that resolves to an authenticated service stub.
217 4
   */
218 4
  initialize() {
219 4
    // If the client stub promise is already initialized, return immediately.
220 4
    if (this.imageAnnotatorStub) {
221 4
      return this.imageAnnotatorStub;
222 4
    }
223 4

224 4
    // Put together the "service stub" for
225 4
    // google.cloud.vision.v1p2beta1.ImageAnnotator.
226 4
    this.imageAnnotatorStub = this._gaxGrpc.createStub(
227 4
      this._opts.fallback
228 4
        ? (this._protos as protobuf.Root).lookupService(
229 0
            'google.cloud.vision.v1p2beta1.ImageAnnotator'
230 4
          )
231 4
        : // eslint-disable-next-line @typescript-eslint/no-explicit-any
232 4
          (this._protos as any).google.cloud.vision.v1p2beta1.ImageAnnotator,
233 4
      this._opts
234 4
    ) as Promise<{[method: string]: Function}>;
235 4

236 4
    // Iterate over each of the methods that the service provides
237 4
    // and create an API call method for each.
238 4
    const imageAnnotatorStubMethods = [
239 4
      'batchAnnotateImages',
240 4
      'asyncBatchAnnotateFiles',
241 4
    ];
242 4
    for (const methodName of imageAnnotatorStubMethods) {
243 4
      const callPromise = this.imageAnnotatorStub.then(
244 4
        stub => (...args: Array<{}>) => {
245 0
          if (this._terminated) {
246 0
            return Promise.reject('The client has already been closed.');
247 0
          }
248 0
          const func = stub[methodName];
249 0
          return func.apply(stub, args);
250 4
        },
251 4
        (err: Error | null | undefined) => () => {
252 0
          throw err;
253 0
        }
254 4
      );
255 4

256 4
      const descriptor = this.descriptors.longrunning[methodName] || undefined;
257 4
      const apiCall = this._gaxModule.createApiCall(
258 4
        callPromise,
259 4
        this._defaults[methodName],
260 4
        descriptor
261 4
      );
262 4

263 4
      this.innerApiCalls[methodName] = apiCall;
264 4
    }
265 4

266 4
    return this.imageAnnotatorStub;
267 4
  }
268 4

269 4
  /**
270 4
   * The DNS address for this API service.
271 4
   */
272 4
  static get servicePath() {
273 4
    return 'vision.googleapis.com';
274 4
  }
275 4

276 4
  /**
277 4
   * The DNS address for this API service - same as servicePath(),
278 4
   * exists for compatibility reasons.
279 4
   */
280 4
  static get apiEndpoint() {
281 4
    return 'vision.googleapis.com';
282 4
  }
283 4

284 4
  /**
285 4
   * The port for this API service.
286 4
   */
287 4
  static get port() {
288 4
    return 443;
289 4
  }
290 4

291 4
  /**
292 4
   * The scopes needed to make gRPC calls for every method defined
293 4
   * in this service.
294 4
   */
295 4
  static get scopes() {
296 4
    return [
297 4
      'https://www.googleapis.com/auth/cloud-platform',
298 4
      'https://www.googleapis.com/auth/cloud-vision',
299 4
    ];
300 4
  }
301 4

302 4
  getProjectId(): Promise<string>;
303 4
  getProjectId(callback: Callback<string, undefined, undefined>): void;
304 4
  /**
305 4
   * Return the project ID used by this class.
306 4
   * @param {function(Error, string)} callback - the callback to
307 4
   *   be called with the current project Id.
308 4
   */
309 4
  getProjectId(
310 4
    callback?: Callback<string, undefined, undefined>
311 4
  ): Promise<string> | void {
312 4
    if (callback) {
313 4
      this.auth.getProjectId(callback);
314 4
      return;
315 4
    }
316 4
    return this.auth.getProjectId();
317 4
  }
318 4

319 4
  // -------------------
320 4
  // -- Service calls --
321 4
  // -------------------
322 4
  batchAnnotateImages(
323 4
    request: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest,
324 4
    options?: gax.CallOptions
325 4
  ): Promise<
326 4
    [
327 4
      protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse,
328 4
      (
329 4
        | protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest
330 4
        | undefined
331 4
      ),
332 4
      {} | undefined
333 4
    ]
334 4
  >;
335 4
  batchAnnotateImages(
336 4
    request: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest,
337 4
    options: gax.CallOptions,
338 4
    callback: Callback<
339 4
      protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse,
340 4
      | protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest
341 4
      | null
342 4
      | undefined,
343 4
      {} | null | undefined
344 4
    >
345 4
  ): void;
346 4
  batchAnnotateImages(
347 4
    request: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest,
348 4
    callback: Callback<
349 4
      protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse,
350 4
      | protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest
351 4
      | null
352 4
      | undefined,
353 4
      {} | null | undefined
354 4
    >
355 4
  ): void;
356 4
  /**
357 4
   * Run image detection and annotation for a batch of images.
358 4
   *
359 4
   * @param {Object} request
360 4
   *   The request object that will be sent.
361 4
   * @param {number[]} request.requests
362 4
   *   Required. Individual image annotation requests for this batch.
363 4
   * @param {object} [options]
364 4
   *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
365 4
   * @returns {Promise} - The promise which resolves to an array.
366 4
   *   The first element of the array is an object representing [BatchAnnotateImagesResponse]{@link google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse}.
367 4
   *   The promise has a method named "cancel" which cancels the ongoing API call.
368 4
   */
369 4
  batchAnnotateImages(
370 4
    request: protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest,
371 4
    optionsOrCallback?:
372 4
      | gax.CallOptions
373 4
      | Callback<
374 4
          protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse,
375 4
          | protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest
376 4
          | null
377 4
          | undefined,
378 4
          {} | null | undefined
379 4
        >,
380 4
    callback?: Callback<
381 4
      protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse,
382 4
      | protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest
383 4
      | null
384 4
      | undefined,
385 4
      {} | null | undefined
386 4
    >
387 4
  ): Promise<
388 4
    [
389 4
      protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesResponse,
390 4
      (
391 4
        | protos.google.cloud.vision.v1p2beta1.IBatchAnnotateImagesRequest
392 4
        | undefined
393 4
      ),
394 4
      {} | undefined
395 4
    ]
396 4
  > | void {
397 4
    request = request || {};
398 4
    let options: gax.CallOptions;
399 4
    if (typeof optionsOrCallback === 'function' && callback === undefined) {
400 4
      callback = optionsOrCallback;
401 4
      options = {};
402 4
    } else {
403 4
      options = optionsOrCallback as gax.CallOptions;
404 4
    }
405 4
    options = options || {};
406 4
    this.initialize();
407 4
    return this.innerApiCalls.batchAnnotateImages(request, options, callback);
408 4
  }
409 4

410 4
  asyncBatchAnnotateFiles(
411 4
    request: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest,
412 4
    options?: gax.CallOptions
413 4
  ): Promise<
414 4
    [
415 4
      LROperation<
416 4
        protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesResponse,
417 4
        protos.google.cloud.vision.v1p2beta1.IOperationMetadata
418 4
      >,
419 4
      protos.google.longrunning.IOperation | undefined,
420 4
      {} | undefined
421 4
    ]
422 4
  >;
423 4
  asyncBatchAnnotateFiles(
424 4
    request: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest,
425 4
    options: gax.CallOptions,
426 4
    callback: Callback<
427 4
      LROperation<
428 4
        protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesResponse,
429 4
        protos.google.cloud.vision.v1p2beta1.IOperationMetadata
430 4
      >,
431 4
      protos.google.longrunning.IOperation | null | undefined,
432 4
      {} | null | undefined
433 4
    >
434 4
  ): void;
435 4
  asyncBatchAnnotateFiles(
436 4
    request: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest,
437 4
    callback: Callback<
438 4
      LROperation<
439 4
        protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesResponse,
440 4
        protos.google.cloud.vision.v1p2beta1.IOperationMetadata
441 4
      >,
442 4
      protos.google.longrunning.IOperation | null | undefined,
443 4
      {} | null | undefined
444 4
    >
445 4
  ): void;
446 4
  /**
447 4
   * Run async image detection and annotation for a list of generic files (e.g.
448 4
   * PDF) which may contain multiple pages and multiple images per page.
449 4
   * Progress and results can be retrieved through the
450 4
   * `google.longrunning.Operations` interface.
451 4
   * `Operation.metadata` contains `OperationMetadata` (metadata).
452 4
   * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).
453 4
   *
454 4
   * @param {Object} request
455 4
   *   The request object that will be sent.
456 4
   * @param {number[]} request.requests
457 4
   *   Required. Individual async file annotation requests for this batch.
458 4
   * @param {object} [options]
459 4
   *   Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
460 4
   * @returns {Promise} - The promise which resolves to an array.
461 4
   *   The first element of the array is an object representing [Operation]{@link google.longrunning.Operation}.
462 4
   *   The promise has a method named "cancel" which cancels the ongoing API call.
463 4
   */
464 4
  asyncBatchAnnotateFiles(
465 4
    request: protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesRequest,
466 4
    optionsOrCallback?:
467 4
      | gax.CallOptions
468 4
      | Callback<
469 4
          LROperation<
470 4
            protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesResponse,
471 4
            protos.google.cloud.vision.v1p2beta1.IOperationMetadata
472 4
          >,
473 4
          protos.google.longrunning.IOperation | null | undefined,
474 4
          {} | null | undefined
475 4
        >,
476 4
    callback?: Callback<
477 4
      LROperation<
478 4
        protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesResponse,
479 4
        protos.google.cloud.vision.v1p2beta1.IOperationMetadata
480 4
      >,
481 4
      protos.google.longrunning.IOperation | null | undefined,
482 4
      {} | null | undefined
483 4
    >
484 4
  ): Promise<
485 4
    [
486 4
      LROperation<
487 4
        protos.google.cloud.vision.v1p2beta1.IAsyncBatchAnnotateFilesResponse,
488 4
        protos.google.cloud.vision.v1p2beta1.IOperationMetadata
489 4
      >,
490 4
      protos.google.longrunning.IOperation | undefined,
491 4
      {} | undefined
492 4
    ]
493 4
  > | void {
494 4
    request = request || {};
495 4
    let options: gax.CallOptions;
496 4
    if (typeof optionsOrCallback === 'function' && callback === undefined) {
497 4
      callback = optionsOrCallback;
498 4
      options = {};
499 4
    } else {
500 4
      options = optionsOrCallback as gax.CallOptions;
501 4
    }
502 4
    options = options || {};
503 4
    this.initialize();
504 4
    return this.innerApiCalls.asyncBatchAnnotateFiles(
505 4
      request,
506 4
      options,
507 4
      callback
508 4
    );
509 4
  }
510 4
  /**
511 4
   * Check the status of the long running operation returned by the asyncBatchAnnotateFiles() method.
512 4
   * @param {String} name
513 4
   *   The operation name that will be passed.
514 4
   * @returns {Promise} - The promise which resolves to an object.
515 4
   *   The decoded operation object has result and metadata field to get information from.
516 4
   *
517 4
   * @example:
518 4
   *   const decodedOperation = await checkAsyncBatchAnnotateFilesProgress(name);
519 4
   *   console.log(decodedOperation.result);
520 4
   *   console.log(decodedOperation.done);
521 4
   *   console.log(decodedOperation.metadata);
522 4
   *
523 4
   */
524 4
  async checkAsyncBatchAnnotateFilesProgress(
525 4
    name: string
526 4
  ): Promise<
527 4
    LROperation<
528 4
      protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesResponse,
529 4
      protos.google.cloud.vision.v1p2beta1.OperationMetadata
530 4
    >
531 4
  > {
532 4
    const request = new operationsProtos.google.longrunning.GetOperationRequest(
533 4
      {name}
534 4
    );
535 4
    const [operation] = await this.operationsClient.getOperation(request);
536 4
    const decodeOperation = new gax.Operation(
537 4
      operation,
538 4
      this.descriptors.longrunning.asyncBatchAnnotateFiles,
539 4
      gax.createDefaultBackoffSettings()
540 4
    );
541 4
    return decodeOperation as LROperation<
542 4
      protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesResponse,
543 4
      protos.google.cloud.vision.v1p2beta1.OperationMetadata
544 4
    >;
545 1
  }
546 4

547 4
  /**
548 4
   * Terminate the GRPC channel and close the client.
549 4
   *
550 4
   * The client will no longer be usable and all future behavior is undefined.
551 4
   */
552 4
  close(): Promise<void> {
553 4
    this.initialize();
554 4
    if (!this._terminated) {
555 4
      return this.imageAnnotatorStub!.then(stub => {
556 4
        this._terminated = true;
557 4
        stub.close();
558 4
      });
559 4
    }
560 0
    return Promise.resolve();
561 0
  }
562 4
}
563 4
import {FeaturesMethod} from '../helpers';
564 4
// eslint-disable-next-line @typescript-eslint/no-empty-interface
565 4
export interface ImageAnnotatorClient extends FeaturesMethod {}

Read our documentation on viewing source code .

Loading