azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
125 lines (51 loc) • 7.77 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 insightsAlertsRulesCommand = cli.category("insights").category("alerts").category("rule").description($("Manages alert rules"));
insightsAlertsRulesCommand.command("list <resourceGroup>").description($("List alert rules for a resource.")).usage("[options] <resourceGroup>").option("-g --resourceGroup <resourceGroup>", $("The resource group.")).option("-n --ruleName <ruleName>", $("The name of the rule to query.")).option("-i --targetResourceId <targetResourceId>", $("The target resource of the query.")).option("-s --subscription <subscription>", $("The subscription identifier.")).execute(function __1(resourceGroup, options, _) { var __frame = { name: "__1", line: 38 }; return __func(_, this, arguments, __1, 2, __frame, function __$__1() {
return insightsAlertsRulesCommand._prepareAndExecute(resourceGroup, options, __cb(_, __frame, 1, 33, function __$__1() { _(); }, true)); }); });
insightsAlertsRulesCommand.command("delete <resourceGroup> <ruleName>").description($("Deletes an alert rule.")).usage("[options] <resourceGroup> <ruleName>").option("-g --resourceGroup <resourceGroup>", $("The resource group.")).option("-n --ruleName <ruleName>", $("The name of the rule to query.")).option("-s --subscription <subscription>", $("The subscription identifier.")).execute(function __2(resourceGroup, ruleName, options, _) { var __frame = { name: "__2", line: 48 }; return __func(_, this, arguments, __2, 3, __frame, function __$__2() {
return insightsAlertsRulesCommand._prepareAndExecuteDelete(resourceGroup, ruleName, options, __cb(_, __frame, 1, 33, function __$__2() { _(); }, true)); }); });
insightsAlertsRulesCommand._prepareAndExecute = function insightsAlertsRulesCommand__prepareAndExecute__3(resourceGroup, options, _) { var client, __this = this; var __frame = { name: "insightsAlertsRulesCommand__prepareAndExecute__3", line: 53 }; return __func(_, this, arguments, insightsAlertsRulesCommand__prepareAndExecute__3, 2, __frame, function __$insightsAlertsRulesCommand__prepareAndExecute__3() {
if (!__.isString(resourceGroup)) {
cli.missingArgument("resourceGroup"); } ;
client = insightsUtils.createInsightsManagementClient(log, options);
return __this._executeCmd(client, resourceGroup, options.ruleName, options.targetResourceId, options, __cb(_, __frame, 7, 9, function __$insightsAlertsRulesCommand__prepareAndExecute__3() { _(); }, true)); }); };
insightsAlertsRulesCommand._prepareAndExecuteDelete = function insightsAlertsRulesCommand__prepareAndExecuteDelete__4(resourceGroup, ruleName, options, _) { var client, __this = this; var __frame = { name: "insightsAlertsRulesCommand__prepareAndExecuteDelete__4", line: 63 }; return __func(_, this, arguments, insightsAlertsRulesCommand__prepareAndExecuteDelete__4, 3, __frame, function __$insightsAlertsRulesCommand__prepareAndExecuteDelete__4() {
if (!__.isString(resourceGroup)) {
cli.missingArgument("resourceGroup"); } ;
if (!__.isString(ruleName)) {
cli.missingArgument("ruleName"); } ;
client = insightsUtils.createInsightsManagementClient(log, options);
return __this._executeDeleteCmd(client, resourceGroup, ruleName, options, __cb(_, __frame, 11, 9, function __$insightsAlertsRulesCommand__prepareAndExecuteDelete__4() { _(); }, true)); }); };
insightsAlertsRulesCommand._executeCmd = function insightsAlertsRulesCommand__executeCmd__5(client, resourceGroup, name, targetResourceId, options, _) { var progress, result, response; var __frame = { name: "insightsAlertsRulesCommand__executeCmd__5", line: 78 }; return __func(_, this, arguments, insightsAlertsRulesCommand__executeCmd__5, 5, __frame, function __$insightsAlertsRulesCommand__executeCmd__5() {
progress = cli.interaction.progress($("Querying for alert rules"));
result = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$insightsAlertsRulesCommand__executeCmd__5() { return (function __$insightsAlertsRulesCommand__executeCmd__5(__then) {
if ((!__.isString(name) || (name === ""))) {
log.silly("Query by resourceGroup or targetResourceId");
return client.alertOperations.listRules(resourceGroup, targetResourceId, __cb(_, __frame, 7, 42, function ___(__0, __1) { response = __1;
log.silly((!response ? util.inspect(response) : "nothing in response"));
log.silly(((!response && response.ruleResourceCollection) ? util.inspect(response.ruleResourceCollection) : "nothing in ruleResourceCollection"));
__.each(response.ruleResourceCollection.value, function(element) { result.push(element); }); __then(); }, true)); } else {
log.silly("Query by name");
return client.alertOperations.getRule(resourceGroup, name, __cb(_, __frame, 15, 42, function ___(__0, __2) { response = __2;
log.silly((!response ? util.inspect(response) : "nothing in response"));
result.push({
id: response.id,
location: response.location,
name: response.name,
properties: response.properties,
tags: response.Tags }); __then(); }, true)); } ; })(function __$insightsAlertsRulesCommand__executeCmd__5() { _(null, null, true); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$insightsAlertsRulesCommand__executeCmd__5() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$insightsAlertsRulesCommand__executeCmd__5() {
insightsUtils.formatOutputList(cli, log, options, result); _(); }); }); }); };
insightsAlertsRulesCommand._executeDeleteCmd = function insightsAlertsRulesCommand__executeDeleteCmd__6(client, resourceGroup, ruleName, options, _) { var progress, response; var __frame = { name: "insightsAlertsRulesCommand__executeDeleteCmd__6", line: 112 }; return __func(_, this, arguments, insightsAlertsRulesCommand__executeDeleteCmd__6, 4, __frame, function __$insightsAlertsRulesCommand__executeDeleteCmd__6() {
progress = cli.interaction.progress(util.format($("Deleting alert rule \"%s\""), ruleName));
response = null; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$insightsAlertsRulesCommand__executeDeleteCmd__6() {
return client.alertOperations.deleteRule(resourceGroup, ruleName, __cb(_, __frame, 4, 40, function ___(__0, __1) { response = __1;
log.silly((!response ? util.inspect(response) : "nothing in response")); _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$insightsAlertsRulesCommand__executeDeleteCmd__6() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$insightsAlertsRulesCommand__executeDeleteCmd__6() {
insightsUtils.formatOutput(cli, log, options, response); _(); }); }); }); };};