azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
76 lines (30 loc) • 4.14 kB
JavaScript
/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ "use strict"; var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb,__tryCatch=__rt.__tryCatch; var util = require("util");
var profile = require("../../../util/profile");
var utils = require("../../../util/utils");
var $ = utils.getLocaleString;
exports.init = function(cli) {
var log = cli.output;
var usage = cli.category("usage").description($("Command to view your aggregated Azure usage data"));
usage.command("list [reportedStartTime] [reportedEndTime]").description($("List the usage aggregates for a provided time range")).option("--reportedStartTime <datetime>", $("The start of the time range to retrieve data for, in UTC format.")).option("--reportedEndTime <datetime>", $("The end of the time range to retrieve data for, in UTC format.")).option("--granularity <daily/hourly>", $("Value is either daily (default) or hourly to tell the API how to return the results grouped by day or hour.")).option("--showDetails <bool>", $("When set to true (default), the aggregates are broken down into the instance metadata which is more granular.")).option("--continuationToken <url>", $("Retrieved from previous calls, this is the bookmark used for progress when the responses are paged.")).option("--subscription <subscription>", $("the subscription identifier")).execute(function __1(reportedStartTime, reportedEndTime, options, _) { var subscription, client, progress, result; var __frame = { name: "__1", line: 39 }; return __func(_, this, arguments, __1, 3, __frame, function __$__1() { return (function __$__1(__then) {
if (!reportedStartTime) {
return cli.interaction.promptIfNotGiven($("reportedStartTime: "), reportedStartTime, __cb(_, __frame, 2, 39, function ___(__0, __1) { reportedStartTime = __1; __then(); }, true)); } else { __then(); } ; })(function __$__1() { return (function __$__1(__then) {
if (!reportedEndTime) {
return cli.interaction.promptIfNotGiven($("reportedEndTime: "), reportedEndTime, __cb(_, __frame, 5, 37, function ___(__0, __2) { reportedEndTime = __2; __then(); }, true)); } else { __then(); } ; })(function __$__1() {
subscription = profile.current.getSubscription(options.subscription);
client = utils.createUsageManagementClient(subscription);
progress = cli.interaction.progress($("Listing usage aggregates")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() {
return client.usageAggregates.get(reportedStartTime, reportedEndTime, options.granularity, options.showDetails, options.continuationToken, __cb(_, __frame, 14, 38, function ___(__0, __3) { result = __3; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__1() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__1() {
cli.interaction.formatOutput(result.usageAggregations, function(data) {
if ((data.length > 0)) {
log.table(data, function(row, item) {
row.cell($("Usage Start "), item.properties.usageStartTime);
row.cell($("Usage End "), item.properties.usageEndTime);
row.cell($("Meter Category "), item.properties.meterCategory);
row.cell($("Meter Name "), item.properties.meterName);
row.cell($("Quantity "), ((item.properties.quantity + " ") + item.properties.unit)); }); }
else {
log.info(util.format($("No usage aggregates found for that time period."))); } ; });
cli.interaction.formatOutput(result, function(data) {
if ((data.nextLink !== undefined)) {
log.info(("continuationToken for continued results: " + data.nextLink)); } ; }); _(); }); }); }); }); }); });};