From e91462a56ff40335f531467512252651e0f7346d Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Mon, 5 Mar 2012 14:02:40 -0800 Subject: [PATCH] Roughing in several early site/space commands --- lib/waz/commands/site.js | 173 ++++++++++++++++++++++++++++++++++----- 1 file changed, 151 insertions(+), 22 deletions(-) diff --git a/lib/waz/commands/site.js b/lib/waz/commands/site.js index 73afbae8e..d2c289d53 100644 --- a/lib/waz/commands/site.js +++ b/lib/waz/commands/site.js @@ -1,23 +1,152 @@ - -exports.init = function(waz) { - - var site = waz.category('site') - .description('Commands to manage your Azure web sites.'); - - site.command('list') - .description('List your Azure web sites.') - .option('-s, --subscription ', 'use the subscription id') - .action(function() { - console.log('this is your list'); - }); - - site.command('init ') - .description('Initialize your Azure web site.') - .option('-s, --subscription ', 'use the subscription id') - .action(function(siteName, options) { - console.log('creating your site \'%s\'', siteName); - if (options.subscription) { - console.log('using subscription \'%s\'', options.subscription); - } - }); + +var fs = require('fs'); +var pfx2pem = require('../../util/certificates/pkcs').pfx2pem; +var Channel = require('../channel'); + + +exports.init = function (waz) { + + var pem = pfx2pem(fs.readFileSync('client-x509-rsa.pfx')); + + var channel = new Channel({ + host: 'umapi-new.rdfetest.dnsdemo4.com', + port: 8443, + key: pem, + cert: pem + }); + + var site = waz.category('site') + .description('Commands to manage your Azure web sites.'); + + site.command('show [name]') + .description('List your Azure web sites.') + .option('-i, --subscription ', 'use the subscription id') + .option('-s, --space ', 'use the space name') + .action(function (name, options) { + + var subscription = options.subscription || waz.category('account').defaultSubscriptionId(); + + channel + .header('x-ms-version', '2011-02-25') + .path('51ca709f-562d-4d4f-8efc-46de5833042e') + .path('services/webspaces') + .path(options.space || '.default') + .path('sites') + .path(name || '') + .header('Content-Type', 'application/xml') + .GET(function(err, thing) { + console.log(thing); + }); + }); + + site.command('create ') + .description('Initialize your Azure web site.') + .option('-i, --subscription ', 'use the subscription id') + .option('-s, --space ', 'use the space name') + .action(function (name, options) { + + var subscription = options.subscription || waz.category('account').defaultSubscriptionId(); + + channel + .header('x-ms-version', '2011-02-25') + .path(subscription) + .path('services/webspaces') + .path(options.space || '.default') + .path('sites/') + .header('Content-Type', 'application/xml') + .POST(function(req) { + req.write(''); + req.write(''); + req.write(''); + req.write(name + '.antares.com'); + req.write(''); + req.write(''); + req.write('www.' + name + '.antares.com'); + req.write(''); + req.write(''); + req.write(''); + req.write(name); + req.write(''); + req.write(''); + + req.end(); + }, + function(err, thing) { + console.log(thing); + }); + }); + + var space = waz.category('space') + .description('Commands to manage your Azure web spaces.'); + + space.command('show [name]') + .description('Show info about a web space.') + .option('-i, --subscription ', 'use the subscription id') + .action(function (name, options) { + + var subscription = options.subscription || waz.category('account').defaultSubscriptionId(); + + channel + .header('x-ms-version', '2011-02-25') + .path(subscription) + .path('services/webspaces') + .path(name || '') + .GET(function(err, thing) { + console.log(thing); + }); + }); + + space.command('delete ') + .description('Kill a web space.') + .option('-i, --subscription ', 'use the subscription id') + .action(function (name, options) { + + var subscription = options.subscription || waz.category('account').defaultSubscriptionId(); + + channel + .header('x-ms-version', '2011-02-25') + .path(subscription) + .path('services/webspaces') + .path(name) + .DELETE(function(err, thing) { + console.log(thing); + }); + }); + + + + + + space.command('create ') + .description('Create a web space.') + .option('-i, --subscription ', 'use the subscription id') + .option('-p, --plan ', 'use the plan') + .action(function (name, options) { + + var subscription = options.subscription || waz.category('account').defaultSubscriptionId(); + + channel + .header('x-ms-version', '2011-02-25') + .path(subscription) + .path('services/webspaces/') + .header('Content-Type', 'application/xml') + .POST(function(req) { + req.write(''); + req.write(''); + req.write(name); + req.write(''); + req.write(''); + req.write(options.plan || 'Plan 1'); + req.write(''); + req.write(''); + req.write(subscription); + req.write(''); + req.write(''); + + req.end(); + }, + function(err, thing) { + console.log(thing); + }); + }); };