<commit_before>/**
* Copyright (c) Microsoft.  All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

var util = require('util');
var azure = require('azure');

var utils = require('../util/utils');

var $ = utils.getLocaleString;

var namespaceNameIsValid = azure.Validate.namespaceNameIsValid;

exports.init = function (cli) {
  var log = cli.output;

  var sb = cli.category('sb')
    .description($('Commands to manage your Service Bus configuration'));

  var sbnamespace = sb.category('namespace')
    .description($('Commands to manage your Service Bus namespaces'));

  sbnamespace.command('list')
    .description($('List currently defined service bus namespaces'))
    .option('-s, --subscription <id>', $('the subscription id'))
    .execute(function (options, _) {
      var service = createService(options.subscription);
      var progress = cli.interaction.progress($('Getting namespaces'));
      var namespaces = service.listNamespaces(_);
      progress.end();

      cli.interaction.formatOutput(namespaces, function(outputData) {
        if(outputData.length === 0) {
          log.info($('No namespaces defined'));
        } else {
          log.table(outputData, function (row, ns) {
            row.cell($('Name'), ns.Name);
            row.cell($('Region'), ns.Region);
            row.cell($('Status'), ns.Status);
          });
        }
      });
    });

  sbnamespace.command('show [name]')
    .description($('Get detailed information about a single service bus namespace'))
    .option('-s, --subscription <id>', $('the subscription id'))
    .execute(function (name, options, _) {
      name = cli.interaction.promptIfNotGiven($('Service Bus namespace: '), name, _);
      namespaceNameIsValid(name, _);
      var service = createService(options.subscription);
      var progress = cli.interaction.progress($('Getting namespace'));
      var namespace = service.getNamespace(name, _);
      progress.end();

      cli.interaction.formatOutput(namespace, function(outputData) {
        Object.keys(outputData).forEach(function (key) {
          if (key !== '_') {
            log.data(util.format($('%s: %s'), key, outputData[key]));
          }
        });
      });
    });

  sbnamespace.command('check <name>')
    .description($('Check that a service bus namespace is legal and available'))
    .usage('[options] <name>')
    .option('-s, --subscription <id>', $('the subscription id'))
    .execute(function (name, options, _) {
      namespaceNameIsValid(name, _);
      var service = createService(options.subscription);
      var progress = cli.interaction.progress('Checking namespace ' + name);
      var result = service.verifyNamespace(name, _);
      progress.end();

      cli.interaction.formatOutput(result, function(outputData) {
        if (outputData) {
          log.data(util.format($('Namespace %s is available'), name));
        } else {
          log.data(util.format($('Namespace %s is not available'), name));
        }
      });
    });

  sbnamespace.command('create [namespace] [region]')
    .description($('Create a service bus namespace'))
    .usage('[options] <namespace> <region>')<commit_msg>Apply code review<commit_after>/**
* Copyright (c) Microsoft.  All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

var util = require('util');
var azure = require('azure');

var utils = require('../util/utils');

var $ = utils.getLocaleString;

var namespaceNameIsValid = azure.Validate.namespaceNameIsValid;

exports.init = function (cli) {
  var log = cli.output;

  var sb = cli.category('sb')
    .description($('Commands to manage your Service Bus configuration'));

  var sbnamespace = sb.category('namespace')
    .description($('Commands to manage your Service Bus namespaces'));

  sbnamespace.command('list')
    .description($('List currently defined service bus namespaces'))
    .option('-s, --subscription <id>', $('the subscription id'))
    .execute(function (options, _) {
      var service = createService(options.subscription);
      var progress = cli.interaction.progress($('Getting namespaces'));
      var namespaces = service.listNamespaces(_);
      progress.end();

      cli.interaction.formatOutput(namespaces, function(outputData) {
        if(outputData.length === 0) {
          log.info($('No namespaces defined'));
        } else {
          log.table(outputData, function (row, ns) {
            row.cell($('Name'), ns.Name);
            row.cell($('Region'), ns.Region);
            row.cell($('Status'), ns.Status);
          });
        }
      });
    });

  sbnamespace.command('show [name]')
    .description($('Get detailed information about a single service bus namespace'))
    .option('-s, --subscription <id>', $('the subscription id'))
    .execute(function (name, options, _) {
      name = cli.interaction.promptIfNotGiven($('Service Bus namespace: '), name, _);
      namespaceNameIsValid(name, _);
      var service = createService(options.subscription);
      var progress = cli.interaction.progress($('Getting namespace'));
      var namespace = service.getNamespace(name, _);
      progress.end();

      cli.interaction.formatOutput(namespace, function(outputData) {
        Object.keys(outputData).forEach(function (key) {
          if (key !== '_') {
            log.data(util.format($('%s: %s'), key, outputData[key]));
          }
        });
      });
    });

  sbnamespace.command('check <name>')
    .description($('Check that a service bus namespace is legal and available'))
    .usage('[options] <name>')
    .option('-s, --subscription <id>', $('the subscription id'))
    .execute(function (name, options, _) {
      namespaceNameIsValid(name, _);
      var service = createService(options.subscription);
      var progress = cli.interaction.progress('Checking namespace ' + name);
      var result = service.verifyNamespace(name, _);
      progress.end();

      cli.interaction.formatOutput({ available: result }, function(outputData) {
        if (outputData.available) {
          log.data(util.format($('Namespace %s is available'), name));
        } else {
          log.data(util.format($('Namespace %s is not available'), name));
        }
      });
    });

  sbnamespace.command('create [namespace] [region]')
    .description($('Create a service bus namespace'))
    .usage('[options] <namespace> <region>')
{'fraction_non_alphanumeric': 0.14673692744223754, 'fraction_numerical': 0.0013511687609782462, 'mean_word_length': 3.305991855730076, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3994451', 'n_tokens_mistral': 2031, 'n_tokens_neox': 2016, 'n_words': 565}