Search in sources :

Example 1 with ScaUploadUrlRequest

use of com.checkmarx.sdk.dto.sca.ScaUploadUrlRequest in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.

the class ScanClientHelper method getSourcesUploadUrl.

private String getSourcesUploadUrl() throws IOException {
    List<ScanConfig> apiScanConfig = Collections.singletonList(getScanConfig());
    ScaUploadUrlRequest request = ScaUploadUrlRequest.builder().config(apiScanConfig).build();
    StringEntity entity = HttpClientHelper.convertToStringEntity(request);
    JsonNode response = httpClient.postRequest(GET_UPLOAD_URL, ContentType.CONTENT_TYPE_APPLICATION_JSON, entity, JsonNode.class, HttpStatus.SC_OK, "get upload URL for sources");
    if (response == null || response.get("url") == null) {
        throw new ScannerRuntimeException("Unable to get the upload URL.");
    }
    return response.get("url").asText();
}
Also used : StringEntity(org.apache.http.entity.StringEntity) ScaUploadUrlRequest(com.checkmarx.sdk.dto.sca.ScaUploadUrlRequest) JsonNode(com.fasterxml.jackson.databind.JsonNode) ScannerRuntimeException(com.checkmarx.sdk.exception.ScannerRuntimeException)

Aggregations

ScaUploadUrlRequest (com.checkmarx.sdk.dto.sca.ScaUploadUrlRequest)1 ScannerRuntimeException (com.checkmarx.sdk.exception.ScannerRuntimeException)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 StringEntity (org.apache.http.entity.StringEntity)1