Skip to content

Commit eb5f4b2

Browse files
committed
Added Examples for key Management
1 parent bc47df4 commit eb5f4b2

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const nodeCloud = require("../../lib/");
2+
const optionsProvider = {
3+
overrideProviders: false
4+
};
5+
const ncProviders = nodeCloud.getProviders(optionsProvider);
6+
const keyManagement = ncProviders.do.keyManagement();
7+
8+
function createKey(){
9+
let options={
10+
"public_key": "ssh-rsa AEXAMPLEaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example",
11+
"name": "My SSH Public Key"
12+
}
13+
keyManagement.createKey(options)
14+
.then(res => {
15+
console.log("Output is"+res);
16+
})
17+
.catch(err => {
18+
console.log(`Oops something happened ${err}`);
19+
});
20+
}
21+
22+
23+
function deleteKey(){
24+
let keyIdentifier="512189";
25+
keyManagement.deleteKey(keyIdentifier)
26+
.then(res => {
27+
console.log("Output is"+res);
28+
})
29+
.catch(err => {
30+
console.log(`Oops something happened ${err}`);
31+
});
32+
}
33+
34+
function getKey(){
35+
let keyIdentifier="512189";
36+
keyManagement.describeKey(keyIdentifier)
37+
.then(res => {
38+
console.log("Output is"+res);
39+
})
40+
.catch(err => {
41+
console.log(`Oops something happened ${err}`);
42+
});
43+
}
44+
45+
function getAllKeys(){
46+
keyManagement.list()
47+
.then(res => {
48+
console.log("Output is"+res);
49+
})
50+
.catch(err => {
51+
console.log(`Oops something happened ${err}`);
52+
});
53+
}

0 commit comments

Comments
 (0)