New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sacloud

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sacloud - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

80

bin/sacloud.js

@@ -146,8 +146,10 @@ #!/usr/bin/env node

// status
console.log(
result.requestInfo.method.toUpperCase(), result.requestInfo.url, '->',
result.responseInfo.status, result.responseInfo.statusText,
'(' + requestedCount + '/' + totalCount + ')',
'~' + (result.responseInfo.latency / 1000) + 'sec'
);
if (!opt.csv && !opt.tsv) {
console.log(
result.requestInfo.method.toUpperCase(), result.requestInfo.url, '->',
result.responseInfo.status, result.responseInfo.statusText,
'(' + requestedCount + '/' + totalCount + ')',
'~' + (result.responseInfo.latency / 1000) + 'sec'
);
}

@@ -165,2 +167,4 @@ if (err) {

if (body === null) return process.exit(0);
switch (result.responseInfo.type) {

@@ -170,3 +174,3 @@

util.puts(util.inspect(result.response, false, null, true));
util.puts(util.inspect(result.response, { colors: true, depth: 0 }));

@@ -193,6 +197,10 @@ break;

var table = new Table({
head : h,
chars: tableChar
});
if (opt.csv || opt.tsv) {
var table = [h];
} else {
var table = new Table({
head : h,
chars: tableChar
});
}

@@ -219,3 +227,14 @@ body.forEach(function(res, i) {

util.puts(table.toString());
if (opt.csv || opt.tsv) {
var lines = [];
table.forEach(function(a) {
if (opt.csv) lines.push(a.join(','));
if (opt.tsv) lines.push(a.join('\t'));
});
util.puts(lines.join('\n'));
} else {
util.puts(table.toString());
}

@@ -226,3 +245,7 @@ break;

var table = new Table({ chars: tableChar });
if (opt.csv || opt.tsv) {
var table = [];
} else {
var table = new Table({ chars: tableChar });
}

@@ -286,3 +309,32 @@ !!body.id && table.push({ id : body.id });

util.puts(table.toString());
if (opt.csv || opt.tsv) {
var lines = [];
var head = [];
var line = [];
table.forEach(function(a) {
for (var k in a) {
head.push(k);
line.push(a[k]);
}
});
if (opt.csv) {
lines.push(
head.join(',').replace(/(\n|\r)/g, ''),
line.join(',').replace(/(\n|\r)/g, '')
);
}
if (opt.tsv) {
lines.push(
head.join('\t').replace(/(\n|\r)/g, ''),
line.join('\t').replace(/(\n|\r)/g, '')
);
}
util.puts(lines.join('\n'));
} else {
util.puts(table.toString());
}

@@ -289,0 +341,0 @@ break;

118

lib/sacloud/command.js

@@ -20,3 +20,6 @@ var sacloud = require('../sacloud');

server : ['zone', 'id:zone', 'plan', 'id:product/server', 'name', 'p:name'],
disk : ['zone', 'id:zone', 'plan', 'id:product/disk', 'size', 'p:size(GB)', 'type', 'k:virtio|ide', 'name', 'p:name']
disk : ['zone', 'id:zone', 'plan', 'id:product/disk', 'size', 'p:size(GB)', 'type', 'k:virtio|ide', 'name', 'p:name'],
'switch' : ['zone', 'id:zone', 'name', 'p:name'],
internet : ['zone', 'id:zone', 'prefix', 'k:28|27', 'bandwidth', 'k:100|500|1000', 'name', 'p:name'],
interface: ['to', 'server', 'id:server']
},

@@ -27,3 +30,3 @@

disk : ['id:disk'],
archive : ['id:archive'],
//archive : ['id:archive'],
cdrom : ['id:cdrom'],

@@ -37,3 +40,3 @@ 'switch' : ['id:switch'],

zone : ['id:zone']
}/*,
},

@@ -43,7 +46,7 @@ update: {

disk : ['id:disk'],
archive : ['id:archive'],
//archive : ['id:archive'],
'switch' : ['id:switch'],
internet : ['id:internet'],
//internet : ['id:internet'],
ipaddress: ['id:ipaddress']
}*/,
},

@@ -53,3 +56,3 @@ 'delete': {

disk : ['id:disk'],
archive : ['id:archive'],
//archive : ['id:archive'],
'switch' : ['id:switch'],

@@ -79,2 +82,30 @@ interface: ['id:interface']

insert: {
cdrom : ['id:cdrom', 'to', 'server', 'id:server']
},
eject: {
cdrom : ['from', 'server', 'id:server']
},
attach: {
disk : ['id:disk', 'to', 'server', 'id:server']
},
detach: {
disk : ['id:disk', 'from', 'server']
},
connect: {
interface: ['id:interface', 'to', 'switch', 'id:switch']
},
disconnect: {
interface: ['id:interface', 'from', 'switch']
},
modify: {
disk : ['id:disk', 'password', 'p:password', 'p:options...']
},
config: {}

@@ -223,2 +254,4 @@ };

'--json': {},
'--csv': {},
'--tsv': {},
'--inspect': {},

@@ -242,71 +275,2 @@ '--compact': {},

return requests.create(args).setOption(this.opt);
};
/* action */
var action = {
create: {
server: {
from: {
server: {}
}
},
disk: {
from: {
disk : {},
archive: {}
}
},
archive: {
from: {
disk : {},
archive: {}
}
},
},
connect: {
interface: {
to: {
'switch': { isRequired: true }
}
}
},
disconnect: {
interface: {
to: {
'switch': { isRequired: true }
}
}
},
'show' : null,
'update' : null,
'delete' : null,
'attach' : ['disk'],
'detach' : ['disk'],
'copy' : {
self: ['disk', 'archive'],
to : ['disk', 'archive']
},
'modify' : ['disk'],
'ftp-open' : ['archive'],
'ftp-close': ['archive'],
'start' : ['server', 'appliance'],
'stop' : ['server', 'appliance'],
'restart' : ['server', 'appliance'],
'shutdown' : ['server', 'appliance'],
'wslash' : null
};
};

@@ -5,2 +5,3 @@ /**

var sacloud = require('../sacloud');
var _ = require('underscore');
//var util = require('util');

@@ -54,2 +55,3 @@

} else {
var path = resource;
var body = {};

@@ -86,2 +88,32 @@

break;
case 'switch':
var res = {};
if (args.shift() === 'zone') res.Zone = { ID: args.shift() };
if (args.shift() === 'name') res.Name = args.shift();
body.Switch = res;
break;
case 'internet':
var res = {};
if (args.shift() === 'zone') res.Zone = { ID: args.shift() };
if (args.shift() === 'prefix') res.NetworkMaskLen = parseInt(args.shift(), 10);
if (args.shift() === 'bandwidth') res.BandWidthMbps = parseInt(args.shift(), 10);
if (args.shift() === 'name') res.Name = args.shift();
body.Internet = res;
break;
case 'interface':
body.Interface = { Server: { ID: _.last(args) } };
break;
}

@@ -91,3 +123,3 @@

method: 'post',
path : resource,
path : path,
body : body

@@ -159,2 +191,80 @@ });

break;
case 'insert':
if (args.length !== 4) {
throw new Error(
'parameters is invalid' + '\n' +
'usage: ' + sacloud.command.structure[action][resource].join(' ')
);
} else {
var body = {};
var q = resource;
if (resource === 'cdrom') q = 'CDROM';
body[q] = { ID: args[0] };
reqs.push({
method: 'PUT',
path : [args[2], args[3], resource].join('/'),
body : body
});
}
break;
case 'eject':
if (args.length !== 3) {
throw new Error(
'parameters is invalid' + '\n' +
'usage: ' + sacloud.command.structure[action][resource].join(' ')
);
} else {
var q = resource;
if (resource === 'cdrom') q = 'CDROM';
reqs.push({
method: 'DELETE',
path : [args[1], args[2], resource].join('/')
});
}
break;
case 'attach':
case 'detach':
if ((action === 'attach' && args.length !== 4) || (action === 'detach' && args.length !== 3)) {
throw new Error(
'parameters is invalid' + '\n' +
'usage: ' + sacloud.command.structure[action][resource].join(' ')
);
} else {
reqs.push({
method: (action === 'attach') ? 'PUT' : 'DELETE',
path : _.compact([resource, args[0], 'to', args[2], args[3] || null]).join('/')
});
}
break;
case 'connect':
case 'disconnect':
if ((action === 'connect' && args.length !== 4) || (action === 'disconnect' && args.length !== 3)) {
throw new Error(
'parameters is invalid' + '\n' +
'usage: ' + sacloud.command.structure[action][resource].join(' ')
);
} else {
reqs.push({
method: (action === 'connect') ? 'PUT' : 'DELETE',
path : _.compact([resource, args[0], 'to', args[2], args[3] || null]).join('/')
});
}
break;

@@ -161,0 +271,0 @@ default:

{
"name": "sacloud",
"version": "0.0.2",
"version": "0.0.3",
"description": "A Node.js Module and CLI for SAKURA Internet Cloud APIs.",

@@ -25,4 +25,5 @@ "main": "index.js",

"complete": "0.3.1",
"cli-table": "git://github.com/kanreisa/cli-table.git"
"cli-table": "git://github.com/kanreisa/cli-table.git",
"underscore": "~1.4.4"
}
}

@@ -8,10 +8,8 @@ node-sacloud (sacloud)

### Install (CLI)
### Installation
* [Install a binary distribution of node.js](http://nodejs.org/#download)
* `npm install -g sacloud`
* `sacloud config --accessToken=**** --accessTokenSecret=********`
see: https://github.com/sakura-internet/node-sacloud/wiki/Installation
### Install (Module)
### Configuration
* `npm install sacloud`
see: https://github.com/sakura-internet/node-sacloud/wiki/Configuration
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc