block-storage
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -116,4 +116,22 @@ const request = require('request-promise') | ||
resize(id, gigabytes, callback) { | ||
const opts = { | ||
method: 'POST', | ||
uri: `${this.url}/${id}/actions`, | ||
headers: { | ||
'Authorization': `Bearer ${this.token}` | ||
}, | ||
body: { | ||
"type": "resize", | ||
"size_gigabytes": gigabytes, | ||
"region": "nyc1" | ||
}, | ||
json: true | ||
} | ||
return Promise.resolve(request(opts)).asCallback(callback) | ||
} | ||
} | ||
module.exports = Client |
{ | ||
"name": "block-storage", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A simple way to connect to Digital Ocean's Volumes API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,3 +13,2 @@ # block-storage | ||
- [Table of Concepts](#table-of-concepts) | ||
- [Installation](#installation) | ||
@@ -25,2 +24,3 @@ - [Authentication: Bearer Token](#authentication-bearer-token) | ||
- [volumes.delete()](#volumesdelete) | ||
- [volumes.resize()](#volumesresize) | ||
- [Ussage](#ussage) | ||
@@ -150,2 +150,15 @@ - [Using callbacks](#using-callbacks) | ||
#### volumes.resize() | ||
Resizes a single volume. | ||
```js | ||
volumes.resize(volumeId, gigabytes, (err, obj) => { | ||
if (err) console.log(err) | ||
console.log(obj) | ||
}) | ||
``` | ||
## Ussage | ||
@@ -152,0 +165,0 @@ |
@@ -23,2 +23,3 @@ 'use strict' | ||
t.is(typeof volumes.actions, 'function', 'actions is a function') | ||
t.is(typeof volumes.resize, 'function', 'resize is a function') | ||
}) | ||
@@ -97,1 +98,10 @@ | ||
}) | ||
test('Resize a single volume', async t => { | ||
let volumes = t.context.volumes | ||
let volumeId = config.test.id | ||
let body = await volumes.resize(volumeId, 2) | ||
t.is(body.action.type, 'resize_volume', 'The request has resised the selected volume') | ||
}) |
14139
279
211