Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

liboneandone

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

liboneandone - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

lib/block-storage.js

1

example/example.js

@@ -131,2 +131,3 @@ /**

},
"server_type":"cloud",
"ip_id": publicIpId,

@@ -133,0 +134,0 @@ "appliance_id": appliance.id,

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -37,2 +37,4 @@ /**

merge('./informational-operations', oneandone)
merge('./block-storage', oneandone)
merge('./ssh-key', oneandone)

@@ -39,0 +41,0 @@

@@ -7,2 +7,3 @@ /**

appliancesEndPointPath: "server_appliances",
recoveryImageEndPointPath: "recovery_appliances",
dvdIsoEndPointPath: "dvd_isos",

@@ -89,2 +90,34 @@ datacentersEndPointPath: "datacenters",

listRecoveryImages: function (callback) {
req.is_get([this.recoveryImageEndPointPath], callback)
},
listRecoveryImagesWithOptions: function (options, callback) {
var path = this.recoveryImageEndPointPath;
if (options) {
path += "?";
if (options.page) {
path += "&page=" + options.page;
}
if (options.perPage) {
path += "&per_page=" + options.perPage;
}
if (options.sort) {
path += "&sort=" + options.sort;
}
if (options.query) {
path += "&q=" + options.query;
}
if (options.fields) {
path += "&fields=" + options.fields;
}
}
req.is_get([path], callback)
},
getRecoveryImage: function (image_id, callback) {
req.is_get([this.recoveryImageEndPointPath, image_id], callback)
},
listDvdIso: function (callback) {

@@ -163,4 +196,3 @@ req.is_get([this.dvdIsoEndPointPath], callback)

req.is_get([path], callback)
}
,
},

@@ -167,0 +199,0 @@ getDatacenters: function (dc_id, callback) {

@@ -35,2 +35,4 @@ /**

merge('./informational-operations', oneandone)
merge('./block-storage', oneandone)
merge('./ssh-key', oneandone)

@@ -37,0 +39,0 @@ module.exports = (function () {

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -41,2 +41,33 @@ /**

listBaremetalModels: function (options,callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
var path = "servers/baremetal_models";
if (options) {
path += "?";
if (options.page) {
path += "&page=" + options.page;
}
if (options.perPage) {
path += "&per_page=" + options.perPage;
}
if (options.sort) {
path += "&sort=" + options.sort;
}
if (options.query) {
path += "&q=" + options.query;
}
if (options.fields) {
path += "&fields=" + options.fields;
}
}
req.is_get([path], callback);
},
getBaremetalModel: function (model_id, callback) {
req.is_get(["servers", "baremetal_models", model_id], callback)
},
createServer: function (json, callback) {

@@ -62,2 +93,12 @@ req.is_post(["servers"], json, callback)

recoveryRebootServer: function (srv_id, recovery_image_id, callback) {
json ={
"recovery_mode": true,
"recovery_image_id": recovery_image_id,
"action": "REBOOT",
"method": "SOFTWARE"
}
req.is_put(["servers", srv_id, "status/action"], json, callback)
},
deleteServer: function (srv_id, keep_ips, callback) {

@@ -64,0 +105,0 @@ if (!keep_ips) {

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

/**
* Created by Ali on 8/13/2016.
*/
var fs = require('fs');
module.exports = {

@@ -44,4 +44,14 @@ vpnEndPointPath: "vpns",

getConfigurationFile: function (vpn_id, callback) {
req.is_get([this.vpnEndPointPath, vpn_id, "configuration_file"], callback)
getConfigurationFile: function (filepath, vpn_id, callback) {
req.is_get([this.vpnEndPointPath, vpn_id, "configuration_file"], function (error, response, body) {
var object = JSON.parse(body);
var base64Data = object.config_zip_file;
base64Data += base64Data.replace('+', ' ');
binaryData = new Buffer(base64Data, 'base64').toString('binary');
fs.writeFile(filepath+'.zip', binaryData, "binary", function (err) {
console.log(err); // writes out file without error
callback(err, response, body);
});
});
},

@@ -48,0 +58,0 @@

5

package.json
{
"name": "liboneandone",
"version": "1.0.0",
"version": "1.1.0",
"description": "The 1&1 Library for Node and Io",

@@ -38,4 +38,5 @@ "main": "./lib/index.js",

"libOneAndone",
"1&1"
"1&1",
"fs"
]
}

@@ -0,0 +0,0 @@ /**

@@ -13,3 +13,3 @@ /**

describe('Images tests', function () {
this.timeout(900000);
this.timeout(1800000);

@@ -32,3 +32,3 @@ before(function (done) {

var serverData = {
"name": "Node Image Server",
"name": "Node Image Server1",
"description": "description",

@@ -58,3 +58,3 @@ "hardware": {

"server_id": server.id,
"name": "node image",
"name": "node image3",
"description": "My image description",

@@ -162,11 +162,13 @@ "frequency": oneandone.ImageFrequency.WEEKLY,

};
oneandone.updateImage(image.id, updateData, function (error, response, body) {
helper.assertNoError(200, response, function (result) {
assert(result);
helper.checkImageReady(image, function () {
oneandone.updateImage(image.id, updateData, function (error, response, body) {
helper.assertNoError(200, response, function (result) {
assert(result);
});
assert.notEqual(response, null);
assert.notEqual(body, null);
var object = JSON.parse(body);
assert.equal(object.name, updateData.name);
done();
});
assert.notEqual(response, null);
assert.notEqual(body, null);
var object = JSON.parse(body);
assert.equal(object.name, updateData.name);
done();
});

@@ -173,0 +175,0 @@ });

@@ -8,2 +8,3 @@ /**

var appliance = {};
var recovery_image = {};
var dvdIso = {};

@@ -217,2 +218,48 @@ var dataCenter = {};

});
it('List Recovery Images', function (done) {
oneandone.listRecoveryImages(function (error, response, body) {
helper.assertNoError(200, response, function (result) {
assert(result);
});
assert.notEqual(response, null);
assert.notEqual(body, null);
var object = JSON.parse(body);
assert(object.length > 0);
recovery_image = object[0];
done();
});
});
it('List Recovery Images with options', function (done) {
var options = {
page: 1
};
setTimeout(function () {
oneandone.listRecoveryImagesWithOptions(options, function (error, response, body) {
helper.assertNoError(200, response, function (result) {
assert(result);
});
assert.notEqual(response, null);
assert.notEqual(body, null);
var object = JSON.parse(body);
assert(object.length > 0);
done();
});
}, 5000);
});
it('Get Recovery Image', function (done) {
oneandone.getRecoveryImage(recovery_image.id, function (error, response, body) {
helper.assertNoError(200, response, function (result) {
assert(result);
});
assert.notEqual(response, null);
assert.notEqual(body, null);
var object = JSON.parse(body);
assert.equal(object.id, recovery_image.id);
done();
});
});
});

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -11,2 +11,3 @@ /**

var hardwareFlavour = {};
var baremetalModel = {};
var currentHdd = {};

@@ -19,3 +20,3 @@ var currentImage = {};

describe('Server tests', function () {
this.timeout(900000);
this.timeout(1800000);

@@ -37,4 +38,5 @@ before(function (done) {

var serverData = {
"name": "Node Server",
"name": "Node Server1",
"description": "description",
"server_type": "cloud",
"hardware": {

@@ -99,7 +101,9 @@ "vcore": 2,

fixedInstace = {
"name": "Node Fixed Instance server",
"name": "Node Fixed Instance server1",
"description": "My server description",
"server_type": "cloud",
"hardware": {
"fixed_instance_size_id": "65929629F35BBFBA63022008F773F3EB"
"fixed_instance_size_id": "81504C620D98BCEBAA5202D145203B4B"
},
"server_type": "cloud",
"appliance_id": appliance.id,

@@ -174,2 +178,27 @@ "datacenter_id": dataCenter.id

it('List Bare metal Model', function (done) {
oneandone.listBaremetalModels(function (error, response, body) {
helper.assertNoError(200, response, function (result) {
assert(result);
});
assert.notEqual(response, null);
assert.notEqual(body, null);
var object = JSON.parse(body);
assert(object.length > 0);
baremetalModel = object[0];
done();
});
});
it('Get Bare metal Model', function (done) {
oneandone.getBaremetalModel(baremetalModel.id, function (error, response, body) {
helper.assertNoError(200, response, function (result) {
assert(result);
});
assert.notEqual(response, null);
assert.notEqual(body, null);
done();
});
});
it('Get server status', function (done) {

@@ -186,2 +215,27 @@ oneandone.getServerStatus(server.id, function (error, response, body) {

it('Recovery Reboot image', function (done) {
var options = {
page: 1,
query: "linux"
};
setTimeout(function () {
oneandone.listRecoveryImagesWithOptions(options, function (error, response, body) {
helper.assertNoError(200, response, function (result) {
assert(result);
});
assert.notEqual(response, null);
assert.notEqual(body, null);
var object = JSON.parse(body);
helper.checkServerReady(fixedInstaceserver, function () {
oneandone.recoveryRebootServer (fixedInstaceserver.id, object[0].id, function (error, response, body) {
assert.notEqual(response, null);
assert.notEqual(body, null);
done();
});
});
});
}, 12000);
});
it('Get server', function (done) {

@@ -208,14 +262,16 @@ oneandone.getServer(server.id, function (error, response, body) {

helper.checkServerReady(server, function () {
oneandone.updateServer(server.id, updateData, function (error, response, body) {
helper.assertNoError(200, response, function (result) {
assert(result);
setTimeout(function () {
oneandone.updateServer(server.id, updateData, function (error, response, body) {
helper.assertNoError(200, response, function (result) {
assert(result);
});
assert.notEqual(response, null);
assert.notEqual(body, null);
var object = JSON.parse(body);
assert.equal(object.id, server.id);
assert.equal(object.name, updateData.name);
assert.equal(object.description, updateData.description);
done();
});
assert.notEqual(response, null);
assert.notEqual(body, null);
var object = JSON.parse(body);
assert.equal(object.id, server.id);
assert.equal(object.name, updateData.name);
assert.equal(object.description, updateData.description);
done();
});
}, 12000);
});

@@ -222,0 +278,0 @@ });

@@ -0,0 +0,0 @@ /**

@@ -5,3 +5,3 @@ /**

var token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
var token = process.env.ONEANDONE_TOKEN;
var url = 'https://cloudpanel-api.1and1.com/v1';

@@ -25,3 +25,3 @@ var oneandone = require('../lib/liboneandone');

helper.checkServerReady(checkServer, callback);
}, 5000);
}, 20000);
} else {

@@ -33,2 +33,17 @@ callback();

helper.checkImageReady = function (currentImage, callback) {
var checkImage = {};
oneandone.getImage(currentImage.id, function (error, response, body) {
checkImage = JSON.parse(body);
if (checkImage.state != "ENABLED"
|| checkImage.state != "ACTIVE") {
setTimeout(function () {
helper.checkImageReady(checkImage, callback);
}, 40000);
} else {
callback();
}
});
};
helper.checkPrivateNetworkReady = function (currentServer, privateNetwork, callback) {

@@ -35,0 +50,0 @@ var checkPn = {};

@@ -59,3 +59,3 @@ /**

var options = {
query: "ali"
query: "node"
};

@@ -62,0 +62,0 @@

@@ -92,3 +92,3 @@ /**

setTimeout(function () {
oneandone.getConfigurationFile(vpn.id, function (error, response, body) {
oneandone.getConfigurationFile('C:\\'+vpn.name, vpn.id, function (error, response, body) {
helper.assertNoError(200, response, function (result) {

@@ -95,0 +95,0 @@ assert(result);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc