-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: bump the Dataplane Selector management API endpoints to
v3
(#…
…4215) * feat: bump the Dataplane Selector management API endpoints to `v3` * DEPENDENCIES
- Loading branch information
1 parent
88e2efe
commit 6eb2a5b
Showing
18 changed files
with
287 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...main/java/org/eclipse/edc/connector/dataplane/selector/api/v3/DataplaneSelectorApiV3.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation | ||
* | ||
*/ | ||
|
||
package org.eclipse.edc.connector.dataplane.selector.api.v3; | ||
|
||
import io.swagger.v3.oas.annotations.OpenAPIDefinition; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.info.Info; | ||
import io.swagger.v3.oas.annotations.media.ArraySchema; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.json.JsonArray; | ||
import jakarta.ws.rs.GET; | ||
import org.eclipse.edc.connector.dataplane.selector.api.schemas.DataPlaneInstanceSchema; | ||
|
||
@OpenAPIDefinition(info = @Info(version = "v3")) | ||
@Tag(name = "Dataplane Selector V3") | ||
public interface DataplaneSelectorApiV3 { | ||
|
||
@Operation(method = "GET", | ||
operationId = "getAllDataPlaneInstancesV3", | ||
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 getAllDataPlaneInstances(); | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
...org/eclipse/edc/connector/dataplane/selector/api/v3/DataplaneSelectorApiV3Controller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation | ||
* | ||
*/ | ||
|
||
package org.eclipse.edc.connector.dataplane.selector.api.v3; | ||
|
||
import jakarta.json.JsonArray; | ||
import jakarta.json.JsonObject; | ||
import jakarta.ws.rs.Consumes; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
import org.eclipse.edc.connector.dataplane.selector.spi.DataPlaneSelectorService; | ||
import org.eclipse.edc.connector.dataplane.selector.spi.instance.DataPlaneInstance; | ||
import org.eclipse.edc.spi.result.Result; | ||
import org.eclipse.edc.transform.spi.TypeTransformerRegistry; | ||
|
||
import static jakarta.json.stream.JsonCollectors.toJsonArray; | ||
import static org.eclipse.edc.web.spi.exception.ServiceResultHandler.exceptionMapper; | ||
|
||
@Consumes({ MediaType.APPLICATION_JSON }) | ||
@Produces({ MediaType.APPLICATION_JSON }) | ||
@Path("/v3/dataplanes") | ||
public class DataplaneSelectorApiV3Controller implements DataplaneSelectorApiV3 { | ||
|
||
private final DataPlaneSelectorService selectionService; | ||
private final TypeTransformerRegistry transformerRegistry; | ||
|
||
public DataplaneSelectorApiV3Controller(DataPlaneSelectorService selectionService, TypeTransformerRegistry transformerRegistry) { | ||
this.selectionService = selectionService; | ||
this.transformerRegistry = transformerRegistry; | ||
} | ||
|
||
@Override | ||
@GET | ||
public JsonArray getAllDataPlaneInstances() { | ||
var instances = selectionService.getAll().orElseThrow(exceptionMapper(DataPlaneInstance.class)); | ||
return instances.stream() | ||
.map(i -> transformerRegistry.transform(i, JsonObject.class)) | ||
.filter(Result::succeeded) | ||
.map(Result::getContent) | ||
.collect(toJsonArray()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.