UNPKG

@devopness/sdk-js

Version:

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

272 lines (271 loc) 14.9 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.CredentialsApiService = void 0; const ApiBaseService_1 = require("../../../services/ApiBaseService"); const ApiResponse_1 = require("../../../common/ApiResponse"); const Exceptions_1 = require("../../../common/Exceptions"); /** * CredentialsApiService - Auto-generated */ class CredentialsApiService extends ApiBaseService_1.ApiBaseService { /** * * @summary Add a Credential to the given organization * @param {string} organizationId The numeric ID or URL Slug of an organization. * @param {CredentialOrganizationCreate} credentialOrganizationCreate A JSON object containing the resource data */ addOrganizationCredential(organizationId, credentialOrganizationCreate) { return __awaiter(this, void 0, void 0, function* () { if (organizationId === null || organizationId === undefined) { throw new Exceptions_1.ArgumentNullException('organizationId', 'addOrganizationCredential'); } if (credentialOrganizationCreate === null || credentialOrganizationCreate === undefined) { throw new Exceptions_1.ArgumentNullException('credentialOrganizationCreate', 'addOrganizationCredential'); } let queryString = ''; const requestUrl = '/organizations/{organization_id}/credentials' + (queryString ? `?${queryString}` : ''); const response = yield this.post(requestUrl.replace(`{${"organization_id"}}`, encodeURIComponent(String(organizationId))), credentialOrganizationCreate); return new ApiResponse_1.ApiResponse(response); }); } /** * * @summary Delete a given credential * @param {number} credentialId The ID of the credential. */ deleteCredential(credentialId) { return __awaiter(this, void 0, void 0, function* () { if (credentialId === null || credentialId === undefined) { throw new Exceptions_1.ArgumentNullException('credentialId', 'deleteCredential'); } let queryString = ''; const requestUrl = '/credentials/{credential_id}' + (queryString ? `?${queryString}` : ''); const response = yield this.delete(requestUrl.replace(`{${"credential_id"}}`, encodeURIComponent(String(credentialId)))); return new ApiResponse_1.ApiResponse(response); }); } /** * * @summary Get a credential by ID * @param {number} credentialId The ID of the credential. */ getCredential(credentialId) { return __awaiter(this, void 0, void 0, function* () { if (credentialId === null || credentialId === undefined) { throw new Exceptions_1.ArgumentNullException('credentialId', 'getCredential'); } let queryString = ''; const requestUrl = '/credentials/{credential_id}' + (queryString ? `?${queryString}` : ''); const response = yield this.get(requestUrl.replace(`{${"credential_id"}}`, encodeURIComponent(String(credentialId)))); return new ApiResponse_1.ApiResponse(response); }); } /** * * @summary Return provider settings * @param {number} environmentId The ID of the environment. * @param {string} providerCode The code of the provider. * @param {string} [state] Optional base64-encoded JSON state to be included in connect URLs. */ getEnvironmentCredentialSettings(environmentId, providerCode, state) { return __awaiter(this, void 0, void 0, function* () { if (environmentId === null || environmentId === undefined) { throw new Exceptions_1.ArgumentNullException('environmentId', 'getEnvironmentCredentialSettings'); } if (providerCode === null || providerCode === undefined) { throw new Exceptions_1.ArgumentNullException('providerCode', 'getEnvironmentCredentialSettings'); } let queryString = ''; const queryParams = { state: state, }; for (const key in queryParams) { if (queryParams[key] === undefined || queryParams[key] === null) { continue; } queryString += (queryString ? '&' : '') + `${key}=${encodeURI(queryParams[key])}`; } const requestUrl = '/environments/{environment_id}/credentials/{provider_code}/settings' + (queryString ? `?${queryString}` : ''); const response = yield this.get(requestUrl.replace(`{${"environment_id"}}`, encodeURIComponent(String(environmentId))).replace(`{${"provider_code"}}`, encodeURIComponent(String(providerCode)))); return new ApiResponse_1.ApiResponse(response); }); } /** * * @summary Return provider settings * @param {string} organizationId The ID or slug of the organization. * @param {string} providerCode The code of the provider. * @param {string} [state] Optional base64-encoded JSON state to be included in connect URLs. */ getOrganizationCredentialSettings(organizationId, providerCode, state) { return __awaiter(this, void 0, void 0, function* () { if (organizationId === null || organizationId === undefined) { throw new Exceptions_1.ArgumentNullException('organizationId', 'getOrganizationCredentialSettings'); } if (providerCode === null || providerCode === undefined) { throw new Exceptions_1.ArgumentNullException('providerCode', 'getOrganizationCredentialSettings'); } let queryString = ''; const queryParams = { state: state, }; for (const key in queryParams) { if (queryParams[key] === undefined || queryParams[key] === null) { continue; } queryString += (queryString ? '&' : '') + `${key}=${encodeURI(queryParams[key])}`; } const requestUrl = '/organizations/{organization_id}/credentials/{provider_code}/settings' + (queryString ? `?${queryString}` : ''); const response = yield this.get(requestUrl.replace(`{${"organization_id"}}`, encodeURIComponent(String(organizationId))).replace(`{${"provider_code"}}`, encodeURIComponent(String(providerCode)))); return new ApiResponse_1.ApiResponse(response); }); } /** * * @summary Get current status of a credential on its provider * @param {number} credentialId The ID of the credential. */ getStatusCredential(credentialId) { return __awaiter(this, void 0, void 0, function* () { if (credentialId === null || credentialId === undefined) { throw new Exceptions_1.ArgumentNullException('credentialId', 'getStatusCredential'); } let queryString = ''; const requestUrl = '/credentials/{credential_id}/get-status' + (queryString ? `?${queryString}` : ''); const response = yield this.post(requestUrl.replace(`{${"credential_id"}}`, encodeURIComponent(String(credentialId)))); return new ApiResponse_1.ApiResponse(response); }); } /** * * @summary Link a credential to an environment * @param {number} credentialId The credential ID. * @param {number} environmentId The environment ID. */ linkCredentialToEnvironment(credentialId, environmentId) { return __awaiter(this, void 0, void 0, function* () { if (credentialId === null || credentialId === undefined) { throw new Exceptions_1.ArgumentNullException('credentialId', 'linkCredentialToEnvironment'); } if (environmentId === null || environmentId === undefined) { throw new Exceptions_1.ArgumentNullException('environmentId', 'linkCredentialToEnvironment'); } let queryString = ''; const requestUrl = '/environments/{environment_id}/credentials/{credential_id}/link' + (queryString ? `?${queryString}` : ''); const response = yield this.post(requestUrl.replace(`{${"credential_id"}}`, encodeURIComponent(String(credentialId))).replace(`{${"environment_id"}}`, encodeURIComponent(String(environmentId)))); return new ApiResponse_1.ApiResponse(response); }); } /** * * @summary Return a list of all Credentials linked 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 * @param {string} [providerCode] Filter credentials by provider code. * @param {string} [providerType] Filter credentials by provider type. */ listEnvironmentCredentials(environmentId, page, perPage, providerCode, providerType) { return __awaiter(this, void 0, void 0, function* () { if (environmentId === null || environmentId === undefined) { throw new Exceptions_1.ArgumentNullException('environmentId', 'listEnvironmentCredentials'); } let queryString = ''; const queryParams = { page: page, per_page: perPage, provider_code: providerCode, provider_type: providerType, }; for (const key in queryParams) { if (queryParams[key] === undefined || queryParams[key] === null) { continue; } queryString += (queryString ? '&' : '') + `${key}=${encodeURI(queryParams[key])}`; } const requestUrl = '/environments/{environment_id}/credentials' + (queryString ? `?${queryString}` : ''); const response = yield this.get(requestUrl.replace(`{${"environment_id"}}`, encodeURIComponent(String(environmentId)))); return new ApiResponse_1.ApiResponse(response); }); } /** * * @summary Return a list of all Credentials belonging to an organization * @param {string} organizationId The numeric ID or URL Slug of an organization. * @param {number} [page] Number of the page to be retrieved * @param {number} [perPage] Number of items returned per page * @param {string} [providerCode] Filter credentials by provider code. * @param {string} [providerType] Filter credentials by provider type. */ listOrganizationCredentials(organizationId, page, perPage, providerCode, providerType) { return __awaiter(this, void 0, void 0, function* () { if (organizationId === null || organizationId === undefined) { throw new Exceptions_1.ArgumentNullException('organizationId', 'listOrganizationCredentials'); } let queryString = ''; const queryParams = { page: page, per_page: perPage, provider_code: providerCode, provider_type: providerType, }; for (const key in queryParams) { if (queryParams[key] === undefined || queryParams[key] === null) { continue; } queryString += (queryString ? '&' : '') + `${key}=${encodeURI(queryParams[key])}`; } const requestUrl = '/organizations/{organization_id}/credentials' + (queryString ? `?${queryString}` : ''); const response = yield this.get(requestUrl.replace(`{${"organization_id"}}`, encodeURIComponent(String(organizationId)))); return new ApiResponse_1.ApiResponse(response); }); } /** * * @summary Unlink a credential from an environment * @param {number} credentialId The credential ID. * @param {number} environmentId The environment ID. */ unlinkCredentialFromEnvironment(credentialId, environmentId) { return __awaiter(this, void 0, void 0, function* () { if (credentialId === null || credentialId === undefined) { throw new Exceptions_1.ArgumentNullException('credentialId', 'unlinkCredentialFromEnvironment'); } if (environmentId === null || environmentId === undefined) { throw new Exceptions_1.ArgumentNullException('environmentId', 'unlinkCredentialFromEnvironment'); } let queryString = ''; const requestUrl = '/environments/{environment_id}/credentials/{credential_id}/unlink' + (queryString ? `?${queryString}` : ''); const response = yield this.delete(requestUrl.replace(`{${"credential_id"}}`, encodeURIComponent(String(credentialId))).replace(`{${"environment_id"}}`, encodeURIComponent(String(environmentId)))); return new ApiResponse_1.ApiResponse(response); }); } /** * * @summary Update an existing Credential * @param {number} credentialId The ID of the credential. * @param {CredentialUpdate} credentialUpdate A JSON object containing the resource data */ updateCredential(credentialId, credentialUpdate) { return __awaiter(this, void 0, void 0, function* () { if (credentialId === null || credentialId === undefined) { throw new Exceptions_1.ArgumentNullException('credentialId', 'updateCredential'); } if (credentialUpdate === null || credentialUpdate === undefined) { throw new Exceptions_1.ArgumentNullException('credentialUpdate', 'updateCredential'); } let queryString = ''; const requestUrl = '/credentials/{credential_id}' + (queryString ? `?${queryString}` : ''); const response = yield this.put(requestUrl.replace(`{${"credential_id"}}`, encodeURIComponent(String(credentialId))), credentialUpdate); return new ApiResponse_1.ApiResponse(response); }); } } exports.CredentialsApiService = CredentialsApiService;