Skip to content

Commit

Permalink
Update speech API client autogen. (#2025)
Browse files Browse the repository at this point in the history
Updates #2019
  • Loading branch information
jmuk authored and stephenplusplus committed Feb 24, 2017
1 parent 8058f52 commit bf54fd7
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 39 deletions.
2 changes: 1 addition & 1 deletion packages/google-cloud-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions packages/google-cloud-node/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
Expand Down
6 changes: 4 additions & 2 deletions packages/google-cloud-node/src/v1beta1/index.js
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
55 changes: 28 additions & 27 deletions packages/google-cloud-node/src/v1beta1/speech_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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',
Expand All @@ -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

/**
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 5 additions & 7 deletions packages/google-cloud-node/src/v1beta1/speech_client_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
8 changes: 6 additions & 2 deletions packages/google-cloud-node/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
Expand Down

0 comments on commit bf54fd7

Please sign in to comment.