/* tslint:disable */ /* eslint-disable */ /** * Sonatype Lifecycle Public REST API * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: 1.207.0-01 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import * as runtime from '../runtime'; import type { ApiApplicationEvaluationResultDTOV2, ApiApplicationEvaluationStatusDTOV2, ApiComponentEvaluationRequestDTOV2, ApiComponentEvaluationResultDTOV2, ApiComponentEvaluationTicketDTOV2, ApiPromoteScanRequestDTOV2, ApiSourceControlEvaluationRequestDTO, } from '../models/index'; import { ApiApplicationEvaluationResultDTOV2FromJSON, ApiApplicationEvaluationResultDTOV2ToJSON, ApiApplicationEvaluationStatusDTOV2FromJSON, ApiApplicationEvaluationStatusDTOV2ToJSON, ApiComponentEvaluationRequestDTOV2FromJSON, ApiComponentEvaluationRequestDTOV2ToJSON, ApiComponentEvaluationResultDTOV2FromJSON, ApiComponentEvaluationResultDTOV2ToJSON, ApiComponentEvaluationTicketDTOV2FromJSON, ApiComponentEvaluationTicketDTOV2ToJSON, ApiPromoteScanRequestDTOV2FromJSON, ApiPromoteScanRequestDTOV2ToJSON, ApiSourceControlEvaluationRequestDTOFromJSON, ApiSourceControlEvaluationRequestDTOToJSON, } from '../models/index'; export interface PolicyEvaluationApiEvaluateComponentsRequest { applicationId: string; apiComponentEvaluationRequestDTOV2?: ApiComponentEvaluationRequestDTOV2; } export interface PolicyEvaluationApiEvaluateSourceControlRequest { applicationId: string; apiSourceControlEvaluationRequestDTO?: ApiSourceControlEvaluationRequestDTO; } export interface PolicyEvaluationApiGetApplicationEvaluationStatusRequest { applicationId: string; statusId: string; } export interface PolicyEvaluationApiGetComponentEvaluationRequest { applicationId: string; resultId: string; } export interface PolicyEvaluationApiPromoteScanRequest { applicationId: string; apiPromoteScanRequestDTOV2?: ApiPromoteScanRequestDTOV2; } /** * PolicyEvaluationApi - interface * * @export * @interface PolicyEvaluationApiInterface */ export interface PolicyEvaluationApiInterface { /** * Use this method to request a component evaluation. This is step 1 of the 2 step policy evaluation for components process. Permissions Required: Evaluate Components * @param {string} applicationId Enter the internal applicationId. Use the Applications REST API to retrieve the internal applicationId. * @param {ApiComponentEvaluationRequestDTOV2} [apiComponentEvaluationRequestDTOV2] The request JSON should contain component coordinates or the hash (SHA1) for each component. You can provide the packageURL instead of component information or hash. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof PolicyEvaluationApiInterface */ evaluateComponentsRaw(requestParameters: PolicyEvaluationApiEvaluateComponentsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** * Use this method to request a component evaluation. This is step 1 of the 2 step policy evaluation for components process. Permissions Required: Evaluate Components */ evaluateComponents(requestParameters: PolicyEvaluationApiEvaluateComponentsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; /** * Use this method to request a source control evaluation for a specific application. This is step 1 of the 2 step source control evaluation process. Permissions Required: Evaluate Applications * @param {string} applicationId Enter the internal applicationId. Use the Applications REST API to retrieve the internal applicationId. * @param {ApiSourceControlEvaluationRequestDTO} [apiSourceControlEvaluationRequestDTO] The request JSON should include the 1. branch name (name of the target branch in the source control repository, 2. stageId (recommended values are \'develop\' for feature branches, and \'source\' for default branches. Other stageIds that can be used are \'build\', \'stage-release\', \'release\', \'operate\' but are not recommended), 3. scanTargets (optional, specify one or more paths inside the repository. If not specified, the entire repository will be evaluated by default). Ensure that the repository paths are not relative and do not contain \'../\' or \'..\\\'. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof PolicyEvaluationApiInterface */ evaluateSourceControlRaw(requestParameters: PolicyEvaluationApiEvaluateSourceControlRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** * Use this method to request a source control evaluation for a specific application. This is step 1 of the 2 step source control evaluation process. Permissions Required: Evaluate Applications */ evaluateSourceControl(requestParameters: PolicyEvaluationApiEvaluateSourceControlRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; /** * This is step 2 of the policy evaluation process. Use the statusUrl obtained from the POST response for the corresponding applicationId. Permissions Required: Evaluate Applications * @param {string} applicationId Enter the applicationId, for the which policy evaluation was requested. * @param {string} statusId Enter the statusId value obtained as response of the POST call in step 1. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof PolicyEvaluationApiInterface */ getApplicationEvaluationStatusRaw(requestParameters: PolicyEvaluationApiGetApplicationEvaluationStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** * This is step 2 of the policy evaluation process. Use the statusUrl obtained from the POST response for the corresponding applicationId. Permissions Required: Evaluate Applications */ getApplicationEvaluationStatus(requestParameters: PolicyEvaluationApiGetApplicationEvaluationStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; /** * This is step 2 of the policy evaluation process for components. Use the resultId obtained from the POST response for the corresponding applicationId. Permissions Required: Evaluate Components * @param {string} applicationId Enter the internal applicationId (same as that sent in the POST request (step 1)) * @param {string} resultId Enter the resultId obtained from the POST response (step 1) used for component evaluation. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof PolicyEvaluationApiInterface */ getComponentEvaluationRaw(requestParameters: PolicyEvaluationApiGetComponentEvaluationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** * This is step 2 of the policy evaluation process for components. Use the resultId obtained from the POST response for the corresponding applicationId. Permissions Required: Evaluate Components */ getComponentEvaluation(requestParameters: PolicyEvaluationApiGetComponentEvaluationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; /** * Use this method to rescan older scans. This is done when the binaries of a previous build are now moving to a new stage in the production pipeline. Using this method, you can avoid rebuilding the application and reuse the scan metadata at the newer stage. This new evaluation will evaluate the most recent security and license data against your current policies. Permissions Required: Evaluate Applications * @param {string} applicationId Enter the internal applicationId. Use the Applications REST API to retrieve the internal applicationId. * @param {ApiPromoteScanRequestDTOV2} [apiPromoteScanRequestDTOV2] You can provide either the scanId (reportId) of the previous scan OR the source stageId (possible values are \'build\', \'stage-release\', \'release\' or \'operate\'). When using the stageId, the latest scanId for the application will be used. Enter the targetStageId for the new stage you want your scan to be promoted to (possible values are \'build\', \'stage-release\', \'release\' or \'operate\'). Using the same value for source and target stage will resubmit the latest scan report. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof PolicyEvaluationApiInterface */ promoteScanRaw(requestParameters: PolicyEvaluationApiPromoteScanRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** * Use this method to rescan older scans. This is done when the binaries of a previous build are now moving to a new stage in the production pipeline. Using this method, you can avoid rebuilding the application and reuse the scan metadata at the newer stage. This new evaluation will evaluate the most recent security and license data against your current policies. Permissions Required: Evaluate Applications */ promoteScan(requestParameters: PolicyEvaluationApiPromoteScanRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; } /** * */ export class PolicyEvaluationApi extends runtime.BaseAPI implements PolicyEvaluationApiInterface { /** * Use this method to request a component evaluation. This is step 1 of the 2 step policy evaluation for components process. Permissions Required: Evaluate Components */ async evaluateComponentsRaw(requestParameters: PolicyEvaluationApiEvaluateComponentsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters['applicationId'] == null) { throw new runtime.RequiredError( 'applicationId', 'Required parameter "applicationId" was null or undefined when calling evaluateComponents().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("BearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/api/v2/evaluation/applications/{applicationId}`; urlPath = urlPath.replace(`{${"applicationId"}}`, encodeURIComponent(String(requestParameters['applicationId']))); const response = await this.request({ path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: ApiComponentEvaluationRequestDTOV2ToJSON(requestParameters['apiComponentEvaluationRequestDTOV2']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ApiComponentEvaluationTicketDTOV2FromJSON(jsonValue)); } /** * Use this method to request a component evaluation. This is step 1 of the 2 step policy evaluation for components process. Permissions Required: Evaluate Components */ async evaluateComponents(requestParameters: PolicyEvaluationApiEvaluateComponentsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.evaluateComponentsRaw(requestParameters, initOverrides); return await response.value(); } /** * Use this method to request a source control evaluation for a specific application. This is step 1 of the 2 step source control evaluation process. Permissions Required: Evaluate Applications */ async evaluateSourceControlRaw(requestParameters: PolicyEvaluationApiEvaluateSourceControlRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters['applicationId'] == null) { throw new runtime.RequiredError( 'applicationId', 'Required parameter "applicationId" was null or undefined when calling evaluateSourceControl().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("BearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/api/v2/evaluation/applications/{applicationId}/sourceControlEvaluation`; urlPath = urlPath.replace(`{${"applicationId"}}`, encodeURIComponent(String(requestParameters['applicationId']))); const response = await this.request({ path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: ApiSourceControlEvaluationRequestDTOToJSON(requestParameters['apiSourceControlEvaluationRequestDTO']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ApiApplicationEvaluationStatusDTOV2FromJSON(jsonValue)); } /** * Use this method to request a source control evaluation for a specific application. This is step 1 of the 2 step source control evaluation process. Permissions Required: Evaluate Applications */ async evaluateSourceControl(requestParameters: PolicyEvaluationApiEvaluateSourceControlRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.evaluateSourceControlRaw(requestParameters, initOverrides); return await response.value(); } /** * This is step 2 of the policy evaluation process. Use the statusUrl obtained from the POST response for the corresponding applicationId. Permissions Required: Evaluate Applications */ async getApplicationEvaluationStatusRaw(requestParameters: PolicyEvaluationApiGetApplicationEvaluationStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters['applicationId'] == null) { throw new runtime.RequiredError( 'applicationId', 'Required parameter "applicationId" was null or undefined when calling getApplicationEvaluationStatus().' ); } if (requestParameters['statusId'] == null) { throw new runtime.RequiredError( 'statusId', 'Required parameter "statusId" was null or undefined when calling getApplicationEvaluationStatus().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("BearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/api/v2/evaluation/applications/{applicationId}/status/{statusId}`; urlPath = urlPath.replace(`{${"applicationId"}}`, encodeURIComponent(String(requestParameters['applicationId']))); urlPath = urlPath.replace(`{${"statusId"}}`, encodeURIComponent(String(requestParameters['statusId']))); const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ApiApplicationEvaluationResultDTOV2FromJSON(jsonValue)); } /** * This is step 2 of the policy evaluation process. Use the statusUrl obtained from the POST response for the corresponding applicationId. Permissions Required: Evaluate Applications */ async getApplicationEvaluationStatus(requestParameters: PolicyEvaluationApiGetApplicationEvaluationStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getApplicationEvaluationStatusRaw(requestParameters, initOverrides); return await response.value(); } /** * This is step 2 of the policy evaluation process for components. Use the resultId obtained from the POST response for the corresponding applicationId. Permissions Required: Evaluate Components */ async getComponentEvaluationRaw(requestParameters: PolicyEvaluationApiGetComponentEvaluationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters['applicationId'] == null) { throw new runtime.RequiredError( 'applicationId', 'Required parameter "applicationId" was null or undefined when calling getComponentEvaluation().' ); } if (requestParameters['resultId'] == null) { throw new runtime.RequiredError( 'resultId', 'Required parameter "resultId" was null or undefined when calling getComponentEvaluation().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("BearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/api/v2/evaluation/applications/{applicationId}/results/{resultId}`; urlPath = urlPath.replace(`{${"applicationId"}}`, encodeURIComponent(String(requestParameters['applicationId']))); urlPath = urlPath.replace(`{${"resultId"}}`, encodeURIComponent(String(requestParameters['resultId']))); const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ApiComponentEvaluationResultDTOV2FromJSON(jsonValue)); } /** * This is step 2 of the policy evaluation process for components. Use the resultId obtained from the POST response for the corresponding applicationId. Permissions Required: Evaluate Components */ async getComponentEvaluation(requestParameters: PolicyEvaluationApiGetComponentEvaluationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getComponentEvaluationRaw(requestParameters, initOverrides); return await response.value(); } /** * Use this method to rescan older scans. This is done when the binaries of a previous build are now moving to a new stage in the production pipeline. Using this method, you can avoid rebuilding the application and reuse the scan metadata at the newer stage. This new evaluation will evaluate the most recent security and license data against your current policies. Permissions Required: Evaluate Applications */ async promoteScanRaw(requestParameters: PolicyEvaluationApiPromoteScanRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters['applicationId'] == null) { throw new runtime.RequiredError( 'applicationId', 'Required parameter "applicationId" was null or undefined when calling promoteScan().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("BearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/api/v2/evaluation/applications/{applicationId}/promoteScan`; urlPath = urlPath.replace(`{${"applicationId"}}`, encodeURIComponent(String(requestParameters['applicationId']))); const response = await this.request({ path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: ApiPromoteScanRequestDTOV2ToJSON(requestParameters['apiPromoteScanRequestDTOV2']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ApiApplicationEvaluationStatusDTOV2FromJSON(jsonValue)); } /** * Use this method to rescan older scans. This is done when the binaries of a previous build are now moving to a new stage in the production pipeline. Using this method, you can avoid rebuilding the application and reuse the scan metadata at the newer stage. This new evaluation will evaluate the most recent security and license data against your current policies. Permissions Required: Evaluate Applications */ async promoteScan(requestParameters: PolicyEvaluationApiPromoteScanRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.promoteScanRaw(requestParameters, initOverrides); return await response.value(); } }