Skip to content

Commit bf35439

Browse files
authored
feat: more v4alpha controllers (#5176)
1 parent 23d7d8f commit bf35439

File tree

31 files changed

+2200
-235
lines changed

31 files changed

+2200
-235
lines changed

extensions/common/api/lib/management-api-lib/src/main/java/org/eclipse/edc/api/management/schema/ManagementApiJsonSchema.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ interface V4 {
2727
String POLICY_DEFINITION = EDC_MGMT_V4_SCHEMA_PREFIX + "/policy-definition-schema.json";
2828
String CONTRACT_DEFINITION = EDC_MGMT_V4_SCHEMA_PREFIX + "/contract-definition-schema.json";
2929
String DATAPLANE_INSTANCE = EDC_MGMT_V4_SCHEMA_PREFIX + "/dataplane-instance-schema.json";
30+
String DATA_ADDRESS = EDC_MGMT_V4_SCHEMA_PREFIX + "/data-address-schema.json#/definitions/DataAddressRoot";
3031
String EDR_ENTRY = EDC_MGMT_V4_SCHEMA_PREFIX + "/edr-entry-schema.json";
3132
String POLICY_EVALUATION_REQUEST = EDC_MGMT_V4_SCHEMA_PREFIX + "/policy-evaluation-plan-request-schema.json";
3233
String POLICY_EVALUATION_PLAN = EDC_MGMT_V4_SCHEMA_PREFIX + "/policy-evaluation-plan-schema.json";

extensions/common/api/management-api-configuration/src/main/resources/management-api-version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{
99
"version": "4.0.0-alpha",
1010
"urlPath": "/v4alpha",
11-
"lastUpdated": "2025-08-01T14:26:00Z",
11+
"lastUpdated": "2025-08-19T14:26:00Z",
1212
"maturity": "alpha"
1313
}
1414
]

extensions/common/api/management-api-schema-validator/src/main/resources/schema/management/v4/data-address-schema.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@
2424
"@type",
2525
"type"
2626
]
27+
},
28+
"DataAddressRoot": {
29+
"type": "object",
30+
"allOf": [
31+
{
32+
"properties": {
33+
"@context": {
34+
"$ref": "https://w3id.org/edc/connector/management/schema/v4/context-schema.json"
35+
}
36+
}
37+
},
38+
{
39+
"$ref": "#/definitions/DataAddress"
40+
}
41+
],
42+
"required": [
43+
"@context",
44+
"@type"
45+
]
2746
}
2847
}
2948
}

extensions/control-plane/api/management-api/contract-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/ContractDefinitionApiExtension.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.eclipse.edc.connector.controlplane.api.management.contractdefinition.transform.JsonObjectFromContractDefinitionTransformer;
2121
import org.eclipse.edc.connector.controlplane.api.management.contractdefinition.transform.JsonObjectToContractDefinitionTransformer;
2222
import org.eclipse.edc.connector.controlplane.api.management.contractdefinition.v3.ContractDefinitionApiV3Controller;
23+
import org.eclipse.edc.connector.controlplane.api.management.contractdefinition.v4.ContractDefinitionApiV4Controller;
2324
import org.eclipse.edc.connector.controlplane.api.management.contractdefinition.validation.ContractDefinitionValidator;
2425
import org.eclipse.edc.connector.controlplane.services.spi.contractdefinition.ContractDefinitionService;
2526
import org.eclipse.edc.jsonld.spi.JsonLd;
@@ -38,6 +39,7 @@
3839
import java.util.Map;
3940

4041
import static org.eclipse.edc.api.management.ManagementApi.MANAGEMENT_SCOPE;
42+
import static org.eclipse.edc.api.management.ManagementApi.MANAGEMENT_SCOPE_V4;
4143
import static org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractDefinition.CONTRACT_DEFINITION_TYPE;
4244
import static org.eclipse.edc.spi.constants.CoreConstants.JSON_LD;
4345

@@ -85,5 +87,8 @@ public void initialize(ServiceExtensionContext context) {
8587
webService.registerResource(ApiContext.MANAGEMENT, new ContractDefinitionApiV3Controller(managementApiTransformerRegistry, service, context.getMonitor(), validatorRegistry));
8688
webService.registerDynamicResource(ApiContext.MANAGEMENT, ContractDefinitionApiV3Controller.class, new JerseyJsonLdInterceptor(jsonLd, typeManager, JSON_LD, MANAGEMENT_SCOPE));
8789

90+
webService.registerResource(ApiContext.MANAGEMENT, new ContractDefinitionApiV4Controller(managementApiTransformerRegistry, service, context.getMonitor(), validatorRegistry));
91+
webService.registerDynamicResource(ApiContext.MANAGEMENT, ContractDefinitionApiV4Controller.class, new JerseyJsonLdInterceptor(jsonLd, typeManager, JSON_LD, MANAGEMENT_SCOPE_V4, validatorRegistry, "v4"));
92+
8893
}
8994
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Copyright (c) 2025 Metaform Systems, Inc.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Apache License, Version 2.0 which is available at
6+
* https://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* SPDX-License-Identifier: Apache-2.0
9+
*
10+
* Contributors:
11+
* Metaform Systems, Inc. - initial API and implementation
12+
*
13+
*/
14+
15+
package org.eclipse.edc.connector.controlplane.api.management.contractdefinition.v4;
16+
17+
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
18+
import io.swagger.v3.oas.annotations.Operation;
19+
import io.swagger.v3.oas.annotations.info.Info;
20+
import io.swagger.v3.oas.annotations.media.ArraySchema;
21+
import io.swagger.v3.oas.annotations.media.Content;
22+
import io.swagger.v3.oas.annotations.media.Schema;
23+
import io.swagger.v3.oas.annotations.parameters.RequestBody;
24+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
25+
import io.swagger.v3.oas.annotations.tags.Tag;
26+
import jakarta.json.JsonArray;
27+
import jakarta.json.JsonObject;
28+
import org.eclipse.edc.api.management.schema.ManagementApiJsonSchema;
29+
import org.eclipse.edc.api.model.ApiCoreSchema;
30+
31+
@OpenAPIDefinition(info = @Info(version = "v4alpha"))
32+
@Tag(name = "Contract Definition v4alpha")
33+
public interface ContractDefinitionApiV4 {
34+
35+
@Operation(description = "Returns all contract definitions according to a query",
36+
requestBody = @RequestBody(content = @Content(schema = @Schema(ref = ManagementApiJsonSchema.V4.QUERY_SPEC))),
37+
responses = {
38+
@ApiResponse(responseCode = "200", description = "The contract definitions matching the query",
39+
content = @Content(array = @ArraySchema(schema = @Schema(ref = ManagementApiJsonSchema.V4.CONTRACT_DEFINITION)))),
40+
@ApiResponse(responseCode = "400", description = "Request was malformed",
41+
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class))))
42+
}
43+
)
44+
JsonArray queryContractDefinitionsV4(JsonObject querySpecJson);
45+
46+
@Operation(description = "Gets an contract definition with the given ID",
47+
responses = {
48+
@ApiResponse(responseCode = "200", description = "The contract definition",
49+
content = @Content(schema = @Schema(ref = ManagementApiJsonSchema.V4.CONTRACT_DEFINITION))),
50+
@ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null",
51+
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))),
52+
@ApiResponse(responseCode = "404", description = "An contract agreement with the given ID does not exist",
53+
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class))))
54+
}
55+
)
56+
JsonObject getContractDefinitionV4(String id);
57+
58+
@Operation(description = "Creates a new contract definition",
59+
requestBody = @RequestBody(content = @Content(schema = @Schema(ref = ManagementApiJsonSchema.V4.CONTRACT_DEFINITION))),
60+
responses = {
61+
@ApiResponse(responseCode = "200", description = "contract definition was created successfully. Returns the Contract Definition Id and created timestamp",
62+
content = @Content(schema = @Schema(ref = ManagementApiJsonSchema.V4.ID_RESPONSE))),
63+
@ApiResponse(responseCode = "400", description = "Request body was malformed",
64+
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))),
65+
@ApiResponse(responseCode = "409", description = "Could not create contract definition, because a contract definition with that ID already exists",
66+
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class))))}
67+
)
68+
JsonObject createContractDefinitionV4(JsonObject createObject);
69+
70+
@Operation(description = "Removes a contract definition with the given ID if possible. " +
71+
"DANGER ZONE: Note that deleting contract definitions can have unexpected results, especially for contract offers that have been sent out or ongoing or contract negotiations.",
72+
responses = {
73+
@ApiResponse(responseCode = "204", description = "Contract definition was deleted successfully"),
74+
@ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null",
75+
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))),
76+
@ApiResponse(responseCode = "404", description = "A contract definition with the given ID does not exist",
77+
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class))))
78+
}
79+
)
80+
void deleteContractDefinitionV4(String id);
81+
82+
@Operation(description = "Updated a contract definition with the given ID. The supplied JSON structure must be a valid JSON-LD object",
83+
requestBody = @RequestBody(content = @Content(schema = @Schema(ref = ManagementApiJsonSchema.V4.CONTRACT_DEFINITION))),
84+
responses = {
85+
@ApiResponse(responseCode = "204", description = "Contract definition was updated successfully"),
86+
@ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null",
87+
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))),
88+
@ApiResponse(responseCode = "404", description = "A contract definition with the given ID does not exist",
89+
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class))))
90+
}
91+
)
92+
void updateContractDefinitionV4(JsonObject updateObject);
93+
94+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright (c) 2025 Metaform Systems, Inc.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Apache License, Version 2.0 which is available at
6+
* https://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* SPDX-License-Identifier: Apache-2.0
9+
*
10+
* Contributors:
11+
* Metaform Systems, Inc. - initial API and implementation
12+
*
13+
*/
14+
15+
package org.eclipse.edc.connector.controlplane.api.management.contractdefinition.v4;
16+
17+
import jakarta.json.JsonArray;
18+
import jakarta.json.JsonObject;
19+
import jakarta.ws.rs.Consumes;
20+
import jakarta.ws.rs.DELETE;
21+
import jakarta.ws.rs.GET;
22+
import jakarta.ws.rs.POST;
23+
import jakarta.ws.rs.PUT;
24+
import jakarta.ws.rs.Path;
25+
import jakarta.ws.rs.PathParam;
26+
import jakarta.ws.rs.Produces;
27+
import org.eclipse.edc.connector.controlplane.api.management.contractdefinition.BaseContractDefinitionApiController;
28+
import org.eclipse.edc.connector.controlplane.services.spi.contractdefinition.ContractDefinitionService;
29+
import org.eclipse.edc.spi.monitor.Monitor;
30+
import org.eclipse.edc.transform.spi.TypeTransformerRegistry;
31+
import org.eclipse.edc.validator.spi.JsonObjectValidatorRegistry;
32+
import org.eclipse.edc.web.spi.validation.SchemaType;
33+
34+
import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON;
35+
import static org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractDefinition.CONTRACT_DEFINITION_TYPE_TERM;
36+
import static org.eclipse.edc.spi.query.QuerySpec.EDC_QUERY_SPEC_TYPE_TERM;
37+
38+
@Consumes(APPLICATION_JSON)
39+
@Produces(APPLICATION_JSON)
40+
@Path("/v4alpha/contractdefinitions")
41+
public class ContractDefinitionApiV4Controller extends BaseContractDefinitionApiController implements ContractDefinitionApiV4 {
42+
public ContractDefinitionApiV4Controller(TypeTransformerRegistry transformerRegistry, ContractDefinitionService service, Monitor monitor, JsonObjectValidatorRegistry validatorRegistry) {
43+
super(transformerRegistry, service, monitor, validatorRegistry);
44+
}
45+
46+
@POST
47+
@Path("/request")
48+
@Override
49+
public JsonArray queryContractDefinitionsV4(@SchemaType(EDC_QUERY_SPEC_TYPE_TERM) JsonObject querySpecJson) {
50+
return queryContractDefinitions(querySpecJson);
51+
}
52+
53+
@GET
54+
@Path("{id}")
55+
@Override
56+
public JsonObject getContractDefinitionV4(@PathParam("id") String id) {
57+
return getContractDefinition(id);
58+
}
59+
60+
@POST
61+
@Override
62+
public JsonObject createContractDefinitionV4(@SchemaType(CONTRACT_DEFINITION_TYPE_TERM) JsonObject createObject) {
63+
return createContractDefinition(createObject);
64+
}
65+
66+
@DELETE
67+
@Path("{id}")
68+
@Override
69+
public void deleteContractDefinitionV4(@PathParam("id") String id) {
70+
deleteContractDefinition(id);
71+
}
72+
73+
@PUT
74+
@Override
75+
public void updateContractDefinitionV4(@SchemaType(CONTRACT_DEFINITION_TYPE_TERM) JsonObject updateObject) {
76+
updateContractDefinition(updateObject);
77+
}
78+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2025 Metaform Systems, Inc.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Apache License, Version 2.0 which is available at
6+
* https://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* SPDX-License-Identifier: Apache-2.0
9+
*
10+
* Contributors:
11+
* Metaform Systems, Inc. - initial API and implementation
12+
*
13+
*/
14+
15+
package org.eclipse.edc.connector.controlplane.api.management.contractdefinition.v4;
16+
17+
import io.restassured.specification.RequestSpecification;
18+
import org.eclipse.edc.connector.controlplane.api.management.contractdefinition.BaseContractDefinitionApiControllerTest;
19+
20+
import static io.restassured.RestAssured.given;
21+
22+
class ContractDefinitionApiV4ControllerTest extends BaseContractDefinitionApiControllerTest {
23+
@Override
24+
protected RequestSpecification baseRequest() {
25+
return given()
26+
.baseUri("http://localhost:" + port + "/v4alpha/contractdefinitions")
27+
.when();
28+
29+
}
30+
31+
@Override
32+
protected Object controller() {
33+
return new ContractDefinitionApiV4Controller(transformerRegistry, service, monitor, validatorRegistry);
34+
}
35+
}

extensions/control-plane/api/management-api/edr-cache-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/edr/EdrCacheApiExtension.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import jakarta.json.Json;
1818
import org.eclipse.edc.connector.controlplane.api.management.edr.transform.JsonObjectFromEndpointDataReferenceEntryTransformer;
1919
import org.eclipse.edc.connector.controlplane.api.management.edr.v3.EdrCacheApiV3Controller;
20+
import org.eclipse.edc.connector.controlplane.api.management.edr.v4.EdrCacheApiV4Controller;
2021
import org.eclipse.edc.edr.spi.store.EndpointDataReferenceStore;
2122
import org.eclipse.edc.jsonld.spi.JsonLd;
2223
import org.eclipse.edc.runtime.metamodel.annotation.Extension;
@@ -34,6 +35,7 @@
3435
import java.util.Map;
3536

3637
import static org.eclipse.edc.api.management.ManagementApi.MANAGEMENT_SCOPE;
38+
import static org.eclipse.edc.api.management.ManagementApi.MANAGEMENT_SCOPE_V4;
3739
import static org.eclipse.edc.connector.controlplane.api.management.edr.EdrCacheApiExtension.NAME;
3840
import static org.eclipse.edc.spi.constants.CoreConstants.JSON_LD;
3941

@@ -74,5 +76,8 @@ public void initialize(ServiceExtensionContext context) {
7476
webService.registerResource(ApiContext.MANAGEMENT, new EdrCacheApiV3Controller(edrStore, managementTypeTransformerRegistry, validator, monitor));
7577
webService.registerDynamicResource(ApiContext.MANAGEMENT, EdrCacheApiV3Controller.class, new JerseyJsonLdInterceptor(jsonLd, typeManager, JSON_LD, MANAGEMENT_SCOPE));
7678

79+
webService.registerResource(ApiContext.MANAGEMENT, new EdrCacheApiV4Controller(edrStore, managementTypeTransformerRegistry, validator, monitor));
80+
webService.registerDynamicResource(ApiContext.MANAGEMENT, EdrCacheApiV4Controller.class, new JerseyJsonLdInterceptor(jsonLd, typeManager, JSON_LD, MANAGEMENT_SCOPE_V4, validator, "v4"));
81+
7782
}
7883
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright (c) 2025 Metaform Systems, Inc.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Apache License, Version 2.0 which is available at
6+
* https://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* SPDX-License-Identifier: Apache-2.0
9+
*
10+
* Contributors:
11+
* Metaform Systems, Inc. - initial API and implementation
12+
*
13+
*/
14+
15+
package org.eclipse.edc.connector.controlplane.api.management.edr.v4;
16+
17+
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
18+
import io.swagger.v3.oas.annotations.Operation;
19+
import io.swagger.v3.oas.annotations.info.Info;
20+
import io.swagger.v3.oas.annotations.media.ArraySchema;
21+
import io.swagger.v3.oas.annotations.media.Content;
22+
import io.swagger.v3.oas.annotations.media.Schema;
23+
import io.swagger.v3.oas.annotations.parameters.RequestBody;
24+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
25+
import io.swagger.v3.oas.annotations.tags.Tag;
26+
import jakarta.json.JsonArray;
27+
import jakarta.json.JsonObject;
28+
import org.eclipse.edc.api.management.schema.ManagementApiJsonSchema;
29+
import org.eclipse.edc.api.model.ApiCoreSchema;
30+
31+
@OpenAPIDefinition(info = @Info(version = "v4alpha"))
32+
@Tag(name = "EDR Cache v4alpha")
33+
public interface EdrCacheApiV4 {
34+
35+
@Operation(description = "Request all Edr entries according to a particular query",
36+
requestBody = @RequestBody(
37+
content = @Content(schema = @Schema(ref = ManagementApiJsonSchema.V4.QUERY_SPEC))
38+
),
39+
responses = {
40+
@ApiResponse(responseCode = "200", description = "The edr entries matching the query",
41+
content = @Content(array = @ArraySchema(schema = @Schema(ref = ManagementApiJsonSchema.V4.EDR_ENTRY)))),
42+
@ApiResponse(responseCode = "400", description = "Request body was malformed",
43+
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class))))
44+
})
45+
JsonArray requestEdrEntriesV4(JsonObject querySpecJson);
46+
47+
@Operation(description = "Gets the EDR data address with the given transfer process ID",
48+
responses = {
49+
@ApiResponse(responseCode = "200", description = "The data address",
50+
content = @Content(schema = @Schema(ref = ManagementApiJsonSchema.V4.DATA_ADDRESS))),
51+
@ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null",
52+
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))),
53+
@ApiResponse(responseCode = "404", description = "An EDR data address with the given transfer process ID does not exist",
54+
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class))))
55+
}
56+
)
57+
JsonObject getEdrEntryDataAddressV4(String transferProcessId);
58+
59+
@Operation(description = "Removes an EDR entry given the transfer process ID",
60+
responses = {
61+
@ApiResponse(responseCode = "204", description = "EDR entry was deleted successfully"),
62+
@ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null",
63+
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))),
64+
@ApiResponse(responseCode = "404", description = "An EDR entry with the given ID does not exist",
65+
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class))))
66+
})
67+
void removeEdrEntryV4(String transferProcessId);
68+
69+
}

0 commit comments

Comments
 (0)