@@ -63,44 +63,61 @@ var ALL_SCOPES = [
63
63
* @class
64
64
*/
65
65
function ImageAnnotatorClient ( gaxGrpc , grpcClients , opts ) {
66
- opts = opts || { } ;
67
- var servicePath = opts . servicePath || SERVICE_ADDRESS ;
68
- var port = opts . port || DEFAULT_SERVICE_PORT ;
69
- var sslCreds = opts . sslCreds || null ;
70
- var clientConfig = opts . clientConfig || { } ;
71
- var appName = opts . appName || 'gax' ;
72
- var appVersion = opts . appVersion || gax . version ;
66
+ opts = extend ( {
67
+ servicePath : SERVICE_ADDRESS ,
68
+ port : DEFAULT_SERVICE_PORT ,
69
+ clientConfig : { }
70
+ } , opts ) ;
73
71
74
72
var googleApiClient = [
75
- appName + '/' + appVersion ,
76
- CODE_GEN_NAME_VERSION ,
73
+ 'gl-node/' + process . versions . node ,
74
+ CODE_GEN_NAME_VERSION
75
+ ] ;
76
+ if ( opts . libName && opts . libVersion ) {
77
+ googleApiClient . push ( opts . libName + '/' + opts . libVersion ) ;
78
+ }
79
+ googleApiClient . push (
77
80
'gax/' + gax . version ,
78
- 'nodejs/' + process . version ] . join ( ' ' ) ;
81
+ 'grpc/' + gaxGrpc . grpcVersion
82
+ ) ;
79
83
80
84
var defaults = gaxGrpc . constructSettings (
81
85
'google.cloud.vision.v1.ImageAnnotator' ,
82
86
configData ,
83
- clientConfig ,
84
- { 'x-goog-api-client' : googleApiClient } ) ;
87
+ opts . clientConfig ,
88
+ { 'x-goog-api-client' : googleApiClient . join ( ' ' ) } ) ;
85
89
90
+ var self = this ;
91
+
92
+ this . auth = gaxGrpc . auth ;
86
93
var imageAnnotatorStub = gaxGrpc . createStub (
87
- servicePath ,
88
- port ,
89
- grpcClients . imageAnnotatorClient . google . cloud . vision . v1 . ImageAnnotator ,
90
- { sslCreds : sslCreds } ) ;
94
+ grpcClients . google . cloud . vision . v1 . ImageAnnotator ,
95
+ opts ) ;
91
96
var imageAnnotatorStubMethods = [
92
97
'batchAnnotateImages'
93
98
] ;
94
99
imageAnnotatorStubMethods . forEach ( function ( methodName ) {
95
- this [ '_' + methodName ] = gax . createApiCall (
100
+ self [ '_' + methodName ] = gax . createApiCall (
96
101
imageAnnotatorStub . then ( function ( imageAnnotatorStub ) {
97
- return imageAnnotatorStub [ methodName ] . bind ( imageAnnotatorStub ) ;
102
+ return function ( ) {
103
+ var args = Array . prototype . slice . call ( arguments , 0 ) ;
104
+ return imageAnnotatorStub [ methodName ] . apply ( imageAnnotatorStub , args ) ;
105
+ } ;
98
106
} ) ,
99
107
defaults [ methodName ] ,
100
108
null ) ;
101
- } . bind ( this ) ) ;
109
+ } ) ;
102
110
}
103
111
112
+ /**
113
+ * Get the project ID used by this class.
114
+ * @aram {function(Error, string)} callback - the callback to be called with
115
+ * the current project Id.
116
+ */
117
+ ImageAnnotatorClient . prototype . getProjectId = function ( callback ) {
118
+ return this . auth . getProjectId ( callback ) ;
119
+ } ;
120
+
104
121
// Service calls
105
122
106
123
/**
@@ -157,9 +174,6 @@ function ImageAnnotatorClientBuilder(gaxGrpc) {
157
174
} ] ) ;
158
175
extend ( this , imageAnnotatorClient . google . cloud . vision . v1 ) ;
159
176
160
- var grpcClients = {
161
- imageAnnotatorClient : imageAnnotatorClient
162
- } ;
163
177
164
178
/**
165
179
* Build a new instance of {@link ImageAnnotatorClient}.
@@ -174,13 +188,9 @@ function ImageAnnotatorClientBuilder(gaxGrpc) {
174
188
* @param {Object= } opts.clientConfig
175
189
* The customized config to build the call settings. See
176
190
* {@link gax.constructSettings} for the format.
177
- * @param {number= } opts.appName
178
- * The codename of the calling service.
179
- * @param {String= } opts.appVersion
180
- * The version of the calling service.
181
191
*/
182
192
this . imageAnnotatorClient = function ( opts ) {
183
- return new ImageAnnotatorClient ( gaxGrpc , grpcClients , opts ) ;
193
+ return new ImageAnnotatorClient ( gaxGrpc , imageAnnotatorClient , opts ) ;
184
194
} ;
185
195
extend ( this . imageAnnotatorClient , ImageAnnotatorClient ) ;
186
196
}
0 commit comments