@gridscale/api
Version:
gridscale API Wrapper
1,485 lines (1,431 loc) • 668 kB
JavaScript
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
var process = require('process');
var colors = require('colors');
var gridscale = require('@gridscale/api').gridscale;
var client;
/**
* creates the client and fires sample requests
* @param _token string - the API Token
* @param _user_uuid string - the User-UUID to which the token belongs
*/
function createClient(_token, _user_uuid) {
client = new gridscale.Client(_token, _user_uuid);
listServers(["power=false"], "Stopped Servers:");
listServers(["power=true"], "Running Servers:");
listStorages("Storages:");
}
/**
* fetches the servers with given filters and outputs a list
* @param _filters string[] - optional filters for the request. field + operator + testValue
* @param _headline string - optional headline to display
*/
function listServers(_filters = [], _headline = "") {
client.Server.list({
page: 0,
limit : 10,
sort: "name",
fields: ["name","object_uuid","power"],
filter: _filters
}).then((_request) => {
// request was successful
output(_headline, 'bold');
for (var x in _request.result.servers) {
if (_request.result.servers.hasOwnProperty(x)) {
let _server = _request.result.servers[x];
output(_server.object_uuid + ": " + _server.name, _server.power ? 'green': 'red');
}
}
}).
catch((_error) => {
// handle the error
output("An error occured", 'bgRed');
if (_error.name == 'GridscaleError' && _error.result && _error.result.response) {
output(_error.message + ": " + _error.result.response.status + " - " + _error.result.response.statusText, 'red');
} else {
output("Unknown error " + _error.message);
}
});
}
/**
* fetches the servers with given filters and outputs a list
* @param _filters string[] - optional filters for the request. field + operator + testValue
* @param _headline string - optional headline to display
*/
function listStorages(_headline = "") {
client.Storage.list({
page: 0,
limit : 10,
sort: "name",
fields: ["name","object_uuid"]
}).then((_request) => {
// request was successful
output(_headline, 'bold');
for (var x in _request.result.storages) {
if (_request.result.storages.hasOwnProperty(x)) {
let _storage = _request.result.storages[x];
output(_storage.object_uuid + ": " + _storage.name, 'yellow');
}
}
}).
catch((_error) => {
// handle the error
output("An error occured", 'bgRed');
if (_error.name == 'GridscaleError' && _error.result && _error.result.response) {
output(_error.message + ": " + _error.result.response.status + " - " + _error.result.response.statusText, 'red');
} else {
output("Unknown error " + _error.message);
}
});
}
/**
* outputs text with colors in browser or in console for node
* @param txt string
* @param color string
*/
function output(txt = "", color = "white") {
if (typeof(document) !== 'undefined' && document.body) {
var div = document.createElement('div');
div.textContent = txt;
if (color.indexOf('bg') === 0) div.style.backgroundColor = color.substr(2).toLowerCase();
else if (['bold'].indexOf(color) >= 0) div.style.fontWeight = color;
else div.style.color = color;
document.body.appendChild(div);
} else {
console.log(colors[color](txt));
}
}
// ask for credentials
if (typeof(document) !== 'undefined' && document.body) {
// for browser ...
var intro = document.createElement('p');
intro.innerHTML = 'Welcome to the gridscale API client example! You will now be asked for an API-Token and an User-UUID. Please log in to the gridscale panel (<a href="https://my.gridscale.io" target="_blank">https://my.gridscale.io</a>) and navigate to the "API-Keys" section to generate one. Read access es enough. The User-UUID is also displayed here.';
intro.setAttribute('class', 'intro');
document.body.appendChild(intro);
var form = document.createElement('form');
var inputToken = document.createElement('input');
inputToken.setAttribute('name', 'token');
inputToken.setAttribute('placeholder', 'API-Token');
inputToken.setAttribute('required', true);
var inputUser = document.createElement('input');
inputUser.setAttribute('name', 'user');
inputUser.setAttribute('placeholder', 'User-UUID');
inputUser.setAttribute('required', true);
var button = document.createElement('input');
button.setAttribute('type', 'submit');
button.setAttribute('value', 'Start request');
form.appendChild(inputToken);
form.appendChild(inputUser);
form.appendChild(button);
document.body.appendChild(form);
form.onsubmit = function(e) {
e.preventDefault();
var p = document.createElement('p');
p.textContent = "Fetching server list";
document.body.appendChild(p);
createClient(inputToken.value.trim(), inputUser.value.trim());
}
} else {
// for node
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
output('Welcome to the gridscale API client example! You will now be asked for an API-Token and an User-UUID. Please log in to the gridscale panel (https://my.gridscale.io) and navigate to the "API-Keys" section to generate one. Read access es enough. The User-UUID is also displayed here."', 'cyan');
output();
readline.question('Please enter an API-Token: ', (_token) => {
readline.question('Please enter the User-UUID: ', (_uuid) => {
readline.close();
createClient(_token.trim(), _uuid.trim());
});
});
}
},{"@gridscale/api":2,"colors":28,"process":38,"readline":23}],2:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Export all publicly accessible modules
*/
var gridscale = require("./src/client");
exports.gridscale = gridscale;
},{"./src/client":22}],3:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var lodash_1 = require("lodash");
var Deleted = /** @class */ (function () {
/**
* Create Object Endpoint
*
*
* @param _api API Class Instance
* @param _path Path to the Object
*/
function Deleted(_api) {
this._api = _api;
this._defaults = {
"page": 0,
"limit": 25
};
}
/**
* Overwrite Default Settings for this Type
*
* @param _options
*/
Deleted.prototype.setDefaults = function (_options) {
lodash_1.assignIn(this._defaults, _options);
};
Deleted.prototype._buildRequestOptions = function (_options) {
// Clone Defaults
var defaults = lodash_1.assignIn({}, this._defaults);
// Add Options
if (!lodash_1.isUndefined(_options) && !lodash_1.isFunction(_options)) {
lodash_1.assignIn(defaults, _options);
}
// Return Default Values
return defaults;
};
Deleted.prototype._deleted = function (_key, _options, _callback) {
var requestOptions = this._buildRequestOptions(_options);
// Set Callback
if (lodash_1.isFunction(_options) && lodash_1.isUndefined(_callback)) {
_callback = _options;
}
return this._api.get('/objects/deleted/' + _key, _options, _callback);
};
Deleted.prototype.ips = function (_options, _callback) {
return this._deleted('ips', _options, _callback);
};
Deleted.prototype.isoimages = function (_options, _callback) {
return this._deleted('isoimages', _options, _callback);
};
Deleted.prototype.networks = function (_options, _callback) {
return this._deleted('networks', _options, _callback);
};
Deleted.prototype.servers = function (_options, _callback) {
return this._deleted('servers', _options, _callback);
};
Deleted.prototype.snapshots = function (_options, _callback) {
return this._deleted('snapshots', _options, _callback);
};
Deleted.prototype.storages = function (_options, _callback) {
return this._deleted('storages', _options, _callback);
};
Deleted.prototype.templates = function (_options, _callback) {
return this._deleted('templates', _options, _callback);
};
Deleted.prototype.paasServices = function (_options, _callback) {
return this._deleted('paas_services', _options, _callback);
};
return Deleted;
}());
exports.Deleted = Deleted;
},{"lodash":36}],4:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var GridscaleObjects_1 = require("./GridscaleObjects");
var Events = /** @class */ (function (_super) {
__extends(Events, _super);
function Events(_api) {
return _super.call(this, _api, '/objects/events') || this;
}
return Events;
}(GridscaleObjects_1.GridscaleObjects));
exports.Events = Events;
},{"./GridscaleObjects":6}],5:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var GridscaleObjects_1 = require("./GridscaleObjects");
var Firewall = /** @class */ (function (_super) {
__extends(Firewall, _super);
function Firewall(_api) {
return _super.call(this, _api, '/objects/firewalls') || this;
}
return Firewall;
}(GridscaleObjects_1.GridscaleObjects));
exports.Firewall = Firewall;
},{"./GridscaleObjects":6}],6:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var lodash_1 = require("lodash");
var GridscaleObjects = /** @class */ (function () {
/**
* Create Object Endpoint
*
* @param _api API Class Instance
* @param _path Path to the Object
*/
function GridscaleObjects(_api, _path) {
this._api = _api;
this._defaults = {
"page": 0,
"limit": 25
};
this._basepath = _path;
}
/**
* Overwrite Default Settings for this Type
*
* @param _options
*/
GridscaleObjects.prototype.setDefaults = function (_options) {
lodash_1.assignIn(this._defaults, _options);
};
/**
* Add Local Options with Defaults
*
*
* @param _options
* @returns {any}
* @private
*/
GridscaleObjects.prototype._buildRequestOptions = function (_options) {
// Clone Defaults
var defaults = lodash_1.assignIn({}, this._defaults);
// Add Options
if (!lodash_1.isUndefined(_options) && !lodash_1.isFunction(_options)) {
lodash_1.assignIn(defaults, _options);
}
// Return Default Values
return defaults;
};
/**
* List Objects
*
*
* @param _options
* @param _callback
* @returns {any}
*/
GridscaleObjects.prototype.list = function (_options, _callback) {
// Get Defaults
var requestOptions = this._buildRequestOptions(_options);
// Set Callback
if (lodash_1.isFunction(_options) && lodash_1.isUndefined(_callback)) {
_callback = _options;
}
var req = this._api.get(this._basepath, requestOptions, _callback);
return req;
};
/**
* Get Single Object by UUID
*
* @param _uuid
* @param _callback
*/
GridscaleObjects.prototype.get = function (_uuid, _callback) {
return this._api.get(this._basepath + '/' + _uuid, _callback);
};
/**
* Get Single Object by UUID
*
* @param _uuid
* @param _callback
*/
GridscaleObjects.prototype.remove = function (_uuid, _callback) {
return this._api.remove(this._basepath + '/' + _uuid, _callback);
};
/**
* Create object
* @param _attributes
* @param _callback
* @returns {any|TRequest|LineCollection}
*/
GridscaleObjects.prototype.create = function (_attributes, _callback) {
return this._api.post(this._basepath, _attributes, _callback);
};
/**
* Patch object
* @param _attributes
* @param _callback
* @returns {any|TRequest|LineCollection}
*/
GridscaleObjects.prototype.patch = function (_uuid, _attributes, _callback) {
return this._api.patch(this._basepath + '/' + _uuid, _attributes, _callback);
};
/**
* Wrapper for Subtypes to save some lines of code
*
* @param _uuid Object UUID
* @param _callback Callback Function
*/
GridscaleObjects.prototype._sub = function (_type, _uuid, _options, _callback) {
// Get Defaults
var requestOptions = this._buildRequestOptions(_options);
// Set Callback
if (lodash_1.isFunction(_options) && lodash_1.isUndefined(_callback)) {
_callback = _options;
}
return this._api.get(this._basepath + '/' + _uuid + '/' + _type, requestOptions, _callback);
};
/**
* Get Single Sub Object by UUID
*
* @param _type
* @param _uuid
* @param _sub_uuid
* @param _callback
* @private
*/
GridscaleObjects.prototype._sub_get = function (_type, _uuid, _sub_uuid, _callback) {
return this._api.get(this._basepath + '/' + _uuid + '/' + _type + '/' + _sub_uuid, _callback);
};
/**
* Post to Subtype ob Object
*
* @param _type
* @param _uuid
* @param _attributes
* @param _callback
* @returns {TRequest|any}
* @private
*/
GridscaleObjects.prototype._sub_post = function (_type, _uuid, _attributes, _callback) {
return this._api.post(this._basepath + '/' + _uuid + '/' + _type, _attributes, _callback);
};
/**
* Patch Subobject
*
* @param _type
* @param _uuid
* @param _sub_uuid
* @param _attributes
* @param _callback
* @returns {any|TRequest}
* @private
*/
GridscaleObjects.prototype._sub_patch = function (_type, _uuid, _sub_uuid, _attributes, _callback) {
return this._api.patch(this._basepath + '/' + _uuid + '/' + _type + '/' + _sub_uuid, _attributes, _callback);
};
/**
* Remove Sub Type from Object
*
*
* @param _type
* @param _uuid
* @param _sub_uuid
* @param _callback
* @returns {any|void|PromiseLike<void>}
* @private
*/
GridscaleObjects.prototype._sub_remove = function (_type, _uuid, _sub_uuid, _callback) {
return this._api.remove(this._basepath + '/' + _uuid + '/' + _type + '/' + _sub_uuid, _callback);
};
/**
* Get Events for this Object
*
* @param _uuid Object UUID
* @param _callback Callback Function
*/
GridscaleObjects.prototype.events = function (_uuid, _options, _callback) {
return this._sub('events', _uuid, _options, _callback);
};
return GridscaleObjects;
}());
exports.GridscaleObjects = GridscaleObjects;
},{"lodash":36}],7:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var GridscaleObjects_1 = require("./GridscaleObjects");
var IP = /** @class */ (function (_super) {
__extends(IP, _super);
function IP(_api) {
return _super.call(this, _api, '/objects/ips') || this;
}
/**
* List Objects
*
*
* @param _options
* @param _callback
* @returns {any}
*/
IP.prototype.list = function (_callback) {
return this._api.get(this._basepath, _callback);
};
return IP;
}(GridscaleObjects_1.GridscaleObjects));
exports.IP = IP;
},{"./GridscaleObjects":6}],8:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var GridscaleObjects_1 = require("./GridscaleObjects");
var ISOImage = /** @class */ (function (_super) {
__extends(ISOImage, _super);
function ISOImage(_api) {
return _super.call(this, _api, '/objects/isoimages') || this;
}
return ISOImage;
}(GridscaleObjects_1.GridscaleObjects));
exports.ISOImage = ISOImage;
},{"./GridscaleObjects":6}],9:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var GridscaleObjects_1 = require("./GridscaleObjects");
var Label = /** @class */ (function (_super) {
__extends(Label, _super);
function Label(_api) {
return _super.call(this, _api, '/objects/labels') || this;
}
return Label;
}(GridscaleObjects_1.GridscaleObjects));
exports.Label = Label;
},{"./GridscaleObjects":6}],10:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var GridscaleObjects_1 = require("./GridscaleObjects");
var Loadbalancer = /** @class */ (function (_super) {
__extends(Loadbalancer, _super);
function Loadbalancer(_api) {
return _super.call(this, _api, '/objects/loadbalancers') || this;
}
return Loadbalancer;
}(GridscaleObjects_1.GridscaleObjects));
exports.Loadbalancer = Loadbalancer;
},{"./GridscaleObjects":6}],11:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var lodash_1 = require("lodash");
var Location = /** @class */ (function () {
/**
* Create Object Endpoint
*
*
* @param _api API Class Instance
* @param _path Path to the Object
*/
function Location(_api) {
this._api = _api;
this._defaults = {
"page": 0,
"limit": 25
};
this._basepath = '/objects/locations';
}
/**
* Overwrite Default Settings for this Type
*
* @param _options
*/
Location.prototype.setDefaults = function (_options) {
lodash_1.assignIn(this._defaults, _options);
};
/**
* Add Local Options with Defaults
*
*
* @param _options
* @returns {any}
* @private
*/
Location.prototype._buildRequestOptions = function (_options) {
// Clone Defaults
var defaults = lodash_1.assignIn({}, this._defaults);
// Add Options
if (!lodash_1.isUndefined(_options) && !lodash_1.isFunction(_options)) {
lodash_1.assignIn(defaults, _options);
}
// Return Default Values
return defaults;
};
/**
* List Objects
*
*
* @param _options
* @param _callback
* @returns {any}
*/
Location.prototype.list = function (_options, _callback) {
// Get Defaults
var requestOptions = this._buildRequestOptions(_options);
// Set Callback
if (lodash_1.isFunction(_options) && lodash_1.isUndefined(_callback)) {
_callback = _options;
}
var req = this._api.get(this._basepath, requestOptions, _callback);
return req;
};
/**
* Get Single Object by UUID
*
* @param _uuid
* @param _callback
*/
Location.prototype.get = function (_uuid, _callback) {
return this._api.get(this._basepath + '/' + _uuid, _callback);
};
/**
Return all IP Adresses for this locations
*/
Location.prototype.getLocationIPs = function (_uuid, _callback) {
return this._api.get(this._basepath + '/' + _uuid + '/ips', _callback);
};
/**
Return all isoimages for this location
*/
Location.prototype.getLocationISOImages = function (_uuid, _callback) {
return this._api.get(this._basepath + '/' + _uuid + '/isoimages', _callback);
};
/**
Return all networks for this location
*/
Location.prototype.getLocationNetworks = function (_uuid, _callback) {
return this._api.get(this._basepath + '/' + _uuid + '/networks', _callback);
};
/**
Return all servers for this location
*/
Location.prototype.getLocationServers = function (_uuid, _callback) {
return this._api.get(this._basepath + '/' + _uuid + '/servers', _callback);
};
/**
Return all snapshots for this location
*/
Location.prototype.getLocationSnapshots = function (_uuid, _callback) {
return this._api.get(this._basepath + '/' + _uuid + '/snapshots', _callback);
};
/**
Return all storages for this location
*/
Location.prototype.getLocationStorages = function (_uuid, _callback) {
return this._api.get(this._basepath + '/' + _uuid + '/storages', _callback);
};
/**
Return all storages for this location
*/
Location.prototype.getLocationTemplates = function (_uuid, _callback) {
return this._api.get(this._basepath + '/' + _uuid + '/templates', _callback);
};
return Location;
}());
exports.Location = Location;
},{"lodash":36}],12:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var GridscaleObjects_1 = require("./GridscaleObjects");
var Marketplace = /** @class */ (function (_super) {
__extends(Marketplace, _super);
function Marketplace(_api) {
return _super.call(this, _api, '/objects/marketplace/templates') || this;
}
return Marketplace;
}(GridscaleObjects_1.GridscaleObjects));
exports.Marketplace = Marketplace;
},{"./GridscaleObjects":6}],13:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var GridscaleObjects_1 = require("./GridscaleObjects");
var Network = /** @class */ (function (_super) {
__extends(Network, _super);
function Network(_api) {
return _super.call(this, _api, '/objects/networks') || this;
}
return Network;
}(GridscaleObjects_1.GridscaleObjects));
exports.Network = Network;
},{"./GridscaleObjects":6}],14:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ObjectStorage = /** @class */ (function () {
/**
* Create Object Endpoint
*
*
* @param _api API Class Instance
* @param _path Path to the Object
*/
function ObjectStorage(_api) {
this._api = _api;
}
/**
* List Access Keys
*
*
* @param _options
* @param _callback
* @returns {any}
*/
ObjectStorage.prototype.accessKeys = function (_callback) {
return this._api.get('/objects/objectstorages/access_keys', _callback);
};
/**
* Get Single Object by UUID
*
* @param _uuid
* @param _callback
*/
ObjectStorage.prototype.accessKey = function (_access_key, _callback) {
return this._api.get('/objects/objectstorages/access_keys/' + _access_key, _callback);
};
/**
* Remove Access Key
*
* @param _uuid
* @param _callback
*/
ObjectStorage.prototype.removeAccessKey = function (_access_key, _callback) {
return this._api.remove('/objects/objectstorages/access_keys/' + _access_key, _callback);
};
/**
* Creates new Access Key
*
* @param _callback
* @returns {any|TRequest|LineCollection}
*/
ObjectStorage.prototype.createAccessKey = function (_callback) {
return this._api.post('/objects/objectstorages/access_keys', _callback);
};
/**
* List Access Keys
*
*
* @param _options
* @param _callback
* @returns {any}
*/
ObjectStorage.prototype.buckets = function (_callback) {
return this._api.get('/objects/objectstorages/buckets', _callback);
};
/**
* Get Single Object by UUID
*
* @param _uuid
* @param _callback
*/
ObjectStorage.prototype.bucket = function (_bucket_name, _callback) {
return this._api.get('/objects/objectstorages/buckets/' + _bucket_name, _callback);
};
return ObjectStorage;
}());
exports.ObjectStorage = ObjectStorage;
},{}],15:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var PAAS = /** @class */ (function () {
/**
* Create Object Endpoint
*
*
* @param _api API Class Instance
* @param _path Path to the Object
*/
function PAAS(_api) {
var _this = this;
this.serviceTemplates = {
list: function (_options, _callback) {
if (_options === void 0) { _options = {}; }
return _this._api.get('/objects/paas/service_templates', _options, _callback);
},
get: function (_uuid, _callback) {
return _this._api.get('/objects/paas/service_templates/' + _uuid, _callback);
}
};
this.securityZones = {
list: function (_options, _callback) {
if (_options === void 0) { _options = {}; }
return _this._api.get('/objects/paas/security_zones', _options, _callback);
},
get: function (_uuid, _callback) {
return _this._api.get('/objects/paas/security_zones/' + _uuid, _callback);
},
events: function (_uuid, _callback) {
return _this._api.get('/objects/paas/security_zones/' + _uuid + '/events', _callback);
},
remove: function (_uuid, _callback) {
return _this._api.remove('/objects/paas/security_zones/' + _uuid, _callback);
},
create: function (_data, _callback) {
return _this._api.post('/objects/paas/security_zones', _data, _callback);
},
patch: function (_uuid, _attributes, _callback) {
return _this._api.patch('/objects/paas/security_zones/' + _uuid, _attributes, _callback);
},
};
this.services = {
list: function (_options, _callback) {
if (_options === void 0) { _options = {}; }
return _this._api.get('/objects/paas/services', _options, _callback);
},
get: function (_uuid, _callback) {
return _this._api.get('/objects/paas/services/' + _uuid, _callback);
},
listMetrics: function (_uuid, _callback) {
return _this._api.get('/objects/paas/services/' + _uuid + '/metrics', _callback);
},
remove: function (_uuid, _callback) {
return _this._api.remove('/objects/paas/services/' + _uuid, _callback);
},
create: function (_data, _callback) {
return _this._api.post('/objects/paas/services', _data, _callback);
},
patch: function (_uuid, _attributes, _callback) {
return _this._api.patch('/objects/paas/services/' + _uuid, _attributes, _callback);
},
events: function (_uuid, _callback) {
return _this._api.get('/objects/paas/services/' + _uuid + '/events', _callback);
},
};
this._api = _api;
}
return PAAS;
}());
exports.PAAS = PAAS;
},{}],16:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var GridscaleObjects_1 = require("./GridscaleObjects");
var Price = /** @class */ (function (_super) {
__extends(Price, _super);
function Price(_api) {
return _super.call(this, _api, '/prices') || this;
}
/**
* List Objects
*
*
* @param _options
* @param _callback
* @returns {any}
*/
Price.prototype.list = function (_callback) {
return this._api.get(this._basepath, _callback);
};
return Price;
}(GridscaleObjects_1.GridscaleObjects));
exports.Price = Price;
},{"./GridscaleObjects":6}],17:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var GridscaleObjects_1 = require("./GridscaleObjects");
var SSHKey = /** @class */ (function (_super) {
__extends(SSHKey, _super);
function SSHKey(_api) {
return _super.call(this, _api, '/objects/sshkeys') || this;
}
return SSHKey;
}(GridscaleObjects_1.GridscaleObjects));
exports.SSHKey = SSHKey;
},{"./GridscaleObjects":6}],18:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var GridscaleObjects_1 = require("./GridscaleObjects");
var Server = /** @class */ (function (_super) {
__extends(Server, _super);
function Server(_api) {
return _super.call(this, _api, '/objects/servers') || this;
}
/**
* Start/Stop Server
*
* @param _uuid
* @param _power
* @param _callback
* @returns {any|TRequest}
*/
Server.prototype.power = function (_uuid, _power, _callback) {
return this._api.patch(this._basepath + '/' + _uuid + '/power', { power: _power }, _callback);
};
/**
* Send ACPI-Shutdown to User
*
* @param _uuid
* @param _callback
* @returns {any|TRequest}
*/
Server.prototype.shutdown = function (_uuid, _callback) {
return this._api.patch(this._basepath + '/' + _uuid + '/shutdown', {}, _callback);
};
/**
* IP Adress Handling
*
*/
/**
* Get IPs for this Object
*
* @param _uuid Object UUID
* @param _callback Callback Function
*/
Server.prototype.ips = function (_uuid, _options, _callback) {
return this._sub('ips', _uuid, _options, _callback);
};
/**
* Get IP that is in Relation with Server
*
* @param _uuid
* @param _ip_uuid
* @param _callback
* @returns {any}
*/
Server.prototype.ip = function (_uuid, _ip_uuid, _callback) {
return this._sub_get('ips', _uuid, _ip_uuid, _callback);
};
/**
* Relate an IP with the Server
*
* @param _uuid Server UUID
* @param _ip_uuid IP UUID
* @param _callback Callback Function
* @returns {TRequest|any}
*/
Server.prototype.addIp = function (_uuid, _ip_uuid, _callback) {
return this._sub_post('ips', _uuid, { "object_uuid": _ip_uuid }, _callback);
};
/**
* Remove IP-Adress from Server
*
*
* @param _uuid Server UUID
* @param _ip_uuid IP UUID
* @param _callback
* @returns {any|void|PromiseLike<void>}
*/
Server.prototype.removeIp = function (_uuid, _ip_uuid, _callback) {
return this._sub_remove('ips', _uuid, _ip_uuid, _callback);
};
/**
* Storages
*
*/
/**
* Get Storages for this Object
*
* @param _uuid Object UUID
* @param _callback Callback Function
*/
Server.prototype.storages = function (_uuid, _options, _callback) {
return this._sub('storages', _uuid, _options, _callback);
};
/**
* Get Metrics for this Object
*
* @param _uuid Object UUID
* @param _callback Callback Function
*/
Server.prototype.metrics = function (_uuid, _options, _callback) {
return this._sub('metrics', _uuid, _options, _callback);
};
/**
* Get single Storage <=> Server Relation
*
* @param _uuid
* @param _storage_uuid
* @param _callback
* @returns {any}
*/
Server.prototype.storage = function (_uuid, _storage_uuid, _callback) {
return this._sub_get('storages', _uuid, _storage_uuid, _callback);
};
/**
* Patch Storage that is related to a Server i flag it as Bootdevice
*
*
* @param _uuid
* @param _storage_uuid
* @param _attribute
* @param _callback
* @returns {any|TRequest}
*/
Server.prototype.patchStorage = function (_uuid, _storage_uuid, _attribute, _callback) {
return this._sub_patch('storages', _uuid, _storage_uuid, _attribute, _callback);
};
/**
* Relate Storage with Server
*
* @param _uuid Server UUID
* @param _storage_uuid IP UUID
* @param _callback Callback Function
* @returns {TRequest|any}
*/
Server.prototype.addStorage = function (_uuid, _storage_uuid, _callback) {
return this._sub_post('storages', _uuid, { "object_uuid": _storage_uuid }, _callback);
};
/**
* Remove Storage from Server
*
*
* @param _uuid Server UUID
* @param _storage_uuid IP UUID
* @param _callback
* @returns {any|void|PromiseLike<void>}
*/
Server.prototype.removeStorage = function (_uuid, _storage_uuid, _callback) {
return this._sub_remove('storages', _uuid, _storage_uuid, _callback);
};
/**
* Isoimages
*
*/
/**
* Get Storages for this Object
*
* @param _uuid Object UUID
* @param _callback Callback Function
*/
Server.prototype.isoimages = function (_uuid, _options, _callback) {
return this._sub('isoimages', _uuid, _options, _callback);
};
/**
* Get single Storage <=> Server Relation
*
* @param _uuid
* @param _isoimage_uuid
* @param _callback
* @returns {any}
*/
Server.prototype.isoimage = function (_uuid, _isoimage_uuid, _callback) {
return this._sub_get('isoimages', _uuid, _isoimage_uuid, _callback);
};
/**
* Patch Storage that is related to a Server i flag it as Bootdevice
*
*
* @param _uuid
* @param _isoimage_uuid
* @param _attribute
* @param _callback
* @returns {any|TRequest}
*/
Server.prototype.patchIsoimage = function (_uuid, _isoimage_uuid, _attribute, _callback) {
return this._sub_patch('isoimages', _uuid, _isoimage_uuid, _attribute, _callback);
};
/**
* Relate Storage with Server
*
* @param _uuid Server UUID
* @param _isoimage_uuid IP UUID
* @param _callback Callback Function
* @returns {TRequest|any}
*/
Server.prototype.addIsoimage = function (_uuid, _isoimage_uuid, _callback) {
return this._sub_post('isoimages', _uuid, { "object_uuid": _isoimage_uuid }, _callback);
};
/**
* Remove Isoimage from Server
*
*
* @param _uuid Server UUID
* @param _isoimage_uuid IP UUID
* @param _callback
* @returns {any|void|PromiseLike<void>}
*/
Server.prototype.removeIsoimage = function (_uuid, _isoimage_uuid, _callback) {
return this._sub_remove('isoimages', _uuid, _isoimage_uuid, _callback);
};
/**
* Networks
*
*/
/**
* Get NEtworks for this Object
*
* @param _uuid Server UUID
* @param _callback Callback Function
*/
Server.prototype.networks = function (_uuid, _options, _callback) {
return this._sub('networks', _uuid, _options, _callback);
};
/**
* Get single NEtwork <=> Server Relation
*
* @param _uuid
* @param _network_uuid Network UUID
* @param _callback
* @returns {any}
*/
Server.prototype.network = function (_uuid, _network_uuid, _callback) {
return this._sub_get('networks', _uuid, _network_uuid, _callback);
};
/**
* Patch Network that is related to a Server
*
* Attributes:
* bootdevice
* l3security
* ordering
*
*
* @param _uuid
* @param _network_uuid Network UUID
* @param _attribute
* @param _callback
* @returns {any|TRequest}
*/
Server.prototype.patchNetwork = function (_uuid, _network_uuid, _attribute, _callback) {
return this._sub_patch('networks', _uuid, _network_uuid, _attribute, _callback);
};
/**
* Relate Storage with Server
*
* @param _uuid Server UUID
* @param _network_uuid Network UUID
* @param _callback Callback Function
* @returns {TRequest|any}
*/
Server.prototype.addNetwork = function (_uuid, _network_uuid, _callback) {
return this._sub_post('networks', _uuid, { "object_uuid": _network_uuid }, _callback);
};
/**
* Remove Storage from Server
*
*
* @param _uuid Server UUID
* @param _network_uuid Network UUID
* @param _callback
* @returns {any|void|PromiseLike<void>}
*/
Server.prototype.removeNetwork = function (_uuid, _network_uuid, _callback) {
return this._sub_remove('networks', _uuid, _network_uuid, _callback);
};
return Server;
}(GridscaleObjects_1.GridscaleObjects));
exports.Server = Server;
},{"./GridscaleObjects":6}],19:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var GridscaleObjects_1 = require("./GridscaleObjects");
var Storage = /** @class */ (function (_super) {
__extends(Storage, _super);
function Storage(_api) {
return _super.call(this, _api, '/objects/storages') || this;
}
/**
* Snapshots
*
*/
/**
* Get Storages for this Object
*
* @param _uuid Object UUID
* @param _callback Callback Function
*/
Storage.prototype.snapshots = function (_uuid, _options, _callback) {
return this._sub('snapshots', _uuid, _options, _callback);
};
/**
* Get Single Snapshot
*
* @param _uuid
* @param _snapshot_uuid
* @param _callback
* @returns {any}
*/
Storage.prototype.snapshot = function (_uuid, _snapshot_uuid, _callback) {
return this._sub_get('snapshots', _uuid, _snapshot_uuid, _callback);
};
/**
* Patch Snapshot
*
* Attribures
* name
* labels
*
*
* @param _uuid
* @param _storage_uuid
* @param _attribute
* @param _callback
* @returns {any|TRequest}
*/
Storage.prototype.patchSnapshot = function (_uuid, _snapshot_uuid, _attribute, _callback) {
return this._sub_patch('snapshots', _uuid, _snapshot_uuid, _attribute, _callback);
};
/**
* Rollback Storage to this Snapshot
*
* Attribures
* name
* labels
*
* @param _uuid
* @param _storage_uuid
* @param _callback
* @returns {any|TRequest}
*/
Storage.prototype.rollbackSnapshot = function (_uuid, _snapshot_uuid, _callback) {
return this._api.patch('/objects/storages/' + _uuid + '/snapshots/' + _snapshot_uuid + '/rollback', { rollback: true }, _callback);
};
/**
* Rollback Storage to this Snapshot
*
* Attribures
* - name
* - labels
*
* @param _uuid
* @param _storage_uuid
* @param _callback
* @returns {any|TRequest}
*/
Storage.prototype.exportSnapshot = function (_uuid, _snapshot_uuid, _data, _callback) {
return this._api.patch('/objects/storages/' + _uuid + '/snapshots/' + _snapshot_uuid + '/export_to_s3', _data, _callback);
};
/**
* Create a Snapshot of this Storage
*
* @param _uuid
* @param _attribute
* @param _callback
* @returns {TRequest|any}
*/
Storage.prototype.createSnapshot = function (_uuid, _attribute, _callback) {
return this._sub_post('snapshots', _uuid, _attribute, _callback);
};
/**
* Remove Snapshot
*
*
* @param _uuid Server UUID
* @param _snapshot_uuid IP UUID
* @param _callback
* @returns {any|void|PromiseLike<void>}
*/
Storage.prototype.removeSnapshot = function (_uuid, _snapshot_uuid, _callback) {
return this._sub_remove('snapshots', _uuid, _snapshot_uuid, _callback);
};
/**
* Snapshots Scheduler
*
*/
/**
* Get Snapshot Schedler for this Storage
*
* @param _uuid Object UUID
* @param _callback Callback Function
*/
Storage.prototype.snapshotSchedulers = function (_uuid, _options, _callback) {
return this._sub('snapshot_schedules', _uuid, _options, _callback);
};
/**
* Get Single Snapshot Schedler
*
* @param _uuid
* @param _snapshot_scheduler_uuid
* @param _callback
* @returns {any}
*/
Storage.prototype.snapshotScheduler = function (_uuid, _snapshot_scheduler_uuid, _callback) {
return this._sub_get('snapshot_schedules', _uuid, _snapshot_scheduler_uuid, _callback);
};
/**
* Patch Snapshot Schedler
*
*
* @param _uuid
* @param _snapshot_scheduler_uuid
* @param _attribute
* @param _callback
* @returns {any|TRequest}
*/
Storage.prototype.patchSnapshotScheduler = function (_uuid, _snapshot_scheduler_uuid, _attribute, _callback) {
return this._sub_patch('snapshot_schedules', _uuid, _snapshot_scheduler_uuid, _attribute, _callback);
};
/**
* Create a Snapshot Schedler for this Storage
*
* @param _uuid
* @param _attribute
* @param _callback
* @returns {TRequest|any}
*/
Storage.prototype.createSnapshotScheduler = function (_uuid, _attribute, _callback) {
return this._sub_post('snapshot_schedules', _uuid, _attribute, _callback);
};
/**
* Remove Snapshot Schedler
*
*
* @param _uuid Server UUID
* @param _snapshot_scheduler_uuid IP UUID
* @param _callback
* @returns {any|void|PromiseLike<void>}
*/
Storage.prototype.removeSnapshotScheduler = function (_uuid, _snapshot_scheduler_uuid, _callback) {
return this._sub_remove('snapshot_schedules', _uuid, _snapshot_scheduler_uuid, _callback);
};
return Storage;
}(GridscaleObjects_1.GridscaleObjects));
exports.Storage = Storage;
},{"./GridscaleObjects":6}],20:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var GridscaleObjects_1 = require("./GridscaleObjects");
var Template = /** @class */ (function (_super) {
__extends(Template, _super);
function Template(_api) {
return _super.call(this, _api, '/objects/templates') || this;
}
return Template;
}(GridscaleObjects_1.GridscaleObjects));
exports.Template = Template;
},{"./GridscaleObjects":6}],21:[function(require,module,exports){
"use strict";
var __extends = (t