Skip to content

Commit

Permalink
fix: minor fixes in management API (#4053)
Browse files Browse the repository at this point in the history
  • Loading branch information
bscholtes1A authored Mar 27, 2024
1 parent 2a2772b commit 0df9e65
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
import static org.eclipse.edc.catalog.spi.CatalogRequest.CATALOG_REQUEST_TYPE;
import static org.eclipse.edc.catalog.spi.DatasetRequest.DATASET_REQUEST_TYPE;

@Path("/v2/catalog")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/v2/catalog")
public class CatalogApiController implements CatalogApi {

private final CatalogService service;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public interface ContractAgreementApi {
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class))))
}
)
JsonArray queryAllAgreements(JsonObject querySpecJson);
JsonArray queryAgreements(JsonObject querySpecJson);

@Operation(description = "Gets an contract agreement with the given ID",
responses = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import jakarta.json.JsonArray;
import jakarta.json.JsonObject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
Expand All @@ -41,6 +42,7 @@
import static org.eclipse.edc.spi.query.QuerySpec.EDC_QUERY_SPEC_TYPE;
import static org.eclipse.edc.web.spi.exception.ServiceResultHandler.exceptionMapper;

@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
@Path("/v2/contractagreements")
public class ContractAgreementApiController implements ContractAgreementApi {
Expand All @@ -60,7 +62,7 @@ public ContractAgreementApiController(ContractAgreementService service, TypeTran
@POST
@Path("/request")
@Override
public JsonArray queryAllAgreements(JsonObject querySpecJson) {
public JsonArray queryAgreements(JsonObject querySpecJson) {
QuerySpec querySpec;
if (querySpecJson == null) {
querySpec = QuerySpec.Builder.newInstance().build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public interface ContractDefinitionApi {
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class))))
}
)
JsonArray queryAllContractDefinitions(JsonObject querySpecJson);
JsonArray queryContractDefinitions(JsonObject querySpecJson);

@Operation(description = "Gets an contract definition with the given ID",
responses = {
Expand All @@ -71,7 +71,7 @@ public interface ContractDefinitionApi {
@ApiResponse(responseCode = "400", description = "Request body was malformed",
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))),
@ApiResponse(responseCode = "409", description = "Could not create contract definition, because a contract definition with that ID already exists",
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) }
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class))))}
)
JsonObject createContractDefinition(JsonObject createObject);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import jakarta.json.JsonArray;
import jakarta.json.JsonObject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
Expand Down Expand Up @@ -44,7 +45,8 @@
import static org.eclipse.edc.web.spi.exception.ServiceResultHandler.exceptionMapper;


@Produces({ MediaType.APPLICATION_JSON })
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
@Path("/v2/contractdefinitions")
public class ContractDefinitionApiController implements ContractDefinitionApi {
private final TypeTransformerRegistry transformerRegistry;
Expand All @@ -63,7 +65,7 @@ public ContractDefinitionApiController(TypeTransformerRegistry transformerRegist
@POST
@Path("/request")
@Override
public JsonArray queryAllContractDefinitions(JsonObject querySpecJson) {
public JsonArray queryContractDefinitions(JsonObject querySpecJson) {
QuerySpec querySpec;
if (querySpecJson == null) {
querySpec = QuerySpec.Builder.newInstance().build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@
import static org.eclipse.edc.spi.query.QuerySpec.EDC_QUERY_SPEC_TYPE;
import static org.eclipse.edc.web.spi.exception.ServiceResultHandler.exceptionMapper;

@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })

@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
@Path("/v2/contractnegotiations")
public class ContractNegotiationApiController implements ContractNegotiationApi {
private final ContractNegotiationService service;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
public interface DataplaneSelectorApi {

@Operation(method = "POST",
operationId = "selectDataPlaneInstance",
description = "Finds the best fitting data plane instance for a particular query",
requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = SelectionRequestSchema.class))),
responses = {
Expand All @@ -45,9 +46,10 @@ public interface DataplaneSelectorApi {
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class))))
})
@POST
JsonObject find(JsonObject request);
JsonObject selectDataPlaneInstance(JsonObject request);

@Operation(method = "POST",
operationId = "addDataPlaneInstance",
description = "Adds one dataplane instance to the internal database of the selector",
requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = DataPlaneInstanceSchema.class))),
responses = {
Expand All @@ -56,16 +58,17 @@ public interface DataplaneSelectorApi {
}
)
@POST
JsonObject addEntry(JsonObject instance);
JsonObject addDataPlaneInstance(JsonObject instance);

@Operation(method = "GET",
operationId = "getAllDataPlaneInstances",
description = "Returns a list of all currently registered data plane instances",
responses = {
@ApiResponse(responseCode = "200", description = "A (potentially empty) list of currently registered data plane instances",
content = @Content(array = @ArraySchema(schema = @Schema(implementation = DataPlaneInstanceSchema.class))))
}
)
@GET
JsonArray getAll();
JsonArray getAllDataPlaneInstances();

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
import static org.eclipse.edc.connector.dataplane.selector.spi.instance.DataPlaneInstance.DATAPLANE_INSTANCE_TYPE;
import static org.eclipse.edc.web.spi.exception.ServiceResultHandler.exceptionMapper;

@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
@Path("/v2/dataplanes")
public class DataplaneSelectorApiController implements DataplaneSelectorApi {

Expand All @@ -63,7 +63,7 @@ public DataplaneSelectorApiController(DataPlaneSelectorService selectionService,
@Override
@POST
@Path("select")
public JsonObject find(JsonObject requestObject) {
public JsonObject selectDataPlaneInstance(JsonObject requestObject) {
var request = transformerRegistry.transform(requestObject, SelectionRequest.class)
.orElseThrow(InvalidRequestException::new);

Expand All @@ -80,7 +80,7 @@ public JsonObject find(JsonObject requestObject) {

@Override
@POST
public JsonObject addEntry(JsonObject jsonObject) {
public JsonObject addDataPlaneInstance(JsonObject jsonObject) {
validatorRegistry.validate(DATAPLANE_INSTANCE_TYPE, jsonObject).orElseThrow(ValidationFailureException::new);

var instance = transformerRegistry.transform(jsonObject, DataPlaneInstance.class)
Expand All @@ -100,7 +100,7 @@ public JsonObject addEntry(JsonObject jsonObject) {

@Override
@GET
public JsonArray getAll() {
public JsonArray getAllDataPlaneInstances() {
var instances = selectionService.getAll();
return instances.stream()
.map(i -> transformerRegistry.transform(i, JsonObject.class))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import static org.eclipse.edc.spi.CoreConstants.EDC_NAMESPACE;

/**
* Represents the request body that the {@link DataplaneSelectorApi#find(jakarta.json.JsonObject)} endpoint requires
* Represents the request body that the {@link DataplaneSelectorApi#selectDataPlaneInstance(jakarta.json.JsonObject)} endpoint requires
* Contains source and destination address and optionally the name of a selection strategy
*/
public class SelectionRequest {
Expand Down

0 comments on commit 0df9e65

Please sign in to comment.