/*** 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; var utils = require("../../../util/utils");

















var insightsUtils = require("./insights.utils");

var $ = utils.getLocaleString;

exports.init = function(cli) {
  var log = cli.output;
  var insightsDiagnosticCommand = cli.category("insights").category("logprofile").description($("Configure log profiles")).command("add").description($("Add a new log profile.")).usage("[options]").option("-n, --name <name>", $("resource Id.")).option("-a, --storageId <storageId>", $("storage account Id.")).option("-b, --serviceBusRuleId <servicesBusRuleId>", $("the authorization rule id of the service bus.")).option("-c, --categories <categories>", $("comma separated list of categories to be included in the captured logs.")).option("-l, --locations <locations>", $("comma separated list of locations of the resources to be included in the log profile.")).option("-t, --retentionInDays <retentionInDays>", $("the number of days the logs will be kept before being delete.")).execute(function __1(options, _) { var __frame = { name: "__1", line: 36 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() {











      return insightsDiagnosticCommand._prepareAndExecute(options, __cb(_, __frame, 1, 34, function __$__1() { _(); }, true)); }); });


  insightsDiagnosticCommand._prepareAndExecute = function insightsDiagnosticCommand__prepareAndExecute__2(options, _) { var client, __this = this; var __frame = { name: "insightsDiagnosticCommand__prepareAndExecute__2", line: 40 }; return __func(_, this, arguments, insightsDiagnosticCommand__prepareAndExecute__2, 1, __frame, function __$insightsDiagnosticCommand__prepareAndExecute__2() {
      client = insightsUtils.createInsightsManagementClient(log, options);

      if (options.categories) {
        options.categories = options.categories.split(","); }

       else {
        options.categories = ["Action","Delete","Write",]; } ;


      if (options.locations) {
        options.locations = options.locations.split(","); } ;


      return __this._executeCmd(client, cli, log, options, __cb(_, __frame, 14, 9, function __$insightsDiagnosticCommand__prepareAndExecute__2() { _(); }, true)); }); };


  insightsDiagnosticCommand._executeCmd = function insightsDiagnosticCommand__executeCmd__3(client, cli, log, options, _) { var retentionPolicy, properties, putParameters; var __frame = { name: "insightsDiagnosticCommand__executeCmd__3", line: 57 }; return __func(_, this, arguments, insightsDiagnosticCommand__executeCmd__3, 4, __frame, function __$insightsDiagnosticCommand__executeCmd__3() {
      retentionPolicy = {
        enabled: false,
        days: 0 };


      if (options.retentionInDays) {
        retentionPolicy.enabled = true;
        retentionPolicy.days = parseInt(options.retentionInDays); } ;


      properties = {
        categories: options.categories,
        locations: options.locations,
        retentionPolicy: retentionPolicy,
        serviceBusRuleId: options.serviceBusRuleId,
        storageAccountId: options.storageId };


      putParameters = {
        properties: properties };


      return client.logProfilesOperations.createOrUpdate(options.name, putParameters, __cb(_, __frame, 23, 33, function __$insightsDiagnosticCommand__executeCmd__3() {

        putParameters.properties.name = options.name;
        putParameters.properties.id = ((("/subscriptionId/" + client.credentials.subscriptionId) + "/providers/microsoft.insights/logprofiles/") + options.name);

        insightsUtils.formatOutput(cli, log, options, putParameters.properties); _(); }, true)); }); };};
