How to use @google-cloud/paginator - 10 common examples

To help you get started, we’ve selected a few @google-cloud/paginator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleapis / nodejs-compute / src / zone.js View on Github external
*     // `autoscaler` is an `Autoscaler` object.
 *   })
 *   .on('end', function() {
 *     // All autoscalers retrieved.
 *   });
 *
 * //-
 * // If you anticipate many results, you can end a stream early to prevent
 * // unnecessary processing and API requests.
 * //-
 * zone.getAutoscalersStream()
 *   .on('data', function(autoscaler) {
 *     this.end();
 *   });
 */
Zone.prototype.getAutoscalersStream = paginator.streamify('getAutoscalers');

/**
 * Get a list of {@link Disk} objects in this zone as a readable object
 * stream.
 *
 * @param {object=} options - Configuration object. See
 *     {@link Zone#getDisks} for a complete list of options.
 * @returns {stream}
 *
 * @example
 * const Compute = require('@google-cloud/compute');
 * const compute = new Compute();
 * const zone = compute.zone('us-central1-a');
 *
 * zone.getDisksStream()
 *   .on('error', console.error)
github googleapis / nodejs-compute / src / index.js View on Github external
*   })
 *   .on('end', function() {
 *     // All disks retrieved.
 *   });
 *
 * //-
 * // If you anticipate many results, you can end a stream early to prevent
 * // unnecessary processing and API requests.
 * //-
 * gce.getDisksStream()
 *   .on('data', function(disk) {
 *     this.end();
 *   });
 */

Compute.prototype.getDisksStream = paginator.streamify('getDisks');

/**
 * Get a list of {@link InstanceGroup} objects as a readable object
 * stream.
 *
 * @method Compute#getInstanceGroupsStream
 * @param {object=} options - Configuration object. See
 *     {@link Compute#getInstanceGroups} for a complete list of options.
 * @returns {stream}
 *
 * @example
 * gce.getInstanceGroupsStream()
 *   .on('error', console.error)
 *   .on('data', function(instanceGroup) {
 *     // `instanceGroup` is an `InstanceGroup` object.
 *   })
github googleapis / nodejs-compute / src / index.js View on Github external
*     // `image` is an `Image` object.
 *   })
 *   .on('end', function() {
 *     // All images retrieved.
 *   });
 *
 * //-
 * // If you anticipate many results, you can end a stream early to prevent
 * // unnecessary processing and API requests.
 * //-
 * gce.getImagesStream()
 *   .on('data', function(image) {
 *     this.end();
 *   });
 */
Compute.prototype.getImagesStream = paginator.streamify('getImages');

/**
 * Get a list of {@link MachineType} objects in this project as a
 * readable object stream.
 *
 * @method Compute#getMachineTypesStream
 * @param {object=} options - Configuration object. See
 *     {@link Compute#getMachineTypes} for a complete list of options.
 * @returns {stream}
 *
 * @example
 * gce.getMachineTypesStream()
 *   .on('error', console.error)
 *   .on('data', function(machineType) {
 *     // `machineType` is a `MachineType` object.
 *   })
github googleapis / nodejs-compute / src / index.js View on Github external
*     // `machineType` is a `MachineType` object.
 *   })
 *   .on('end', function() {
 *     // All machine types retrieved.
 *   });
 *
 * //-
 * // If you anticipate many results, you can end a stream early to prevent
 * // unnecessary processing and API requests.
 * //-
 * gce.getMachineTypesStream()
 *   .on('data', function(machineType) {
 *     this.end();
 *   });
 */
Compute.prototype.getMachineTypesStream = paginator.streamify(
  'getMachineTypes'
);

/**
 * Get a list of {@link Network} objects as a readable object stream.
 *
 * @method Compute#getNetworksStream
 * @param {object=} options - Configuration object. See
 *     {@link Compute#getNetworks} for a complete list of options.
 * @returns {stream}
 *
 * @example
 * gce.getNetworksStream()
 *   .on('error', console.error)
 *   .on('data', function(network) {
 *     // `network` is a `Network` object.
github googleapis / nodejs-compute / src / index.js View on Github external
*     // `operation` is a `Operation` object.
 *   })
 *   .on('end', function() {
 *     // All operations retrieved.
 *   });
 *
 * //-
 * // If you anticipate many results, you can end a stream early to prevent
 * // unnecessary processing and API requests.
 * //-
 * gce.getOperationsStream()
 *   .on('data', function(operation) {
 *     this.end();
 *   });
 */
Compute.prototype.getOperationsStream = paginator.streamify('getOperations');

/**
 * Return the {@link Region} objects available to your project as a
 * readable object stream.
 *
 * @method Compute#getRegionsStream
 * @param {object=} options - Configuration object. See
 *     {@link Compute#getRegions} for a complete list of options.
 * @returns {stream}
 *
 * @example
 * gce.getRegionsStream()
 *   .on('error', console.error)
 *   .on('data', function(region) {
 *     // `region` is a `Region` object.
 *   })
github googleapis / nodejs-compute / src / index.js View on Github external
*     // `vm` is a `VM` object.
 *   })
 *   .on('end', function() {
 *     // All vms retrieved.
 *   });
 *
 * //-
 * // If you anticipate many results, you can end a stream early to prevent
 * // unnecessary processing and API requests.
 * //-
 * gce.getVMsStream()
 *   .on('data', function(vm) {
 *     this.end();
 *   });
 */
Compute.prototype.getVMsStream = paginator.streamify('getVMs');

/**
 * Return the {@link Zone} objects available to your project as a
 * readable object stream.
 *
 * @method Compute#getZonesStream
 * @param {object=} options - Configuration object. See
 *     {@link Compute#getZones} for a complete list of options.
 * @returns {stream}
 *
 * @example
 * gce.getZonesStream()
 *   .on('error', console.error)
 *   .on('data', function(zone) {
 *     // `zone` is a `Zone` object.
 *   })
github googleapis / nodejs-compute / src / index.js View on Github external
*     // `network` is a `Network` object.
 *   })
 *   .on('end', function() {
 *     // All networks retrieved.
 *   });
 *
 * //-
 * // If you anticipate many results, you can end a stream early to prevent
 * // unnecessary processing and API requests.
 * //-
 * gce.getNetworksStream()
 *   .on('data', function(network) {
 *     this.end();
 *   });
 */
Compute.prototype.getNetworksStream = paginator.streamify('getNetworks');

/**
 * Get a list of global {@link Operation} objects as a readable object
 * stream.
 *
 * @method Compute#getOperationsStream
 * @param {object=} options - Configuration object. See
 *     {@link Compute#getOperations} for a complete list of options.
 * @returns {stream}
 *
 * @example
 * gce.getOperationsStream()
 *   .on('error', console.error)
 *   .on('data', function(operation) {
 *     // `operation` is a `Operation` object.
 *   })
github googleapis / nodejs-bigquery / src / dataset.ts View on Github external
*   .on('error', console.error)
     *   .on('data', (table) => {})
     *   .on('end', () => {
     *     // All tables have been retrieved
     *   });
     *
     * //-
     * // If you anticipate many results, you can end a stream early to prevent
     * // unnecessary processing and API requests.
     * //-
     * dataset.getTablesStream()
     *   .on('data', function(table) {
     *     this.end();
     *   });
     */
    this.getTablesStream = paginator.streamify('getTables');
  }
github googleapis / nodejs-compute / src / zone.js View on Github external
*     // `vm` is a `VM` object.
 *   })
 *   .on('end', function() {
 *     // All instances retrieved.
 *   });
 *
 * //-
 * // If you anticipate many results, you can end a stream early to prevent
 * // unnecessary processing and API requests.
 * //-
 * zone.getVMsStream()
 *   .on('data', function(vm) {
 *     this.end();
 *   });
 */
Zone.prototype.getVMsStream = paginator.streamify('getVMs');

/*! Developer Documentation
 *
 * These methods can be auto-paginated.
 */
paginator.extend(Zone, [
  'getAutoscalers',
  'getDisks',
  'getInstanceGroups',
  'getInstanceGroupManagers',
  'getMachineTypes',
  'getOperations',
  'getVMs',
]);

/*! Developer Documentation
github googleapis / nodejs-bigquery / src / index.ts View on Github external
*     // dataset is a Dataset object.
 *   })
 *   .on('end', function() {
 *     // All datasets retrieved.
 *   });
 *
 * //-
 * // If you anticipate many results, you can end a stream early to prevent
 * // unnecessary processing and API requests.
 * //-
 * bigquery.getDatasetsStream()
 *   .on('data', function(dataset) {
 *     this.end();
 *   });
 */
BigQuery.prototype.getDatasetsStream = paginator.streamify(
  'getDatasets'
);

/**
 * Get all of the jobs from your project.
 *
 * @see [Jobs: list API Documentation]{@link https://cloud.google.com/bigquery/docs/reference/v2/jobs/list}
 *
 * @param {object} [options] Configuration object.
 * @param {boolean} [options.allUsers] Display jobs owned by all users in the
 *     project.
 * @param {boolean} [options.autoPaginate] Have pagination handled
 *     automatically. Default: true.
 * @param {number} [options.maxApiCalls] Maximum number of API calls to make.
 * @param {number} [options.maxResults] Maximum number of results to return.
 * @param {string} [options.pageToken] Token returned from a previous call, to

@google-cloud/paginator

A result paging utility used by Google node.js modules

Apache-2.0
Latest version published 6 months ago

Package Health Score

87 / 100
Full package analysis