Skip to content

Commit e24a734

Browse files
logging: update gapic layer (#1735)
1 parent c2db58f commit e24a734

4 files changed

Lines changed: 202 additions & 326 deletions

File tree

packages/logging/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"@google-cloud/common": "^0.7.0",
5656
"arrify": "^1.0.0",
5757
"extend": "^3.0.0",
58-
"google-gax": "^0.7.0",
58+
"google-gax": "^0.8.1",
5959
"google-proto-files": "^0.8.0",
6060
"is": "^3.0.1",
6161
"is-circular": "^1.0.1",

packages/logging/src/v2/config_service_v2_api.js

Lines changed: 69 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ var SINK_PATH_TEMPLATE = new gax.PathTemplate(
130130
* @param {String} project
131131
* @returns {String}
132132
*/
133-
ConfigServiceV2Api.prototype.parentPath = function parentPath(project) {
133+
ConfigServiceV2Api.prototype.parentPath = function(project) {
134134
return PARENT_PATH_TEMPLATE.render({
135135
project: project
136136
});
@@ -142,8 +142,7 @@ ConfigServiceV2Api.prototype.parentPath = function parentPath(project) {
142142
* A fully-qualified path representing a parent resources.
143143
* @returns {String} - A string representing the project.
144144
*/
145-
ConfigServiceV2Api.prototype.matchProjectFromParentName =
146-
function matchProjectFromParentName(parentName) {
145+
ConfigServiceV2Api.prototype.matchProjectFromParentName = function(parentName) {
147146
return PARENT_PATH_TEMPLATE.match(parentName).project;
148147
};
149148

@@ -153,7 +152,7 @@ ConfigServiceV2Api.prototype.matchProjectFromParentName =
153152
* @param {String} sink
154153
* @returns {String}
155154
*/
156-
ConfigServiceV2Api.prototype.sinkPath = function sinkPath(project, sink) {
155+
ConfigServiceV2Api.prototype.sinkPath = function(project, sink) {
157156
return SINK_PATH_TEMPLATE.render({
158157
project: project,
159158
sink: sink
@@ -166,8 +165,7 @@ ConfigServiceV2Api.prototype.sinkPath = function sinkPath(project, sink) {
166165
* A fully-qualified path representing a sink resources.
167166
* @returns {String} - A string representing the project.
168167
*/
169-
ConfigServiceV2Api.prototype.matchProjectFromSinkName =
170-
function matchProjectFromSinkName(sinkName) {
168+
ConfigServiceV2Api.prototype.matchProjectFromSinkName = function(sinkName) {
171169
return SINK_PATH_TEMPLATE.match(sinkName).project;
172170
};
173171

@@ -177,8 +175,7 @@ ConfigServiceV2Api.prototype.matchProjectFromSinkName =
177175
* A fully-qualified path representing a sink resources.
178176
* @returns {String} - A string representing the sink.
179177
*/
180-
ConfigServiceV2Api.prototype.matchSinkFromSinkName =
181-
function matchSinkFromSinkName(sinkName) {
178+
ConfigServiceV2Api.prototype.matchSinkFromSinkName = function(sinkName) {
182179
return SINK_PATH_TEMPLATE.match(sinkName).sink;
183180
};
184181

@@ -187,39 +184,38 @@ ConfigServiceV2Api.prototype.matchSinkFromSinkName =
187184
/**
188185
* Lists sinks.
189186
*
190-
* @param {string} parent
187+
* @param {Object} request
188+
* The request object that will be sent.
189+
* @param {string} request.parent
191190
* Required. The cloud resource containing the sinks.
192191
* Example: `"projects/my-logging-project"`.
193-
* @param {Object=} options
194-
* Optional parameters. You can override the default settings for this call, e.g, timeout,
195-
* retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
196-
*
197-
* In addition, options may contain the following optional parameters.
198-
* @param {number=} options.pageSize
192+
* @param {number=} request.pageSize
199193
* The maximum number of resources contained in the underlying API
200194
* response. If page streaming is performed per-resource, this
201195
* parameter does not affect the return value. If page streaming is
202196
* performed per-page, this determines the maximum number of
203197
* resources in a page.
204-
*
198+
* @param {Object=} options
199+
* Optional parameters. You can override the default settings for this call, e.g, timeout,
200+
* retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
205201
* @param {function(?Error, ?Object, ?string)=} callback
206202
* When specified, the results are not streamed but this callback
207203
* will be called with the response object representing [ListSinksResponse]{@link ListSinksResponse}.
208204
* The third item will be set if the response contains the token for the further results
209205
* and can be reused to `pageToken` field in the options in the next request.
210-
* @returns {Stream|gax.EventEmitter}
206+
* @returns {Stream|Promise}
211207
* An object stream which emits an object representing
212208
* [LogSink]{@link LogSink} on 'data' event.
213209
* When the callback is specified or streaming is suppressed through options,
214-
* it will return an event emitter to handle the call status and the callback
215-
* will be called with the response object.
210+
* it will return a promise that resolves to the response object. The promise
211+
* has a method named "cancel" which cancels the ongoing API call.
216212
*
217213
* @example
218214
*
219215
* var api = loggingV2.configServiceV2Api();
220216
* var formattedParent = api.parentPath("[PROJECT]");
221217
* // Iterate over all elements.
222-
* api.listSinks(formattedParent).on('data', function(element) {
218+
* api.listSinks({parent: formattedParent}).on('data', function(element) {
223219
* // doThingsWith(element)
224220
* });
225221
*
@@ -232,35 +228,28 @@ ConfigServiceV2Api.prototype.matchSinkFromSinkName =
232228
* // doThingsWith(response)
233229
* if (nextPageToken) {
234230
* // fetch the next page.
235-
* api.listSinks(formattedParent, {pageToken: nextPageToken}, callback);
231+
* api.listSinks({parent: formattedParent}, {pageToken: nextPageToken}, callback);
236232
* }
237233
* }
238-
* api.listSinks(formattedParent, {flattenPages: false}, callback);
234+
* api.listSinks({parent: formattedParent}, {flattenPages: false}, callback);
239235
*/
240-
ConfigServiceV2Api.prototype.listSinks = function listSinks(
241-
parent,
242-
options,
243-
callback) {
236+
ConfigServiceV2Api.prototype.listSinks = function(request, options, callback) {
244237
if (options instanceof Function && callback === undefined) {
245238
callback = options;
246239
options = {};
247240
}
248241
if (options === undefined) {
249242
options = {};
250243
}
251-
var req = {
252-
parent: parent
253-
};
254-
if ('pageSize' in options) {
255-
req.pageSize = options.pageSize;
256-
}
257-
return this._listSinks(req, options, callback);
244+
return this._listSinks(request, options, callback);
258245
};
259246

260247
/**
261248
* Gets a sink.
262249
*
263-
* @param {string} sinkName
250+
* @param {Object} request
251+
* The request object that will be sent.
252+
* @param {string} request.sinkName
264253
* Required. The resource name of the sink to return.
265254
* Example: `"projects/my-project-id/sinks/my-sink-id"`.
266255
* @param {Object=} options
@@ -270,46 +259,40 @@ ConfigServiceV2Api.prototype.listSinks = function listSinks(
270259
* The function which will be called with the result of the API call.
271260
*
272261
* The second parameter to the callback is an object representing [LogSink]{@link LogSink}
273-
* @returns {gax.EventEmitter} - the event emitter to handle the call
274-
* status.
262+
* @returns {Promise} - The promise which resolves to the response object.
263+
* The promise has a method named "cancel" which cancels the ongoing API call.
275264
*
276265
* @example
277266
*
278267
* var api = loggingV2.configServiceV2Api();
279268
* var formattedSinkName = api.sinkPath("[PROJECT]", "[SINK]");
280-
* api.getSink(formattedSinkName, function(err, response) {
281-
* if (err) {
282-
* console.error(err);
283-
* return;
284-
* }
269+
* api.getSink({sinkName: formattedSinkName}).then(function(response) {
285270
* // doThingsWith(response)
271+
* }).catch(function(err) {
272+
* console.error(err);
286273
* });
287274
*/
288-
ConfigServiceV2Api.prototype.getSink = function getSink(
289-
sinkName,
290-
options,
291-
callback) {
275+
ConfigServiceV2Api.prototype.getSink = function(request, options, callback) {
292276
if (options instanceof Function && callback === undefined) {
293277
callback = options;
294278
options = {};
295279
}
296280
if (options === undefined) {
297281
options = {};
298282
}
299-
var req = {
300-
sinkName: sinkName
301-
};
302-
return this._getSink(req, options, callback);
283+
return this._getSink(request, options, callback);
303284
};
304285

305286
/**
306287
* Creates a sink.
307288
*
308-
* @param {string} parent
289+
* @param {Object} request
290+
* The request object that will be sent.
291+
* @param {string} request.parent
309292
* Required. The resource in which to create the sink.
310293
* Example: `"projects/my-project-id"`.
311294
* The new sink must be provided in the request.
312-
* @param {Object} sink
295+
* @param {Object} request.sink
313296
* Required. The new sink, whose `name` parameter is a sink identifier that
314297
* is not already in use.
315298
*
@@ -321,49 +304,45 @@ ConfigServiceV2Api.prototype.getSink = function getSink(
321304
* The function which will be called with the result of the API call.
322305
*
323306
* The second parameter to the callback is an object representing [LogSink]{@link LogSink}
324-
* @returns {gax.EventEmitter} - the event emitter to handle the call
325-
* status.
307+
* @returns {Promise} - The promise which resolves to the response object.
308+
* The promise has a method named "cancel" which cancels the ongoing API call.
326309
*
327310
* @example
328311
*
329312
* var api = loggingV2.configServiceV2Api();
330313
* var formattedParent = api.parentPath("[PROJECT]");
331314
* var sink = {};
332-
* api.createSink(formattedParent, sink, function(err, response) {
333-
* if (err) {
334-
* console.error(err);
335-
* return;
336-
* }
315+
* var request = {
316+
* parent: formattedParent,
317+
* sink: sink
318+
* };
319+
* api.createSink(request).then(function(response) {
337320
* // doThingsWith(response)
321+
* }).catch(function(err) {
322+
* console.error(err);
338323
* });
339324
*/
340-
ConfigServiceV2Api.prototype.createSink = function createSink(
341-
parent,
342-
sink,
343-
options,
344-
callback) {
325+
ConfigServiceV2Api.prototype.createSink = function(request, options, callback) {
345326
if (options instanceof Function && callback === undefined) {
346327
callback = options;
347328
options = {};
348329
}
349330
if (options === undefined) {
350331
options = {};
351332
}
352-
var req = {
353-
parent: parent,
354-
sink: sink
355-
};
356-
return this._createSink(req, options, callback);
333+
return this._createSink(request, options, callback);
357334
};
358335

359336
/**
360337
* Updates or creates a sink.
361338
*
362-
* @param {string} sinkName
339+
* @param {Object} request
340+
* The request object that will be sent.
341+
* @param {string} request.sinkName
363342
* Required. The resource name of the sink to update, including the parent
364343
* resource and the sink identifier. If the sink does not exist, this method
365344
* creates the sink. Example: `"projects/my-project-id/sinks/my-sink-id"`.
366-
* @param {Object} sink
345+
* @param {Object} request.sink
367346
* Required. The updated sink, whose name is the same identifier that appears
368347
* as part of `sinkName`. If `sinkName` does not exist, then
369348
* this method creates a new sink.
@@ -376,45 +355,41 @@ ConfigServiceV2Api.prototype.createSink = function createSink(
376355
* The function which will be called with the result of the API call.
377356
*
378357
* The second parameter to the callback is an object representing [LogSink]{@link LogSink}
379-
* @returns {gax.EventEmitter} - the event emitter to handle the call
380-
* status.
358+
* @returns {Promise} - The promise which resolves to the response object.
359+
* The promise has a method named "cancel" which cancels the ongoing API call.
381360
*
382361
* @example
383362
*
384363
* var api = loggingV2.configServiceV2Api();
385364
* var formattedSinkName = api.sinkPath("[PROJECT]", "[SINK]");
386365
* var sink = {};
387-
* api.updateSink(formattedSinkName, sink, function(err, response) {
388-
* if (err) {
389-
* console.error(err);
390-
* return;
391-
* }
366+
* var request = {
367+
* sinkName: formattedSinkName,
368+
* sink: sink
369+
* };
370+
* api.updateSink(request).then(function(response) {
392371
* // doThingsWith(response)
372+
* }).catch(function(err) {
373+
* console.error(err);
393374
* });
394375
*/
395-
ConfigServiceV2Api.prototype.updateSink = function updateSink(
396-
sinkName,
397-
sink,
398-
options,
399-
callback) {
376+
ConfigServiceV2Api.prototype.updateSink = function(request, options, callback) {
400377
if (options instanceof Function && callback === undefined) {
401378
callback = options;
402379
options = {};
403380
}
404381
if (options === undefined) {
405382
options = {};
406383
}
407-
var req = {
408-
sinkName: sinkName,
409-
sink: sink
410-
};
411-
return this._updateSink(req, options, callback);
384+
return this._updateSink(request, options, callback);
412385
};
413386

414387
/**
415388
* Deletes a sink.
416389
*
417-
* @param {string} sinkName
390+
* @param {Object} request
391+
* The request object that will be sent.
392+
* @param {string} request.sinkName
418393
* Required. The resource name of the sink to delete, including the parent
419394
* resource and the sink identifier. Example:
420395
* `"projects/my-project-id/sinks/my-sink-id"`. It is an error if the sink
@@ -424,34 +399,26 @@ ConfigServiceV2Api.prototype.updateSink = function updateSink(
424399
* retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
425400
* @param {function(?Error)=} callback
426401
* The function which will be called with the result of the API call.
427-
* @returns {gax.EventEmitter} - the event emitter to handle the call
428-
* status.
402+
* @returns {Promise} - The promise which resolves to the response object.
403+
* The promise has a method named "cancel" which cancels the ongoing API call.
429404
*
430405
* @example
431406
*
432407
* var api = loggingV2.configServiceV2Api();
433408
* var formattedSinkName = api.sinkPath("[PROJECT]", "[SINK]");
434-
* api.deleteSink(formattedSinkName, function(err) {
435-
* if (err) {
436-
* console.error(err);
437-
* }
409+
* api.deleteSink({sinkName: formattedSinkName}).catch(function(err) {
410+
* console.error(err);
438411
* });
439412
*/
440-
ConfigServiceV2Api.prototype.deleteSink = function deleteSink(
441-
sinkName,
442-
options,
443-
callback) {
413+
ConfigServiceV2Api.prototype.deleteSink = function(request, options, callback) {
444414
if (options instanceof Function && callback === undefined) {
445415
callback = options;
446416
options = {};
447417
}
448418
if (options === undefined) {
449419
options = {};
450420
}
451-
var req = {
452-
sinkName: sinkName
453-
};
454-
return this._deleteSink(req, options, callback);
421+
return this._deleteSink(request, options, callback);
455422
};
456423

457424
function ConfigServiceV2ApiBuilder(gaxGrpc) {

0 commit comments

Comments
 (0)