@devopness/sdk-js
Version:
Devopness API JS/TS SDK - Painless essential DevOps to everyone
255 lines (254 loc) • 12.4 kB
JavaScript
/* eslint-disable */
/**
* devopness API
* Devopness API - Painless essential DevOps to everyone
*
* The version of the OpenAPI document: latest
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServersApiService = void 0;
const ApiBaseService_1 = require("../../../services/ApiBaseService");
const ApiResponse_1 = require("../../../common/ApiResponse");
const Exceptions_1 = require("../../../common/Exceptions");
/**
* ServersApiService - Auto-generated
*/
class ServersApiService extends ApiBaseService_1.ApiBaseService {
/**
*
* @summary Creates a server and link it to the given environment
* @param {number} environmentId The ID of the environment.
* @param {ServerEnvironmentCreate} serverEnvironmentCreate A JSON object containing the resource data
*/
addEnvironmentServer(environmentId, serverEnvironmentCreate) {
return __awaiter(this, void 0, void 0, function* () {
if (environmentId === null || environmentId === undefined) {
throw new Exceptions_1.ArgumentNullException('environmentId', 'addEnvironmentServer');
}
if (serverEnvironmentCreate === null || serverEnvironmentCreate === undefined) {
throw new Exceptions_1.ArgumentNullException('serverEnvironmentCreate', 'addEnvironmentServer');
}
let queryString = '';
const requestUrl = '/environments/{environment_id}/servers' + (queryString ? `?${queryString}` : '');
const response = yield this.post(requestUrl.replace(`{${"environment_id"}}`, encodeURIComponent(String(environmentId))), serverEnvironmentCreate);
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Connect a server to devopness platform
* @param {string} activationToken The server activation token.
* @param {number} serverId The ID of the server.
*/
connectServer(activationToken, serverId) {
return __awaiter(this, void 0, void 0, function* () {
if (activationToken === null || activationToken === undefined) {
throw new Exceptions_1.ArgumentNullException('activationToken', 'connectServer');
}
if (serverId === null || serverId === undefined) {
throw new Exceptions_1.ArgumentNullException('serverId', 'connectServer');
}
let queryString = '';
const requestUrl = '/servers/{server_id}/connect/{activation_token}' + (queryString ? `?${queryString}` : '');
const response = yield this.post(requestUrl.replace(`{${"activation_token"}}`, encodeURIComponent(String(activationToken))).replace(`{${"server_id"}}`, encodeURIComponent(String(serverId))));
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Delete a given server
* @param {number} serverId The ID of the server.
* @param {boolean} [destroyServerDisks] Indicates whether disks associated with a cloud server should be deleted after the server is destroyed
*/
deleteServer(serverId, destroyServerDisks) {
return __awaiter(this, void 0, void 0, function* () {
if (serverId === null || serverId === undefined) {
throw new Exceptions_1.ArgumentNullException('serverId', 'deleteServer');
}
let queryString = '';
const queryParams = { destroy_server_disks: destroyServerDisks, };
for (const key in queryParams) {
if (queryParams[key] === undefined || queryParams[key] === null) {
continue;
}
queryString += (queryString ? '&' : '') + `${key}=${encodeURI(queryParams[key])}`;
}
const requestUrl = '/servers/{server_id}' + (queryString ? `?${queryString}` : '');
const response = yield this.delete(requestUrl.replace(`{${"server_id"}}`, encodeURIComponent(String(serverId))));
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Get a server by ID
* @param {number} serverId The ID of the server.
*/
getServer(serverId) {
return __awaiter(this, void 0, void 0, function* () {
if (serverId === null || serverId === undefined) {
throw new Exceptions_1.ArgumentNullException('serverId', 'getServer');
}
let queryString = '';
const requestUrl = '/servers/{server_id}' + (queryString ? `?${queryString}` : '');
const response = yield this.get(requestUrl.replace(`{${"server_id"}}`, encodeURIComponent(String(serverId))));
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Get commands to be executed on the given server
* @param {number} serverId The ID of the server.
*/
getServerCommands(serverId) {
return __awaiter(this, void 0, void 0, function* () {
if (serverId === null || serverId === undefined) {
throw new Exceptions_1.ArgumentNullException('serverId', 'getServerCommands');
}
let queryString = '';
const requestUrl = '/servers/{server_id}/commands' + (queryString ? `?${queryString}` : '');
const response = yield this.get(requestUrl.replace(`{${"server_id"}}`, encodeURIComponent(String(serverId))));
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Get current status of the server on the cloud provider
* @param {number} serverId The ID of the server.
*/
getStatusServer(serverId) {
return __awaiter(this, void 0, void 0, function* () {
if (serverId === null || serverId === undefined) {
throw new Exceptions_1.ArgumentNullException('serverId', 'getStatusServer');
}
let queryString = '';
const requestUrl = '/servers/{server_id}/get-status' + (queryString ? `?${queryString}` : '');
const response = yield this.post(requestUrl.replace(`{${"server_id"}}`, encodeURIComponent(String(serverId))));
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Return a list of all servers belonging to an environment
* @param {number} environmentId The ID of the environment.
* @param {number} [page] Number of the page to be retrieved
* @param {number} [perPage] Number of items returned per page
*/
listEnvironmentServers(environmentId, page, perPage) {
return __awaiter(this, void 0, void 0, function* () {
if (environmentId === null || environmentId === undefined) {
throw new Exceptions_1.ArgumentNullException('environmentId', 'listEnvironmentServers');
}
let queryString = '';
const queryParams = { page: page, per_page: perPage, };
for (const key in queryParams) {
if (queryParams[key] === undefined || queryParams[key] === null) {
continue;
}
queryString += (queryString ? '&' : '') + `${key}=${encodeURI(queryParams[key])}`;
}
const requestUrl = '/environments/{environment_id}/servers' + (queryString ? `?${queryString}` : '');
const response = yield this.get(requestUrl.replace(`{${"environment_id"}}`, encodeURIComponent(String(environmentId))));
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Restart a current running server
* @param {number} serverId The ID of the server.
*/
restartServer(serverId) {
return __awaiter(this, void 0, void 0, function* () {
if (serverId === null || serverId === undefined) {
throw new Exceptions_1.ArgumentNullException('serverId', 'restartServer');
}
let queryString = '';
const requestUrl = '/servers/{server_id}/restart' + (queryString ? `?${queryString}` : '');
const response = yield this.post(requestUrl.replace(`{${"server_id"}}`, encodeURIComponent(String(serverId))));
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Rotate the key used to access the server
* @param {number} serverId The ID of the server.
*/
rotateKeyServer(serverId) {
return __awaiter(this, void 0, void 0, function* () {
if (serverId === null || serverId === undefined) {
throw new Exceptions_1.ArgumentNullException('serverId', 'rotateKeyServer');
}
let queryString = '';
const requestUrl = '/servers/{server_id}/rotate-key' + (queryString ? `?${queryString}` : '');
const response = yield this.post(requestUrl.replace(`{${"server_id"}}`, encodeURIComponent(String(serverId))));
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Start a previously stopped server
* @param {number} serverId The ID of the server.
*/
startServer(serverId) {
return __awaiter(this, void 0, void 0, function* () {
if (serverId === null || serverId === undefined) {
throw new Exceptions_1.ArgumentNullException('serverId', 'startServer');
}
let queryString = '';
const requestUrl = '/servers/{server_id}/start' + (queryString ? `?${queryString}` : '');
const response = yield this.post(requestUrl.replace(`{${"server_id"}}`, encodeURIComponent(String(serverId))));
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Stop a running server
* @param {number} serverId The ID of the server.
*/
stopServer(serverId) {
return __awaiter(this, void 0, void 0, function* () {
if (serverId === null || serverId === undefined) {
throw new Exceptions_1.ArgumentNullException('serverId', 'stopServer');
}
let queryString = '';
const requestUrl = '/servers/{server_id}/stop' + (queryString ? `?${queryString}` : '');
const response = yield this.post(requestUrl.replace(`{${"server_id"}}`, encodeURIComponent(String(serverId))));
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Update an existing server
* @param {number} serverId The ID of the server.
* @param {ServerUpdate} serverUpdate A JSON object containing the resource data
*/
updateServer(serverId, serverUpdate) {
return __awaiter(this, void 0, void 0, function* () {
if (serverId === null || serverId === undefined) {
throw new Exceptions_1.ArgumentNullException('serverId', 'updateServer');
}
if (serverUpdate === null || serverUpdate === undefined) {
throw new Exceptions_1.ArgumentNullException('serverUpdate', 'updateServer');
}
let queryString = '';
const requestUrl = '/servers/{server_id}' + (queryString ? `?${queryString}` : '');
const response = yield this.put(requestUrl.replace(`{${"server_id"}}`, encodeURIComponent(String(serverId))), serverUpdate);
return new ApiResponse_1.ApiResponse(response);
});
}
}
exports.ServersApiService = ServersApiService;
;