azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
96 lines (44 loc) • 5.97 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 __ = require("underscore");
var util = require("util");
var utils = require("../../../util/utils");
var insightsUtils = require("./insights.utils");
var $ = utils.getLocaleString;
exports.init = function(cli) {
var log = cli.output;
var insightsAutoscaleCommand = cli.category("insights").category("autoscale").description($("Retrieve autoscale logs")).command("list").description($("List autoscale logs for a resource.")).usage("[options]").option("-i --resourceId <resourceId>", $("The resource Id.")).option("-b --startTime <startTime>", $("The start time of the query.")).option("-e --endTime <endTime>", $("The end time of the query.")).option("--status <status>", $("The status.")).option("--caller <caller>", $("Caller to look for when querying.")).option("-d --detailedOutput", $("Shows the details of the events in the log.")).option("-s --subscription <subscription>", $("The subscription identifier.")).execute(function __1(options, _) { var __frame = { name: "__1", line: 39 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() {
return insightsAutoscaleCommand._prepareAndExecute(options, __cb(_, __frame, 1, 33, function __$__1() { _(); }, true)); }); });
insightsAutoscaleCommand._filterByResourceId = function(resourceId) {
if (__.isString(resourceId)) {
var resourceIdLowerCase = resourceId.toLowerCase();
log.silly(("resourceIdLowerCase: " + resourceIdLowerCase));
return function(record) {
log.silly(("record: " + record));
return (__.isString(record.resourceId) && (record.resourceId.toLowerCase() === resourceIdLowerCase)); }; }
else {
return insightsUtils.passAllFilter; } ; };
insightsAutoscaleCommand._processGeneralParameters = function(startTime, endTime, status, caller) {
var queryFilter = insightsUtils.validateDateTimeRangeAndAddDefaultsEvents(startTime, endTime);
queryFilter = insightsUtils.addConditionIfPresent(queryFilter, "status", status);
queryFilter = insightsUtils.addConditionIfPresent(queryFilter, "caller", caller);
return queryFilter; };
insightsAutoscaleCommand._prepareAndExecute = function insightsAutoscaleCommand__prepareAndExecute__2(options, _) { var client, queryFilter, __this = this; var __frame = { name: "insightsAutoscaleCommand__prepareAndExecute__2", line: 64 }; return __func(_, this, arguments, insightsAutoscaleCommand__prepareAndExecute__2, 1, __frame, function __$insightsAutoscaleCommand__prepareAndExecute__2() {
client = insightsUtils.createInsightsClient(log, options);
queryFilter = __this._processGeneralParameters(options.startTime, options.endTime, options.status, options.caller);
queryFilter = insightsUtils.addConditionIfPresent(queryFilter, "eventSource", insightsUtils.autoscaleEventSourceName);
return __this._executeEventsCmd(client, queryFilter, (!options.detailedOutput ? insightsUtils.selectedFields : null), __this._filterByResourceId(options.resourceId), options, __cb(_, __frame, 5, 9, function __$insightsAutoscaleCommand__prepareAndExecute__2() { _(); }, true)); }); };
insightsAutoscaleCommand._executeEventsCmd = function insightsAutoscaleCommand__executeEventsCmd__3(client, queryFilter, selectedFields, keepTheRecord, options, _) { var progress, result, response, keepRecordFilter, nextLink; var __frame = { name: "insightsAutoscaleCommand__executeEventsCmd__3", line: 72 }; return __func(_, this, arguments, insightsAutoscaleCommand__executeEventsCmd__3, 5, __frame, function __$insightsAutoscaleCommand__executeEventsCmd__3() {
progress = cli.interaction.progress(util.format($("Querying \"%s\""), queryFilter));
result = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$insightsAutoscaleCommand__executeEventsCmd__3() {
return client.eventOperations.listEvents(queryFilter, selectedFields, __cb(_, __frame, 4, 44, function ___(__0, __1) { response = __1;
log.silly((!response ? util.inspect(response) : "nothing in response"));
log.silly(((!response && response.eventDataCollection) ? util.inspect(response.eventDataCollection) : "nothing in eventDataCollection"));
keepRecordFilter = function(element) { if (keepTheRecord(element)) { result.push(element); } ; };
__.each(response.eventDataCollection.value, keepRecordFilter);
nextLink = response.eventDataCollection.nextLink; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$insightsAutoscaleCommand__executeEventsCmd__3() { __more = false;
var __4 = nextLink; if (__4) {
log.silly("Following nextLink");
return client.eventOperations.listEventsNext(nextLink, __cb(_, __frame, 15, 42, function ___(__0, __2) { response = __2;
__.each(response.eventDataCollection.value, keepRecordFilter);
nextLink = response.eventDataCollection.nextLink; while (__more) { __loop(); }; __more = true; }, true)); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(function __$insightsAutoscaleCommand__executeEventsCmd__3() { _(null, null, true); }); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$insightsAutoscaleCommand__executeEventsCmd__3() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$insightsAutoscaleCommand__executeEventsCmd__3() {
insightsUtils.formatOutputList(cli, log, options, result); _(); }); }); }); };};