1616
1717'use strict' ;
1818
19- const arrify = require ( 'arrify' ) ;
20- const { Service} = require ( '@google-cloud/common' ) ;
21- const { paginator} = require ( '@google-cloud/paginator' ) ;
22- const { promisifyAll} = require ( '@google-cloud/promisify' ) ;
23- const extend = require ( 'extend' ) ;
24- const is = require ( 'is' ) ;
25- const teenyRequest = require ( 'teeny-request' ) . teenyRequest ;
19+ import * as arrify from 'arrify' ;
20+ import { Service } from '@google-cloud/common' ;
21+ import { paginator } from '@google-cloud/paginator' ;
22+ import { promisifyAll } from '@google-cloud/promisify' ;
23+ import * as extend from 'extend' ;
24+ import * as is from 'is' ;
25+ import { teenyRequest } from 'teeny-request' ;
2626
27- const Zone = require ( './zone' ) ;
27+ import { Zone } from './zone' ;
2828
2929/**
3030 * @typedef {object } ClientConfig
@@ -80,6 +80,7 @@ const Zone = require('./zone');
8080 * Full quickstart example:
8181 */
8282class DNS extends Service {
83+ getZonesStream ;
8384 constructor ( options ) {
8485 options = options || { } ;
8586 const config = {
@@ -88,10 +89,42 @@ class DNS extends Service {
8889 'https://www.googleapis.com/auth/ndev.clouddns.readwrite' ,
8990 'https://www.googleapis.com/auth/cloud-platform' ,
9091 ] ,
91- packageJson : require ( '../package.json' ) ,
92- requestModule : teenyRequest ,
92+ packageJson : require ( '../../ package.json' ) ,
93+ requestModule : teenyRequest as any ,
9394 } ;
9495 super ( config , options ) ;
96+
97+ /**
98+ * Get {@link Zone} objects for all of the zones in your project as
99+ * a readable object stream.
100+ *
101+ * @method DNS#getZonesStream
102+ * @param {GetZonesRequest } [query] Query object for listing zones.
103+ * @returns {ReadableStream } A readable stream that emits {@link Zone} instances.
104+ *
105+ * @example
106+ * const DNS = require('@google-cloud/dns');
107+ * const dns = new DNS();
108+ *
109+ * dns.getZonesStream()
110+ * .on('error', console.error)
111+ * .on('data', function(zone) {
112+ * // zone is a Zone object.
113+ * })
114+ * .on('end', function() {
115+ * // All zones retrieved.
116+ * });
117+ *
118+ * //-
119+ * // If you anticipate many results, you can end a stream early to prevent
120+ * // unnecessary processing and API requests.
121+ * //-
122+ * dns.getZonesStream()
123+ * .on('data', function(zone) {
124+ * this.end();
125+ * });
126+ */
127+ this . getZonesStream = paginator . streamify ( 'getZones' ) ;
95128 }
96129 /**
97130 * Config to set for the zone.
@@ -166,7 +199,7 @@ class DNS extends Service {
166199 uri : '/managedZones' ,
167200 json : config ,
168201 } ,
169- function ( err , resp ) {
202+ function ( err , resp ) {
170203 if ( err ) {
171204 callback ( err , null , resp ) ;
172205 return ;
@@ -233,12 +266,12 @@ class DNS extends Service {
233266 uri : '/managedZones' ,
234267 qs : query ,
235268 } ,
236- function ( err , resp ) {
269+ function ( err , resp ) {
237270 if ( err ) {
238271 callback ( err , null , null , resp ) ;
239272 return ;
240273 }
241- const zones = arrify ( resp . managedZones ) . map ( function ( zone ) {
274+ const zones = arrify ( resp . managedZones ) . map ( function ( zone ) {
242275 const zoneInstance = self . zone ( zone . name ) ;
243276 zoneInstance . metadata = zone ;
244277 return zoneInstance ;
@@ -276,38 +309,6 @@ class DNS extends Service {
276309 }
277310}
278311
279- /**
280- * Get {@link Zone} objects for all of the zones in your project as
281- * a readable object stream.
282- *
283- * @method DNS#getZonesStream
284- * @param {GetZonesRequest } [query] Query object for listing zones.
285- * @returns {ReadableStream } A readable stream that emits {@link Zone} instances.
286- *
287- * @example
288- * const DNS = require('@google-cloud/dns');
289- * const dns = new DNS();
290- *
291- * dns.getZonesStream()
292- * .on('error', console.error)
293- * .on('data', function(zone) {
294- * // zone is a Zone object.
295- * })
296- * .on('end', function() {
297- * // All zones retrieved.
298- * });
299- *
300- * //-
301- * // If you anticipate many results, you can end a stream early to prevent
302- * // unnecessary processing and API requests.
303- * //-
304- * dns.getZonesStream()
305- * .on('data', function(zone) {
306- * this.end();
307- * });
308- */
309- DNS . prototype . getZonesStream = paginator . streamify ( 'getZones' ) ;
310-
311312/*! Developer Documentation
312313 *
313314 * These methods can be auto-paginated.
@@ -330,7 +331,7 @@ promisifyAll(DNS, {
330331 * @see Zone
331332 * @type {Constructor }
332333 */
333- DNS . Zone = Zone ;
334+ export { Zone } ;
334335
335336/**
336337 * The default export of the `@google-cloud/dns` package is the {@link DNS}
@@ -361,4 +362,4 @@ DNS.Zone = Zone;
361362 * region_tag:dns_quickstart
362363 * Full quickstart example:
363364 */
364- module . exports = DNS ;
365+ export { DNS } ;
0 commit comments