UNPKG

dyn-js

Version:
93 lines (83 loc) 2.49 kB
// Generated by CoffeeScript 1.7.1 (function() { var Dyn, async, dyn, dynClient, fail, log; Dyn = require('../lib/dyn-js.js'); async = require('async-q'); log = require('npmlog'); dynClient = Dyn({ traffic: { customer_name: 'yourcustomer', user_name: 'youruser', password: 'yourpassword' } }); dynClient.log.level = 'sil'; dyn = dynClient.traffic.withZone('example.com'); fail = function(bad) { return console.log('FAIL', arguments); }; async.series([ function() { return dyn.session.create(); }, function() { return dyn.zone.list().then(function(x) { log.info('RESULT', "got zones: " + (JSON.stringify(x))); return x; }); }, function() { return dyn.zone.destroy().then(function(x) { log.info('RESULT', "zone removed: " + (JSON.stringify(x))); return x; }); }, function() { return dyn.zone.create({ rname: 'admin@example.com', ttl: 60 }).then(function(x) { log.info('RESULT', "created new zone: " + (JSON.stringify(x))); return x; }); }, function() { return dyn.record._A.create('local2.example.com', { rdata: { address: '127.0.0.1' } }).then(function(x) { log.info('RESULT', "created an A record: " + (JSON.stringify(x))); return x; }); }, function() { return dyn.record._CNAME.create('local.example.com', { rdata: { cname: 'locale2.example.com' } }).then(function(x) { log.info('RESULT', "created a CNAME record: " + (JSON.stringify(x))); return x; }); }, function() { return dyn.http_redirect.create('overhere.example.com', 302, "Y", 'http://overthere.example.com').then(function(x) { log.info('RESULT', "created a redirect: " + (JSON.stringify(x))); return x; }); }, function() { return dyn.gslb.create('hello.example.com', { region: { region_code: 'global', pool: { address: 'hi.example.com' } } }).then(function(x) { log.info('RESULT', "created a gslb service: " + (JSON.stringify(x))); return x; }); }, function() { return dyn.session.destroy(); } ]).then(function() { return _(arguments[0]).forEach(function(x) { return log.info('RESULT', "finished : " + (JSON.stringify(x))); }); }, fail); }).call(this);