diff --git a/packages/video-intelligence/package.json b/packages/video-intelligence/package.json index 29ae4c606c9..c9ec22c8fca 100644 --- a/packages/video-intelligence/package.json +++ b/packages/video-intelligence/package.json @@ -26,7 +26,8 @@ ], "dependencies": { "extend": "^3.0", - "google-gax": "^0.13.5" + "google-gax": "^0.14.0", + "protobufjs": "^6.8.0" }, "devDependencies": { "mocha": "^3.2.0" diff --git a/packages/video-intelligence/src/index.js b/packages/video-intelligence/src/index.js index f68907b7cc1..0e8185d6736 100644 --- a/packages/video-intelligence/src/index.js +++ b/packages/video-intelligence/src/index.js @@ -31,6 +31,7 @@ var path = require('path'); const VERSION = require('../package.json').version; + /** * Create an videoIntelligenceServiceClient with additional helpers for common * tasks. @@ -60,7 +61,7 @@ const VERSION = require('../package.json').version; * @param {string=} options.servicePath - The domain name of the * API remote host. */ -function videoIntelligenceV1beta2(options) { +function videoIntelligenceV1beta1(options) { // Define the header options. options = extend({}, options, { libName: 'gccl', @@ -68,16 +69,16 @@ function videoIntelligenceV1beta2(options) { }); // Create the client with the provided options. - var client = gapic.v1beta2(options).videoIntelligenceServiceClient(options); + var client = gapic.v1beta1(options).videoIntelligenceServiceClient(options); return client; } -var v1beta2Protos = {}; +var v1beta1Protos = {}; -extend(v1beta2Protos, gaxGrpc.loadProto( - path.join(__dirname, '..', 'protos', - 'google/cloud/videointelligence/v1beta2/video_intelligence.proto') -).google.cloud.videointelligence.v1beta2); +extend(v1beta1Protos, gaxGrpc.loadProto( + path.join(__dirname, '..', 'protos'), + 'google/cloud/videointelligence/v1beta1/video_intelligence.proto') + .google.cloud.videointelligence.v1beta1); /** @@ -109,7 +110,7 @@ extend(v1beta2Protos, gaxGrpc.loadProto( * @param {string=} options.servicePath - The domain name of the * API remote host. */ -function videoIntelligenceV1beta1(options) { +function videoIntelligenceV1beta2(options) { // Define the header options. options = extend({}, options, { libName: 'gccl', @@ -117,17 +118,16 @@ function videoIntelligenceV1beta1(options) { }); // Create the client with the provided options. - var client = gapic.v1beta1(options).videoIntelligenceServiceClient(options); + var client = gapic.v1beta2(options).videoIntelligenceServiceClient(options); return client; } -var v1beta1Protos = {}; - -extend(v1beta1Protos, gaxGrpc.loadProto( - path.join(__dirname, '..', 'protos', - 'google/cloud/videointelligence/v1beta1/video_intelligence.proto') -).google.cloud.videointelligence.v1beta1); +var v1beta2Protos = {}; +extend(v1beta2Protos, gaxGrpc.loadProto( + path.join(__dirname, '..', 'protos'), + 'google/cloud/videointelligence/v1beta2/video_intelligence.proto') + .google.cloud.videointelligence.v1beta2); module.exports = videoIntelligenceV1beta2; module.exports.types = v1beta2Protos; diff --git a/packages/video-intelligence/src/v1beta1/video_intelligence_service_client.js b/packages/video-intelligence/src/v1beta1/video_intelligence_service_client.js index 24872b7a448..d404f937988 100644 --- a/packages/video-intelligence/src/v1beta1/video_intelligence_service_client.js +++ b/packages/video-intelligence/src/v1beta1/video_intelligence_service_client.js @@ -31,6 +31,7 @@ var configData = require('./video_intelligence_service_client_config'); var extend = require('extend'); var gax = require('google-gax'); var path = require('path'); +var protobuf = require('protobufjs'); var SERVICE_ADDRESS = 'videointelligence.googleapis.com'; @@ -76,11 +77,19 @@ function VideoIntelligenceServiceClient(gaxGrpc, loadedProtos, opts) { grpc: gaxGrpc.grpc }).operationsClient(opts); + var protoFilesRoot = new gax.grpc.GoogleProtoFilesRoot(); + protoFilesRoot = protobuf.loadSync( + path.join(__dirname, '..', '..', 'protos', 'google/cloud/videointelligence/v1beta1/video_intelligence.proto'), + protoFilesRoot); + + var annotateVideoResponse = protoFilesRoot.lookup('google.cloud.videointelligence.v1beta1.AnnotateVideoResponse'); + var annotateVideoMetadata = protoFilesRoot.lookup('google.cloud.videointelligence.v1beta1.AnnotateVideoProgress'); + this.longrunningDescriptors = { annotateVideo: new gax.LongrunningDescriptor( this.operationsClient, - loadedProtos.google.cloud.videointelligence.v1beta1.AnnotateVideoResponse.decode, - loadedProtos.google.cloud.videointelligence.v1beta1.AnnotateVideoProgress.decode) + annotateVideoResponse.decode.bind(annotateVideoResponse), + annotateVideoMetadata.decode.bind(annotateVideoMetadata)) }; var defaults = gaxGrpc.constructSettings( @@ -262,7 +271,7 @@ function VideoIntelligenceServiceClientBuilder(gaxGrpc) { } var videoIntelligenceServiceStubProtos = gaxGrpc.loadProto( - path.join(__dirname, '..', '..', 'protos', 'google/cloud/videointelligence/v1beta1/video_intelligence.proto')); + path.join(__dirname, '..', '..', 'protos'), 'google/cloud/videointelligence/v1beta1/video_intelligence.proto'); extend(this, videoIntelligenceServiceStubProtos.google.cloud.videointelligence.v1beta1); @@ -287,4 +296,4 @@ function VideoIntelligenceServiceClientBuilder(gaxGrpc) { } module.exports = VideoIntelligenceServiceClientBuilder; module.exports.SERVICE_ADDRESS = SERVICE_ADDRESS; -module.exports.ALL_SCOPES = ALL_SCOPES; \ No newline at end of file +module.exports.ALL_SCOPES = ALL_SCOPES; diff --git a/packages/video-intelligence/src/v1beta2/video_intelligence_service_client.js b/packages/video-intelligence/src/v1beta2/video_intelligence_service_client.js index 378a97bd62d..fecd7239eb4 100644 --- a/packages/video-intelligence/src/v1beta2/video_intelligence_service_client.js +++ b/packages/video-intelligence/src/v1beta2/video_intelligence_service_client.js @@ -31,6 +31,7 @@ var configData = require('./video_intelligence_service_client_config'); var extend = require('extend'); var gax = require('google-gax'); var path = require('path'); +var protobuf = require('protobufjs'); var SERVICE_ADDRESS = 'videointelligence.googleapis.com'; @@ -76,11 +77,19 @@ function VideoIntelligenceServiceClient(gaxGrpc, loadedProtos, opts) { grpc: gaxGrpc.grpc }).operationsClient(opts); + var protoFilesRoot = new gax.grpc.GoogleProtoFilesRoot(); + protoFilesRoot = protobuf.loadSync( + path.join(__dirname, '..', '..', 'protos', 'google/cloud/videointelligence/v1beta2/video_intelligence.proto'), + protoFilesRoot); + + var annotateVideoResponse = protoFilesRoot.lookup('google.cloud.videointelligence.v1beta2.AnnotateVideoResponse'); + var annotateVideoMetadata = protoFilesRoot.lookup('google.cloud.videointelligence.v1beta2.AnnotateVideoProgress'); + this.longrunningDescriptors = { annotateVideo: new gax.LongrunningDescriptor( this.operationsClient, - loadedProtos.google.cloud.videointelligence.v1beta2.AnnotateVideoResponse.decode, - loadedProtos.google.cloud.videointelligence.v1beta2.AnnotateVideoProgress.decode) + annotateVideoResponse.decode.bind(annotateVideoResponse), + annotateVideoMetadata.decode.bind(annotateVideoMetadata)) }; var defaults = gaxGrpc.constructSettings( @@ -131,7 +140,7 @@ VideoIntelligenceServiceClient.prototype.getProjectId = function(callback) { * * @param {Object} request * The request object that will be sent. - * @param {string} request.inputUri + * @param {string=} request.inputUri * Input video location. Currently, only * [Google Cloud Storage](https://cloud.google.com/storage/) URIs are * supported, which must be specified in the following format: @@ -142,13 +151,13 @@ VideoIntelligenceServiceClient.prototype.getProjectId = function(callback) { * multiple videos. Supported wildcards: '*' to match 0 or more characters; * '?' to match 1 character. If unset, the input video should be embedded * in the request as `input_content`. If set, `input_content` should be unset. - * @param {number[]} request.features - * Requested video annotation features. - * - * The number should be among the values of [Feature]{@link Feature} * @param {string=} request.inputContent * The video data bytes. Encoding: base64. If unset, the input video(s) * should be specified via `input_uri`. If set, `input_uri` should be unset. + * @param {number[]=} request.features + * Requested video annotation features. + * + * The number should be among the values of [Feature]{@link Feature} * @param {Object=} request.videoContext * Additional video context and/or feature-specific parameters. * @@ -183,15 +192,10 @@ VideoIntelligenceServiceClient.prototype.getProjectId = function(callback) { * // optional auth parameters. * }); * - * var inputUri = ''; - * var features = []; - * var request = { - * inputUri: inputUri, - * features: features - * }; + * * * // Handle the operation using the promise pattern. - * client.annotateVideo(request).then(function(responses) { + * client.annotateVideo({}).then(function(responses) { * var operation = responses[0]; * var initialApiResponse = responses[1]; * @@ -211,15 +215,10 @@ VideoIntelligenceServiceClient.prototype.getProjectId = function(callback) { * 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) { + * client.annotateVideo({}).then(function(responses) { * var operation = responses[0]; * var initialApiResponse = responses[1]; * @@ -262,7 +261,7 @@ function VideoIntelligenceServiceClientBuilder(gaxGrpc) { } var videoIntelligenceServiceStubProtos = gaxGrpc.loadProto( - path.join(__dirname, '..', '..', 'protos', 'google/cloud/videointelligence/v1beta2/video_intelligence.proto')); + path.join(__dirname, '..', '..', 'protos'), 'google/cloud/videointelligence/v1beta2/video_intelligence.proto'); extend(this, videoIntelligenceServiceStubProtos.google.cloud.videointelligence.v1beta2); @@ -287,4 +286,4 @@ function VideoIntelligenceServiceClientBuilder(gaxGrpc) { } module.exports = VideoIntelligenceServiceClientBuilder; module.exports.SERVICE_ADDRESS = SERVICE_ADDRESS; -module.exports.ALL_SCOPES = ALL_SCOPES; \ No newline at end of file +module.exports.ALL_SCOPES = ALL_SCOPES; diff --git a/packages/video-intelligence/test/gapic-v1beta1.js b/packages/video-intelligence/test/gapic-v1beta1.js index aab6c6af542..2363e93191e 100644 --- a/packages/video-intelligence/test/gapic-v1beta1.js +++ b/packages/video-intelligence/test/gapic-v1beta1.js @@ -77,6 +77,12 @@ describe('VideoIntelligenceServiceClient', function() { done(); }); }); + + it('has longrunning decoder functions', function() { + var client = videointelligence.v1beta1(); + assert(client.longrunningDescriptors.annotateVideo.responseDecoder instanceof Function); + assert(client.longrunningDescriptors.annotateVideo.metadataDecoder instanceof Function); + }); }); }); diff --git a/packages/video-intelligence/test/gapic-v1beta2.js b/packages/video-intelligence/test/gapic-v1beta2.js index e8d196874db..07e7c5d25ce 100644 --- a/packages/video-intelligence/test/gapic-v1beta2.js +++ b/packages/video-intelligence/test/gapic-v1beta2.js @@ -28,12 +28,7 @@ describe('VideoIntelligenceServiceClient', function() { var client = videoIntelligence.v1beta2(); // Mock request - var inputUri = 'inputUri1707300727'; - var features = []; - var request = { - inputUri : inputUri, - features : features - }; + var request = {}; // Mock response var expectedResponse = {}; @@ -56,12 +51,7 @@ describe('VideoIntelligenceServiceClient', function() { var client = videoIntelligence.v1beta2(); // Mock request - var inputUri = 'inputUri1707300727'; - var features = []; - var request = { - inputUri : inputUri, - features : features - }; + var request = {}; // Mock Grpc layer client._annotateVideo = mockLongRunningGrpcMethod(request, null, error); @@ -77,6 +67,12 @@ describe('VideoIntelligenceServiceClient', function() { done(); }); }); + + it('has longrunning decoder functions', function() { + var client = videoIntelligence.v1beta2(); + assert(client.longrunningDescriptors.annotateVideo.responseDecoder instanceof Function); + assert(client.longrunningDescriptors.annotateVideo.metadataDecoder instanceof Function); + }); }); });