Skip to content

Commit f708f6f

Browse files
authored
feat: participant context api (#63)
1 parent ce028f4 commit f708f6f

File tree

15 files changed

+1216
-55
lines changed

15 files changed

+1216
-55
lines changed

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

Lines changed: 0 additions & 53 deletions
This file was deleted.

extensions/control-plane/api/management-api/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ dependencies {
2525
api(project(":extensions:control-plane:api:management-api:policy-definition-api"))
2626
api(project(":extensions:control-plane:api:management-api:contract-negotiation-api"))
2727
api(project(":extensions:control-plane:api:management-api:transfer-process-api"))
28+
api(project(":extensions:control-plane:api:management-api:participant-context-api"))
2829
api(project(":extensions:control-plane:api:management-api:management-api-configuration"))
2930
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
16+
17+
plugins {
18+
`java-library`
19+
id(libs.plugins.swagger.get().pluginId)
20+
21+
}
22+
23+
dependencies {
24+
25+
api(project(":spi:v-auth-spi"))
26+
implementation(libs.edc.spi.core)
27+
implementation(libs.edc.spi.contract)
28+
implementation(libs.edc.spi.controlplane)
29+
implementation(libs.edc.spi.asset)
30+
implementation(libs.edc.spi.validator)
31+
implementation(libs.edc.spi.web)
32+
implementation(libs.edc.spi.transform)
33+
implementation(libs.edc.lib.controlplane.transform)
34+
implementation(libs.jakarta.annotation)
35+
36+
implementation(libs.edc.lib.api)
37+
implementation(libs.edc.lib.jersey.providers)
38+
implementation(libs.edc.lib.mgmtapi)
39+
implementation(libs.edc.lib.validator)
40+
41+
testImplementation(testFixtures(libs.edc.core.jersey))
42+
testImplementation(libs.restAssured)
43+
testImplementation(libs.awaitility)
44+
}
45+
46+
edcBuild {
47+
swagger {
48+
apiGroup.set("management-api")
49+
}
50+
}
51+
52+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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.virtualized.connector.controlplane.api.management.participantcontext;
16+
17+
import jakarta.json.Json;
18+
import org.eclipse.edc.api.auth.spi.AuthorizationService;
19+
import org.eclipse.edc.api.management.schema.ManagementApiJsonSchema;
20+
import org.eclipse.edc.connector.controlplane.transform.edc.participantcontext.from.JsonObjectFromParticipantContextTransformer;
21+
import org.eclipse.edc.connector.controlplane.transform.edc.participantcontext.to.JsonObjectToParticipantContextTransformer;
22+
import org.eclipse.edc.jsonld.spi.JsonLd;
23+
import org.eclipse.edc.participantcontext.spi.service.ParticipantContextService;
24+
import org.eclipse.edc.runtime.metamodel.annotation.Extension;
25+
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
26+
import org.eclipse.edc.spi.monitor.Monitor;
27+
import org.eclipse.edc.spi.system.ServiceExtension;
28+
import org.eclipse.edc.spi.system.ServiceExtensionContext;
29+
import org.eclipse.edc.spi.types.TypeManager;
30+
import org.eclipse.edc.transform.spi.TypeTransformerRegistry;
31+
import org.eclipse.edc.validator.spi.JsonObjectValidatorRegistry;
32+
import org.eclipse.edc.virtualized.connector.controlplane.api.management.participantcontext.v4.ParticipantContextApiV4Controller;
33+
import org.eclipse.edc.web.jersey.providers.jsonld.JerseyJsonLdInterceptor;
34+
import org.eclipse.edc.web.spi.WebService;
35+
import org.eclipse.edc.web.spi.configuration.ApiContext;
36+
37+
import java.util.Map;
38+
39+
import static org.eclipse.edc.api.management.ManagementApi.MANAGEMENT_SCOPE_V4;
40+
import static org.eclipse.edc.spi.constants.CoreConstants.JSON_LD;
41+
import static org.eclipse.edc.virtualized.connector.controlplane.api.management.participantcontext.ParticipantContextManagementApiExtension.NAME;
42+
43+
@Extension(value = NAME)
44+
public class ParticipantContextManagementApiExtension implements ServiceExtension {
45+
46+
public static final String NAME = "ParticipantContext management API Extension";
47+
48+
@Inject
49+
private WebService webService;
50+
51+
@Inject
52+
private TypeTransformerRegistry transformerRegistry;
53+
54+
@Inject
55+
private JsonObjectValidatorRegistry validatorRegistry;
56+
57+
@Inject
58+
private JsonLd jsonLd;
59+
60+
@Inject
61+
private TypeManager typeManager;
62+
@Inject
63+
private AuthorizationService authorizationService;
64+
65+
@Inject
66+
private ParticipantContextService participantContextService;
67+
68+
@Inject
69+
private Monitor monitor;
70+
71+
@Override
72+
public void initialize(ServiceExtensionContext context) {
73+
var factory = Json.createBuilderFactory(Map.of());
74+
75+
var managementApiTransformerRegistry = transformerRegistry.forContext("management-api");
76+
77+
managementApiTransformerRegistry.register(new JsonObjectFromParticipantContextTransformer(factory));
78+
managementApiTransformerRegistry.register(new JsonObjectToParticipantContextTransformer());
79+
80+
webService.registerResource(ApiContext.MANAGEMENT, new ParticipantContextApiV4Controller(participantContextService, authorizationService, managementApiTransformerRegistry, monitor));
81+
webService.registerDynamicResource(ApiContext.MANAGEMENT, ParticipantContextApiV4Controller.class, new JerseyJsonLdInterceptor(jsonLd, typeManager, JSON_LD, MANAGEMENT_SCOPE_V4, validatorRegistry, ManagementApiJsonSchema.V4.version()));
82+
83+
}
84+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
* Copyright (c) 2024 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.virtualized.connector.controlplane.api.management.participantcontext.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.Parameter;
20+
import io.swagger.v3.oas.annotations.info.Info;
21+
import io.swagger.v3.oas.annotations.media.ArraySchema;
22+
import io.swagger.v3.oas.annotations.media.Content;
23+
import io.swagger.v3.oas.annotations.media.Schema;
24+
import io.swagger.v3.oas.annotations.parameters.RequestBody;
25+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
26+
import io.swagger.v3.oas.annotations.tags.Tag;
27+
import jakarta.json.JsonArray;
28+
import jakarta.json.JsonObject;
29+
import jakarta.ws.rs.core.SecurityContext;
30+
import org.eclipse.edc.api.management.schema.ManagementApiJsonSchema;
31+
32+
@OpenAPIDefinition(info = @Info(title = "ParticipantContext Management API", version = "v4alpha"))
33+
@Tag(name = "Participant Context v4alpha")
34+
public interface ParticipantContextApiV4 {
35+
36+
@Operation(description = "Creates a new ParticipantContext object.",
37+
requestBody = @RequestBody(content = @Content(schema = @Schema(ref = ManagementApiJsonSchema.V4.PARTICIPANT_CONTEXT), mediaType = "application/json")),
38+
responses = {
39+
@ApiResponse(responseCode = "201", description = "The ParticipantContext was created successfully, its API token is returned in the response body.",
40+
content = @Content(schema = @Schema(ref = ManagementApiJsonSchema.V4.ID_RESPONSE))),
41+
@ApiResponse(responseCode = "400", description = "Request body was malformed, or the request could not be processed",
42+
content = @Content(array = @ArraySchema(schema = @Schema(ref = ManagementApiJsonSchema.V4.API_ERROR)), mediaType = "application/json")),
43+
@ApiResponse(responseCode = "401", description = "The request could not be completed, because either the authentication was missing or was not valid.",
44+
content = @Content(array = @ArraySchema(schema = @Schema(ref = ManagementApiJsonSchema.V4.API_ERROR)), mediaType = "application/json")),
45+
@ApiResponse(responseCode = "409", description = "Can't create the ParticipantContext, because a object with the same ID already exists",
46+
content = @Content(array = @ArraySchema(schema = @Schema(ref = ManagementApiJsonSchema.V4.API_ERROR)), mediaType = "application/json"))
47+
}
48+
)
49+
JsonObject createParticipantV4(JsonObject participantContext);
50+
51+
@Operation(description = "Gets ParticipantContexts by ID.",
52+
responses = {
53+
@ApiResponse(responseCode = "200", description = "The list of ParticipantContexts.",
54+
content = @Content(schema = @Schema(ref = ManagementApiJsonSchema.V4.PARTICIPANT_CONTEXT))),
55+
@ApiResponse(responseCode = "400", description = "Request body was malformed, or the request could not be processed",
56+
content = @Content(array = @ArraySchema(schema = @Schema(ref = ManagementApiJsonSchema.V4.API_ERROR)), mediaType = "application/json")),
57+
@ApiResponse(responseCode = "401", description = "The request could not be completed, because either the authentication was missing or was not valid.",
58+
content = @Content(array = @ArraySchema(schema = @Schema(ref = ManagementApiJsonSchema.V4.API_ERROR)), mediaType = "application/json")),
59+
@ApiResponse(responseCode = "404", description = "A ParticipantContext with the given ID does not exist.",
60+
content = @Content(array = @ArraySchema(schema = @Schema(ref = ManagementApiJsonSchema.V4.API_ERROR)), mediaType = "application/json"))
61+
}
62+
)
63+
JsonObject getParticipantV4(String participantContextId, SecurityContext securityContext);
64+
65+
@Operation(description = "Updates a ParticipantContext object.",
66+
requestBody = @RequestBody(content = @Content(schema = @Schema(ref = ManagementApiJsonSchema.V4.PARTICIPANT_CONTEXT), mediaType = "application/json")),
67+
responses = {
68+
@ApiResponse(responseCode = "204", description = "The ParticipantContext was updated successfully."),
69+
@ApiResponse(responseCode = "400", description = "Request body was malformed, or the request could not be processed",
70+
content = @Content(array = @ArraySchema(schema = @Schema(ref = ManagementApiJsonSchema.V4.API_ERROR)), mediaType = "application/json")),
71+
@ApiResponse(responseCode = "401", description = "The request could not be completed, because either the authentication was missing or was not valid.",
72+
content = @Content(array = @ArraySchema(schema = @Schema(ref = ManagementApiJsonSchema.V4.API_ERROR)), mediaType = "application/json")),
73+
@ApiResponse(responseCode = "409", description = "Can't create the ParticipantContext, because a object with the same ID already exists",
74+
content = @Content(array = @ArraySchema(schema = @Schema(ref = ManagementApiJsonSchema.V4.API_ERROR)), mediaType = "application/json"))
75+
}
76+
)
77+
void updateParticipantV4(String id, JsonObject manifest);
78+
79+
@Operation(description = "Delete a ParticipantContext.",
80+
responses = {
81+
@ApiResponse(responseCode = "204", description = "The ParticipantContext was deleted successfully"),
82+
@ApiResponse(responseCode = "400", description = "Request body was malformed, or the request could not be processed",
83+
content = @Content(array = @ArraySchema(schema = @Schema(ref = ManagementApiJsonSchema.V4.API_ERROR)), mediaType = "application/json")),
84+
@ApiResponse(responseCode = "401", description = "The request could not be completed, because either the authentication was missing or was not valid.",
85+
content = @Content(array = @ArraySchema(schema = @Schema(ref = ManagementApiJsonSchema.V4.API_ERROR)), mediaType = "application/json")),
86+
@ApiResponse(responseCode = "404", description = "A ParticipantContext with the given ID does not exist.",
87+
content = @Content(array = @ArraySchema(schema = @Schema(ref = ManagementApiJsonSchema.V4.API_ERROR)), mediaType = "application/json"))
88+
}
89+
)
90+
void deleteParticipantV4(String participantContextId);
91+
92+
@Operation(description = "Get all DID documents across all Participant Contexts. Requires elevated access.",
93+
parameters = {
94+
@Parameter(name = "offset", description = "the paging offset. defaults to 0"),
95+
@Parameter(name = "limit", description = "the page size. defaults to 50")},
96+
responses = {
97+
@ApiResponse(responseCode = "200", description = "The list of ParticipantContexts.",
98+
content = @Content(array = @ArraySchema(schema = @Schema(ref = ManagementApiJsonSchema.V4.PARTICIPANT_CONTEXT)))),
99+
@ApiResponse(responseCode = "401", description = "The request could not be completed, because either the authentication was missing or was not valid.",
100+
content = @Content(array = @ArraySchema(schema = @Schema(ref = ManagementApiJsonSchema.V4.API_ERROR)), mediaType = "application/json")),
101+
@ApiResponse(responseCode = "400", description = "The query was malformed or was not understood by the server.",
102+
content = @Content(array = @ArraySchema(schema = @Schema(ref = ManagementApiJsonSchema.V4.API_ERROR)), mediaType = "application/json")),
103+
}
104+
)
105+
JsonArray getAllParticipantsV4(Integer offset, Integer limit);
106+
}

0 commit comments

Comments
 (0)