@@ -130,6 +130,14 @@ util.inherits(Logging, common.GrpcService);
130130 * }
131131 *
132132 * logging.createSink('new-sink-name', config, callback);
133+ *
134+ * //-
135+ * // If the callback is omitted, we'll return a Promise.
136+ * //-
137+ * logging.createSink('new-sink-name', config).then(function(data) {
138+ * var sink = data[0];
139+ * var apiResponse = data[1];
140+ * });
133141 */
134142Logging . prototype . createSink = function ( name , config , callback ) {
135143 // jscs:enable maximumLineLength
@@ -273,26 +281,11 @@ Logging.prototype.entry = function(resource, data) {
273281 * }, callback);
274282 *
275283 * //-
276- * // Get the entries from your project as a readable object stream .
284+ * // If the callback is omitted, we'll return a Promise .
277285 * //-
278- * logging.getEntries()
279- * .on('error', console.error)
280- * .on('data', function(entry) {
281- * // `entry` is a Stackdriver Logging entry object.
282- * // See the `data` property to read the data from the entry.
283- * })
284- * .on('end', function() {
285- * // All entries retrieved.
286- * });
287- *
288- * //-
289- * // If you anticipate many results, you can end a stream early to prevent
290- * // unnecessary processing and API requests.
291- * //-
292- * logging.getEntries()
293- * .on('data', function(entry) {
294- * this.end();
295- * });
286+ * logging.getEntries().then(function(data) {
287+ * var entries = data[0];
288+ * });
296289 */
297290Logging . prototype . getEntries = function ( options , callback ) {
298291 if ( is . fn ( options ) ) {
@@ -331,6 +324,36 @@ Logging.prototype.getEntries = function(options, callback) {
331324 } ) ;
332325} ;
333326
327+ /**
328+ * List the {module:logging/entry} objects in your logs as a readable object
329+ * stream.
330+ *
331+ * @param {object= } options - Configuration object. See
332+ * {module:logging#getEntries} for a complete list of options.
333+ * @return {stream }
334+ *
335+ * @example
336+ * logging.getEntriesStream()
337+ * .on('error', console.error)
338+ * .on('data', function(entry) {
339+ * // `entry` is a Stackdriver Logging entry object.
340+ * // See the `data` property to read the data from the entry.
341+ * })
342+ * .on('end', function() {
343+ * // All entries retrieved.
344+ * });
345+ *
346+ * //-
347+ * // If you anticipate many results, you can end a stream early to prevent
348+ * // unnecessary processing and API requests.
349+ * //-
350+ * logging.getEntriesStream()
351+ * .on('data', function(entry) {
352+ * this.end();
353+ * });
354+ */
355+ Logging . prototype . getEntriesStream = common . paginator . streamify ( 'getEntries' ) ;
356+
334357/**
335358 * Get the sinks associated with this project.
336359 *
@@ -352,25 +375,11 @@ Logging.prototype.getEntries = function(options, callback) {
352375 * });
353376 *
354377 * //-
355- * // Get the sinks from your project as a readable object stream .
378+ * // If the callback is omitted, we'll return a Promise .
356379 * //-
357- * logging.getSinks()
358- * .on('error', console.error)
359- * .on('data', function(sink) {
360- * // `sink` is a Sink object.
361- * })
362- * .on('end', function() {
363- * // All sinks retrieved.
364- * });
365- *
366- * //-
367- * // If you anticipate many results, you can end a stream early to prevent
368- * // unnecessary processing and API requests.
369- * //-
370- * logging.getSinks()
371- * .on('data', function(sink) {
372- * this.end();
373- * });
380+ * logging.getSinks().then(function(data) {
381+ * var sinks = data[0];
382+ * });
374383 */
375384Logging . prototype . getSinks = function ( options , callback ) {
376385 var self = this ;
@@ -413,6 +422,35 @@ Logging.prototype.getSinks = function(options, callback) {
413422 } ) ;
414423} ;
415424
425+ /**
426+ * Get the {module:logging/sink} objects associated with this project as a
427+ * readable object stream.
428+ *
429+ * @param {object= } options - Configuration object. See
430+ * {module:logging#getSinks} for a complete list of options.
431+ * @return {stream }
432+ *
433+ * @example
434+ * logging.getSinksStream()
435+ * .on('error', console.error)
436+ * .on('data', function(sink) {
437+ * // `sink` is a Sink object.
438+ * })
439+ * .on('end', function() {
440+ * // All sinks retrieved.
441+ * });
442+ *
443+ * //-
444+ * // If you anticipate many results, you can end a stream early to prevent
445+ * // unnecessary processing and API requests.
446+ * //-
447+ * logging.getSinksStream()
448+ * .on('data', function(sink) {
449+ * this.end();
450+ * });
451+ */
452+ Logging . prototype . getSinksStream = common . paginator . streamify ( 'getSinks' ) ;
453+
416454/**
417455 * Get a reference to a Stackdriver Logging log.
418456 *
@@ -557,10 +595,18 @@ Logging.prototype.setAclForTopic_ = function(name, config, callback) {
557595
558596/*! Developer Documentation
559597 *
560- * These methods can be used with either a callback or as a readable object
561- * stream. `streamRouter` is used to add this dual behavior.
598+ * These methods can be auto-paginated.
599+ */
600+ common . paginator . extend ( Logging , [ 'getEntries' , 'getSinks' ] ) ;
601+
602+ /*! Developer Documentation
603+ *
604+ * All async methods (except for streams) will return a Promise in the event
605+ * that a callback is omitted.
562606 */
563- common . streamRouter . extend ( Logging , [ 'getEntries' , 'getSinks' ] ) ;
607+ common . util . promisifyAll ( Logging , {
608+ exclude : [ 'entry' , 'log' , 'sink' ]
609+ } ) ;
564610
565611Logging . Entry = Entry ;
566612Logging . Log = Log ;
0 commit comments