@devopness/sdk-js
Version:
Devopness API JS/TS SDK - Painless essential DevOps to everyone
231 lines (230 loc) • 11.6 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.ServicesApiService = void 0;
const ApiBaseService_1 = require("../../../services/ApiBaseService");
const ApiResponse_1 = require("../../../common/ApiResponse");
const Exceptions_1 = require("../../../common/Exceptions");
/**
* ServicesApiService - Auto-generated
*/
class ServicesApiService extends ApiBaseService_1.ApiBaseService {
/**
*
* @summary Add a Service to the given environment
* @param {number} environmentId The ID of the environment.
* @param {ServiceEnvironmentCreate} serviceEnvironmentCreate A JSON object containing the resource data
*/
addEnvironmentService(environmentId, serviceEnvironmentCreate) {
return __awaiter(this, void 0, void 0, function* () {
if (environmentId === null || environmentId === undefined) {
throw new Exceptions_1.ArgumentNullException('environmentId', 'addEnvironmentService');
}
if (serviceEnvironmentCreate === null || serviceEnvironmentCreate === undefined) {
throw new Exceptions_1.ArgumentNullException('serviceEnvironmentCreate', 'addEnvironmentService');
}
let queryString = '';
const requestUrl = '/environments/{environment_id}/services' + (queryString ? `?${queryString}` : '');
const response = yield this.post(requestUrl.replace(`{${"environment_id"}}`, encodeURIComponent(String(environmentId))), serviceEnvironmentCreate);
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Delete a given service
* @param {number} serviceId The ID of the service.
*/
deleteService(serviceId) {
return __awaiter(this, void 0, void 0, function* () {
if (serviceId === null || serviceId === undefined) {
throw new Exceptions_1.ArgumentNullException('serviceId', 'deleteService');
}
let queryString = '';
const requestUrl = '/services/{service_id}' + (queryString ? `?${queryString}` : '');
const response = yield this.delete(requestUrl.replace(`{${"service_id"}}`, encodeURIComponent(String(serviceId))));
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Get details of a single service
* @param {number} serviceId The ID of the service.
*/
getService(serviceId) {
return __awaiter(this, void 0, void 0, function* () {
if (serviceId === null || serviceId === undefined) {
throw new Exceptions_1.ArgumentNullException('serviceId', 'getService');
}
let queryString = '';
const requestUrl = '/services/{service_id}' + (queryString ? `?${queryString}` : '');
const response = yield this.get(requestUrl.replace(`{${"service_id"}}`, encodeURIComponent(String(serviceId))));
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Get current status of a service
* @param {number} serviceId The ID of the service.
* @param {ServiceGetStatus} serviceGetStatus A JSON object containing the resource data
*/
getStatusService(serviceId, serviceGetStatus) {
return __awaiter(this, void 0, void 0, function* () {
if (serviceId === null || serviceId === undefined) {
throw new Exceptions_1.ArgumentNullException('serviceId', 'getStatusService');
}
if (serviceGetStatus === null || serviceGetStatus === undefined) {
throw new Exceptions_1.ArgumentNullException('serviceGetStatus', 'getStatusService');
}
let queryString = '';
const requestUrl = '/services/{service_id}/get-status' + (queryString ? `?${queryString}` : '');
const response = yield this.post(requestUrl.replace(`{${"service_id"}}`, encodeURIComponent(String(serviceId))), serviceGetStatus);
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Return a list of all services belonging to a 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
*/
listEnvironmentServices(environmentId, page, perPage) {
return __awaiter(this, void 0, void 0, function* () {
if (environmentId === null || environmentId === undefined) {
throw new Exceptions_1.ArgumentNullException('environmentId', 'listEnvironmentServices');
}
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}/services' + (queryString ? `?${queryString}` : '');
const response = yield this.get(requestUrl.replace(`{${"environment_id"}}`, encodeURIComponent(String(environmentId))));
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Reload a service
* @param {number} serviceId The ID of the service.
* @param {ServiceReload} serviceReload A JSON object containing the resource data
*/
reloadService(serviceId, serviceReload) {
return __awaiter(this, void 0, void 0, function* () {
if (serviceId === null || serviceId === undefined) {
throw new Exceptions_1.ArgumentNullException('serviceId', 'reloadService');
}
if (serviceReload === null || serviceReload === undefined) {
throw new Exceptions_1.ArgumentNullException('serviceReload', 'reloadService');
}
let queryString = '';
const requestUrl = '/services/{service_id}/reload' + (queryString ? `?${queryString}` : '');
const response = yield this.post(requestUrl.replace(`{${"service_id"}}`, encodeURIComponent(String(serviceId))), serviceReload);
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Restart a service
* @param {number} serviceId The ID of the service.
* @param {ServiceRestart} serviceRestart A JSON object containing the resource data
*/
restartService(serviceId, serviceRestart) {
return __awaiter(this, void 0, void 0, function* () {
if (serviceId === null || serviceId === undefined) {
throw new Exceptions_1.ArgumentNullException('serviceId', 'restartService');
}
if (serviceRestart === null || serviceRestart === undefined) {
throw new Exceptions_1.ArgumentNullException('serviceRestart', 'restartService');
}
let queryString = '';
const requestUrl = '/services/{service_id}/restart' + (queryString ? `?${queryString}` : '');
const response = yield this.post(requestUrl.replace(`{${"service_id"}}`, encodeURIComponent(String(serviceId))), serviceRestart);
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Start a service
* @param {number} serviceId The ID of the service.
* @param {ServiceStart} serviceStart A JSON object containing the resource data
*/
startService(serviceId, serviceStart) {
return __awaiter(this, void 0, void 0, function* () {
if (serviceId === null || serviceId === undefined) {
throw new Exceptions_1.ArgumentNullException('serviceId', 'startService');
}
if (serviceStart === null || serviceStart === undefined) {
throw new Exceptions_1.ArgumentNullException('serviceStart', 'startService');
}
let queryString = '';
const requestUrl = '/services/{service_id}/start' + (queryString ? `?${queryString}` : '');
const response = yield this.post(requestUrl.replace(`{${"service_id"}}`, encodeURIComponent(String(serviceId))), serviceStart);
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Stop a service
* @param {number} serviceId The ID of the service.
* @param {ServiceStop} serviceStop A JSON object containing the resource data
*/
stopService(serviceId, serviceStop) {
return __awaiter(this, void 0, void 0, function* () {
if (serviceId === null || serviceId === undefined) {
throw new Exceptions_1.ArgumentNullException('serviceId', 'stopService');
}
if (serviceStop === null || serviceStop === undefined) {
throw new Exceptions_1.ArgumentNullException('serviceStop', 'stopService');
}
let queryString = '';
const requestUrl = '/services/{service_id}/stop' + (queryString ? `?${queryString}` : '');
const response = yield this.post(requestUrl.replace(`{${"service_id"}}`, encodeURIComponent(String(serviceId))), serviceStop);
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Update an existing service
* @param {number} serviceId The ID of the service.
* @param {ServiceUpdate} serviceUpdate A JSON object containing the resource data
*/
updateService(serviceId, serviceUpdate) {
return __awaiter(this, void 0, void 0, function* () {
if (serviceId === null || serviceId === undefined) {
throw new Exceptions_1.ArgumentNullException('serviceId', 'updateService');
}
if (serviceUpdate === null || serviceUpdate === undefined) {
throw new Exceptions_1.ArgumentNullException('serviceUpdate', 'updateService');
}
let queryString = '';
const requestUrl = '/services/{service_id}' + (queryString ? `?${queryString}` : '');
const response = yield this.put(requestUrl.replace(`{${"service_id"}}`, encodeURIComponent(String(serviceId))), serviceUpdate);
return new ApiResponse_1.ApiResponse(response);
});
}
}
exports.ServicesApiService = ServicesApiService;
;