Skip to content

Commit d2bfedc

Browse files
feat!: drop node8 support, support for async iterators (#396)
BREAKING CHANGE: The library now supports Node.js v10+. The last version to support Node.js v8 is tagged legacy-8 on NPM. New feature: methods with pagination now support async iteration.
1 parent 5c4d3b6 commit d2bfedc

File tree

5 files changed

+111
-111
lines changed

5 files changed

+111
-111
lines changed

monitoring/snippets/alerts.js

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -308,23 +308,23 @@ async function listPolicies(projectId) {
308308
// [END monitoring_alert_list_policies]
309309
}
310310

311-
require(`yargs`)
311+
require('yargs')
312312
.demand(1)
313313
.command(
314-
`backup <projectId>`,
315-
`Save alert policies to a ./policies_backup.json file.`,
314+
'backup <projectId>',
315+
'Save alert policies to a ./policies_backup.json file.',
316316
{},
317317
opts => backupPolicies(opts.projectId, opts.filter || '')
318318
)
319319
.command(
320-
`restore <projectId>`,
321-
`Restore alert policies from a ./policies_backup.json file.`,
320+
'restore <projectId>',
321+
'Restore alert policies from a ./policies_backup.json file.',
322322
{},
323323
opts => restorePolicies(opts.projectId, opts.filter || '')
324324
)
325325
.command(
326-
`replace <alertPolicyName> <channelNames..>`,
327-
`Replace the notification channels of the specified alert policy.`,
326+
'replace <alertPolicyName> <channelNames..>',
327+
'Replace the notification channels of the specified alert policy.',
328328
{},
329329
opts => {
330330
const parts = opts.alertPolicyName.split('/');
@@ -333,69 +333,69 @@ require(`yargs`)
333333
}
334334
)
335335
.command(
336-
`disable <projectId> [filter]`,
337-
`Disables policies that match the given filter.`,
336+
'disable <projectId> [filter]',
337+
'Disables policies that match the given filter.',
338338
{},
339-
opts => enablePolicies(opts.projectId, false, opts.filter || ``)
339+
opts => enablePolicies(opts.projectId, false, opts.filter || '')
340340
)
341341
.command(
342-
`enable <projectId> [filter]`,
343-
`Enables policies that match the given filter.`,
342+
'enable <projectId> [filter]',
343+
'Enables policies that match the given filter.',
344344
{},
345-
opts => enablePolicies(opts.projectId, true, opts.filter || ``)
345+
opts => enablePolicies(opts.projectId, true, opts.filter || '')
346346
)
347347
.command(
348-
`list <projectId>`,
349-
`Lists alert policies in the specified project.`,
348+
'list <projectId>',
349+
'Lists alert policies in the specified project.',
350350
{},
351351
opts => listPolicies(opts.projectId)
352352
)
353353
.command(
354-
`deleteChannels <projectId> [filter]`,
355-
`Lists and deletes all channels in the specified project.`,
354+
'deleteChannels <projectId> [filter]',
355+
'Lists and deletes all channels in the specified project.',
356356
{},
357-
opts => deleteChannels(opts.projectId, opts.filter || ``)
357+
opts => deleteChannels(opts.projectId, opts.filter || '')
358358
)
359359
.options({
360360
alertPolicyName: {
361361
type: 'string',
362362
requiresArg: true,
363363
},
364364
})
365-
.example(`node $0 backup my-project-id`, `Backup policies.`)
366-
.example(`node $0 restore my-project-id`, `Restore policies.`)
365+
.example('node $0 backup my-project-id', 'Backup policies.')
366+
.example('node $0 restore my-project-id', 'Restore policies.')
367367
.example(
368-
`node $0 replace projects/my-project-id/alertPolicies/12345 channel-1 channel-2 channel-3`,
369-
`Replace the notification channels of the specified alert policy.`
368+
'node $0 replace projects/my-project-id/alertPolicies/12345 channel-1 channel-2 channel-3',
369+
'Replace the notification channels of the specified alert policy.'
370370
)
371371
.example(
372-
`node $0 disable my-project-id "(NOT display_name.empty OR NOT description.empty) AND user_labels='active'"`,
373-
`Disables policies that match the given filter.`
372+
'node $0 disable my-project-id "(NOT display_name.empty OR NOT description.empty) AND user_labels=\'active\'"',
373+
'Disables policies that match the given filter.'
374374
)
375375
.example(
376-
`node $0 disable my-project-id "description:'cloud'"`,
377-
`Disables policies that match the given filter.`
376+
'node $0 disable my-project-id "description:\'cloud\'"',
377+
'Disables policies that match the given filter.'
378378
)
379379
.example(
380-
`node $0 disable my-project-id "display_name=monitoring.regex.full_match('Temp \\d{4}')"`,
381-
`Disables policies that match the given filter.`
380+
'node $0 disable my-project-id "display_name=monitoring.regex.full_match(\'Temp \\d{4}\')"',
381+
'Disables policies that match the given filter.'
382382
)
383383
.example(
384-
`node $0 enable my-project-id "(NOT display_name.empty OR NOT description.empty) AND user_labels='active'"`,
385-
`Enables policies that match the given filter.`
384+
'node $0 enable my-project-id "(NOT display_name.empty OR NOT description.empty) AND user_labels=\'active\'"',
385+
'Enables policies that match the given filter.'
386386
)
387387
.example(
388-
`node $0 enable my-project-id "description:'cloud'"`,
389-
`Enables policies that match the given filter.`
388+
'node $0 enable my-project-id "description:\'cloud\'"',
389+
'Enables policies that match the given filter.'
390390
)
391391
.example(
392-
`node $0 enable my-project-id "display_name=monitoring.regex.full_match('Temp \\d{4}')"`,
393-
`Enables policies that match the given filter.`
392+
'node $0 enable my-project-id "display_name=monitoring.regex.full_match(\'Temp \\d{4}\')"',
393+
'Enables policies that match the given filter.'
394394
)
395395
.wrap(120)
396396
.recommendCommands()
397397
.epilogue(
398-
`For more information, see https://cloud.google.com/monitoring/docs/`
398+
'For more information, see https://cloud.google.com/monitoring/docs/'
399399
)
400400
.help()
401401
.strict().argv;

monitoring/snippets/metrics.js

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ async function writeTimeSeriesData(projectId) {
200200

201201
// Writes time series data
202202
const result = await client.createTimeSeries(request);
203-
console.log(`Done writing time series data.`, result);
203+
console.log('Done writing time series data.', result);
204204

205205
// [END monitoring_write_timeseries]
206206
}
@@ -330,7 +330,7 @@ async function readTimeSeriesAggregate(projectId) {
330330
}
331331
console.log(` Now: ${data.points[0].value.doubleValue}`);
332332
console.log(` 10 min ago: ${data.points[1].value.doubleValue}`);
333-
console.log(`=====`);
333+
console.log('=====');
334334
});
335335
// [END monitoring_read_timeseries_align]
336336
}
@@ -409,7 +409,7 @@ async function listMonitoredResourceDescriptors(projectId) {
409409
console.log(descriptor.name);
410410
console.log(` Type: ${descriptor.type}`);
411411
if (descriptor.labels) {
412-
console.log(` Labels:`);
412+
console.log(' Labels:');
413413
descriptor.labels.forEach(label => {
414414
console.log(
415415
` ${label.key} (${label.valueType}): ${label.description}`
@@ -456,65 +456,65 @@ async function getMonitoredResourceDescriptor(projectId, resourceType) {
456456
// [END monitoring_get_resource]
457457
}
458458

459-
const cli = require(`yargs`)
459+
const cli = require('yargs')
460460
.demand(1)
461461
.command(
462-
`create [projectId]`,
463-
`Creates an example 'custom.googleapis.com/stores/daily_sales' custom metric descriptor.`,
462+
'create [projectId]',
463+
"Creates an example 'custom.googleapis.com/stores/daily_sales' custom metric descriptor.",
464464
{},
465465
opts => createMetricDescriptor(opts.projectId)
466466
)
467-
.command(`list [projectId]`, `Lists metric descriptors.`, {}, opts =>
467+
.command('list [projectId]', 'Lists metric descriptors.', {}, opts =>
468468
listMetricDescriptors(opts.projectId)
469469
)
470-
.command(`get <metricId> [projectId]`, `Get a metric descriptor.`, {}, opts =>
470+
.command('get <metricId> [projectId]', 'Get a metric descriptor.', {}, opts =>
471471
getMetricDescriptor(opts.projectId, opts.metricId)
472472
)
473473
.command(
474-
`delete <metricId> [projectId]`,
475-
`Deletes a custom metric descriptor.`,
474+
'delete <metricId> [projectId]',
475+
'Deletes a custom metric descriptor.',
476476
{},
477477
opts => deleteMetricDescriptor(opts.projectId, opts.metricId)
478478
)
479479
.command(
480-
`write [projectId]`,
481-
`Writes example time series data to 'custom.googleapis.com/stores/daily_sales'.`,
480+
'write [projectId]',
481+
"Writes example time series data to 'custom.googleapis.com/stores/daily_sales'.",
482482
{},
483483
opts => writeTimeSeriesData(opts.projectId)
484484
)
485485
.command(
486-
`read <filter> [projectId]`,
487-
`Reads time series data that matches the given filter.`,
486+
'read <filter> [projectId]',
487+
'Reads time series data that matches the given filter.',
488488
{},
489489
opts => readTimeSeriesData(opts.projectId, opts.filter)
490490
)
491491
.command(
492-
`read-fields [projectId]`,
493-
`Reads headers of time series data that matches 'compute.googleapis.com/instance/cpu/utilization'.`,
492+
'read-fields [projectId]',
493+
"Reads headers of time series data that matches 'compute.googleapis.com/instance/cpu/utilization'.",
494494
{},
495495
opts => readTimeSeriesFields(opts.projectId)
496496
)
497497
.command(
498-
`read-aggregate [projectId]`,
499-
`Aggregates time series data that matches 'compute.googleapis.com/instance/cpu/utilization'.`,
498+
'read-aggregate [projectId]',
499+
"Aggregates time series data that matches 'compute.googleapis.com/instance/cpu/utilization'.",
500500
{},
501501
opts => readTimeSeriesAggregate(opts.projectId)
502502
)
503503
.command(
504-
`read-reduce [projectId]`,
505-
`Reduces time series data that matches 'compute.googleapis.com/instance/cpu/utilization'.`,
504+
'read-reduce [projectId]',
505+
"Reduces time series data that matches 'compute.googleapis.com/instance/cpu/utilization'.",
506506
{},
507507
opts => readTimeSeriesReduce(opts.projectId)
508508
)
509509
.command(
510-
`list-resources [projectId]`,
511-
`Lists monitored resource descriptors.`,
510+
'list-resources [projectId]',
511+
'Lists monitored resource descriptors.',
512512
{},
513513
opts => listMonitoredResourceDescriptors(opts.projectId)
514514
)
515515
.command(
516-
`get-resource <resourceType> [projectId]`,
517-
`Get a monitored resource descriptor.`,
516+
'get-resource <resourceType> [projectId]',
517+
'Get a monitored resource descriptor.',
518518
{},
519519
opts => getMonitoredResourceDescriptor(opts.projectId, opts.resourceType)
520520
)
@@ -527,23 +527,23 @@ const cli = require(`yargs`)
527527
type: 'string',
528528
},
529529
})
530-
.example(`node $0 create`)
531-
.example(`node $0 list`)
532-
.example(`node $0 get logging.googleapis.com/log_entry_count`)
533-
.example(`node $0 delete custom.googleapis.com/stores/daily_sales`)
534-
.example(`node $0 list-resources`)
535-
.example(`node $0 get-resource cloudsql_database`)
536-
.example(`node $0 write`)
530+
.example('node $0 create')
531+
.example('node $0 list')
532+
.example('node $0 get logging.googleapis.com/log_entry_count')
533+
.example('node $0 delete custom.googleapis.com/stores/daily_sales')
534+
.example('node $0 list-resources')
535+
.example('node $0 get-resource cloudsql_database')
536+
.example('node $0 write')
537537
.example(
538-
`node $0 read 'metric.type="compute.googleapis.com/instance/cpu/utilization"'`
538+
'node $0 read \'metric.type="compute.googleapis.com/instance/cpu/utilization"\''
539539
)
540-
.example(`node $0 read-fields`)
541-
.example(`node $0 read-aggregate`)
542-
.example(`node $0 read-reduce`)
540+
.example('node $0 read-fields')
541+
.example('node $0 read-aggregate')
542+
.example('node $0 read-reduce')
543543
.wrap(120)
544544
.recommendCommands()
545545
.epilogue(
546-
`For more information, see https://cloud.google.com/monitoring/docs`
546+
'For more information, see https://cloud.google.com/monitoring/docs'
547547
);
548548

549549
if (module === require.main) {

monitoring/snippets/quickstart.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async function quickstart() {
6363

6464
// Writes time series data
6565
const [result] = await client.createTimeSeries(request);
66-
console.log(`Done writing time series data.`, result);
66+
console.log('Done writing time series data.', result);
6767
}
6868
// [END monitoring_quickstart]
6969

monitoring/snippets/test/metrics.test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ const retry = require('p-retry');
2323
const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});
2424

2525
const client = new monitoring.MetricServiceClient();
26-
const cmd = `node metrics.js`;
27-
const customMetricId = `custom.googleapis.com/stores/daily_sales`;
28-
const computeMetricId = `compute.googleapis.com/instance/cpu/utilization`;
26+
const cmd = 'node metrics.js';
27+
const customMetricId = 'custom.googleapis.com/stores/daily_sales';
28+
const computeMetricId = 'compute.googleapis.com/instance/cpu/utilization';
2929
const filter = `metric.type="${computeMetricId}"`;
3030
const projectId = process.env.GCLOUD_PROJECT;
31-
const resourceId = `cloudsql_database`;
31+
const resourceId = 'cloudsql_database';
3232

3333
describe('metrics', () => {
3434
it('should create a metric descriptors', () => {
@@ -121,7 +121,7 @@ describe('metrics', () => {
121121
},
122122
// Don't return time series data, instead just return information about
123123
// the metrics that match the filter
124-
view: `HEADERS`,
124+
view: 'HEADERS',
125125
});
126126
const output = execSync(`${cmd} read-fields`);
127127
assert.include(output, 'Found data points for the following instances');
@@ -148,7 +148,7 @@ describe('metrics', () => {
148148
alignmentPeriod: {
149149
seconds: 600,
150150
},
151-
perSeriesAligner: `ALIGN_MEAN`,
151+
perSeriesAligner: 'ALIGN_MEAN',
152152
},
153153
});
154154
let output;
@@ -184,8 +184,8 @@ describe('metrics', () => {
184184
alignmentPeriod: {
185185
seconds: 600,
186186
},
187-
crossSeriesReducer: `REDUCE_MEAN`,
188-
perSeriesAligner: `ALIGN_MEAN`,
187+
crossSeriesReducer: 'REDUCE_MEAN',
188+
perSeriesAligner: 'ALIGN_MEAN',
189189
},
190190
});
191191
const output = execSync(`${cmd} read-reduce`);

0 commit comments

Comments
 (0)