From bf54fd7a2cb6ad13ac2e7ec5a158c17822b36e30 Mon Sep 17 00:00:00 2001 From: Jun Mukai Date: Fri, 24 Feb 2017 13:38:59 -0800 Subject: [PATCH] Update speech API client autogen. (#2025) Updates #2019 --- packages/google-cloud-node/package.json | 2 +- packages/google-cloud-node/src/index.js | 5 ++ .../google-cloud-node/src/v1beta1/index.js | 6 +- .../src/v1beta1/speech_client.js | 55 ++++++++++--------- .../src/v1beta1/speech_client_config.json | 12 ++-- packages/google-cloud-node/test/index.js | 8 ++- 6 files changed, 49 insertions(+), 39 deletions(-) diff --git a/packages/google-cloud-node/package.json b/packages/google-cloud-node/package.json index a904418c89e5..c8202cbd38c5 100644 --- a/packages/google-cloud-node/package.json +++ b/packages/google-cloud-node/package.json @@ -58,7 +58,7 @@ "@google-cloud/common-grpc": "^0.1.1", "events-intercept": "^2.0.0", "extend": "^3.0.0", - "google-gax": "^0.10.2", + "google-gax": "^0.12.0", "google-proto-files": "^0.9.1", "is": "^3.1.0", "propprop": "^0.3.1", diff --git a/packages/google-cloud-node/src/index.js b/packages/google-cloud-node/src/index.js index 6fd49e25f8b8..e2face8b39e6 100644 --- a/packages/google-cloud-node/src/index.js +++ b/packages/google-cloud-node/src/index.js @@ -61,6 +61,11 @@ function Speech(options) { return new Speech(options); } + options = extend({}, options, { + libName: 'gccl', + libVersion: require('../package.json').version + }); + this.api = { Speech: v1beta1(options).speechClient(options) }; diff --git a/packages/google-cloud-node/src/v1beta1/index.js b/packages/google-cloud-node/src/v1beta1/index.js index 3731715047a8..9e78f821b1d5 100644 --- a/packages/google-cloud-node/src/v1beta1/index.js +++ b/packages/google-cloud-node/src/v1beta1/index.js @@ -1,5 +1,5 @@ -/*! - * Copyright 2016 Google Inc. All Rights Reserved. +/* + * Copyright 2016 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. @@ -26,6 +26,8 @@ function v1beta1(options) { var gaxGrpc = gax.grpc(options); return speechClient(gaxGrpc); } + v1beta1.SERVICE_ADDRESS = speechClient.SERVICE_ADDRESS; v1beta1.ALL_SCOPES = speechClient.ALL_SCOPES; + module.exports = v1beta1; diff --git a/packages/google-cloud-node/src/v1beta1/speech_client.js b/packages/google-cloud-node/src/v1beta1/speech_client.js index a1af53729560..6324dc235d2a 100644 --- a/packages/google-cloud-node/src/v1beta1/speech_client.js +++ b/packages/google-cloud-node/src/v1beta1/speech_client.js @@ -65,32 +65,29 @@ var ALL_SCOPES = [ * @class */ function SpeechClient(gaxGrpc, grpcClients, opts) { - opts = opts || {}; - var servicePath = opts.servicePath || SERVICE_ADDRESS; - var port = opts.port || DEFAULT_SERVICE_PORT; - var sslCreds = opts.sslCreds || null; - var clientConfig = opts.clientConfig || {}; - var appName = opts.appName || 'gax'; - var appVersion = opts.appVersion || gax.version; + opts = extend({ + servicePath: SERVICE_ADDRESS, + port: DEFAULT_SERVICE_PORT, + clientConfig: {} + }, opts); var googleApiClient = [ - appName + '/' + appVersion, - CODE_GEN_NAME_VERSION, + 'gl-node/' + process.versions.node, + CODE_GEN_NAME_VERSION + ]; + if (opts.libName && opts.libVersion) { + googleApiClient.push(opts.libName + '/' + opts.libVersion); + } + googleApiClient.push( 'gax/' + gax.version, - 'nodejs/' + process.version].join(' '); + 'grpc/' + gaxGrpc.grpcVersion + ); this.operationsClient = new gax.lro({ auth: gaxGrpc.auth, grpc: gaxGrpc.grpc - }).operationsClient({ - servicePath: servicePath, - port: port, - sslCreds: sslCreds, - clientConfig: clientConfig, - appName: appName, - appVersion: appVersion - }); + }).operationsClient(opts); this.longrunningDescriptors = { asyncRecognize: new gax.LongrunningDescriptor( @@ -102,16 +99,15 @@ function SpeechClient(gaxGrpc, grpcClients, opts) { var defaults = gaxGrpc.constructSettings( 'google.cloud.speech.v1beta1.Speech', configData, - clientConfig, - {'x-goog-api-client': googleApiClient}); + opts.clientConfig, + {'x-goog-api-client': googleApiClient.join(' ')}); var self = this; + this.auth = gaxGrpc.auth; var speechStub = gaxGrpc.createStub( - servicePath, - port, grpcClients.google.cloud.speech.v1beta1.Speech, - {sslCreds: sslCreds}); + opts); var speechStubMethods = [ 'syncRecognize', 'asyncRecognize', @@ -130,6 +126,15 @@ function SpeechClient(gaxGrpc, grpcClients, opts) { }); } +/** + * Get the project ID used by this class. + * @aram {function(Error, string)} callback - the callback to be called with + * the current project Id. + */ +SpeechClient.prototype.getProjectId = function(callback) { + return this.auth.getProjectId(callback); +}; + // Service calls /** @@ -352,10 +357,6 @@ function SpeechClientBuilder(gaxGrpc) { * @param {Object=} opts.clientConfig * The customized config to build the call settings. See * {@link gax.constructSettings} for the format. - * @param {number=} opts.appName - * The codename of the calling service. - * @param {String=} opts.appVersion - * The version of the calling service. */ this.speechClient = function(opts) { return new SpeechClient(gaxGrpc, speechClient, opts); diff --git a/packages/google-cloud-node/src/v1beta1/speech_client_config.json b/packages/google-cloud-node/src/v1beta1/speech_client_config.json index a9afe9326756..da873998217a 100644 --- a/packages/google-cloud-node/src/v1beta1/speech_client_config.json +++ b/packages/google-cloud-node/src/v1beta1/speech_client_config.json @@ -2,13 +2,11 @@ "interfaces": { "google.cloud.speech.v1beta1.Speech": { "retry_codes": { - "retry_codes_def": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "non_idempotent": [] - } + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "non_idempotent": [] }, "retry_params": { "default": { diff --git a/packages/google-cloud-node/test/index.js b/packages/google-cloud-node/test/index.js index 55fc13c25baf..9058536389c9 100644 --- a/packages/google-cloud-node/test/index.js +++ b/packages/google-cloud-node/test/index.js @@ -129,11 +129,15 @@ describe('Speech', function() { var expectedSpeechService = {}; fakeV1Beta1Override = function(options) { - assert.strictEqual(options, OPTIONS); + var expected = extend({}, OPTIONS, { + libName: 'gccl', + libVersion: require('../package.json').version + }); + assert.deepStrictEqual(options, expected); return { speechClient: function(options) { - assert.strictEqual(options, OPTIONS); + assert.deepStrictEqual(options, expected); return expectedSpeechService; } };