UNPKG

@devopness/sdk-js

Version:

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

152 lines (151 loc) 8.92 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.ResourceLinksApiService = void 0; const ApiBaseService_1 = require("../../../services/ApiBaseService"); const ApiResponse_1 = require("../../../common/ApiResponse"); const Exceptions_1 = require("../../../common/Exceptions"); /** * ResourceLinksApiService - Auto-generated */ class ResourceLinksApiService extends ApiBaseService_1.ApiBaseService { /** * * @summary Link the given resources * @param {number} childId The child resource ID. * @param {string} childType The resource type of the child resource. * @param {number} resourceId The parent resource ID. * @param {string} resourceType The resource type of the parent resource. */ linkResourceLinkToResourceLink(childId, childType, resourceId, resourceType) { return __awaiter(this, void 0, void 0, function* () { if (childId === null || childId === undefined) { throw new Exceptions_1.ArgumentNullException('childId', 'linkResourceLinkToResourceLink'); } if (childType === null || childType === undefined) { throw new Exceptions_1.ArgumentNullException('childType', 'linkResourceLinkToResourceLink'); } if (resourceId === null || resourceId === undefined) { throw new Exceptions_1.ArgumentNullException('resourceId', 'linkResourceLinkToResourceLink'); } if (resourceType === null || resourceType === undefined) { throw new Exceptions_1.ArgumentNullException('resourceType', 'linkResourceLinkToResourceLink'); } let queryString = ''; const requestUrl = '/resource-links/{resource_type}/{resource_id}/{child_type}/{child_id}/link' + (queryString ? `?${queryString}` : ''); const response = yield this.post(requestUrl.replace(`{${"child_id"}}`, encodeURIComponent(String(childId))).replace(`{${"child_type"}}`, encodeURIComponent(String(childType))).replace(`{${"resource_id"}}`, encodeURIComponent(String(resourceId))).replace(`{${"resource_type"}}`, encodeURIComponent(String(resourceType)))); return new ApiResponse_1.ApiResponse(response); }); } /** * * @summary List linked resources of the given resource * @param {number} resourceId The resource ID. * @param {string} resourceType The resource type to get linked resources. * @param {number} [page] Number of the page to be retrieved * @param {number} [perPage] Number of items returned per page */ listResourceLinksByResourceType(resourceId, resourceType, page, perPage) { return __awaiter(this, void 0, void 0, function* () { if (resourceId === null || resourceId === undefined) { throw new Exceptions_1.ArgumentNullException('resourceId', 'listResourceLinksByResourceType'); } if (resourceType === null || resourceType === undefined) { throw new Exceptions_1.ArgumentNullException('resourceType', 'listResourceLinksByResourceType'); } 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 = '/resource-links/{resource_type}/{resource_id}' + (queryString ? `?${queryString}` : ''); const response = yield this.get(requestUrl.replace(`{${"resource_id"}}`, encodeURIComponent(String(resourceId))).replace(`{${"resource_type"}}`, encodeURIComponent(String(resourceType)))); return new ApiResponse_1.ApiResponse(response); }); } /** * * @summary List linked resources of specified link type * @param {string} linkType The link type (`child` or `parent`). * @param {number} resourceId The resource ID. * @param {string} resourceType The resource type to get linked resources. * @param {number} [page] Number of the page to be retrieved * @param {number} [perPage] Number of items returned per page */ listResourceLinksByResourceTypeAndLinkType(linkType, resourceId, resourceType, page, perPage) { return __awaiter(this, void 0, void 0, function* () { if (linkType === null || linkType === undefined) { throw new Exceptions_1.ArgumentNullException('linkType', 'listResourceLinksByResourceTypeAndLinkType'); } if (resourceId === null || resourceId === undefined) { throw new Exceptions_1.ArgumentNullException('resourceId', 'listResourceLinksByResourceTypeAndLinkType'); } if (resourceType === null || resourceType === undefined) { throw new Exceptions_1.ArgumentNullException('resourceType', 'listResourceLinksByResourceTypeAndLinkType'); } 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 = '/resource-links/{resource_type}/{resource_id}/{link_type}' + (queryString ? `?${queryString}` : ''); const response = yield this.get(requestUrl.replace(`{${"link_type"}}`, encodeURIComponent(String(linkType))).replace(`{${"resource_id"}}`, encodeURIComponent(String(resourceId))).replace(`{${"resource_type"}}`, encodeURIComponent(String(resourceType)))); return new ApiResponse_1.ApiResponse(response); }); } /** * * @summary Delete a given resource link * @param {number} childId The child resource ID. * @param {string} childType The resource type of the child resource. * @param {number} resourceId The parent resource ID. * @param {string} resourceType The resource type of the parent resource. */ unlinkResourceLinkFromResourceLink(childId, childType, resourceId, resourceType) { return __awaiter(this, void 0, void 0, function* () { if (childId === null || childId === undefined) { throw new Exceptions_1.ArgumentNullException('childId', 'unlinkResourceLinkFromResourceLink'); } if (childType === null || childType === undefined) { throw new Exceptions_1.ArgumentNullException('childType', 'unlinkResourceLinkFromResourceLink'); } if (resourceId === null || resourceId === undefined) { throw new Exceptions_1.ArgumentNullException('resourceId', 'unlinkResourceLinkFromResourceLink'); } if (resourceType === null || resourceType === undefined) { throw new Exceptions_1.ArgumentNullException('resourceType', 'unlinkResourceLinkFromResourceLink'); } let queryString = ''; const requestUrl = '/resource-links/{resource_type}/{resource_id}/{child_type}/{child_id}/unlink' + (queryString ? `?${queryString}` : ''); const response = yield this.delete(requestUrl.replace(`{${"child_id"}}`, encodeURIComponent(String(childId))).replace(`{${"child_type"}}`, encodeURIComponent(String(childType))).replace(`{${"resource_id"}}`, encodeURIComponent(String(resourceId))).replace(`{${"resource_type"}}`, encodeURIComponent(String(resourceType)))); return new ApiResponse_1.ApiResponse(response); }); } } exports.ResourceLinksApiService = ResourceLinksApiService;