-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Partik SIngh <[email protected]>
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const nodeCloud = require("../../lib/"); | ||
const optionsProvider = { | ||
overrideProviders: false | ||
}; | ||
const ncProviders = nodeCloud.getProviders(optionsProvider); | ||
|
||
const volume = ncProviders.linode.blockStorage(); | ||
|
||
//List all volumes | ||
function listVolumes() { | ||
volume | ||
.list() | ||
.then(result => { | ||
console.log("Volumes are: ", result); | ||
}) | ||
.catch(err => { | ||
console.log("Error is: ", err); | ||
}); | ||
} | ||
|
||
//Create a volume | ||
function createVolume() { | ||
let option = { | ||
"label": "my-volume", | ||
"size": 20, | ||
"linode_id": 12346 | ||
}; | ||
volume | ||
.create(option) | ||
.then(result => { | ||
console.log("Output is: ", result); | ||
}) | ||
.catch(err => { | ||
console.log("Error is: ", err); | ||
}); | ||
} | ||
|
||
//Update details of a Volume | ||
function updateVolume() { | ||
let volumeId = 5067840; | ||
let option = { | ||
"label": "my-volume" | ||
} | ||
volume | ||
.update(volumeId,option) | ||
.then(result => { | ||
console.log("Output is: ", result); | ||
}) | ||
.catch(err => { | ||
console.log("Error is: ", err); | ||
}); | ||
} | ||
|
||
//Delete a volume | ||
function deleteVolume() { | ||
let volumeId = 5067840; | ||
volume | ||
.delete(volumeId) | ||
.then(result => { | ||
console.log("Output is: ", result); | ||
}) | ||
.catch(err => { | ||
console.log("Error is: ", err); | ||
}); | ||
} |