Skip to content

Commit

Permalink
Update videointelligence v1beta1 client (#2524)
Browse files Browse the repository at this point in the history
  • Loading branch information
evaogbe authored and stephenplusplus committed Aug 15, 2017
1 parent 118b622 commit 9ecf6cc
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 72 deletions.
10 changes: 5 additions & 5 deletions packages/video-intelligence/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Node.js Client for Google Cloud Video Intelligence API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-node#versioning))
# Node.js Client for Google Cloud Video Intelligence API ([Beta](https://github.com/GoogleCloudPlatform/google-cloud-node#versioning))

Idiomatic Node.js client for [Google Cloud Video Intelligence API][Product Documentation]
[Google Cloud Video Intelligence API][Product Documentation]: Google Cloud Video Intelligence API.
- [Client Library Documentation][]
- [Product Documentation][]

## Quick Start
In order to use this library, you first need to go through the following steps:

1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
2. [Enable the video-intelligence api.](https://console.cloud.google.com/apis/api/video-intelligence)
2. [Enable the Google Cloud Video Intelligence API.](https://console.cloud.google.com/apis/api/video-intelligence)
3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-node/#/docs/google-cloud/master/guides/authentication)

### Installation
```
$ npm install @google-cloud/video-intelligence
$ npm install --save @google-cloud/video-intelligence
```

### Next Steps
Expand All @@ -22,4 +22,4 @@ $ npm install @google-cloud/video-intelligence
- View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/README.md) to see the full list of Cloud APIs that we cover.

[Client Library Documentation]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/video-intelligence
[Product Documentation]: https://cloud.google.com/video-intelligence
[Product Documentation]: https://cloud.google.com/video-intelligence
8 changes: 4 additions & 4 deletions packages/video-intelligence/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"repository": "GoogleCloudPlatform/google-cloud-node",
"name": "@google-cloud/video-intelligence",
"version": "0.1.1",
"author": "Google Inc",
Expand All @@ -7,10 +8,8 @@
"files": [
"src",
"AUTHORS",
"CONTRIBUTORS",
"COPYING"
],
"repository": "googlecloudplatform/google-cloud-node",
"keywords": [
"google apis client",
"google api client",
Expand All @@ -22,10 +21,10 @@
"cloud",
"google video intelligence",
"video intelligence",
"video"
"Google Cloud Video Intelligence API"
],
"dependencies": {
"extend": "^3.0.0",
"extend": "^3.0",
"google-gax": "^0.13.2",
"google-proto-files": "^0.12.0"
},
Expand All @@ -34,6 +33,7 @@
},
"scripts": {
"publish-module": "node ../../scripts/publish.js video-intelligence",
"smoke-test": "mocha smoke-test/*.js --timeout 5000",
"test": "mocha test/*.js"
},
"license": "Apache-2.0",
Expand Down
73 changes: 34 additions & 39 deletions packages/video-intelligence/src/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2017 Google Inc. All rights reserved.
* Copyright 2017, 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
* 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,
Expand All @@ -16,57 +16,52 @@

/*!
* @module video-intelligence
* @name VideoIntelligence
*/

'use strict';

var v1beta1 = require('./v1beta1/index.js');
var extend = require('extend');
var gapic = {
v1beta1: require('./v1beta1')
};
var gaxGrpc = require('google-gax').grpc();

const VERSION = require('../package.json').version;

/**
* [Google Cloud Video Intelligence API](https://cloud.google.com/video-intelligence)
* makes videos searchable, and discoverable, by extracting metadata with an
* easy to use REST API. You can now search every moment of every video file in
* your catalog and find every occurrence as well as its significance. It
* quickly annotates videos stored in Google Cloud Storage, and helps you
* identify key nouns entities of your video, and when they occur within the
* video. Separate signal from noise, by retrieving relevant information at the
* video, shot or per frame.
* Create a videoIntelligenceServiceClient with additional helpers for common
* tasks.
*
* <h2>This is an auto-generated API</h2>
*
* It does not follow the conventions you're familiar with from other parts of
* our library. A handwritten layer is not yet available.
*
* The example below shows you how to instantiate the generated client. For
* further documentation, please browse the
* [Video Intelligence .proto files](https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta1/video_intelligence.proto)
* on GitHub.
*
* @constructor
* @alias module:video-intelligence
* Use this service to interact with the Google Cloud Video Intelligence API.
*
* @param {object=} options - [Configuration object](#/docs).
* @param {number=} options.port - The port on which to connect to
* the remote host.
* @param {string=} options.servicePath - The domain name of the
* API remote host.
* @resource [Cloud Video Intelligence](https://cloud.google.com/video-intelligence)
*
* @param {object} options - [Configuration object](#/docs).
* @param {number=} options.port - The port on which to connect to the remote
* host.
* @param {string=} options.servicePath - The domain name of the API remote
* host.
*/
function VideoIntelligence(options) {
function videoIntelligenceV1beta1(options) {
// Define the header options.
options = options || {};
options.libName = 'gccl';
options.libVersion = VERSION;
options = extend({}, options, {
libName: 'gccl',
libVersion: VERSION
});

// Create the image annotator client with the provided options.
var client = v1beta1(options).videoIntelligenceServiceClient(options);
// Create the client with the provided options.
var client = gapic.v1beta1(options).videoIntelligenceServiceClient(options);
return client;
}

// The default export should be the latest version.
// Assign all versions as version properties on the default.
module.exports = VideoIntelligence;
module.exports.v1beta1 = v1beta1;
var v1beta1Protos = {};

extend(v1beta1Protos, gaxGrpc.load([{
root: require('google-proto-files')('..'),
file: 'google/cloud/videointelligence/v1beta1/video_intelligence.proto'
}]).google.cloud.videointelligence.v1beta1);

module.exports = videoIntelligenceV1beta1;
module.exports.types = v1beta1Protos;
module.exports.v1beta1 = videoIntelligenceV1beta1;
module.exports.v1beta1.types = v1beta1Protos;
8 changes: 4 additions & 4 deletions packages/video-intelligence/src/v1beta1/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2017 Google Inc. All rights reserved.
* Copyright 2017, 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
* 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,
Expand All @@ -27,8 +27,8 @@ function v1beta1(options) {
return videoIntelligenceServiceClient(gaxGrpc);
}

v1beta1.GAPIC_VERSION = '0.7.1';
v1beta1.GAPIC_VERSION = '0.0.5';
v1beta1.SERVICE_ADDRESS = videoIntelligenceServiceClient.SERVICE_ADDRESS;
v1beta1.ALL_SCOPES = videoIntelligenceServiceClient.ALL_SCOPES;

module.exports = v1beta1;
module.exports = v1beta1;
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var SERVICE_ADDRESS = 'videointelligence.googleapis.com';

var DEFAULT_SERVICE_PORT = 443;

var CODE_GEN_NAME_VERSION = 'gapic/0.7.1';
var CODE_GEN_NAME_VERSION = 'gapic/0.0.5';

/**
* The scopes needed to make gRPC calls to all of the methods defined in
Expand All @@ -48,15 +48,6 @@ var ALL_SCOPES = [
/**
* Service that implements Google Cloud Video Intelligence API.
*
* This will be created through a builder function which can be obtained by the module.
* See the following example of how to initialize the module and how to access to the builder.
* @see {@link videoIntelligenceServiceClient}
*
* @example
* var videointelligenceV1beta1 = require('@google-cloud/videointelligence').v1beta1({
* // optional auth parameters.
* });
* var client = videointelligenceV1beta1.videoIntelligenceServiceClient();
*
* @class
*/
Expand Down Expand Up @@ -185,7 +176,12 @@ VideoIntelligenceServiceClient.prototype.getProjectId = function(callback) {
*
* @example
*
* var client = videointelligenceV1beta1.videoIntelligenceServiceClient();
* var videointelligence = require('@google-cloud/videointelligence');
*
* var client = videointelligence.v1beta1({
* // optional auth parameters.
* });
*
* var inputUri = '';
* var features = [];
* var request = {
Expand All @@ -209,10 +205,18 @@ VideoIntelligenceServiceClient.prototype.getProjectId = function(callback) {
*
* // The response of the api call returning the complete operation.
* var finalApiResponse = responses[2];
* }).catch(function(err) {
* })
* .catch(function(err) {
* console.error(err);
* });
*
* var inputUri = '';
* var features = [];
* var request = {
* inputUri: inputUri,
* features: features
* };
*
* // Handle the operation using the event emitter pattern.
* client.annotateVideo(request).then(function(responses) {
* var operation = responses[0];
Expand All @@ -234,7 +238,8 @@ VideoIntelligenceServiceClient.prototype.getProjectId = function(callback) {
* operation.on('error', function(err) {
* // throw(err);
* })
* }).catch(function(err) {
* })
* .catch(function(err) {
* console.error(err);
* });
*/
Expand Down Expand Up @@ -283,4 +288,4 @@ function VideoIntelligenceServiceClientBuilder(gaxGrpc) {
}
module.exports = VideoIntelligenceServiceClientBuilder;
module.exports.SERVICE_ADDRESS = SERVICE_ADDRESS;
module.exports.ALL_SCOPES = ALL_SCOPES;
module.exports.ALL_SCOPES = ALL_SCOPES;
15 changes: 9 additions & 6 deletions packages/video-intelligence/test/gapic-v1beta1.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
/*
* Copyright 2017 Google Inc. All rights reserved.
* Copyright 2017, 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
* 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.
*/
'use strict';

var assert = require('assert');
var videointelligenceV1beta1 = require('../src/v1beta1')();
var videointelligence = require('../src');

var FAKE_STATUS_CODE = 1;
var error = new Error();
Expand All @@ -24,7 +25,8 @@ error.code = FAKE_STATUS_CODE;
describe('VideoIntelligenceServiceClient', function() {
describe('annotateVideo', function() {
it('invokes annotateVideo without error', function(done) {
var client = videointelligenceV1beta1.videoIntelligenceServiceClient();
var client = videointelligence.v1beta1();

// Mock request
var inputUri = 'inputUri1707300727';
var features = [];
Expand All @@ -51,7 +53,8 @@ describe('VideoIntelligenceServiceClient', function() {
});

it('invokes annotateVideo with error', function(done) {
var client = videointelligenceV1beta1.videoIntelligenceServiceClient();
var client = videointelligence.v1beta1();

// Mock request
var inputUri = 'inputUri1707300727';
var features = [];
Expand Down Expand Up @@ -98,7 +101,7 @@ function mockLongRunningGrpcMethod(expectedRequest, response, error) {
promise: function() {
return new Promise(function(resolve, reject) {
if (error) {
reject(error)
reject(error);
} else {
resolve([response]);
}
Expand Down

0 comments on commit 9ecf6cc

Please sign in to comment.