@devopness/sdk-js
Version:
Devopness API JS/TS SDK - Painless essential DevOps to everyone
131 lines (130 loc) • 6.45 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.CronJobsApiService = void 0;
const ApiBaseService_1 = require("../../../services/ApiBaseService");
const ApiResponse_1 = require("../../../common/ApiResponse");
const Exceptions_1 = require("../../../common/Exceptions");
/**
* CronJobsApiService - Auto-generated
*/
class CronJobsApiService extends ApiBaseService_1.ApiBaseService {
/**
*
* @summary Add a Cron Job to the given environment
* @param {number} environmentId The ID of the environment.
* @param {CronJobEnvironmentCreate} cronJobEnvironmentCreate A JSON object containing the resource data
*/
addEnvironmentCronJob(environmentId, cronJobEnvironmentCreate) {
return __awaiter(this, void 0, void 0, function* () {
if (environmentId === null || environmentId === undefined) {
throw new Exceptions_1.ArgumentNullException('environmentId', 'addEnvironmentCronJob');
}
if (cronJobEnvironmentCreate === null || cronJobEnvironmentCreate === undefined) {
throw new Exceptions_1.ArgumentNullException('cronJobEnvironmentCreate', 'addEnvironmentCronJob');
}
let queryString = '';
const requestUrl = '/environments/{environment_id}/cron-jobs' + (queryString ? `?${queryString}` : '');
const response = yield this.post(requestUrl.replace(`{${"environment_id"}}`, encodeURIComponent(String(environmentId))), cronJobEnvironmentCreate);
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Delete a given Cron Job
* @param {number} cronJobId The ID of the cron job.
*/
deleteCronJob(cronJobId) {
return __awaiter(this, void 0, void 0, function* () {
if (cronJobId === null || cronJobId === undefined) {
throw new Exceptions_1.ArgumentNullException('cronJobId', 'deleteCronJob');
}
let queryString = '';
const requestUrl = '/cron-jobs/{cron_job_id}' + (queryString ? `?${queryString}` : '');
const response = yield this.delete(requestUrl.replace(`{${"cron_job_id"}}`, encodeURIComponent(String(cronJobId))));
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Get a Cron Job by ID
* @param {number} cronJobId The ID of the cron job.
*/
getCronJob(cronJobId) {
return __awaiter(this, void 0, void 0, function* () {
if (cronJobId === null || cronJobId === undefined) {
throw new Exceptions_1.ArgumentNullException('cronJobId', 'getCronJob');
}
let queryString = '';
const requestUrl = '/cron-jobs/{cron_job_id}' + (queryString ? `?${queryString}` : '');
const response = yield this.get(requestUrl.replace(`{${"cron_job_id"}}`, encodeURIComponent(String(cronJobId))));
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Return a list of all Cron Jobs 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
*/
listEnvironmentCronJobs(environmentId, page, perPage) {
return __awaiter(this, void 0, void 0, function* () {
if (environmentId === null || environmentId === undefined) {
throw new Exceptions_1.ArgumentNullException('environmentId', 'listEnvironmentCronJobs');
}
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}/cron-jobs' + (queryString ? `?${queryString}` : '');
const response = yield this.get(requestUrl.replace(`{${"environment_id"}}`, encodeURIComponent(String(environmentId))));
return new ApiResponse_1.ApiResponse(response);
});
}
/**
*
* @summary Update an existing Cron Job
* @param {number} cronJobId The ID of the cron job.
* @param {CronJobUpdate} cronJobUpdate A JSON object containing the resource data
*/
updateCronJob(cronJobId, cronJobUpdate) {
return __awaiter(this, void 0, void 0, function* () {
if (cronJobId === null || cronJobId === undefined) {
throw new Exceptions_1.ArgumentNullException('cronJobId', 'updateCronJob');
}
if (cronJobUpdate === null || cronJobUpdate === undefined) {
throw new Exceptions_1.ArgumentNullException('cronJobUpdate', 'updateCronJob');
}
let queryString = '';
const requestUrl = '/cron-jobs/{cron_job_id}' + (queryString ? `?${queryString}` : '');
const response = yield this.put(requestUrl.replace(`{${"cron_job_id"}}`, encodeURIComponent(String(cronJobId))), cronJobUpdate);
return new ApiResponse_1.ApiResponse(response);
});
}
}
exports.CronJobsApiService = CronJobsApiService;
;