"use strict"; /** * Copyright 2015 Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* jshint maxlen: false */ const apirequest_1 = require("../../lib/apirequest"); /** * Google Cloud Vision API * * Integrates Google Vision features, including image labeling, face, logo, and landmark detection, optical character recognition (OCR), and detection of explicit content, into applications. * * @example * const google = require('googleapis'); * const vision = google.vision('v1'); * * @namespace vision * @type {Function} * @version v1 * @variation v1 * @param {object=} options Options for Vision */ function Vision(options) { const self = this; self._options = options || {}; self.images = { /** * vision.images.annotate * * @desc Run image detection and annotation for a batch of images. * * @example * // BEFORE RUNNING: * // --------------- * // 1. If not already done, enable the Google Cloud Vision API * // and check the quota for your project at * // https://console.developers.google.com/apis/api/vision * // 2. This sample uses Application Default Credentials for authentication. * // If not already done, install the gcloud CLI from * // https://cloud.google.com/sdk and run * // `gcloud beta auth application-default login`. * // For more information, see * // https://developers.google.com/identity/protocols/application-default-credentials * // 3. Install the Node.js client library by running * // `npm install googleapis --save` * * var google = require('googleapis'); * var vision = google.vision('v1'); * * authorize(function(authClient) { * var request = { * resource: { * // TODO: Add desired properties to the request body. * }, * * auth: authClient, * }; * * vision.images.annotate(request, function(err, response) { * if (err) { * console.error(err); * return; * } * * // TODO: Change code below to process the `response` object: * console.log(JSON.stringify(response, null, 2)); * }); * }); * * function authorize(callback) { * google.auth.getApplicationDefault(function(err, authClient) { * if (err) { * console.error('authentication failed: ', err); * return; * } * if (authClient.createScopedRequired && authClient.createScopedRequired()) { * var scopes = ['https://www.googleapis.com/auth/cloud-platform']; * authClient = authClient.createScoped(scopes); * } * callback(authClient); * }); * } * * @alias vision.images.annotate * @memberOf! vision(v1) * * @param {object} params Parameters for request * @param {vision(v1).BatchAnnotateImagesRequest} params.resource Request body data * @param {object} [options] Optionally override request options, such as `url`, `method`, and `encoding`. * @param {callback} callback The callback that handles the response. * @return {object} Request object */ annotate: function (params, options, callback) { if (typeof options === 'function') { callback = options; options = {}; } options || (options = {}); const rootUrl = options.rootUrl || 'https://vision.googleapis.com/'; const parameters = { options: Object.assign({ url: (rootUrl + '/v1/images:annotate').replace(/([^:]\/)\/+/g, '$1'), method: 'POST' }, options), params: params, requiredParams: [], pathParams: [], context: self }; return apirequest_1.default(parameters, callback); } }; } module.exports = Vision; //# sourceMappingURL=v1.js.map