UNPKG

@devopness/sdk-js

Version:

Devopness API JS/TS SDK - Painless essential DevOps to everyone

143 lines (142 loc) 7.47 kB
"use strict"; /* 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.ProjectsAPITokensApiService = void 0; const ApiBaseService_1 = require("../../../services/ApiBaseService"); const ApiResponse_1 = require("../../../common/ApiResponse"); const Exceptions_1 = require("../../../common/Exceptions"); /** * ProjectsAPITokensApiService - Auto-generated */ class ProjectsAPITokensApiService extends ApiBaseService_1.ApiBaseService { /** * * @summary Create a new API token for specific project. * @param {number} projectId The ID of the project. * @param {ApiTokenProjectCreate} apiTokenProjectCreate A JSON object containing the resource data */ addProjectApiToken(projectId, apiTokenProjectCreate) { return __awaiter(this, void 0, void 0, function* () { if (projectId === null || projectId === undefined) { throw new Exceptions_1.ArgumentNullException('projectId', 'addProjectApiToken'); } if (apiTokenProjectCreate === null || apiTokenProjectCreate === undefined) { throw new Exceptions_1.ArgumentNullException('apiTokenProjectCreate', 'addProjectApiToken'); } let queryString = ''; const requestUrl = '/projects/{project_id}/tokens' + (queryString ? `?${queryString}` : ''); const response = yield this.post(requestUrl.replace(`{${"project_id"}}`, encodeURIComponent(String(projectId))), apiTokenProjectCreate); return new ApiResponse_1.ApiResponse(response); }); } /** * * @summary Get details of a specific project API token. * @param {number} projectId The ID of the project. * @param {string} tokenId The ID of the token. */ getProjectApiToken(projectId, tokenId) { return __awaiter(this, void 0, void 0, function* () { if (projectId === null || projectId === undefined) { throw new Exceptions_1.ArgumentNullException('projectId', 'getProjectApiToken'); } if (tokenId === null || tokenId === undefined) { throw new Exceptions_1.ArgumentNullException('tokenId', 'getProjectApiToken'); } let queryString = ''; const requestUrl = '/projects/{project_id}/tokens/{token_id}' + (queryString ? `?${queryString}` : ''); const response = yield this.get(requestUrl.replace(`{${"project_id"}}`, encodeURIComponent(String(projectId))).replace(`{${"token_id"}}`, encodeURIComponent(String(tokenId)))); return new ApiResponse_1.ApiResponse(response); }); } /** * * @summary List the API tokens of specific project. * @param {number} projectId The ID of the project. * @param {number} [page] Number of the page to be retrieved * @param {number} [perPage] Number of items returned per page */ listProjectApiTokens(projectId, page, perPage) { return __awaiter(this, void 0, void 0, function* () { if (projectId === null || projectId === undefined) { throw new Exceptions_1.ArgumentNullException('projectId', 'listProjectApiTokens'); } 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 = '/projects/{project_id}/tokens' + (queryString ? `?${queryString}` : ''); const response = yield this.get(requestUrl.replace(`{${"project_id"}}`, encodeURIComponent(String(projectId)))); return new ApiResponse_1.ApiResponse(response); }); } /** * * @summary Revoke a specific project API token. * @param {number} projectId The ID of the project. * @param {string} tokenId The ID of the token. */ revokeProjectApiToken(projectId, tokenId) { return __awaiter(this, void 0, void 0, function* () { if (projectId === null || projectId === undefined) { throw new Exceptions_1.ArgumentNullException('projectId', 'revokeProjectApiToken'); } if (tokenId === null || tokenId === undefined) { throw new Exceptions_1.ArgumentNullException('tokenId', 'revokeProjectApiToken'); } let queryString = ''; const requestUrl = '/projects/{project_id}/tokens/{token_id}/revoke' + (queryString ? `?${queryString}` : ''); const response = yield this.delete(requestUrl.replace(`{${"project_id"}}`, encodeURIComponent(String(projectId))).replace(`{${"token_id"}}`, encodeURIComponent(String(tokenId)))); return new ApiResponse_1.ApiResponse(response); }); } /** * * @summary Rotate a specific project API token. * @param {number} projectId The ID of the project. * @param {string} tokenId The ID of the token. * @param {ApiTokenProjectRotate} apiTokenProjectRotate A JSON object containing the resource data */ rotateProjectApiToken(projectId, tokenId, apiTokenProjectRotate) { return __awaiter(this, void 0, void 0, function* () { if (projectId === null || projectId === undefined) { throw new Exceptions_1.ArgumentNullException('projectId', 'rotateProjectApiToken'); } if (tokenId === null || tokenId === undefined) { throw new Exceptions_1.ArgumentNullException('tokenId', 'rotateProjectApiToken'); } if (apiTokenProjectRotate === null || apiTokenProjectRotate === undefined) { throw new Exceptions_1.ArgumentNullException('apiTokenProjectRotate', 'rotateProjectApiToken'); } let queryString = ''; const requestUrl = '/projects/{project_id}/tokens/{token_id}/rotate' + (queryString ? `?${queryString}` : ''); const response = yield this.post(requestUrl.replace(`{${"project_id"}}`, encodeURIComponent(String(projectId))).replace(`{${"token_id"}}`, encodeURIComponent(String(tokenId))), apiTokenProjectRotate); return new ApiResponse_1.ApiResponse(response); }); } } exports.ProjectsAPITokensApiService = ProjectsAPITokensApiService;