azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
332 lines (125 loc) • 22.5 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,__catch=__rt.__catch,__tryCatch=__rt.__tryCatch; var generatorUtils = require("../../../util/generatorUtils");
var util = require("util");
var validation = require("../../../util/validation");
var profile = require("../../../util/profile");
var utils = require("../../../util/utils");
var $ = utils.getLocaleString;
exports.init = function(cli) {
var network = cli.category("network").description($("Commands to manage network resources"));
var trafficManager = network.category("traffic-manager").description($("Commands to manage Traffic Manager"));
var endpoints = trafficManager.category("endpoint").description($("Commands to manage endpoints"));
endpoints.command("create [resource-group] [profile-name] [type] [name]").description($("Create an endpoint")).usage("[options] <resource-group> <profile-name> <type> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-f, --profile-name <profile-name>", $("the profile name")).option("-y, --type <type>", $("the type")).option("-n, --name <name>", $("the name of the endpoint")).option("-i, --target-resource-id [target-resource-id]", $(("the Azure Resource URI of the of the" + "\n endpoint. Not applicable to endpoints of type 'ExternalEndpoints'"))).option("-t, --target [target]", $((("the fully-qualified DNS name of the" + "\n endpoint. Traffic Manager returns this value in DNS responses to direct traffic") + "\n to this endpoint"))).option("-u, --status [status]", $((("the status of the endpoint. If the" + "\n endpoint is Enabled, it is probed for endpoint health and is included in the") + "\n traffic routing method"))).option("-w, --weight [weight]", $(("the weight of this endpoint when using" + "\n the 'Weighted' traffic routing method. Possible values are from 1 to 1000"))).option("-p, --priority [priority]", $((((("the priority of this endpoint when" + "\n using the 'Priority' traffic routing method. Possible values are from 1 to") + "\n 1000, lower values represent higher priority. This is an optional parameter.") + "\n If specified, it must be specified on all endpoints, and no two endpoints can") + "\n share the same priority value"))).option("-l, --location [location]", $(("specifies the location of the external" + "\n or nested endpoints when using the 'Performance' traffic routing method"))).option("-c, --min-child-endpoints [min-child-endpoints]", $((("the minimum number of endpoints that" + "\n must be available in the child profile in order for the parent profile to be") + "\n considered available. Only applicable to endpoint of type 'NestedEndpoints'"))).option("-m, --geo-mapping [geo-mapping]", $(((("the list of countries/regions mapped to" + "\n this endpoint when using the 'Geographic' traffic routing method. Please") + "\n consult Traffic Manager Geographic documentation for a full list of accepted") + "\n values"))).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __1(resourceGroup, profileName, type, name, options, _) { var subscription, trafficManagerManagementClient, endpoint, progress, parameters; var __frame = { name: "__1", line: 72 }; return __func(_, this, arguments, __1, 5, __frame, function __$__1() {
return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __1) { resourceGroup = __1;
return cli.interaction.promptIfNotGiven($("profile name : "), profileName, __cb(_, __frame, 2, 36, function ___(__0, __2) { profileName = __2;
return cli.interaction.promptIfNotGiven($("type : "), type, __cb(_, __frame, 3, 37, function ___(__0, __3) { options.type = __3;
return cli.interaction.promptIfNotGiven($("name : "), name, __cb(_, __frame, 4, 29, function ___(__0, __4) { name = __4;
subscription = profile.current.getSubscription(options.subscription);
trafficManagerManagementClient = utils.createTrafficManagerManagementClient(subscription);
progress = cli.interaction.progress(util.format($("Looking up the endpoint \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() {
return trafficManagerManagementClient.endpoints.get(resourceGroup, profileName, options.type, name, null, __cb(_, __frame, 12, 60, function ___(__0, __5) { endpoint = __5; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__1() { if (e) {
if ((e.statusCode === 404)) {
endpoint = null; }
else {
return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__1() { _(null, null, 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() {
if (endpoint) {
return _(new Error(util.format($("endpoint with name \"%s\" already exists in the resource group \"%s\""), name, resourceGroup))); } ;
parameters = { };
if (options.targetResourceId) {
parameters.targetResourceId = options.targetResourceId; } ;
if (options.target) {
parameters.target = options.target; } ;
if (options.status) {
parameters.endpointStatus = validation.isIn(options.status, ["Enabled","Disabled",], "--status"); } ;
if (options.weight) {
parameters.weight = parseInt(options.weight, 10); } ;
if (options.priority) {
parameters.priority = parseInt(options.priority, 10); } ;
if (options.location) {
parameters.endpointLocation = options.location; } ;
if (options.minChildEndpoints) {
parameters.minChildEndpoints = parseInt(options.minChildEndpoints, 10); } ;
if (options.geoMapping) {
parameters.geoMapping = generatorUtils.splitStringByCharacter(options.geoMapping, ","); } ;
generatorUtils.removeEmptyObjects(parameters);
progress = cli.interaction.progress(util.format($("Creating endpoint \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() {
return trafficManagerManagementClient.endpoints.createOrUpdate(resourceGroup, profileName, options.type, name, parameters, __cb(_, __frame, 63, 60, function ___(__0, __6) { endpoint = __6; _(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(endpoint, generatorUtils.traverse); _(); }); }); }); }); }, true)); }, true)); }, true)); }, true)); }); });
endpoints.command("set [resource-group] [profile-name] [type] [name]").description($("Update an endpoint")).usage("[options] <resource-group> <profile-name> <type> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-f, --profile-name <profile-name>", $("the profile name")).option("-y, --type <type>", $("the type")).option("-n, --name <name>", $("the name of the endpoint")).option("-i, --target-resource-id [target-resource-id]", $(("the Azure Resource URI of the of the" + "\n endpoint. Not applicable to endpoints of type 'ExternalEndpoints'"))).option("-t, --target [target]", $((("the fully-qualified DNS name of the" + "\n endpoint. Traffic Manager returns this value in DNS responses to direct traffic") + "\n to this endpoint"))).option("-u, --status [status]", $((("the status of the endpoint. If the" + "\n endpoint is Enabled, it is probed for endpoint health and is included in the") + "\n traffic routing method"))).option("-w, --weight [weight]", $(("the weight of this endpoint when using" + "\n the 'Weighted' traffic routing method. Possible values are from 1 to 1000"))).option("-p, --priority [priority]", $((((("the priority of this endpoint when" + "\n using the 'Priority' traffic routing method. Possible values are from 1 to") + "\n 1000, lower values represent higher priority. This is an optional parameter.") + "\n If specified, it must be specified on all endpoints, and no two endpoints can") + "\n share the same priority value"))).option("-l, --location [location]", $(("specifies the location of the external" + "\n or nested endpoints when using the 'Performance' traffic routing method"))).option("-c, --min-child-endpoints [min-child-endpoints]", $((("the minimum number of endpoints that" + "\n must be available in the child profile in order for the parent profile to be") + "\n considered available. Only applicable to endpoint of type 'NestedEndpoints'"))).option("-m, --geo-mapping [geo-mapping]", $(((("the list of countries/regions mapped to" + "\n this endpoint when using the 'Geographic' traffic routing method. Please") + "\n consult Traffic Manager Geographic documentation for a full list of accepted") + "\n values"))).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __2(resourceGroup, profileName, type, name, options, _) { var subscription, trafficManagerManagementClient, endpoint, progress, parameters; var __frame = { name: "__2", line: 175 }; return __func(_, this, arguments, __2, 5, __frame, function __$__2() {
return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __1) { resourceGroup = __1;
return cli.interaction.promptIfNotGiven($("profile name : "), profileName, __cb(_, __frame, 2, 36, function ___(__0, __2) { profileName = __2;
return cli.interaction.promptIfNotGiven($("type : "), type, __cb(_, __frame, 3, 37, function ___(__0, __3) { options.type = __3;
return cli.interaction.promptIfNotGiven($("name : "), name, __cb(_, __frame, 4, 29, function ___(__0, __4) { name = __4;
subscription = profile.current.getSubscription(options.subscription);
trafficManagerManagementClient = utils.createTrafficManagerManagementClient(subscription);
progress = cli.interaction.progress(util.format($("Looking up the endpoint \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() {
return trafficManagerManagementClient.endpoints.get(resourceGroup, profileName, options.type, name, null, __cb(_, __frame, 12, 60, function ___(__0, __5) { endpoint = __5; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__2() { if (e) {
if ((e.statusCode === 404)) {
endpoint = null; }
else {
return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__2() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__2() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__2() {
if (!endpoint) {
return _(new Error(util.format($("endpoint with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup))); } ;
parameters = endpoint;
if (options.targetResourceId) {
parameters.targetResourceId = options.targetResourceId; } ;
if (options.target) {
parameters.target = options.target; } ;
if (options.status) {
parameters.endpointStatus = validation.isIn(options.status, ["Enabled","Disabled",], "--status"); } ;
if (options.weight) {
parameters.weight = parseInt(options.weight, 10); } ;
if (options.priority) {
parameters.priority = parseInt(options.priority, 10); } ;
if (options.location) {
parameters.endpointLocation = options.location; } ;
if (options.minChildEndpoints) {
parameters.minChildEndpoints = parseInt(options.minChildEndpoints, 10); } ;
if (options.geoMapping) {
parameters.geoMapping = generatorUtils.splitStringByCharacter(options.geoMapping, ","); } ;
generatorUtils.removeEmptyObjects(parameters);
progress = cli.interaction.progress(util.format($("Updating endpoint \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() {
return trafficManagerManagementClient.endpoints.createOrUpdate(resourceGroup, profileName, options.type, name, parameters, __cb(_, __frame, 63, 60, function ___(__0, __6) { endpoint = __6; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__2() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__2() {
cli.interaction.formatOutput(endpoint, generatorUtils.traverse); _(); }); }); }); }); }, true)); }, true)); }, true)); }, true)); }); });
endpoints.command("delete [resource-group] [profile-name] [type] [name]").description($("Delete an endpoint")).usage("[options] <resource-group> <profile-name> <type> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-f, --profile-name <profile-name>", $("the profile name")).option("-y, --type <type>", $("the type")).option("-n, --name <name>", $("the name of the endpoint")).option("-q, --quiet", $("quiet mode, do not ask for delete confirmation")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __3(resourceGroup, profileName, type, name, options, _) { var subscription, trafficManagerManagementClient, endpoint, progress; var __frame = { name: "__3", line: 255 }; return __func(_, this, arguments, __3, 5, __frame, function __$__3() {
return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __2) { resourceGroup = __2;
return cli.interaction.promptIfNotGiven($("profile name : "), profileName, __cb(_, __frame, 2, 36, function ___(__0, __3) { profileName = __3;
return cli.interaction.promptIfNotGiven($("type : "), type, __cb(_, __frame, 3, 37, function ___(__0, __4) { options.type = __4;
return cli.interaction.promptIfNotGiven($("name : "), name, __cb(_, __frame, 4, 29, function ___(__0, __5) { name = __5;
subscription = profile.current.getSubscription(options.subscription);
trafficManagerManagementClient = utils.createTrafficManagerManagementClient(subscription);
progress = cli.interaction.progress(util.format($("Looking up the endpoint \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() {
return trafficManagerManagementClient.endpoints.get(resourceGroup, profileName, options.type, name, null, __cb(_, __frame, 12, 60, function ___(__0, __6) { endpoint = __6; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__3() { if (e) {
if ((e.statusCode === 404)) {
endpoint = null; }
else {
return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__3() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__3() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__3() {
if (!endpoint) {
return _(new Error(util.format($("endpoint with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup))); } ; return (function __$__3(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return cli.interaction.confirm(util.format($("Delete endpoint \"%s\"? [y/n] "), name), __cb(_, __frame, 27, 45, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -254, 17, function ___(__0, __7) { return (function __$__3(__then) { if (__7) {
cli.output.info(util.format($("endpoint \"%s\" was not deleted and still exists in the resource group \"%s\""), name, resourceGroup)); return _(null); } else { __then(); } ; })(function __$__3() {
progress = cli.interaction.progress(util.format($("Deleting endpoint \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() {
return trafficManagerManagementClient.endpoints.deleteMethod(resourceGroup, profileName, options.type, name, __cb(_, __frame, 34, 60, function ___(__0, __8) { endpoint = __8;
cli.output.info(util.format($("endpoint \"%s\" was successfully deleted from resource group \"%s\""), name, resourceGroup)); _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__3() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__3() { _(); }); }); }); }, true)); }); }); }, true)); }, true)); }, true)); }, true)); }); });
endpoints.command("show [resource-group] [profile-name] [type] [name]").description($("Show an endpoint")).usage("[options] <resource-group> <profile-name> <type> <name>").option("-g, --resource-group <resource-group>", $("the name of the resource group")).option("-f, --profile-name <profile-name>", $("the profile name")).option("-y, --type <type>", $("the type")).option("-n, --name <name>", $("the name of the endpoint")).option("-s, --subscription <subscription>", $("the subscription identifier")).execute(function __4(resourceGroup, profileName, type, name, options, _) { var subscription, trafficManagerManagementClient, endpoint, progress; var __frame = { name: "__4", line: 304 }; return __func(_, this, arguments, __4, 5, __frame, function __$__4() {
return cli.interaction.promptIfNotGiven($("resource group : "), resourceGroup, __cb(_, __frame, 1, 38, function ___(__0, __1) { resourceGroup = __1;
return cli.interaction.promptIfNotGiven($("profile name : "), profileName, __cb(_, __frame, 2, 36, function ___(__0, __2) { profileName = __2;
return cli.interaction.promptIfNotGiven($("type : "), type, __cb(_, __frame, 3, 37, function ___(__0, __3) { options.type = __3;
return cli.interaction.promptIfNotGiven($("name : "), name, __cb(_, __frame, 4, 29, function ___(__0, __4) { name = __4;
subscription = profile.current.getSubscription(options.subscription);
trafficManagerManagementClient = utils.createTrafficManagerManagementClient(subscription);
progress = cli.interaction.progress(util.format($("Looking up the endpoint \"%s\""), name)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() {
return trafficManagerManagementClient.endpoints.get(resourceGroup, profileName, options.type, name, null, __cb(_, __frame, 12, 60, function ___(__0, __5) { endpoint = __5; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__4() { if (e) {
if ((e.statusCode === 404)) {
endpoint = null; }
else {
return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__4() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__4() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__4() {
if (!endpoint) {
cli.output.warn(util.format($("endpoint with name \"%s\" not found in the resource group \"%s\""), name, resourceGroup)); } ;
cli.interaction.formatOutput(endpoint, generatorUtils.traverse); _(); }); }); }, true)); }, true)); }, true)); }, true)); }); });};