Skip to content

Commit

Permalink
Added Examples
Browse files Browse the repository at this point in the history
Signed-off-by: Partik SIngh <partik.sbumrah.cse21@itbhu.ac.in>
  • Loading branch information
partik03 authored and mbcse committed Aug 25, 2023
1 parent 8287968 commit 65574b4
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions examples/storage/linode-blockStorage.js
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);
});
}

0 comments on commit 65574b4

Please sign in to comment.