From d40656d884c2dbb85ce6532f1d71e871c42e9e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicklas=20K=C3=B6rtge?= Date: Thu, 14 Nov 2024 13:27:42 +0100 Subject: [PATCH] updaet api MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nicklas Körtge --- frontend/api.json | 2 +- frontend/src/helpers/api.js | 2 +- .../presentation/api/v1/database/CBOMResource.java | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/frontend/api.json b/frontend/api.json index 5727767ca..cf1ab1dfe 100644 --- a/frontend/api.json +++ b/frontend/api.json @@ -1,5 +1,5 @@ { "SCAN": "v1/scan", - "LAST_CBOMS": "api/v1/cbom/lastn", + "LAST_CBOMS": "api/v1/cbom/last", "CHECK_POLICY": "api/v1/compliance/check" } diff --git a/frontend/src/helpers/api.js b/frontend/src/helpers/api.js index 1235b0003..1868402a7 100644 --- a/frontend/src/helpers/api.js +++ b/frontend/src/helpers/api.js @@ -4,7 +4,7 @@ import { checkValidComplianceResults, createLocalComplianceReport, isViewerOnly export function fetchLastCboms(number) { - let apiUrl = `${API_LAST_CBOM_URL}?limit=${number}`; + let apiUrl = `${API_LAST_CBOM_URL}/${number}`; fetchDataFromApi(apiUrl, null) .then((jsonData) => { model.lastCboms = jsonData; diff --git a/src/main/java/com/ibm/presentation/api/v1/database/CBOMResource.java b/src/main/java/com/ibm/presentation/api/v1/database/CBOMResource.java index a563683fc..a6676cb50 100644 --- a/src/main/java/com/ibm/presentation/api/v1/database/CBOMResource.java +++ b/src/main/java/com/ibm/presentation/api/v1/database/CBOMResource.java @@ -32,7 +32,7 @@ import jakarta.ws.rs.core.Response; import java.util.concurrent.ExecutionException; import org.eclipse.microprofile.openapi.annotations.Operation; -import org.jboss.resteasy.reactive.RestQuery; +import org.jboss.resteasy.reactive.RestPath; @Path("/api/v1/cbom") @ApplicationScoped @@ -45,7 +45,7 @@ public CBOMResource(@Nonnull IQueryBus queryBus) { } @GET - @Path("/lastn") + @Path("/last/{limit}") @Produces(MediaType.APPLICATION_JSON) @Operation( summary = "Return recently generated CBOMs from the repository", @@ -53,7 +53,7 @@ public CBOMResource(@Nonnull IQueryBus queryBus) { "Returns a list of the most recently generated CBOMs. " + "The length of the list can by specified via the optional 'limit' " + "parameter.") - public Response getLastCBOMs(@RestQuery @Nullable Integer limit) + public Response getLastCBOMs(@RestPath @Nullable Integer limit) throws ExecutionException, InterruptedException { return this.queryBus .send(new ListStoredCBOMsQuery(limit)) @@ -62,15 +62,15 @@ public Response getLastCBOMs(@RestQuery @Nullable Integer limit) } @GET - @Path("/byIdentifier") + @Path("/{projectIdentifier}") @Produces(MediaType.APPLICATION_JSON) - public Response getCBOM(@RestQuery @Nullable String identifier) + public Response getCBOM(@RestPath @Nullable String projectIdentifier) throws ExecutionException, InterruptedException { - if (identifier == null) { + if (projectIdentifier == null) { return Response.status(Response.Status.BAD_REQUEST).build(); } return this.queryBus - .send(new GetCBOMByProjectIdentifierQuery(identifier)) + .send(new GetCBOMByProjectIdentifierQuery(projectIdentifier)) .thenApply(readModel -> Response.ok(readModel).build()) .get(); }