UNPKG

@soos-io/api-client

Version:

This is the SOOS API Client for registered clients leveraging the various integrations to the SOOS platform. Register for a free trial today at https://app.soos.io/register

42 lines (41 loc) 1.98 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const constants_1 = require("../constants"); const SOOSApiClient_1 = tslib_1.__importDefault(require("./SOOSApiClient")); class SOOSAttributionApiClient { baseUri; apiKey; client; createApiClient = (skipDebugResponseLogging) => SOOSApiClient_1.default.create({ baseUri: this.baseUri, apiKey: this.apiKey, apiClientName: "Analysis Attribution API", skipDebugResponseLogging, }); constructor(apiKey, baseUri = constants_1.SOOS_CONSTANTS.Urls.API.Analysis) { this.apiKey = apiKey; this.baseUri = baseUri; this.client = this.createApiClient(false); } async createAttributionRequest({ clientId, projectHash, branchHash, scanId, format, fileType, includeDependentProjects, includeVulnerabilities, includeOriginalSbom, }) { const response = await this.client.post(`clients/${clientId}/projects/${projectHash}/branches/${branchHash}/scans/${scanId}/attributions`, { format, fileType, includeDependentProjects, includeVulnerabilities, includeOriginalSbom, }); return response.data; } async getAttributionStatus({ clientId, projectHash, branchHash, scanId, attributionId, }) { const response = await this.client.get(`clients/${clientId}/projects/${projectHash}/branches/${branchHash}/scans/${scanId}/attributions/${attributionId}/status`); return response.data; } async getScanAttribution({ clientId, projectHash, branchHash, scanId, attributionId, }) { const client = this.createApiClient(true); const response = await client.get(`clients/${clientId}/projects/${projectHash}/branches/${branchHash}/scans/${scanId}/attributions/${attributionId}`, { responseType: "blob" }); return response.data; } } exports.default = SOOSAttributionApiClient;