azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
863 lines (397 loc) • 127 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 util = require("util");
var cdnManagementUtil = require("./cdnmanagement.utils");
var profile = require("../../../util/profile");
var utils = require("../../../util/utils");
var tagUtils = require("../tag/tagUtils");
var $ = utils.getLocaleString;
exports.init = function(cli) {
var log = cli.output;
var cdn = cli.category("cdn").description($("Commands to manage Azure Content Delivery Network (CDN)"));
var profiles = cdn.category("profile").description($("Commands to manage your Azure cdn profiles"));
profiles.command("list").description($("List all profiles under the current subscription")).usage("[options] [resource-group]").option("-g, --resource-group [resource-group]", $("Name of the Resource Group")).option("--subscription <subscription>", $("the subscription identifier")).execute(function __1(options, _) { var subscription, client, operation, progress, result; var __frame = { name: "__1", line: 50 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() {
subscription = profile.current.getSubscription(options.subscription);
client = utils.createCdnManagementClient(subscription); return (function __$__1(__then) {
if (options.resourceGroup) {
return client.profiles.listByResourceGroup(options.resourceGroup, __cb(_, __frame, 10, 36, function ___(__0, __1) { operation = __1; __then(); }, true)); } else {
return client.profiles.list(__cb(_, __frame, 12, 36, function ___(__0, __2) { operation = __2; __then(); }, true)); } ; })(function __$__1() {
progress = cli.interaction.progress(util.format($("Listing Cdn profile(s)"))); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() {
result = operation; _(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() {
cli.interaction.formatOutput(result, function() {
if ((!result || (result.length === 0))) {
log.info($("No profiles found.")); }
else {
log.table(result, function(row, profile) {
row.cell($("Name"), profile.name);
row.cell($("ResourceGroup"), cdnManagementUtil.getResourceGroupFromProfileId(profile.id));
row.cell($("Location"), profile.location);
row.cell($("Tags"), tagUtils.getTagsInfo(profile.tags));
row.cell($("ProvisioningState"), profile.provisioningState);
row.cell($("ResourceState"), profile.resourceState);
row.cell($("Sku"), profile.sku.name);
row.cell($("Subscription"), subscription.id); }); } ; }); _(); }); }); }); }); });
profiles.command("show [name] [resource-group]").description($("Show the infomation of a specific cdn profile")).usage("[options] <name> <resource-group>").option("-n, --name <name>", $("Name of the Cdn Profile")).option("-g, --resource-group <resource-group>", $("Name of the Resource Group")).option("--subscription <subscription>", $("the subscription identifier")).execute(function __2(name, resourceGroup, options, _) { var subscription, client, progress, callbackArgs, result, response; var __frame = { name: "__2", line: 98 }; return __func(_, this, arguments, __2, 3, __frame, function __$__2() {
return cli.interaction.promptIfNotGiven($("Profile name: "), name, __cb(_, __frame, 5, 26, function ___(__0, __1) { name = __1;
return cli.interaction.promptIfNotGiven($("Resource group name: "), resourceGroup, __cb(_, __frame, 6, 35, function ___(__0, __2) { resourceGroup = __2;
subscription = profile.current.getSubscription(options.subscription);
client = utils.createCdnManagementClient(subscription);
progress = cli.interaction.progress(util.format($("Get cdn profile %s ..."), name));
callbackArgs = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__2() {
return client.profiles.get(resourceGroup, name, __cb(_, __frame, 20, 39, function ___(__0, __3) { callbackArgs = __3;
result = callbackArgs[0];
response = callbackArgs[2]; __then(); }, true, true)); }); })(function ___(e, __result) { __catch(function __$__2() { if (e) {
return _(e); } 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() {
cli.interaction.formatOutput(result, function(data) {
if (!data) {
log.info($("No profile named %s found."), name); }
else {
log.data("");
log.data($("Profile name :"), result.name);
log.data("");
log.data($("Resource Group :"), resourceGroup);
log.data($("Location :"), result.location);
log.data($("ResourceState :"), result.resourceState);
log.data($("ProvisioningState :"), result.provisioningState);
log.data($("Sku :"), result.sku.name);
log.data($("Tags :"), tagUtils.getTagsInfo(result.tags));
log.data($("Id :"), result.id);
log.data(""); } ; }); _(); }); }); }, true)); }, true)); }); });
profiles.command("create [name] [resource-group] [location] [sku-name]").description($("Create a profile under given resource group and subscription")).usage("[options] <name> <resource-group> <location> <sku-name> [tags]").option("-n, --name <name>", $("Name of the profile")).option("-g, --resource-group <resource-group>", $("The resource group of the Azure Cdn Profile will be created in")).option("-l, --location <location>", $("The location in which to create the Cdn Profile")).option("-k, --sku-name <sku-name>", $("The pricing sku name of the Azure Cdn Profile")).option("-t, --tags [tags]", $(("Tags to set to the profile. Can be multiple. " + "In the format of 'name=value'. Name is required and value is optional."))).option("--subscription <subscription>", $("the subscription identifier")).execute(function __3(name, resourceGroup, location, skuName, options, _) { var tags, subscription, client, creationParameter, progress, callbackArgs, result, response; var __frame = { name: "__3", line: 157 }; return __func(_, this, arguments, __3, 5, __frame, function __$__3() {
log.verbose(("arguments: " + JSON.stringify({
profileName: name,
options: options })));
return cli.interaction.promptIfNotGiven($("Profile name: "), name, __cb(_, __frame, 11, 26, function ___(__0, __1) { name = __1;
return cli.interaction.promptIfNotGiven($("Resource group name: "), resourceGroup, __cb(_, __frame, 12, 35, function ___(__0, __2) { resourceGroup = __2;
return cli.interaction.promptIfNotGiven($("Profile location: "), location, __cb(_, __frame, 13, 30, function ___(__0, __3) { location = __3;
return cli.interaction.promptIfNotGiven($("Profile skuName name: "), skuName, __cb(_, __frame, 14, 29, function ___(__0, __4) { skuName = __4;
tags = { };
tags = tagUtils.buildTagsParameter(tags, options);
subscription = profile.current.getSubscription(options.subscription);
client = utils.createCdnManagementClient(subscription);
creationParameter = {
location: location,
sku: {
name: skuName },
tags: tags };
progress = cli.interaction.progress(util.format($("Attempting to create cdn profile %s ..."), name));
callbackArgs = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__3() {
return client.profiles.create(resourceGroup, name, creationParameter, __cb(_, __frame, 42, 39, function ___(__0, __5) { callbackArgs = __5;
result = callbackArgs[0];
response = callbackArgs[2]; __then(); }, true, true)); }); })(function ___(e, __result) { __catch(function __$__3() { if (e) {
return _(e); } 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() {
cli.interaction.formatOutput(result, function(data) {
if (!data) {
log.info($("No profile information available")); }
else {
log.data("");
log.data($("Profile name :"), result.name);
log.data("");
log.data($("Resource Group :"), resourceGroup);
log.data($("Location :"), result.location);
log.data($("ResourceState :"), result.resourceState);
log.data($("ProvisioningState :"), result.provisioningState);
log.data($("Sku :"), result.sku.name);
log.data($("Tags :"), tagUtils.getTagsInfo(result.tags));
log.data($("Id :"), result.id);
log.data(""); } ; });
if ((response.statusCode == 200)) {
log.info((("Cdn profile " + name) + " is getting created...")); }
else {
log.info(("Failed in creating profile " + name)); } ; _(); }); }); }, true)); }, true)); }, true)); }, true)); }); });
profiles.command("delete [name] [resource-group]").description($("Delete a profile under given resource group and subscription")).usage("[options] <profile-name> <resource-group>").option("-n, --name <name>", $("Name of the profile")).option("-g, --resource-group <resource-group>", $("The resource group of the Azure Cdn Profile will be delete in")).option("--subscription <subscription>", $("the subscription identifier")).execute(function __4(name, resourceGroup, options, _) { var subscription, client, progress, callbackArgs, result, response; var __frame = { name: "__4", line: 240 }; return __func(_, this, arguments, __4, 3, __frame, function __$__4() {
log.verbose(("arguments: " + JSON.stringify({
profileName: name,
options: options })));
return cli.interaction.promptIfNotGiven($("Profile name: "), name, __cb(_, __frame, 11, 29, function ___(__0, __1) { name = __1;
return cli.interaction.promptIfNotGiven($("Resource group name: "), resourceGroup, __cb(_, __frame, 12, 35, function ___(__0, __2) { resourceGroup = __2;
subscription = profile.current.getSubscription();
client = utils.createCdnManagementClient(subscription);
progress = cli.interaction.progress(util.format($("Deleting Cdn Profile %s"), name));
callbackArgs = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__4() {
return client.profiles.deleteMethod(resourceGroup, name, __cb(_, __frame, 29, 39, function ___(__0, __3) { callbackArgs = __3;
result = callbackArgs[0];
response = callbackArgs[2]; _(null, null, true); }, true, 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 ((response.statusCode == 200)) {
log.info(("Delete command successfully invoked for Cdn Profile " + name)); } else {
if ((response.statusCode == 204)) {
log.info((("Delete sucess, but no profile named " + name) + " was found")); }
else {
log.info(("Error in deleting profile " + name)); } ; } ; _(); }); }); }, true)); }, true)); }); });
profiles.command("set [name] [resource-group]").description($("Update a profile's tags")).usage("[options] <name> <resource-group> [tags]").option("-n, --name <name>", $("Name of the profile")).option("-g, --resource-group <resource-group>", $("The resource group of the Azure Cdn Profile will be created in")).option("-t, --tags [tags]", $(("Tags to set to the profile. Can be multiple. " + "In the format of 'name=value'. Name is required and value is optional."))).option("--subscription <subscription>", $("the subscription identifier")).execute(function __5(name, resourceGroup, options, _) { var tags, subscription, client, progress, callbackArgs, result, response; var __frame = { name: "__5", line: 294 }; return __func(_, this, arguments, __5, 3, __frame, function __$__5() {
return cli.interaction.promptIfNotGiven($("Profile name: "), name, __cb(_, __frame, 5, 29, function ___(__0, __1) { name = __1;
return cli.interaction.promptIfNotGiven($("Resource group name: "), resourceGroup, __cb(_, __frame, 6, 35, function ___(__0, __2) { resourceGroup = __2;
tags = { };
tags = tagUtils.buildTagsParameter(tags, options);
subscription = profile.current.getSubscription(options.subscription);
client = utils.createCdnManagementClient(subscription);
progress = cli.interaction.progress(util.format($("Attempting to update tags for cdn profile %s ..."), name));
callbackArgs = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__5() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__5() {
return client.profiles.update(resourceGroup, name, tags, __cb(_, __frame, 23, 39, function ___(__0, __3) { callbackArgs = __3;
result = callbackArgs[0];
response = callbackArgs[2]; __then(); }, true, true)); }); })(function ___(e, __result) { __catch(function __$__5() { if (e) {
return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__5() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__5() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__5() {
cli.interaction.formatOutput(result, function(data) {
if (!data) {
log.info($("No profile information available")); }
else {
log.data("");
log.data($("Profile name :"), result.name);
log.data("");
log.data($("Resource Group :"), resourceGroup);
log.data($("Location :"), result.location);
log.data($("ResourceState :"), result.resourceState);
log.data($("ProvisioningState :"), result.provisioningState);
log.data($("Sku :"), result.sku.name);
log.data($("Tags :"), tagUtils.getTagsInfo(result.tags));
log.data($("Id :"), result.id);
log.data(""); } ; });
if (((response.statusCode == 202) || (response.statusCode == 200))) {
log.info(("Successfully updated tags of profile " + name)); }
else {
log.info(("Failed in updating tags of profile " + name)); } ; _(); }); }); }, true)); }, true)); }); });
profiles.command("checkUsage [name] [resource-group]").description($("List the usages of resources under profile.")).usage("[options] <name> <profile-name> <resource-group>").option("-n, --name <name>", $("Name of the profile")).option("-g, --resource-group <resource-group>", $("The resource group of the Azure Cdn Profile")).option("--subscription <subscription>", $("the subscription identifier")).execute(function __6(name, resourceGroup, options, _) { var subscription, client, progress, callbackArgs, result, response; var __frame = { name: "__6", line: 358 }; return __func(_, this, arguments, __6, 3, __frame, function __$__6() {
return cli.interaction.promptIfNotGiven($("Profile name: "), name, __cb(_, __frame, 5, 29, function ___(__0, __1) { name = __1;
return cli.interaction.promptIfNotGiven($("Resource group name: "), resourceGroup, __cb(_, __frame, 6, 38, function ___(__0, __2) { resourceGroup = __2;
subscription = profile.current.getSubscription();
client = utils.createCdnManagementClient(subscription);
progress = cli.interaction.progress(util.format($(("Listing usages for profile: " + name))));
callbackArgs = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__6() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__6() {
return client.profiles.listResourceUsage(resourceGroup, name, __cb(_, __frame, 19, 39, function ___(__0, __3) { callbackArgs = __3;
result = callbackArgs[0];
response = callbackArgs[2]; __then(); }, true, true)); }); })(function ___(e, __result) { __catch(function __$__6() { if (e) {
return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__6() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__6() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__6() {
if ((response.statusCode != 200)) {
log.info("Command invoke failed, please retry"); }
else {
cli.interaction.formatOutput(result, function() {
if ((!result || (result.length === 0))) {
log.info($("No usage record was found.")); }
else {
log.table(result, function(row, usage) {
row.cell($("ResourceType"), usage.resourceType);
row.cell($("Unit"), usage.unit);
row.cell($("CurrentValue"), usage.currentValue);
row.cell($("Limit"), usage.limit); }); } ; }); } ; _(); }); }); }, true)); }, true)); }); });
var ssoUri = cdn.category("ssouri").description($("Commands to generate sso uri of your Azure cdn profiles"));
ssoUri.command("create [profile-name] [resource-group]").description($("Create sso uri of the profile")).usage("[options] <profile-name> <resource-group>").option("-n, --profile-name <profile-name>", $("Name of the profile")).option("-g, --resource-group <resource-group>", $("The resource group of the Azure Cdn Profile")).option("--subscription <subscription>", $("the subscription identifier")).execute(function __7(profileName, resourceGroup, options, _) { var subscription, client, progress, callbackArgs, result, response; var __frame = { name: "__7", line: 416 }; return __func(_, this, arguments, __7, 3, __frame, function __$__7() {
return cli.interaction.promptIfNotGiven($("Profile name: "), profileName, __cb(_, __frame, 6, 36, function ___(__0, __1) { profileName = __1;
return cli.interaction.promptIfNotGiven($("Resource group name: "), resourceGroup, __cb(_, __frame, 7, 35, function ___(__0, __2) { resourceGroup = __2;
subscription = profile.current.getSubscription();
client = utils.createCdnManagementClient(subscription);
progress = cli.interaction.progress(util.format($("Generating Cdn profile(s) sso uri")));
callbackArgs = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__7() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__7() {
return client.profiles.generateSsoUri(resourceGroup, profileName, __cb(_, __frame, 21, 39, function ___(__0, __3) { callbackArgs = __3;
result = callbackArgs[0];
response = callbackArgs[2]; __then(); }, true, true)); }); })(function ___(e, __result) { __catch(function __$__7() { if (e) {
return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__7() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__7() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__7() {
log.info($(((("Sso uri of profile " + profileName) + " is:\n ") + result.ssoUriValue))); _(); }); }); }, true)); }, true)); }); });
var endpoint = cdn.category("endpoint").description($("Commands to manage Azure cdn profile endpoints"));
endpoint.command("list [profile-name] [resource-group]").description($("List endpoints by profile and resource group")).usage("[options] <profile-name> <resource-group>").option("-n, --profile-name <profile-name>", $("Name of the profile")).option("-g, --resource-group <resource-group>", $("The resource group of the Azure Cdn Profile")).option("--subscription <subscription>", $("the subscription identifier")).execute(function __8(profileName, resourceGroup, options, _) { var subscription, client, progress, callbackArgs, result, response; var __frame = { name: "__8", line: 461 }; return __func(_, this, arguments, __8, 3, __frame, function __$__8() {
return cli.interaction.promptIfNotGiven($("Profile name: "), profileName, __cb(_, __frame, 5, 36, function ___(__0, __1) { profileName = __1;
return cli.interaction.promptIfNotGiven($("Resource group name: "), resourceGroup, __cb(_, __frame, 6, 35, function ___(__0, __2) { resourceGroup = __2;
subscription = profile.current.getSubscription();
client = utils.createCdnManagementClient(subscription);
progress = cli.interaction.progress(util.format($("Listing endpoints...")));
callbackArgs = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__8() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__8() {
return client.endpoints.listByProfile(resourceGroup, profileName, __cb(_, __frame, 20, 40, function ___(__0, __3) { callbackArgs = __3;
result = callbackArgs[0];
response = callbackArgs[2]; __then(); }, true, true)); }); })(function ___(e, __result) { __catch(function __$__8() { if (e) {
return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__8() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__8() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__8() {
cli.interaction.formatOutput(result, function() {
if ((!result || (result.length === 0))) {
log.info($("No endpoints found.")); }
else {
log.table(result, function(row, endpoint) {
row.cell($("Name"), endpoint.name);
row.cell($("ProfileName"), profileName);
row.cell($("ResourceGroup"), resourceGroup);
row.cell($("Subscription"), subscription.id);
row.cell($("Location"), endpoint.location);
row.cell($("Tags"), tagUtils.getTagsInfo(endpoint.tags)); }); } ; }); _(); }); }); }, true)); }, true)); }); });
endpoint.command("show [name] [profile-name] [resource-group]").description($("Get endpoint by endpoint name, profile name, and resource group")).usage("[options] <name> <profile-name> <resource-group>").option("-n, --name <name>", $("Name of the endpoint")).option("-p, --profile-name <profile-name>", $("Name of the profile")).option("-g, --resource-group <resource-group>", $("The resource group of the Azure Cdn Profile")).option("--subscription <subscription>", $("the subscription identifier")).execute(function __9(name, profileName, resourceGroup, options, _) { var subscription, client, progress, callbackArgs, result, response; var __frame = { name: "__9", line: 514 }; return __func(_, this, arguments, __9, 4, __frame, function __$__9() {
return cli.interaction.promptIfNotGiven($("Endpoint name: "), name, __cb(_, __frame, 5, 26, function ___(__0, __1) { name = __1;
return cli.interaction.promptIfNotGiven($("Profile name: "), profileName, __cb(_, __frame, 6, 36, function ___(__0, __2) { profileName = __2;
return cli.interaction.promptIfNotGiven($("Resource group name: "), resourceGroup, __cb(_, __frame, 7, 35, function ___(__0, __3) { resourceGroup = __3;
subscription = profile.current.getSubscription();
client = utils.createCdnManagementClient(subscription);
progress = cli.interaction.progress(util.format($(("Getting endpoint named " + name))));
callbackArgs = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__9() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__9() {
return client.endpoints.get(resourceGroup, profileName, name, __cb(_, __frame, 21, 40, function ___(__0, __4) { callbackArgs = __4;
result = callbackArgs[0];
response = callbackArgs[2]; __then(); }, true, true)); }); })(function ___(e, __result) { __catch(function __$__9() { if (e) {
return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__9() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__9() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__9() {
cli.interaction.formatOutput(result, function(data) {
if (!data) {
log.info($("No endpoint named %s found."), profileName); }
else {
log.data("");
log.data($("Endpoint name :"), result.name);
log.data("");
log.data($("Profile name :"), profileName);
log.data($("Resource Group :"), resourceGroup);
log.data($("Location :"), result.location);
log.data($("Tags :"), tagUtils.getTagsInfo(result.tags));
log.data($("Host Name :"), result.hostName);
log.data($("Origin Host Header :"), result.originHostHeader);
log.data($("Origin Path :"), result.originPath);
log.data($("Content Types To Compress :"), result.contentTypesToCompress.join(","));
log.data($("Is Compression Enabled :"), result.isCompressionEnabled);
log.data($("Is Http Allowed :"), result.isHttpAllowed);
log.data($("Is Https Allowed :"), result.isHttpsAllowed);
log.data($("Query String Caching Behavior :"), result.queryStringCachingBehavior);
log.data($("Origin Names :"), cdnManagementUtil.getOriginNamesString(result.origins));
log.data($("OptimizationType :"), result.optimizationType);
log.data($("Number of geo filters :"), result.geoFilters.length);
log.data($("Resource State :"), result.resourceState);
log.data($("Provisioning State :"), result.provisioningState);
log.data(""); } ; }); _(); }); }); }, true)); }, true)); }, true)); }); });
endpoint.command("create [name] [profile-name] [resource-group] [location] [origin-name] [origin-host-name]").description($("Create endpoint with given name and properties.")).usage("[options] <name> <profile-name> <resource-group> <location> <origin-name> <origin-host-name> [origin-host-header] [origin-path] [content-type-to-compress] [is-compression-enabled] [is-http-allowed] [is-https-allowed] [query-string-caching-behavior] [http-port] [https-port] [tags]").option("-n, --name <name>", $("Name of the endpoint")).option("-p, --profile-name <profile-name>", $("Name of the profile")).option("-g, --resource-group <resource-group>", $("The resource group of the Azure Cdn Profile")).option("-l, --location <location>", $("The location of the Cdn endpoint")).option("-o, --origin-name <origin-name>", $("The name of the origin used to identify the origin")).option("-r, --origin-host-name <origin-host-name>", $("The host name of the origin")).option("-e, --origin-host-header [origin-host-header]", $("The origin host header of the Azure Cdn Endpoint")).option("-i, --origin-path [origin-path]", $("The origin path Azure Cdn Endpoint")).option("-c, --content-types-to-compress [content-types-to-compress]", $("The list of mime types that need to be compressed by Cdn edge nodes")).option("-d, --is-compression-enabled [is-compression-enabled]", $("Is the compression enabled for the Cdn. Valid input: -d [true|false]")).option("-w, --is-http-allowed [is-http-allowed]", $("Is the http traffic allowed for the Cdn. Valid input: -w [true|false]")).option("-a, --is-https-allowed [is-https-allowed]", $("Is the https traffic allowed for the Cdn. Valid input: -a [true|false]")).option("-q, --query-string-caching-behavior [query-string-caching-behavior]", $("The way Cdn handles requests with query string")).option("-u, --http-port [http-port]", $("The port http traffic used on the origin server")).option("-f, --https-port [https-port]", $("The port https traffic used on the origin server")).option("-t, --tags [tags]", $("The tags to associate with the Azure Cdn Endpoint")).option("--subscription <subscription>", $("the subscription identifier")).execute(function __10(name, profileName, resourceGroup, location, originName, originHostName, options, _) { var subscription, client, tags, contentTypesToCompress, endpointCreateParameters, progress, callbackArgs, result, response; var __frame = { name: "__10", line: 594 }; return __func(_, this, arguments, __10, 7, __frame, function __$__10() {
return cli.interaction.promptIfNotGiven($("Endpoint name: "), name, __cb(_, __frame, 5, 29, function ___(__0, __1) { name = __1;
return cli.interaction.promptIfNotGiven($("Profile name: "), profileName, __cb(_, __frame, 6, 36, function ___(__0, __2) { profileName = __2;
return cli.interaction.promptIfNotGiven($("Resource group name: "), resourceGroup, __cb(_, __frame, 7, 38, function ___(__0, __3) { resourceGroup = __3;
return cli.interaction.promptIfNotGiven($("Endpoint location: "), location, __cb(_, __frame, 8, 33, function ___(__0, __4) { location = __4;
return cli.interaction.promptIfNotGiven($("Origin name: "), originName, __cb(_, __frame, 9, 35, function ___(__0, __5) { originName = __5;
return cli.interaction.promptIfNotGiven($("Origin host name: "), originHostName, __cb(_, __frame, 10, 39, function ___(__0, __6) { originHostName = __6;
subscription = profile.current.getSubscription();
client = utils.createCdnManagementClient(subscription);
tags = { };
tags = tagUtils.buildTagsParameter(tags, options);
contentTypesToCompress = (options.contentTypesToCompress ? options.contentTypesToCompress.split(",") : []);
endpointCreateParameters = {
contentTypesToCompress: contentTypesToCompress,
location: location,
originHostHeader: options.originHostHeader,
originPath: options.originPath,
origins: [{
name: originName,
hostName: originHostName,
httpPort: parseInt(options.httpPort),
httpsPort: parseInt(options.httpsPort) },],
queryStringCachingBehavior: options.queryStringCachingBehavior,
tags: tags };
if (options.isCompressionEnabled) {
endpointCreateParameters.isCompressionEnabled = cdnManagementUtil.getBooleanFromString(options.isCompressionEnabled); } ;
if (options.isHttpAllowed) {
endpointCreateParameters.isHttpAllowed = cdnManagementUtil.getBooleanFromString(options.isHttpAllowed); } ;
if (options.isHttpsAllowed) {
endpointCreateParameters.isHttpsAllowed = cdnManagementUtil.getBooleanFromString(options.isHttpsAllowed); } ;
progress = cli.interaction.progress(util.format($(("Creating endpoint named " + name))));
callbackArgs = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__10() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__10() {
return client.endpoints.create(resourceGroup, profileName, name, endpointCreateParameters, __cb(_, __frame, 54, 40, function ___(__0, __7) { callbackArgs = __7;
result = callbackArgs[0];
response = callbackArgs[2]; __then(); }, true, true)); }); })(function ___(e, __result) { __catch(function __$__10() { if (e) {
return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__10() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__10() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__10() {
cli.interaction.formatOutput(result, function(data) {
if (!data) {
log.info($("Error creating endpoint %s.")); }
else {
log.data("");
log.data($("Endpoint name :"), result.name);
log.data("");
log.data($("Profile name :"), profileName);
log.data($("Resource Group :"), resourceGroup);
log.data($("Location :"), result.location);
log.data($("Tags :"), tagUtils.getTagsInfo(result.tags));
log.data($("Host Name :"), result.hostName);
log.data($("Origin Host Header :"), result.originHostHeader);
log.data($("Origin Path :"), result.originPath);
log.data($("Content Types To Compress :"), result.contentTypesToCompress.join(","));
log.data($("Is Compression Enabled :"), result.isCompressionEnabled);
log.data($("Is Http Allowed :"), result.isHttpAllowed);
log.data($("Is Https Allowed :"), result.isHttpsAllowed);
log.data($("Query String Caching Behavior :"), result.queryStringCachingBehavior);
log.data($("Origin Names :"), cdnManagementUtil.getOriginNamesString(result.origins));
log.data($("OptimizationType :"), result.optimizationType);
log.data($("Number of geo filters :"), result.geoFilters.length);
log.data($("Resource State :"), result.resourceState);
log.data($("Provisioning State :"), result.provisioningState);
log.data(""); } ; }); _(); }); }); }, true)); }, true)); }, true)); }, true)); }, true)); }, true)); }); });
endpoint.command("set [name] [profile-name] [resource-group]").description($("Update endpoint with given properties.")).usage("[options] <name> <profile-name> <resource-group> [origin-host-header] [origin-path] [content-type-to-compress] [is-compression-enabled] [is-http-allowed] [is-https-allowed] [query-string-caching-behavior] [tags]").option("-n, --name <name>", $("Name of the endpoint")).option("-p, --profile-name <profile-name>", $("Name of the profile")).option("-g, --resource-group <resource-group>", $("The resource group of the Azure Cdn Profile")).option("-e, --origin-host-header [origin-host-header]", $("The origin host header of the Azure Cdn Endpoint")).option("-i, --origin-path [origin-path]", $("The origin path Azure Cdn Endpoint")).option("-c, --content-types-to-compress [content-types-to-compress]", $("The list of mime types that need to be compressed by Cdn edge nodes")).option("-d, --is-compression-enabled [is-compression-enabled]", $("Is the compression enabled for the Cdn. Valid input: -d [true|false]")).option("-u, --is-http-allowed [is-http-allowed]", $("Is the http traffic allowed for the Cdn. Valid input: -u [true|false]")).option("-w, --is-https-allowed [is-https-allowed]", $("Is the https traffic allowed for the Cdn. Valid input: -w [true|false]")).option("-q, --query-string-caching-behavior [query-string-caching-behavior]", $("The way Cdn handles requests with query string")).option("-t, --tags [tags]", $("The tags to associate with the Azure Cdn Endpoint")).option("--subscription <subscription>", $("the subscription identifier")).execute(function __11(name, profileName, resourceGroup, options, _) { var subscription, client, endpointUpdateParameters, tags, progress, callbackArgs, result, response; var __frame = { name: "__11", line: 702 }; return __func(_, this, arguments, __11, 4, __frame, function __$__11() {
return cli.interaction.promptIfNotGiven($("Endpoint name: "), name, __cb(_, __frame, 5, 29, function ___(__0, __1) { name = __1;
return cli.interaction.promptIfNotGiven($("Profile name: "), profileName, __cb(_, __frame, 6, 36, function ___(__0, __2) { profileName = __2;
return cli.interaction.promptIfNotGiven($("Resource group name: "), resourceGroup, __cb(_, __frame, 7, 38, function ___(__0, __3) { resourceGroup = __3;
subscription = profile.current.getSubscription();
client = utils.createCdnManagementClient(subscription);
endpointUpdateParameters = { };
if (options.originHostHeader) {
endpointUpdateParameters.originHostHeader = options.originHostHeader; } ;
if (options.originPath) {
endpointUpdateParameters.originPath = options.originPath; } ;
if (options.isCompressionEnabled) {
endpointUpdateParameters.isCompressionEnabled = cdnManagementUtil.getBooleanFromString(options.isCompressionEnabled); } ;
if (options.contentTypesToCompress) {
endpointUpdateParameters.contentTypesToCompress = options.contentTypesToCompress.split(","); } ;
if (options.isHttpAllowed) {
endpointUpdateParameters.isHttpAllowed = cdnManagementUtil.getBooleanFromString(options.isHttpAllowed); } ;
if (options.isHttpsAllowed) {
endpointUpdateParameters.isHttpsAllowed = cdnManagementUtil.getBooleanFromString(options.isHttpsAllowed); } ;
if (options.queryStringCachingBehavior) {
endpointUpdateParameters.queryStringCachingBehavior = options.queryStringCachingBehavior; } ;
if (options.tags) {
tags = { };
tags = tagUtils.buildTagsParameter(tags, options);
endpointUpdateParameters.tags = tags; } ;
progress = cli.interaction.progress(util.format($(("Updating endpoint named " + name))));
callbackArgs = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__11() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__11() {
return client.endpoints.update(resourceGroup, profileName, name, endpointUpdateParameters, __cb(_, __frame, 54, 40, function ___(__0, __4) { callbackArgs = __4;
result = callbackArgs[0];
response = callbackArgs[2]; __then(); }, true, true)); }); })(function ___(e, __result) { __catch(function __$__11() { if (e) {
return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__11() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__11() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__11() {
cli.interaction.formatOutput(result, function(data) {
if (!data) {
log.info($("Error updating endpoint %s.")); }
else {
log.data("");
log.data($("Endpoint name :"), result.name);
log.data("");
log.data($("Profile name :"), profileName);
log.data($("Resource Group :"), resourceGroup);
log.data($("Location :"), result.location);
log.data($("Tags :"), tagUtils.getTagsInfo(result.tags));
log.data($("Host Name :"), result.hostName);
log.data($("Origin Host Header :"), result.originHostHeader);
log.data($("Origin Path :"), result.originPath);
log.data($("Content Types To Compress :"), result.contentTypesToCompress.join(","));
log.data($("Is Compression Enabled :"), result.isCompressionEnabled);
log.data($("Is Http Allowed :"), result.isHttpAllowed);
log.data($("Is Https Allowed :"), result.isHttpsAllowed);
log.data($("Query String Caching Behavior :"), result.queryStringCachingBehavior);
log.data($("Origin Names :"), cdnManagementUtil.getOriginNamesString(result.origins));
log.data($("OptimizationType :"), result.optimizationType);
log.data($("Number of geo filters :"), result.geoFilters.length);
log.data($("Resource State :"), result.resourceState);
log.data($("Provisioning State :"), result.provisioningState);
log.data(""); } ; }); _(); }); }); }, true)); }, true)); }, true)); }); });
endpoint.command("delete [name] [profile-name] [resource-group]").description($("Delete an endpoint by endpoint name, profile name, and resource group")).usage("[options] <ename> <profile-name> <resource-group>").option("-n, --name <name>", $("Name of the endpoint")).option("-p, --profile-name <profile-name>", $("Name of the profile")).option("-g, --resource-group <resource-group>", $("The resource group of the Azure Cdn Profile")).option("--subscription <subscription>", $("the subscription identifier")).execute(function __12(name, profileName, resourceGroup, options, _) { var subscription, client, progress, callbackArgs, result, response; var __frame = { name: "__12", line: 803 }; return __func(_, this, arguments, __12, 4, __frame, function __$__12() {
return cli.interaction.promptIfNotGiven($("Endpoint name: "), name, __cb(_, __frame, 5, 29, function ___(__0, __1) { name = __1;
return cli.interaction.promptIfNotGiven($("Profile name: "), profileName, __cb(_, __frame, 6, 36, function ___(__0, __2) { profileName = __2;
return cli.interaction.promptIfNotGiven($("Resource group name: "), resourceGroup, __cb(_, __frame, 7, 35, function ___(__0, __3) { resourceGroup = __3;
subscription = profile.current.getSubscription();
client = utils.createCdnManagementClient(subscription);
progress = cli.interaction.progress(util.format($(("Deleting endpoint named " + name))));
callbackArgs = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__12() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__12() {
return client.endpoints.deleteMethod(resourceGroup, profileName, name, __cb(_, __frame, 21, 40, function ___(__0, __4) { callbackArgs = __4;
result = callbackArgs[0];
response = callbackArgs[2]; __then(); }, true, true)); }); })(function ___(e, __result) { __catch(function __$__12() { if (e) {
return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__12() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__12() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__12() {
if ((response.statusCode == 200)) {
log.info(("Delete command successfully invoked for endpoint " + name)); } else {
if ((response.statusCode == 204)) {
log.info((("Delete sucess, but no endpoint named " + name) + " was found")); }
else {
log.info(("Error in deleting endpoint " + name)); } ; } ; _(); }); }); }, true)); }, true)); }, true)); }); });
endpoint.command("start [name] [profile-name] [resource-group]").description($("Start an endpoint by endpoint name, profile name, and resource group")).usage("[options] <name> <profile-name> <resource-group>").option("-n, --name <name>", $("Name of the endpoint")).option("-p, --profile-name <profile-name>", $("Name of the profile")).option("-g, --resource-group <resource-group>", $("The resource group of the Azure Cdn Profile")).option("--subscription <subscription>", $("the subscription identifier")).execute(function __13(name, profileName, resourceGroup, options, _) { var subscription, client, progress, callbackArgs, result, response; var __frame = { name: "__13", line: 850 }; return __func(_, this, arguments, __13, 4, __frame, function __$__13() {
return cli.interaction.promptIfNotGiven($("Endpoint name: "), name, __cb(_, __frame, 5, 29, function ___(__0, __1) { name = __1;
return cli.interaction.promptIfNotGiven($("Profile name: "), profileName, __cb(_, __frame, 6, 36, function ___(__0, __2) { profileName = __2;
return cli.interaction.promptIfNotGiven($("Resource group name: "), resourceGroup, __cb(_, __frame, 7, 35, function ___(__0, __3) { resourceGroup = __3;