Comparing version 0.0.8 to 0.0.9
@@ -16,3 +16,3 @@ /** | ||
this.req.method = this.req.method || 'get'; | ||
this.req.method = this.req.method || 'GET'; | ||
this.req.body = this.req.body || {}; | ||
@@ -46,2 +46,4 @@ // | ||
this.req.method = this.req.method.toUpperCase(); | ||
var xhr = new XMLHttpRequest(); | ||
@@ -132,3 +134,3 @@ | ||
if (this.req.method === 'get') this.req.url += '?' + JSON.stringify(this.req.body); | ||
if (this.req.method === 'GET') this.req.url += '?' + JSON.stringify(this.req.body); | ||
@@ -144,3 +146,3 @@ xhr.open( | ||
xhr.setRequestHeader('X-Sakura-Cloud-Client-Version', '3.node-sacloud'); | ||
xhr.setRequestHeader('X-Sakura-HTTP-Method', this.req.method.toUpperCase()); | ||
xhr.setRequestHeader('X-Sakura-HTTP-Method', this.req.method); | ||
xhr.setRequestHeader('X-Sakura-No-Authenticate-Header', '1'); | ||
@@ -151,3 +153,3 @@ xhr.setRequestHeader('X-Sakura-API-Request-Format', 'json'); | ||
if (this.req.method === 'get') { | ||
if (this.req.method === 'GET') { | ||
xhr.send(); | ||
@@ -154,0 +156,0 @@ } else { |
{ | ||
"name": "sacloud", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "A Node.js Module and CLI for SAKURA Internet Cloud APIs.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -15,1 +15,73 @@ node-sacloud (sacloud) | ||
see: https://github.com/sakura-internet/node-sacloud/wiki/Configuration | ||
## Getting started | ||
##### Load the module: | ||
```javascript | ||
var sacloud = require('sacloud'); | ||
``` | ||
##### Then create a new client: | ||
```javascript | ||
var client = sacloud.createClient({ | ||
accessToken : 'account_access_token_here', | ||
accessTokenSecret : '********', | ||
disableLocalizeKeys: false,// (optional;default:false) false: lower-camelize the property names in response Object | ||
debug : true// (optional;default:false) output debug requests to console. | ||
}); | ||
``` | ||
* API-key manager: https://secure.sakura.ad.jp/cloud/#!/pref/apikey/ | ||
##### Let's get list of server. | ||
```javascript | ||
client.createRequest({ | ||
method: 'GET', | ||
path : 'server' | ||
}).send(function(err, result) { | ||
if (err) throw new Error(err); | ||
console.log( JSON.stringify(result, null, ' ') ); | ||
}); | ||
``` | ||
##### new server creation | ||
```javascript | ||
var request = client.createRequest({ | ||
method: 'POST', | ||
path : 'server', | ||
body : { | ||
Server: { | ||
Zone : { ID: 31001 }, | ||
ServerPlan : { ID: 1 }, | ||
Name : 'test-server', | ||
Description: 'blah blah blah...', | ||
Tags : ['test'] | ||
} | ||
} | ||
}); | ||
request.send(function(err, result) { | ||
if (!err) console.log('created successfully! serverId=' + result.response.server.id); | ||
}); | ||
``` | ||
### CLI? | ||
see: https://github.com/sakura-internet/node-sacloud/wiki/Getting-started-Guide | ||
### API? | ||
see: http://developer.sakura.ad.jp/cloud/api/1.0/ | ||
## Comments / Questions | ||
Please feel free to send any messages: ```@kanreisa``` / ```y-kan at sakura.ad.jp``` | ||
Or just open github issues. |
36061
1016
87