From da2090524f6572775732cd832f656cb201301d19 Mon Sep 17 00:00:00 2001 From: andrea bertagnolli Date: Tue, 14 Jan 2025 11:43:14 +0100 Subject: [PATCH] refactor: cleanup deprecated management-api endpoint (#4713) --- .../resources/management-api-version.json | 4 +- .../HashicorpVaultClientIntegrationTest.java | 2 +- .../catalog/CatalogApiExtension.java | 2 - .../management/catalog/v2/CatalogApiV2.java | 251 -------------- .../catalog/v2/CatalogApiV2Controller.java | 59 ---- .../catalog/CatalogApiExtensionTest.java | 2 - .../v2/CatalogApiV2ControllerTest.java | 32 -- .../ContractAgreementApiExtension.java | 7 +- .../v2/ContractAgreementApiV2.java | 77 ----- .../v2/ContractAgreementApiV2Controller.java | 65 ---- .../ContractAgreementApiExtensionTest.java | 4 +- .../ContractAgreementApiV2ControllerTest.java | 34 -- .../ContractDefinitionApiExtension.java | 2 - .../v2/ContractDefinitionApiV2.java | 161 --------- .../v2/ContractDefinitionApiV2Controller.java | 81 ----- .../ContractDefinitionApiExtensionTest.java | 2 - .../ContractDefinitionApiTest.java | 4 +- ...ContractDefinitionApiV2ControllerTest.java | 36 -- .../ContractNegotiationApiExtension.java | 2 - .../v2/ContractNegotiationApiV2.java | 221 ------------- .../ContractNegotiationApiV2Controller.java | 88 ----- .../BaseContractNegotiationApiTest.java | 4 +- .../ContractNegotiationApiExtensionTest.java | 2 - ...ontractNegotiationApiV2ControllerTest.java | 37 --- .../v2/ContractNegotiationApiV2Test.java | 43 --- .../management/edr/EdrCacheApiExtension.java | 2 - .../api/management/edr/v1/EdrCacheApiV1.java | 98 ------ .../edr/v1/EdrCacheApiV1Controller.java | 67 ---- .../edr/EdrCacheApiExtensionTest.java | 2 - .../api/management/edr/EdrCacheApiTest.java | 2 +- .../edr/v1/EdrCacheApiControllerTest.java | 39 --- .../policy/PolicyDefinitionApiExtension.java | 2 - .../policy/v2/PolicyDefinitionApiV2.java | 180 ---------- .../v2/PolicyDefinitionApiV2Controller.java | 82 ----- .../PolicyDefinitionApiExtensionTest.java | 2 - .../policy/PolicyDefinitionApiTest.java | 4 +- .../PolicyDefinitionApiV2ControllerTest.java | 36 -- .../secret/SecretsApiExtension.java | 2 - .../management/secret/v1/SecretsApiV1.java | 132 -------- .../secret/v1/SecretsApiV1Controller.java | 75 ----- .../secret/SecretsApiExtensionTest.java | 2 - .../api/management/secret/SecretsApiTest.java | 4 +- .../secret/v1/SecretsApiV1ControllerTest.java | 35 -- .../TransferProcessApiExtension.java | 2 - .../v2/TransferProcessApiV2.java | 312 ------------------ .../v2/TransferProcessApiV2Controller.java | 104 ------ .../TransferProcessApiExtensionTest.java | 2 - .../TransferProcessApiV2ControllerTest.java | 34 -- .../DataPlaneSelectorApiExtension.java | 20 -- .../selector/api/model/SelectionRequest.java | 92 ------ .../api/v2/DataPlaneInstanceSchemaV2.java | 63 ---- .../api/v2/DataplaneSelectorApiV2.java | 75 ----- .../v2/DataplaneSelectorApiV2Controller.java | 116 ------- .../api/v2/SelectionRequestSchema.java | 49 --- .../api/v4/DataplaneSelectorApiV4.java | 2 +- ...onObjectToSelectionRequestTransformer.java | 53 --- .../DataPlaneSelectorApiExtensionTest.java | 3 - .../DataPlaneSelectorApiV2ControllerTest.java | 284 ---------------- .../api/v3/DataPlaneApiSelectorV3Test.java | 2 - .../api/v4/DataPlaneApiSelectorV4Test.java | 2 - ...jectToSelectionRequestTransformerTest.java | 77 ----- 61 files changed, 16 insertions(+), 3264 deletions(-) delete mode 100644 extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/catalog/v2/CatalogApiV2.java delete mode 100644 extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/catalog/v2/CatalogApiV2Controller.java delete mode 100644 extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/catalog/v2/CatalogApiV2ControllerTest.java delete mode 100644 extensions/control-plane/api/management-api/contract-agreement-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractagreement/v2/ContractAgreementApiV2.java delete mode 100644 extensions/control-plane/api/management-api/contract-agreement-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractagreement/v2/ContractAgreementApiV2Controller.java delete mode 100644 extensions/control-plane/api/management-api/contract-agreement-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractagreement/v2/ContractAgreementApiV2ControllerTest.java delete mode 100644 extensions/control-plane/api/management-api/contract-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/v2/ContractDefinitionApiV2.java delete mode 100644 extensions/control-plane/api/management-api/contract-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/v2/ContractDefinitionApiV2Controller.java delete mode 100644 extensions/control-plane/api/management-api/contract-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/v2/ContractDefinitionApiV2ControllerTest.java delete mode 100644 extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/v2/ContractNegotiationApiV2.java delete mode 100644 extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/v2/ContractNegotiationApiV2Controller.java delete mode 100644 extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/v2/ContractNegotiationApiV2ControllerTest.java delete mode 100644 extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/v2/ContractNegotiationApiV2Test.java delete mode 100644 extensions/control-plane/api/management-api/edr-cache-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/edr/v1/EdrCacheApiV1.java delete mode 100644 extensions/control-plane/api/management-api/edr-cache-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/edr/v1/EdrCacheApiV1Controller.java delete mode 100644 extensions/control-plane/api/management-api/edr-cache-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/edr/v1/EdrCacheApiControllerTest.java delete mode 100644 extensions/control-plane/api/management-api/policy-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/policy/v2/PolicyDefinitionApiV2.java delete mode 100644 extensions/control-plane/api/management-api/policy-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/policy/v2/PolicyDefinitionApiV2Controller.java delete mode 100644 extensions/control-plane/api/management-api/policy-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/policy/v2/PolicyDefinitionApiV2ControllerTest.java delete mode 100644 extensions/control-plane/api/management-api/secrets-api/src/main/java/org/eclipse/edc/connector/api/management/secret/v1/SecretsApiV1.java delete mode 100644 extensions/control-plane/api/management-api/secrets-api/src/main/java/org/eclipse/edc/connector/api/management/secret/v1/SecretsApiV1Controller.java delete mode 100644 extensions/control-plane/api/management-api/secrets-api/src/test/java/org/eclipse/edc/connector/api/management/secret/v1/SecretsApiV1ControllerTest.java delete mode 100644 extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/transferprocess/v2/TransferProcessApiV2.java delete mode 100644 extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/transferprocess/v2/TransferProcessApiV2Controller.java delete mode 100644 extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/transferprocess/v2/TransferProcessApiV2ControllerTest.java delete mode 100644 extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/model/SelectionRequest.java delete mode 100644 extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/v2/DataPlaneInstanceSchemaV2.java delete mode 100644 extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/v2/DataplaneSelectorApiV2.java delete mode 100644 extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/v2/DataplaneSelectorApiV2Controller.java delete mode 100644 extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/v2/SelectionRequestSchema.java delete mode 100644 extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/transformer/JsonObjectToSelectionRequestTransformer.java delete mode 100644 extensions/data-plane-selector/data-plane-selector-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/api/v2/DataPlaneSelectorApiV2ControllerTest.java delete mode 100644 extensions/data-plane-selector/data-plane-selector-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/transformer/JsonObjectToSelectionRequestTransformerTest.java diff --git a/extensions/common/api/management-api-configuration/src/main/resources/management-api-version.json b/extensions/common/api/management-api-configuration/src/main/resources/management-api-version.json index 7a8bf93746d..f3c38c3b46f 100644 --- a/extensions/common/api/management-api-configuration/src/main/resources/management-api-version.json +++ b/extensions/common/api/management-api-configuration/src/main/resources/management-api-version.json @@ -1,8 +1,8 @@ [ { - "version": "3.0.5", + "version": "3.0.6", "urlPath": "/v3", - "lastUpdated": "2025-01-08T14:26:00Z", + "lastUpdated": "2025-01-10T16:46:00Z", "maturity": "stable" }, { diff --git a/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultClientIntegrationTest.java b/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultClientIntegrationTest.java index bb02af0ca88..c9128ba7fe1 100644 --- a/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultClientIntegrationTest.java +++ b/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultClientIntegrationTest.java @@ -190,4 +190,4 @@ void beforeEach() throws IOException, InterruptedException { ); } } -} \ No newline at end of file +} diff --git a/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/catalog/CatalogApiExtension.java b/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/catalog/CatalogApiExtension.java index a2b24d078d5..cf8ffd75586 100644 --- a/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/catalog/CatalogApiExtension.java +++ b/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/catalog/CatalogApiExtension.java @@ -16,7 +16,6 @@ import org.eclipse.edc.connector.controlplane.api.management.catalog.transform.JsonObjectToCatalogRequestTransformer; import org.eclipse.edc.connector.controlplane.api.management.catalog.transform.JsonObjectToDatasetRequestTransformer; -import org.eclipse.edc.connector.controlplane.api.management.catalog.v2.CatalogApiV2Controller; import org.eclipse.edc.connector.controlplane.api.management.catalog.v3.CatalogApiV3Controller; import org.eclipse.edc.connector.controlplane.api.management.catalog.v31alpha.CatalogApiV31AlphaController; import org.eclipse.edc.connector.controlplane.api.management.catalog.validation.CatalogRequestValidator; @@ -66,7 +65,6 @@ public void initialize(ServiceExtensionContext context) { transformerRegistry.register(new JsonObjectToDatasetRequestTransformer()); var managementApiTransformerRegistry = transformerRegistry.forContext("management-api"); - webService.registerResource(ApiContext.MANAGEMENT, new CatalogApiV2Controller(service, managementApiTransformerRegistry, validatorRegistry, context.getMonitor())); webService.registerResource(ApiContext.MANAGEMENT, new CatalogApiV3Controller(service, managementApiTransformerRegistry, validatorRegistry)); webService.registerResource(ApiContext.MANAGEMENT, new CatalogApiV31AlphaController(service, managementApiTransformerRegistry, validatorRegistry)); diff --git a/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/catalog/v2/CatalogApiV2.java b/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/catalog/v2/CatalogApiV2.java deleted file mode 100644 index 8978d7aa317..00000000000 --- a/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/catalog/v2/CatalogApiV2.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * 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.controlplane.api.management.catalog.v2; - -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.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.parameters.RequestBody; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.json.JsonObject; -import jakarta.ws.rs.container.AsyncResponse; -import jakarta.ws.rs.container.Suspended; -import org.eclipse.edc.api.model.ApiCoreSchema; - -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.NOT_REQUIRED; -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; -import static org.eclipse.edc.connector.controlplane.catalog.spi.CatalogRequest.CATALOG_REQUEST_TYPE; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.CONTEXT; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; - -@OpenAPIDefinition(info = @Info(version = "v2")) -@Tag(name = "Catalog V2") -public interface CatalogApiV2 { - - @Operation( - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = CatalogRequestSchema.class))), - responses = { @ApiResponse( - content = @Content( - mediaType = "application/json", - schema = @Schema(implementation = CatalogSchema.class) - ), - description = "Gets contract offers (=catalog) of a single connector") }, - deprecated = true - ) - @Deprecated(since = "0.7.0") - void requestCatalogV2(JsonObject request, @Suspended AsyncResponse response); - - @Operation( - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = DatasetRequestSchema.class))), - responses = { @ApiResponse( - content = @Content( - mediaType = "application/json", - schema = @Schema(implementation = DatasetSchema.class) - ), - description = "Gets single dataset from a connector") }, - deprecated = true - ) - @Deprecated(since = "0.7.0") - void getDatasetV2(JsonObject request, @Suspended AsyncResponse response); - - @Schema(name = "CatalogRequest", example = CatalogRequestSchema.CATALOG_REQUEST_EXAMPLE) - record CatalogRequestSchema( - @Schema(name = CONTEXT, requiredMode = REQUIRED) - Object context, - @Schema(name = TYPE, example = CATALOG_REQUEST_TYPE) - String type, - @Schema(requiredMode = REQUIRED) - String counterPartyAddress, - // Switch to required in the next API iteration - @Schema(requiredMode = NOT_REQUIRED) - String counterPartyId, - @Schema(requiredMode = REQUIRED) - String protocol, - ApiCoreSchema.QuerySpecSchema querySpec) { - - public static final String CATALOG_REQUEST_EXAMPLE = """ - { - "@context": { "@vocab": "https://w3id.org/edc/v0.0.1/ns/" }, - "@type": "CatalogRequest", - "counterPartyAddress": "http://provider-address", - "counterPartyId": "providerId", - "protocol": "dataspace-protocol-http", - "querySpec": { - "offset": 0, - "limit": 50, - "sortOrder": "DESC", - "sortField": "fieldName", - "filterExpression": [] - } - } - """; - } - - @Schema(name = "DatasetRequest", example = DatasetRequestSchema.DATASET_REQUEST_EXAMPLE) - record DatasetRequestSchema( - @Schema(name = TYPE, example = CATALOG_REQUEST_TYPE) - String type, - String counterPartyAddress, - String counterPartyId, - String protocol, - ApiCoreSchema.QuerySpecSchema querySpec) { - - public static final String DATASET_REQUEST_EXAMPLE = """ - { - "@context": { "@vocab": "https://w3id.org/edc/v0.0.1/ns/" }, - "@type": "DatasetRequest", - "@id": "dataset-id", - "counterPartyAddress": "http://counter-party-address", - "counterPartyId": "counter-party-id", - "protocol": "dataspace-protocol-http" - } - """; - } - - @Schema(name = "Catalog", description = "DCAT catalog", example = CatalogSchema.CATALOG_EXAMPLE) - record CatalogSchema( - ) { - public static final String CATALOG_EXAMPLE = """ - { - "@id": "7df65569-8c59-4013-b1c0-fa14f6641bf2", - "@type": "dcat:Catalog", - "dcat:dataset": { - "@id": "bcca61be-e82e-4da6-bfec-9716a56cef35", - "@type": "dcat:Dataset", - "odrl:hasPolicy": { - "@id": "OGU0ZTMzMGMtODQ2ZS00ZWMxLThmOGQtNWQxNWM0NmI2NmY4:YmNjYTYxYmUtZTgyZS00ZGE2LWJmZWMtOTcxNmE1NmNlZjM1:NDY2ZTZhMmEtNjQ1Yy00ZGQ0LWFlZDktMjdjNGJkZTU4MDNj", - "@type": "odrl:Set", - "odrl:permission": { - "odrl:target": "bcca61be-e82e-4da6-bfec-9716a56cef35", - "odrl:action": { - "odrl:type": "http://www.w3.org/ns/odrl/2/use" - }, - "odrl:constraint": { - "odrl:and": [ - { - "odrl:leftOperand": "https://w3id.org/edc/v0.0.1/ns/inForceDate", - "odrl:operator": { - "@id": "odrl:gteq" - }, - "odrl:rightOperand": "2023-07-07T07:19:58.585601395Z" - }, - { - "odrl:leftOperand": "https://w3id.org/edc/v0.0.1/ns/inForceDate", - "odrl:operator": { - "@id": "odrl:lteq" - }, - "odrl:rightOperand": "2023-07-12T07:19:58.585601395Z" - } - ] - } - }, - "odrl:prohibition": [], - "odrl:obligation": [] - }, - "dcat:distribution": [ - { - "@type": "dcat:Distribution", - "dct:format": { - "@id": "HttpData" - }, - "dcat:accessService": "5e839777-d93e-4785-8972-1005f51cf367" - } - ], - "description": "description", - "id": "bcca61be-e82e-4da6-bfec-9716a56cef35" - }, - "dcat:service": { - "@id": "5e839777-d93e-4785-8972-1005f51cf367", - "@type": "dcat:DataService", - "dct:terms": "connector", - "dct:endpointUrl": "http://localhost:16806/protocol" - }, - "dspace:participantId": "urn:connector:provider", - "@context": { - "@vocab": "https://w3id.org/edc/v0.0.1/ns/", - "dct": "http://purl.org/dc/terms/", - "edc": "https://w3id.org/edc/v0.0.1/ns/", - "dcat": "http://www.w3.org/ns/dcat#", - "odrl": "http://www.w3.org/ns/odrl/2/", - "dspace": "https://w3id.org/dspace/v0.8/" - } - } - """; - } - - @Schema(name = "Dataset", description = "DCAT dataset", example = DatasetSchema.DATASET_EXAMPLE) - record DatasetSchema( - ) { - public static final String DATASET_EXAMPLE = """ - { - "@id": "bcca61be-e82e-4da6-bfec-9716a56cef35", - "@type": "dcat:Dataset", - "odrl:hasPolicy": { - "@id": "OGU0ZTMzMGMtODQ2ZS00ZWMxLThmOGQtNWQxNWM0NmI2NmY4:YmNjYTYxYmUtZTgyZS00ZGE2LWJmZWMtOTcxNmE1NmNlZjM1:NDY2ZTZhMmEtNjQ1Yy00ZGQ0LWFlZDktMjdjNGJkZTU4MDNj", - "@type": "odrl:Set", - "odrl:permission": { - "odrl:target": "bcca61be-e82e-4da6-bfec-9716a56cef35", - "odrl:action": { - "odrl:type": "http://www.w3.org/ns/odrl/2/use" - }, - "odrl:constraint": { - "odrl:and": [ - { - "odrl:leftOperand": "https://w3id.org/edc/v0.0.1/ns/inForceDate", - "odrl:operator": { - "@id": "odrl:gteq" - }, - "odrl:rightOperand": "2023-07-07T07:19:58.585601395Z" - }, - { - "odrl:leftOperand": "https://w3id.org/edc/v0.0.1/ns/inForceDate", - "odrl:operator": { - "@id": "odrl:lteq" - }, - "odrl:rightOperand": "2023-07-12T07:19:58.585601395Z" - } - ] - } - }, - "odrl:prohibition": [], - "odrl:obligation": [], - "odrl:target": "bcca61be-e82e-4da6-bfec-9716a56cef35" - }, - "dcat:distribution": [ - { - "@type": "dcat:Distribution", - "dct:format": { - "@id": "HttpData" - }, - "dcat:accessService": "5e839777-d93e-4785-8972-1005f51cf367" - } - ], - "description": "description", - "id": "bcca61be-e82e-4da6-bfec-9716a56cef35", - "@context": { - "@vocab": "https://w3id.org/edc/v0.0.1/ns/", - "dct": "http://purl.org/dc/terms/", - "edc": "https://w3id.org/edc/v0.0.1/ns/", - "dcat": "http://www.w3.org/ns/dcat#", - "odrl": "http://www.w3.org/ns/odrl/2/", - "dspace": "https://w3id.org/dspace/v0.8/" - } - } - """; - } -} diff --git a/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/catalog/v2/CatalogApiV2Controller.java b/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/catalog/v2/CatalogApiV2Controller.java deleted file mode 100644 index 21e5d6f9cec..00000000000 --- a/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/catalog/v2/CatalogApiV2Controller.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.controlplane.api.management.catalog.v2; - -import jakarta.json.JsonObject; -import jakarta.ws.rs.Consumes; -import jakarta.ws.rs.POST; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.Produces; -import jakarta.ws.rs.container.AsyncResponse; -import jakarta.ws.rs.container.Suspended; -import org.eclipse.edc.connector.controlplane.api.management.catalog.BaseCatalogApiController; -import org.eclipse.edc.connector.controlplane.services.spi.catalog.CatalogService; -import org.eclipse.edc.spi.monitor.Monitor; -import org.eclipse.edc.transform.spi.TypeTransformerRegistry; -import org.eclipse.edc.validator.spi.JsonObjectValidatorRegistry; - -import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON; -import static org.eclipse.edc.api.ApiWarnings.deprecationWarning; - -@Consumes(APPLICATION_JSON) -@Produces(APPLICATION_JSON) -@Path("/v2/catalog") -public class CatalogApiV2Controller extends BaseCatalogApiController implements CatalogApiV2 { - private final Monitor monitor; - - public CatalogApiV2Controller(CatalogService service, TypeTransformerRegistry transformerRegistry, JsonObjectValidatorRegistry validatorRegistry, Monitor monitor) { - super(service, transformerRegistry, validatorRegistry); - this.monitor = monitor; - } - - @POST - @Path("/request") - @Override - public void requestCatalogV2(JsonObject requestBody, @Suspended AsyncResponse response) { - monitor.warning(deprecationWarning("/v2", "/v3")); - requestCatalog(requestBody, response); - } - - @POST - @Path("dataset/request") - @Override - public void getDatasetV2(JsonObject requestBody, @Suspended AsyncResponse response) { - monitor.warning(deprecationWarning("/v2", "/v3")); - getDataset(requestBody, response); - } -} diff --git a/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/catalog/CatalogApiExtensionTest.java b/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/catalog/CatalogApiExtensionTest.java index 22e7d184d2e..e536a6a37f1 100644 --- a/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/catalog/CatalogApiExtensionTest.java +++ b/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/catalog/CatalogApiExtensionTest.java @@ -14,7 +14,6 @@ package org.eclipse.edc.connector.controlplane.api.management.catalog; -import org.eclipse.edc.connector.controlplane.api.management.catalog.v2.CatalogApiV2Controller; import org.eclipse.edc.connector.controlplane.api.management.catalog.v3.CatalogApiV3Controller; import org.eclipse.edc.connector.controlplane.api.management.catalog.v31alpha.CatalogApiV31AlphaController; import org.eclipse.edc.junit.extensions.DependencyInjectionExtension; @@ -57,7 +56,6 @@ void initiate_shouldRegisterValidators(CatalogApiExtension extension, ServiceExt void initiate_shouldRegisterControllers(CatalogApiExtension extension, ServiceExtensionContext context) { extension.initialize(context); - verify(webService).registerResource(any(), isA(CatalogApiV2Controller.class)); verify(webService).registerResource(any(), isA(CatalogApiV3Controller.class)); verify(webService).registerResource(any(), isA(CatalogApiV31AlphaController.class)); } diff --git a/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/catalog/v2/CatalogApiV2ControllerTest.java b/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/catalog/v2/CatalogApiV2ControllerTest.java deleted file mode 100644 index 07a242ab6f8..00000000000 --- a/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/catalog/v2/CatalogApiV2ControllerTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.controlplane.api.management.catalog.v2; - -import org.eclipse.edc.connector.controlplane.api.management.catalog.BaseCatalogApiControllerTest; - -import static org.mockito.Mockito.mock; - -class CatalogApiV2ControllerTest extends BaseCatalogApiControllerTest { - - @Override - protected Object controller() { - return new CatalogApiV2Controller(service, transformerRegistry, validatorRegistry, mock()); - } - - @Override - protected String baseUrl() { - return "/v2/catalog"; - } -} \ No newline at end of file diff --git a/extensions/control-plane/api/management-api/contract-agreement-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractagreement/ContractAgreementApiExtension.java b/extensions/control-plane/api/management-api/contract-agreement-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractagreement/ContractAgreementApiExtension.java index ec8ebc59fd4..9268a152634 100644 --- a/extensions/control-plane/api/management-api/contract-agreement-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractagreement/ContractAgreementApiExtension.java +++ b/extensions/control-plane/api/management-api/contract-agreement-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractagreement/ContractAgreementApiExtension.java @@ -15,7 +15,6 @@ package org.eclipse.edc.connector.controlplane.api.management.contractagreement; -import org.eclipse.edc.connector.controlplane.api.management.contractagreement.v2.ContractAgreementApiV2Controller; import org.eclipse.edc.connector.controlplane.api.management.contractagreement.v3.ContractAgreementApiV3Controller; import org.eclipse.edc.connector.controlplane.api.management.contractagreement.v4alpha.ContractAgreementApiV4AlphaController; import org.eclipse.edc.connector.controlplane.services.spi.contractagreement.ContractAgreementService; @@ -57,11 +56,9 @@ public void initialize(ServiceExtensionContext context) { var monitor = context.getMonitor(); var managementApiTransformerRegistry = transformerRegistry.forContext(MANAGEMENT_API_CONTEXT); - var managementApiTransformerRegistryV31Alpha = managementApiTransformerRegistry.forContext(MANAGEMENT_API_V_4_ALPHA); + var managementApiTransformerRegistryV4Alpha = managementApiTransformerRegistry.forContext(MANAGEMENT_API_V_4_ALPHA); - - webService.registerResource(ApiContext.MANAGEMENT, new ContractAgreementApiV2Controller(service, managementApiTransformerRegistry, monitor, validatorRegistry)); webService.registerResource(ApiContext.MANAGEMENT, new ContractAgreementApiV3Controller(service, managementApiTransformerRegistry, monitor, validatorRegistry)); - webService.registerResource(ApiContext.MANAGEMENT, new ContractAgreementApiV4AlphaController(service, managementApiTransformerRegistryV31Alpha, monitor, validatorRegistry)); + webService.registerResource(ApiContext.MANAGEMENT, new ContractAgreementApiV4AlphaController(service, managementApiTransformerRegistryV4Alpha, monitor, validatorRegistry)); } } diff --git a/extensions/control-plane/api/management-api/contract-agreement-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractagreement/v2/ContractAgreementApiV2.java b/extensions/control-plane/api/management-api/contract-agreement-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractagreement/v2/ContractAgreementApiV2.java deleted file mode 100644 index 6276c7269c8..00000000000 --- a/extensions/control-plane/api/management-api/contract-agreement-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractagreement/v2/ContractAgreementApiV2.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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.controlplane.api.management.contractagreement.v2; - -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.parameters.RequestBody; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.json.JsonArray; -import jakarta.json.JsonObject; -import org.eclipse.edc.api.management.schema.ManagementApiSchema; -import org.eclipse.edc.api.model.ApiCoreSchema; - -@OpenAPIDefinition(info = @Info(version = "v2")) -@Tag(name = "Contract Agreement V2") -public interface ContractAgreementApiV2 { - - @Operation(description = "Gets all contract agreements according to a particular query", - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = ApiCoreSchema.QuerySpecSchema.class))), - responses = { - @ApiResponse(responseCode = "200", description = "The contract agreements matching the query", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ManagementApiSchema.ContractAgreementSchema.class)))), - @ApiResponse(responseCode = "400", description = "Request body was malformed", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }, - deprecated = true - ) - @Deprecated(since = "0.7.0") - JsonArray queryAgreementsV2(JsonObject querySpecJson); - - @Operation(description = "Gets an contract agreement with the given ID", - responses = { - @ApiResponse(responseCode = "200", description = "The contract agreement", - content = @Content(schema = @Schema(implementation = ManagementApiSchema.ContractAgreementSchema.class))), - @ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "An contract agreement with the given ID does not exist", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }, - deprecated = true - ) - @Deprecated(since = "0.7.0") - JsonObject getAgreementByIdV2(String id); - - - @Operation(description = "Gets a contract negotiation with the given contract agreement ID", - responses = { - @ApiResponse(responseCode = "200", description = "The contract negotiation", - content = @Content(schema = @Schema(implementation = ManagementApiSchema.ContractNegotiationSchema.class))), - @ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "An contract agreement with the given ID does not exist", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }, - deprecated = true - ) - @Deprecated(since = "0.7.0") - JsonObject getNegotiationByAgreementIdV2(String id); - -} diff --git a/extensions/control-plane/api/management-api/contract-agreement-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractagreement/v2/ContractAgreementApiV2Controller.java b/extensions/control-plane/api/management-api/contract-agreement-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractagreement/v2/ContractAgreementApiV2Controller.java deleted file mode 100644 index 7094f6ffba7..00000000000 --- a/extensions/control-plane/api/management-api/contract-agreement-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractagreement/v2/ContractAgreementApiV2Controller.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.controlplane.api.management.contractagreement.v2; - -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; -import jakarta.ws.rs.PathParam; -import jakarta.ws.rs.Produces; -import org.eclipse.edc.connector.controlplane.api.management.contractagreement.BaseContractAgreementApiController; -import org.eclipse.edc.connector.controlplane.services.spi.contractagreement.ContractAgreementService; -import org.eclipse.edc.spi.monitor.Monitor; -import org.eclipse.edc.transform.spi.TypeTransformerRegistry; -import org.eclipse.edc.validator.spi.JsonObjectValidatorRegistry; - -import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON; -import static org.eclipse.edc.api.ApiWarnings.deprecationWarning; - -@Consumes(APPLICATION_JSON) -@Produces(APPLICATION_JSON) -@Path("/v2/contractagreements") -public class ContractAgreementApiV2Controller extends BaseContractAgreementApiController implements ContractAgreementApiV2 { - public ContractAgreementApiV2Controller(ContractAgreementService service, TypeTransformerRegistry transformerRegistry, Monitor monitor, JsonObjectValidatorRegistry validatorRegistry) { - super(service, transformerRegistry, monitor, validatorRegistry); - } - - @POST - @Path("/request") - @Override - public JsonArray queryAgreementsV2(JsonObject querySpecJson) { - monitor.warning(deprecationWarning("/v2", "/v3")); - return queryAgreements(querySpecJson); - } - - @GET - @Path("{id}") - @Override - public JsonObject getAgreementByIdV2(@PathParam("id") String id) { - monitor.warning(deprecationWarning("/v2", "/v3")); - return getAgreementById(id); - } - - @GET - @Path("{id}/negotiation") - @Override - public JsonObject getNegotiationByAgreementIdV2(@PathParam("id") String id) { - monitor.warning(deprecationWarning("/v2", "/v3")); - return getNegotiationByAgreementId(id); - } -} diff --git a/extensions/control-plane/api/management-api/contract-agreement-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractagreement/ContractAgreementApiExtensionTest.java b/extensions/control-plane/api/management-api/contract-agreement-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractagreement/ContractAgreementApiExtensionTest.java index d6a2e334c75..9665938609e 100644 --- a/extensions/control-plane/api/management-api/contract-agreement-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractagreement/ContractAgreementApiExtensionTest.java +++ b/extensions/control-plane/api/management-api/contract-agreement-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractagreement/ContractAgreementApiExtensionTest.java @@ -14,7 +14,6 @@ package org.eclipse.edc.connector.controlplane.api.management.contractagreement; -import org.eclipse.edc.connector.controlplane.api.management.contractagreement.v2.ContractAgreementApiV2Controller; import org.eclipse.edc.connector.controlplane.api.management.contractagreement.v3.ContractAgreementApiV3Controller; import org.eclipse.edc.junit.extensions.DependencyInjectionExtension; import org.eclipse.edc.spi.system.ServiceExtensionContext; @@ -48,7 +47,6 @@ void setUp(ServiceExtensionContext context) { void initiate_shouldRegisterControllers(ContractAgreementApiExtension extension, ServiceExtensionContext context) { extension.initialize(context); - verify(webService).registerResource(any(), isA(ContractAgreementApiV2Controller.class)); verify(webService).registerResource(any(), isA(ContractAgreementApiV3Controller.class)); } -} \ No newline at end of file +} diff --git a/extensions/control-plane/api/management-api/contract-agreement-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractagreement/v2/ContractAgreementApiV2ControllerTest.java b/extensions/control-plane/api/management-api/contract-agreement-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractagreement/v2/ContractAgreementApiV2ControllerTest.java deleted file mode 100644 index 5f0394afa9b..00000000000 --- a/extensions/control-plane/api/management-api/contract-agreement-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractagreement/v2/ContractAgreementApiV2ControllerTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.controlplane.api.management.contractagreement.v2; - -import io.restassured.specification.RequestSpecification; -import org.eclipse.edc.connector.controlplane.api.management.contractagreement.BaseContractAgreementApiControllerTest; - -import static io.restassured.RestAssured.given; - -class ContractAgreementApiV2ControllerTest extends BaseContractAgreementApiControllerTest { - - @Override - protected Object controller() { - return new ContractAgreementApiV2Controller(service, transformerRegistry, monitor, validatorRegistry); - } - - protected RequestSpecification baseRequest() { - return given() - .baseUri("http://localhost:" + port + "/v2/contractagreements") - .when(); - } -} \ No newline at end of file diff --git a/extensions/control-plane/api/management-api/contract-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/ContractDefinitionApiExtension.java b/extensions/control-plane/api/management-api/contract-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/ContractDefinitionApiExtension.java index 289391c0477..71cc9391a2a 100644 --- a/extensions/control-plane/api/management-api/contract-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/ContractDefinitionApiExtension.java +++ b/extensions/control-plane/api/management-api/contract-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/ContractDefinitionApiExtension.java @@ -19,7 +19,6 @@ import jakarta.json.Json; import org.eclipse.edc.connector.controlplane.api.management.contractdefinition.transform.JsonObjectFromContractDefinitionTransformer; import org.eclipse.edc.connector.controlplane.api.management.contractdefinition.transform.JsonObjectToContractDefinitionTransformer; -import org.eclipse.edc.connector.controlplane.api.management.contractdefinition.v2.ContractDefinitionApiV2Controller; import org.eclipse.edc.connector.controlplane.api.management.contractdefinition.v3.ContractDefinitionApiV3Controller; import org.eclipse.edc.connector.controlplane.api.management.contractdefinition.validation.ContractDefinitionValidator; import org.eclipse.edc.connector.controlplane.services.spi.contractdefinition.ContractDefinitionService; @@ -78,7 +77,6 @@ public void initialize(ServiceExtensionContext context) { var managementApiTransformerRegistry = transformerRegistry.forContext("management-api"); - webService.registerResource(ApiContext.MANAGEMENT, new ContractDefinitionApiV2Controller(managementApiTransformerRegistry, service, context.getMonitor(), validatorRegistry)); webService.registerResource(ApiContext.MANAGEMENT, new ContractDefinitionApiV3Controller(managementApiTransformerRegistry, service, context.getMonitor(), validatorRegistry)); } } diff --git a/extensions/control-plane/api/management-api/contract-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/v2/ContractDefinitionApiV2.java b/extensions/control-plane/api/management-api/contract-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/v2/ContractDefinitionApiV2.java deleted file mode 100644 index 3805af042a9..00000000000 --- a/extensions/control-plane/api/management-api/contract-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/v2/ContractDefinitionApiV2.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * 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.controlplane.api.management.contractdefinition.v2; - -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.parameters.RequestBody; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.json.JsonArray; -import jakarta.json.JsonObject; -import org.eclipse.edc.api.model.ApiCoreSchema; - -import java.util.List; - -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; -import static org.eclipse.edc.connector.controlplane.api.management.contractdefinition.v2.ContractDefinitionApiV2.ContractDefinitionInputSchema.CONTRACT_DEFINITION_INPUT_EXAMPLE; -import static org.eclipse.edc.connector.controlplane.api.management.contractdefinition.v2.ContractDefinitionApiV2.ContractDefinitionOutputSchema.CONTRACT_DEFINITION_OUTPUT_EXAMPLE; -import static org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractDefinition.CONTRACT_DEFINITION_TYPE; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.CONTEXT; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; - -@OpenAPIDefinition(info = @Info(version = "v2")) -@Tag(name = "Contract Definition V2") -public interface ContractDefinitionApiV2 { - - @Operation(description = "Returns all contract definitions according to a query", - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = ApiCoreSchema.QuerySpecSchema.class))), - responses = { - @ApiResponse(responseCode = "200", description = "The contract definitions matching the query", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ContractDefinitionOutputSchema.class)))), - @ApiResponse(responseCode = "400", description = "Request was malformed", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }, - deprecated = true - ) - @Deprecated(since = "0.7.0") - JsonArray queryContractDefinitionsV2(JsonObject querySpecJson); - - @Operation(description = "Gets an contract definition with the given ID", - responses = { - @ApiResponse(responseCode = "200", description = "The contract definition", - content = @Content(schema = @Schema(implementation = ContractDefinitionOutputSchema.class))), - @ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "An contract agreement with the given ID does not exist", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }, - deprecated = true - ) - @Deprecated(since = "0.7.0") - JsonObject getContractDefinitionV2(String id); - - @Operation(description = "Creates a new contract definition", - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = ContractDefinitionInputSchema.class))), - responses = { - @ApiResponse(responseCode = "200", description = "contract definition was created successfully. Returns the Contract Definition Id and created timestamp", - content = @Content(schema = @Schema(implementation = ApiCoreSchema.IdResponseSchema.class))), - @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)))) }, - deprecated = true - ) - @Deprecated(since = "0.7.0") - JsonObject createContractDefinitionV2(JsonObject createObject); - - @Operation(description = "Removes a contract definition with the given ID if possible. " + - "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.", - responses = { - @ApiResponse(responseCode = "204", description = "Contract definition was deleted successfully"), - @ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "A contract definition with the given ID does not exist", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }, - deprecated = true - ) - @Deprecated(since = "0.7.0") - void deleteContractDefinitionV2(String id); - - @Operation(description = "Updated a contract definition with the given ID. The supplied JSON structure must be a valid JSON-LD object", - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = ContractDefinitionInputSchema.class))), - responses = { - @ApiResponse(responseCode = "204", description = "Contract definition was updated successfully"), - @ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "A contract definition with the given ID does not exist", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }, - deprecated = true - ) - @Deprecated(since = "0.7.0") - void updateContractDefinitionV2(JsonObject updateObject); - - @Schema(name = "ContractDefinitionInput", example = CONTRACT_DEFINITION_INPUT_EXAMPLE) - record ContractDefinitionInputSchema( - @Schema(name = CONTEXT, requiredMode = REQUIRED) - Object context, - @Schema(name = ID) - String id, - @Schema(name = TYPE, example = CONTRACT_DEFINITION_TYPE) - String type, - @Schema(requiredMode = REQUIRED) - String accessPolicyId, - @Schema(requiredMode = REQUIRED) - String contractPolicyId, - @Schema(requiredMode = REQUIRED) - List assetsSelector) { - - public static final String CONTRACT_DEFINITION_INPUT_EXAMPLE = """ - { - "@context": { "@vocab": "https://w3id.org/edc/v0.0.1/ns/" }, - "@id": "definition-id", - "accessPolicyId": "asset-policy-id", - "contractPolicyId": "contract-policy-id", - "assetsSelector": [] - } - """; - } - - @Schema(name = "ContractDefinitionOutput", example = CONTRACT_DEFINITION_OUTPUT_EXAMPLE) - record ContractDefinitionOutputSchema( - @Schema(name = ID) - String id, - @Schema(name = TYPE, example = CONTRACT_DEFINITION_TYPE) - String type, - String accessPolicyId, - String contractPolicyId, - List assetsSelector, - long createdAt) { - - public static final String CONTRACT_DEFINITION_OUTPUT_EXAMPLE = """ - { - "@context": { "@vocab": "https://w3id.org/edc/v0.0.1/ns/" }, - "@id": "definition-id", - "accessPolicyId": "asset-policy-id", - "contractPolicyId": "contract-policy-id", - "assetsSelector": [], - "createdAt": 1688465655 - } - """; - } -} diff --git a/extensions/control-plane/api/management-api/contract-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/v2/ContractDefinitionApiV2Controller.java b/extensions/control-plane/api/management-api/contract-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/v2/ContractDefinitionApiV2Controller.java deleted file mode 100644 index a0ae952c3ad..00000000000 --- a/extensions/control-plane/api/management-api/contract-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/v2/ContractDefinitionApiV2Controller.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.controlplane.api.management.contractdefinition.v2; - -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; -import jakarta.ws.rs.PUT; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.PathParam; -import jakarta.ws.rs.Produces; -import org.eclipse.edc.connector.controlplane.api.management.contractdefinition.BaseContractDefinitionApiController; -import org.eclipse.edc.connector.controlplane.services.spi.contractdefinition.ContractDefinitionService; -import org.eclipse.edc.spi.monitor.Monitor; -import org.eclipse.edc.transform.spi.TypeTransformerRegistry; -import org.eclipse.edc.validator.spi.JsonObjectValidatorRegistry; - -import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON; -import static org.eclipse.edc.api.ApiWarnings.deprecationWarning; - -@Consumes(APPLICATION_JSON) -@Produces(APPLICATION_JSON) -@Path("/v2/contractdefinitions") -public class ContractDefinitionApiV2Controller extends BaseContractDefinitionApiController implements ContractDefinitionApiV2 { - public ContractDefinitionApiV2Controller(TypeTransformerRegistry transformerRegistry, ContractDefinitionService service, Monitor monitor, JsonObjectValidatorRegistry validatorRegistry) { - super(transformerRegistry, service, monitor, validatorRegistry); - } - - @POST - @Path("/request") - @Override - public JsonArray queryContractDefinitionsV2(JsonObject querySpecJson) { - monitor.warning(deprecationWarning("/v2", "/v3")); - return queryContractDefinitions(querySpecJson); - } - - @GET - @Path("{id}") - @Override - public JsonObject getContractDefinitionV2(@PathParam("id") String id) { - monitor.warning(deprecationWarning("/v2", "/v3")); - return getContractDefinition(id); - } - - @POST - @Override - public JsonObject createContractDefinitionV2(JsonObject createObject) { - monitor.warning(deprecationWarning("/v2", "/v3")); - return createContractDefinition(createObject); - } - - @DELETE - @Path("{id}") - @Override - public void deleteContractDefinitionV2(@PathParam("id") String id) { - monitor.warning(deprecationWarning("/v2", "/v3")); - deleteContractDefinition(id); - } - - @PUT - @Override - public void updateContractDefinitionV2(JsonObject updateObject) { - monitor.warning(deprecationWarning("/v2", "/v3")); - updateContractDefinition(updateObject); - } -} diff --git a/extensions/control-plane/api/management-api/contract-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/ContractDefinitionApiExtensionTest.java b/extensions/control-plane/api/management-api/contract-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/ContractDefinitionApiExtensionTest.java index a1728d7d78b..3dd58b87902 100644 --- a/extensions/control-plane/api/management-api/contract-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/ContractDefinitionApiExtensionTest.java +++ b/extensions/control-plane/api/management-api/contract-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/ContractDefinitionApiExtensionTest.java @@ -15,7 +15,6 @@ package org.eclipse.edc.connector.controlplane.api.management.contractdefinition; import org.eclipse.edc.boot.system.injection.ObjectFactory; -import org.eclipse.edc.connector.controlplane.api.management.contractdefinition.v2.ContractDefinitionApiV2Controller; import org.eclipse.edc.connector.controlplane.api.management.contractdefinition.v3.ContractDefinitionApiV3Controller; import org.eclipse.edc.junit.extensions.DependencyInjectionExtension; import org.eclipse.edc.spi.system.ServiceExtensionContext; @@ -58,7 +57,6 @@ void verifyValidatorIsRegistered(ServiceExtensionContext context) { void verifyControllersRegistered(ServiceExtensionContext context) { extension.initialize(context); - verify(webService).registerResource(any(), isA(ContractDefinitionApiV2Controller.class)); verify(webService).registerResource(any(), isA(ContractDefinitionApiV3Controller.class)); } diff --git a/extensions/control-plane/api/management-api/contract-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/ContractDefinitionApiTest.java b/extensions/control-plane/api/management-api/contract-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/ContractDefinitionApiTest.java index d84a2c5c7e9..7503df156da 100644 --- a/extensions/control-plane/api/management-api/contract-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/ContractDefinitionApiTest.java +++ b/extensions/control-plane/api/management-api/contract-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/ContractDefinitionApiTest.java @@ -29,8 +29,8 @@ import org.junit.jupiter.api.Test; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static org.eclipse.edc.connector.controlplane.api.management.contractdefinition.v2.ContractDefinitionApiV2.ContractDefinitionInputSchema.CONTRACT_DEFINITION_INPUT_EXAMPLE; -import static org.eclipse.edc.connector.controlplane.api.management.contractdefinition.v2.ContractDefinitionApiV2.ContractDefinitionOutputSchema.CONTRACT_DEFINITION_OUTPUT_EXAMPLE; +import static org.eclipse.edc.connector.controlplane.api.management.contractdefinition.v3.ContractDefinitionApiV3.ContractDefinitionInputSchema.CONTRACT_DEFINITION_INPUT_EXAMPLE; +import static org.eclipse.edc.connector.controlplane.api.management.contractdefinition.v3.ContractDefinitionApiV3.ContractDefinitionOutputSchema.CONTRACT_DEFINITION_OUTPUT_EXAMPLE; import static org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractDefinition.CONTRACT_DEFINITION_ACCESSPOLICY_ID; import static org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractDefinition.CONTRACT_DEFINITION_ASSETS_SELECTOR; import static org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractDefinition.CONTRACT_DEFINITION_CONTRACTPOLICY_ID; diff --git a/extensions/control-plane/api/management-api/contract-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/v2/ContractDefinitionApiV2ControllerTest.java b/extensions/control-plane/api/management-api/contract-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/v2/ContractDefinitionApiV2ControllerTest.java deleted file mode 100644 index 52d983579c4..00000000000 --- a/extensions/control-plane/api/management-api/contract-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractdefinition/v2/ContractDefinitionApiV2ControllerTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.controlplane.api.management.contractdefinition.v2; - -import io.restassured.specification.RequestSpecification; -import org.eclipse.edc.connector.controlplane.api.management.contractdefinition.BaseContractDefinitionApiControllerTest; - -import static io.restassured.RestAssured.given; - -class ContractDefinitionApiV2ControllerTest extends BaseContractDefinitionApiControllerTest { - - @Override - protected RequestSpecification baseRequest() { - return given() - .baseUri("http://localhost:" + port + "/v2/contractdefinitions") - .when(); - - } - - @Override - protected Object controller() { - return new ContractDefinitionApiV2Controller(transformerRegistry, service, monitor, validatorRegistry); - } -} \ No newline at end of file diff --git a/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/ContractNegotiationApiExtension.java b/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/ContractNegotiationApiExtension.java index 0412c0dfac0..7e5025c485b 100644 --- a/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/ContractNegotiationApiExtension.java +++ b/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/ContractNegotiationApiExtension.java @@ -20,7 +20,6 @@ import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.transform.JsonObjectToContractOfferTransformer; import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.transform.JsonObjectToContractRequestTransformer; import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.transform.JsonObjectToTerminateNegotiationCommandTransformer; -import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.v2.ContractNegotiationApiV2Controller; import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.v3.ContractNegotiationApiV3Controller; import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.validation.ContractRequestValidator; import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.validation.TerminateNegotiationValidator; @@ -77,7 +76,6 @@ public void initialize(ServiceExtensionContext context) { validatorRegistry.register(CONTRACT_REQUEST_TYPE, ContractRequestValidator.instance()); validatorRegistry.register(TERMINATE_NEGOTIATION_TYPE, TerminateNegotiationValidator.instance()); - webService.registerResource(ApiContext.MANAGEMENT, new ContractNegotiationApiV2Controller(service, managementApiTransformerRegistry, monitor, validatorRegistry)); webService.registerResource(ApiContext.MANAGEMENT, new ContractNegotiationApiV3Controller(service, managementApiTransformerRegistry, monitor, validatorRegistry)); } } diff --git a/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/v2/ContractNegotiationApiV2.java b/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/v2/ContractNegotiationApiV2.java deleted file mode 100644 index 8aae11f61fc..00000000000 --- a/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/v2/ContractNegotiationApiV2.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * 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.controlplane.api.management.contractnegotiation.v2; - -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.links.Link; -import io.swagger.v3.oas.annotations.links.LinkParameter; -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.parameters.RequestBody; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.json.JsonArray; -import jakarta.json.JsonObject; -import org.eclipse.edc.api.management.schema.ManagementApiSchema; -import org.eclipse.edc.api.model.ApiCoreSchema; -import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.model.NegotiationState; - -import java.util.List; - -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; -import static org.eclipse.edc.connector.controlplane.contract.spi.types.command.TerminateNegotiationCommand.TERMINATE_NEGOTIATION_TYPE; -import static org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractRequest.CONTRACT_REQUEST_TYPE; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.CONTEXT; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_POLICY_TYPE_OFFER; - -@OpenAPIDefinition(info = @Info(version = "v2")) -@Tag(name = "Contract Negotiation V2") -public interface ContractNegotiationApiV2 { - - @Operation(description = "Returns all contract negotiations according to a query", - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = ApiCoreSchema.QuerySpecSchema.class))), - responses = { - @ApiResponse(responseCode = "200", description = "The contract negotiations that match the query", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ManagementApiSchema.ContractNegotiationSchema.class)))), - @ApiResponse(responseCode = "400", description = "Request was malformed", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) }, - deprecated = true - ) - @Deprecated(since = "0.7.0") - JsonArray queryNegotiationsV2(JsonObject querySpecJson); - - @Operation(description = "Gets a contract negotiation with the given ID", - responses = { - @ApiResponse(responseCode = "200", description = "The contract negotiation", - content = @Content(schema = @Schema(implementation = ManagementApiSchema.ContractNegotiationSchema.class))), - @ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "An contract negotiation with the given ID does not exist", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }, - deprecated = true - ) - @Deprecated(since = "0.7.0") - JsonObject getNegotiationV2(String id); - - @Operation(description = "Gets the state of a contract negotiation with the given ID", - responses = { - @ApiResponse(responseCode = "200", description = "The contract negotiation's state", - content = @Content(schema = @Schema(implementation = NegotiationState.class))), - @ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "An contract negotiation with the given ID does not exist", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }, - deprecated = true - ) - @Deprecated(since = "0.7.0") - JsonObject getNegotiationStateV2(String id); - - @Operation(description = "Gets a contract agreement for a contract negotiation with the given ID", - responses = { - @ApiResponse(responseCode = "200", description = "The contract agreement that is attached to the negotiation, or null", - content = @Content(schema = @Schema(implementation = ManagementApiSchema.ContractAgreementSchema.class))), - @ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "An contract negotiation with the given ID does not exist", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }, - deprecated = true - ) - @Deprecated(since = "0.7.0") - JsonObject getAgreementForNegotiationV2(String negotiationId); - - @Operation(description = "Initiates a contract negotiation for a given offer and with the given counter part. Please note that successfully invoking this endpoint " + - "only means that the negotiation was initiated. Clients must poll the /{id}/state endpoint to track the state", - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = ContractRequestSchema.class))), - responses = { - @ApiResponse(responseCode = "200", description = "The negotiation was successfully initiated. Returns the contract negotiation ID and created timestamp", - content = @Content(schema = @Schema(implementation = ApiCoreSchema.IdResponseSchema.class)), - links = @Link(name = "poll-state", operationId = "getNegotiationStateV2", parameters = { - @LinkParameter(name = "id", expression = "$response.body#/id") - }) - ), - @ApiResponse(responseCode = "400", description = "Request body was malformed", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - }, - deprecated = true) - @Deprecated(since = "0.7.0") - JsonObject initiateContractNegotiationV2(JsonObject requestDto); - - @Operation(description = "Terminates the contract negotiation.", - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = TerminateNegotiationSchema.class))), - responses = { - @ApiResponse(responseCode = "200", description = "ContractNegotiation is terminating", - links = @Link(name = "poll-state", operationId = "getNegotiationStateV2")), - @ApiResponse(responseCode = "400", description = "Request was malformed", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "A contract negotiation with the given ID does not exist", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }, - deprecated = true - ) - @Deprecated(since = "0.7.0") - void terminateNegotiationV2(String id, JsonObject terminateNegotiation); - - @Schema(name = "ContractRequest", example = ContractRequestSchema.CONTRACT_REQUEST_EXAMPLE) - record ContractRequestSchema( - @Schema(name = CONTEXT, requiredMode = REQUIRED) - Object context, - @Schema(name = TYPE, example = CONTRACT_REQUEST_TYPE) - String type, - @Schema(requiredMode = REQUIRED) - String protocol, - @Schema(requiredMode = REQUIRED) - String counterPartyAddress, - @Schema(deprecated = true, description = "please use policy.assigner instead") - String providerId, - @Schema(requiredMode = REQUIRED) - OfferSchema policy, - List callbackAddresses) { - - // policy example took from https://w3c.github.io/odrl/bp/ - public static final String CONTRACT_REQUEST_EXAMPLE = """ - { - "@context": { "@vocab": "https://w3id.org/edc/v0.0.1/ns/" }, - "@type": "https://w3id.org/edc/v0.0.1/ns/ContractRequest", - "counterPartyAddress": "http://provider-address", - "protocol": "dataspace-protocol-http", - "policy": { - "@context": "http://www.w3.org/ns/odrl.jsonld", - "@type": "odrl:Offer", - "@id": "offer-id", - "assigner": "providerId", - "permission": [], - "prohibition": [], - "obligation": [], - "target": "assetId" - }, - "callbackAddresses": [{ - "transactional": false, - "uri": "http://callback/url", - "events": ["contract.negotiation", "transfer.process"], - "authKey": "auth-key", - "authCodeId": "auth-code-id" - }] - } - """; - } - - @Schema(name = "Offer", description = "ODRL offer", example = OfferSchema.OFFER_EXAMPLE) - record OfferSchema( - @Schema(name = TYPE, example = ODRL_POLICY_TYPE_OFFER) - String type, - @Schema(name = ID, requiredMode = REQUIRED) - String id, - @Schema(requiredMode = REQUIRED) - String assigner, - @Schema(requiredMode = REQUIRED) - String target - ) { - public static final String OFFER_EXAMPLE = """ - { - "@context": "http://www.w3.org/ns/odrl.jsonld", - "@type": "odrl:Offer", - "@id": "offer-id", - "assigner": "providerId", - "target": "assetId", - "permission": [], - "prohibition": [], - "obligation": [] - } - """; - } - - @Schema(example = TerminateNegotiationSchema.TERMINATE_NEGOTIATION_EXAMPLE) - record TerminateNegotiationSchema( - @Schema(name = TYPE, example = TERMINATE_NEGOTIATION_TYPE) - String ldType, - @Schema(name = ID) - String id, - String reason - ) { - public static final String TERMINATE_NEGOTIATION_EXAMPLE = """ - { - "@context": { "@vocab": "https://w3id.org/edc/v0.0.1/ns/" }, - "@type": "https://w3id.org/edc/v0.0.1/ns/TerminateNegotiation", - "@id": "negotiation-id", - "reason": "a reason to terminate" - } - """; - } - -} diff --git a/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/v2/ContractNegotiationApiV2Controller.java b/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/v2/ContractNegotiationApiV2Controller.java deleted file mode 100644 index 1c350a2e92e..00000000000 --- a/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/v2/ContractNegotiationApiV2Controller.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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.controlplane.api.management.contractnegotiation.v2; - -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; -import jakarta.ws.rs.PathParam; -import jakarta.ws.rs.Produces; -import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.BaseContractNegotiationApiController; -import org.eclipse.edc.connector.controlplane.services.spi.contractnegotiation.ContractNegotiationService; -import org.eclipse.edc.spi.monitor.Monitor; -import org.eclipse.edc.transform.spi.TypeTransformerRegistry; -import org.eclipse.edc.validator.spi.JsonObjectValidatorRegistry; - -import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON; -import static org.eclipse.edc.api.ApiWarnings.deprecationWarning; - -@Consumes(APPLICATION_JSON) -@Produces(APPLICATION_JSON) -@Path("/v2/contractnegotiations") -public class ContractNegotiationApiV2Controller extends BaseContractNegotiationApiController implements ContractNegotiationApiV2 { - public ContractNegotiationApiV2Controller(ContractNegotiationService service, TypeTransformerRegistry transformerRegistry, Monitor monitor, JsonObjectValidatorRegistry validatorRegistry) { - super(service, transformerRegistry, monitor, validatorRegistry); - } - - @POST - @Path("/request") - @Override - public JsonArray queryNegotiationsV2(JsonObject querySpecJson) { - monitor.warning(deprecationWarning("/v2", "/v3")); - return queryNegotiations(querySpecJson); - } - - @GET - @Path("/{id}") - @Override - public JsonObject getNegotiationV2(@PathParam("id") String id) { - monitor.warning(deprecationWarning("/v2", "/v3")); - return getNegotiation(id); - } - - @GET - @Path("/{id}/state") - @Override - public JsonObject getNegotiationStateV2(@PathParam("id") String id) { - monitor.warning(deprecationWarning("/v2", "/v3")); - return getNegotiationState(id); - } - - @GET - @Path("/{id}/agreement") - @Override - public JsonObject getAgreementForNegotiationV2(@PathParam("id") String negotiationId) { - monitor.warning(deprecationWarning("/v2", "/v3")); - return getAgreementForNegotiation(negotiationId); - } - - @POST - @Override - public JsonObject initiateContractNegotiationV2(JsonObject requestObject) { - monitor.warning(deprecationWarning("/v2", "/v3")); - return initiateContractNegotiation(requestObject); - } - - @POST - @Path("/{id}/terminate") - @Override - public void terminateNegotiationV2(@PathParam("id") String id, JsonObject terminateNegotiation) { - monitor.warning(deprecationWarning("/v2", "/v3")); - terminateNegotiation(id, terminateNegotiation); - } -} diff --git a/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/BaseContractNegotiationApiTest.java b/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/BaseContractNegotiationApiTest.java index be21b8b6553..9e655f2a4d1 100644 --- a/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/BaseContractNegotiationApiTest.java +++ b/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/BaseContractNegotiationApiTest.java @@ -21,7 +21,7 @@ import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.transform.JsonObjectToContractOfferTransformer; import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.transform.JsonObjectToContractRequestTransformer; import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.transform.JsonObjectToTerminateNegotiationCommandTransformer; -import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.v2.ContractNegotiationApiV2; +import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.v3.ContractNegotiationApiV3; import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.validation.ContractRequestValidator; import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.validation.TerminateNegotiationValidator; import org.eclipse.edc.connector.controlplane.contract.spi.types.command.TerminateNegotiationCommand; @@ -82,7 +82,7 @@ void contractRequestExample() throws JsonProcessingException { void offerExample() throws JsonProcessingException { var validator = ContractRequestValidator.offerValidator(JsonObjectValidator.newValidator()).build(); - var jsonObject = objectMapper.readValue(ContractNegotiationApiV2.OfferSchema.OFFER_EXAMPLE, JsonObject.class); + var jsonObject = objectMapper.readValue(ContractNegotiationApiV3.OfferSchema.OFFER_EXAMPLE, JsonObject.class); assertThat(jsonObject).isNotNull(); var expanded = jsonLd.expand(jsonObject); diff --git a/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/ContractNegotiationApiExtensionTest.java b/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/ContractNegotiationApiExtensionTest.java index 9c69a957e0e..ba938631efe 100644 --- a/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/ContractNegotiationApiExtensionTest.java +++ b/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/ContractNegotiationApiExtensionTest.java @@ -18,7 +18,6 @@ import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.transform.JsonObjectFromNegotiationStateTransformer; import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.transform.JsonObjectToContractOfferTransformer; import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.transform.JsonObjectToTerminateNegotiationCommandTransformer; -import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.v2.ContractNegotiationApiV2Controller; import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.v3.ContractNegotiationApiV3Controller; import org.eclipse.edc.junit.extensions.DependencyInjectionExtension; import org.eclipse.edc.spi.system.ServiceExtensionContext; @@ -65,7 +64,6 @@ void initiate_shouldRegisterValidators(ServiceExtensionContext context, Contract void initiate_shouldRegisterControllers(ServiceExtensionContext context, ContractNegotiationApiExtension extension) { extension.initialize(context); - verify(webService).registerResource(any(), isA(ContractNegotiationApiV2Controller.class)); verify(webService).registerResource(any(), isA(ContractNegotiationApiV3Controller.class)); } diff --git a/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/v2/ContractNegotiationApiV2ControllerTest.java b/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/v2/ContractNegotiationApiV2ControllerTest.java deleted file mode 100644 index 4dbde87e70a..00000000000 --- a/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/v2/ContractNegotiationApiV2ControllerTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.controlplane.api.management.contractnegotiation.v2; - -import io.restassured.specification.RequestSpecification; -import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.BaseContractNegotiationApiControllerTest; -import org.eclipse.edc.junit.annotations.ApiTest; - -import static io.restassured.RestAssured.given; - -@ApiTest -class ContractNegotiationApiV2ControllerTest extends BaseContractNegotiationApiControllerTest { - - @Override - protected Object controller() { - return new ContractNegotiationApiV2Controller(service, transformerRegistry, monitor, validatorRegistry); - } - - @Override - protected RequestSpecification baseRequest() { - return given() - .baseUri("http://localhost:" + port + "/v2/contractnegotiations") - .when(); - } -} diff --git a/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/v2/ContractNegotiationApiV2Test.java b/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/v2/ContractNegotiationApiV2Test.java deleted file mode 100644 index 5c6bc872ac2..00000000000 --- a/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/contractnegotiation/v2/ContractNegotiationApiV2Test.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.controlplane.api.management.contractnegotiation.v2; - -import org.eclipse.edc.api.transformer.JsonObjectToCallbackAddressTransformer; -import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.BaseContractNegotiationApiTest; -import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.transform.JsonObjectToContractOfferTransformer; -import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.transform.JsonObjectToContractRequestTransformer; -import org.eclipse.edc.connector.controlplane.api.management.contractnegotiation.transform.JsonObjectToTerminateNegotiationCommandTransformer; -import org.eclipse.edc.connector.controlplane.transform.odrl.OdrlTransformersFactory; -import org.eclipse.edc.participant.spi.ParticipantIdMapper; -import org.junit.jupiter.api.BeforeEach; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -class ContractNegotiationApiV2Test extends BaseContractNegotiationApiTest { - - @BeforeEach - void setUp() { - transformer.register(new JsonObjectToContractRequestTransformer()); - transformer.register(new JsonObjectToContractOfferTransformer()); - transformer.register(new JsonObjectToCallbackAddressTransformer()); - transformer.register(new JsonObjectToTerminateNegotiationCommandTransformer()); - ParticipantIdMapper participantIdMapper = mock(); - when(participantIdMapper.fromIri(any())).thenAnswer(a -> a.getArgument(0)); - OdrlTransformersFactory.jsonObjectToOdrlTransformers(participantIdMapper).forEach(transformer::register); - } - -} diff --git a/extensions/control-plane/api/management-api/edr-cache-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/edr/EdrCacheApiExtension.java b/extensions/control-plane/api/management-api/edr-cache-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/edr/EdrCacheApiExtension.java index 66ad839fc5f..a2893e1064e 100644 --- a/extensions/control-plane/api/management-api/edr-cache-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/edr/EdrCacheApiExtension.java +++ b/extensions/control-plane/api/management-api/edr-cache-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/edr/EdrCacheApiExtension.java @@ -16,7 +16,6 @@ import jakarta.json.Json; import org.eclipse.edc.connector.controlplane.api.management.edr.transform.JsonObjectFromEndpointDataReferenceEntryTransformer; -import org.eclipse.edc.connector.controlplane.api.management.edr.v1.EdrCacheApiV1Controller; import org.eclipse.edc.connector.controlplane.api.management.edr.v3.EdrCacheApiV3Controller; import org.eclipse.edc.edr.spi.store.EndpointDataReferenceStore; import org.eclipse.edc.runtime.metamodel.annotation.Extension; @@ -61,7 +60,6 @@ public void initialize(ServiceExtensionContext context) { managementTypeTransformerRegistry.register(new JsonObjectFromEndpointDataReferenceEntryTransformer(jsonFactory)); - webService.registerResource(ApiContext.MANAGEMENT, new EdrCacheApiV1Controller(edrStore, managementTypeTransformerRegistry, validator, monitor)); webService.registerResource(ApiContext.MANAGEMENT, new EdrCacheApiV3Controller(edrStore, managementTypeTransformerRegistry, validator, monitor)); } } diff --git a/extensions/control-plane/api/management-api/edr-cache-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/edr/v1/EdrCacheApiV1.java b/extensions/control-plane/api/management-api/edr-cache-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/edr/v1/EdrCacheApiV1.java deleted file mode 100644 index 547c5833e5d..00000000000 --- a/extensions/control-plane/api/management-api/edr-cache-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/edr/v1/EdrCacheApiV1.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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.controlplane.api.management.edr.v1; - -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.parameters.RequestBody; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.json.JsonArray; -import jakarta.json.JsonObject; -import org.eclipse.edc.api.model.ApiCoreSchema; -import org.eclipse.edc.edr.spi.types.EndpointDataReferenceEntry; - -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; - -@OpenAPIDefinition(info = @Info(version = "v1")) -@Tag(name = "EDR Cache V1") -public interface EdrCacheApiV1 { - - @Operation(description = "Request all Edr entries according to a particular query", - requestBody = @RequestBody( - content = @Content(schema = @Schema(implementation = ApiCoreSchema.QuerySpecSchema.class)) - ), - responses = { - @ApiResponse(responseCode = "200", description = "The edr entries matching the query", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = EndpointDataReferenceEntrySchema.class)))), - @ApiResponse(responseCode = "400", description = "Request body was malformed", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }, deprecated = true) - @Deprecated(since = "0.7.0") - JsonArray requestEdrEntriesV1(JsonObject querySpecJson); - - @Operation(description = "Gets the EDR data address with the given transfer process ID", - responses = { - @ApiResponse(responseCode = "200", description = "The data address", - content = @Content(schema = @Schema(implementation = ApiCoreSchema.DataAddressSchema.class))), - @ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "An EDR data address with the given transfer process ID does not exist", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }, - deprecated = true - ) - @Deprecated(since = "0.7.0") - JsonObject getEdrEntryDataAddressV1(String transferProcessId); - - @Operation(description = "Removes an EDR entry given the transfer process ID", - responses = { - @ApiResponse(responseCode = "204", description = "EDR entry was deleted successfully"), - @ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "An EDR entry with the given ID does not exist", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }, deprecated = true) - @Deprecated(since = "0.7.0") - void removeEdrEntryV1(String transferProcessId); - - @ArraySchema() - @Schema(name = "EndpointDataReferenceEntry", example = EndpointDataReferenceEntrySchema.EDR_ENTRY_OUTPUT_EXAMPLE) - record EndpointDataReferenceEntrySchema( - @Schema(name = ID) - String id, - @Schema(name = TYPE, example = EndpointDataReferenceEntry.EDR_ENTRY_TYPE) - String type - ) { - public static final String EDR_ENTRY_OUTPUT_EXAMPLE = """ - { - "@context": { "@vocab": "https://w3id.org/edc/v0.0.1/ns/" }, - "@id": "transfer-process-id", - "transferProcessId": "transfer-process-id", - "agreementId": "agreement-id", - "contractNegotiationId": "contract-negotiation-id", - "assetId": "asset-id", - "providerId": "provider-id", - "createdAt": 1688465655 - } - """; - } - -} diff --git a/extensions/control-plane/api/management-api/edr-cache-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/edr/v1/EdrCacheApiV1Controller.java b/extensions/control-plane/api/management-api/edr-cache-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/edr/v1/EdrCacheApiV1Controller.java deleted file mode 100644 index 02fa1823a8e..00000000000 --- a/extensions/control-plane/api/management-api/edr-cache-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/edr/v1/EdrCacheApiV1Controller.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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.controlplane.api.management.edr.v1; - - -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; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.PathParam; -import jakarta.ws.rs.Produces; -import org.eclipse.edc.connector.controlplane.api.management.edr.BaseEdrCacheApiController; -import org.eclipse.edc.edr.spi.store.EndpointDataReferenceStore; -import org.eclipse.edc.spi.monitor.Monitor; -import org.eclipse.edc.transform.spi.TypeTransformerRegistry; -import org.eclipse.edc.validator.spi.JsonObjectValidatorRegistry; - -import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON; -import static org.eclipse.edc.api.ApiWarnings.deprecationWarning; - -@Consumes(APPLICATION_JSON) -@Produces(APPLICATION_JSON) -@Path("/v1/edrs") -public class EdrCacheApiV1Controller extends BaseEdrCacheApiController implements EdrCacheApiV1 { - public EdrCacheApiV1Controller(EndpointDataReferenceStore edrStore, TypeTransformerRegistry transformerRegistry, JsonObjectValidatorRegistry validator, Monitor monitor) { - super(edrStore, transformerRegistry, validator, monitor); - } - - @POST - @Path("/request") - @Override - public JsonArray requestEdrEntriesV1(JsonObject querySpecJson) { - monitor.warning(deprecationWarning("/v1", "/v3")); - return requestEdrEntries(querySpecJson); - } - - @GET - @Path("{transferProcessId}/dataaddress") - @Override - public JsonObject getEdrEntryDataAddressV1(@PathParam("transferProcessId") String transferProcessId) { - monitor.warning(deprecationWarning("/v1", "/v3")); - return getEdrEntryDataAddress(transferProcessId); - } - - @DELETE - @Path("{transferProcessId}") - @Override - public void removeEdrEntryV1(@PathParam("transferProcessId") String transferProcessId) { - monitor.warning(deprecationWarning("/v1", "/v3")); - removeEdrEntry(transferProcessId); - } -} diff --git a/extensions/control-plane/api/management-api/edr-cache-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/edr/EdrCacheApiExtensionTest.java b/extensions/control-plane/api/management-api/edr-cache-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/edr/EdrCacheApiExtensionTest.java index 06495cf1653..500918b995d 100644 --- a/extensions/control-plane/api/management-api/edr-cache-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/edr/EdrCacheApiExtensionTest.java +++ b/extensions/control-plane/api/management-api/edr-cache-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/edr/EdrCacheApiExtensionTest.java @@ -15,7 +15,6 @@ package org.eclipse.edc.connector.controlplane.api.management.edr; import org.eclipse.edc.connector.controlplane.api.management.edr.transform.JsonObjectFromEndpointDataReferenceEntryTransformer; -import org.eclipse.edc.connector.controlplane.api.management.edr.v1.EdrCacheApiV1Controller; import org.eclipse.edc.connector.controlplane.api.management.edr.v3.EdrCacheApiV3Controller; import org.eclipse.edc.junit.extensions.DependencyInjectionExtension; import org.eclipse.edc.spi.system.ServiceExtensionContext; @@ -53,7 +52,6 @@ void setUp(ServiceExtensionContext context) { void initialize_shouldRegisterControllers(EdrCacheApiExtension extension, ServiceExtensionContext context) { extension.initialize(context); - verify(webService).registerResource(any(), isA(EdrCacheApiV1Controller.class)); verify(webService).registerResource(any(), isA(EdrCacheApiV3Controller.class)); } diff --git a/extensions/control-plane/api/management-api/edr-cache-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/edr/EdrCacheApiTest.java b/extensions/control-plane/api/management-api/edr-cache-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/edr/EdrCacheApiTest.java index 3830108350b..8b7a4f06b8a 100644 --- a/extensions/control-plane/api/management-api/edr-cache-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/edr/EdrCacheApiTest.java +++ b/extensions/control-plane/api/management-api/edr-cache-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/edr/EdrCacheApiTest.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.edc.connector.controlplane.api.management.edr.v1.EdrCacheApiV1.EndpointDataReferenceEntrySchema.EDR_ENTRY_OUTPUT_EXAMPLE; +import static org.eclipse.edc.connector.controlplane.api.management.edr.v3.EdrCacheApiV3.EndpointDataReferenceEntrySchema.EDR_ENTRY_OUTPUT_EXAMPLE; import static org.eclipse.edc.edr.spi.types.EndpointDataReferenceEntry.EDR_ENTRY_AGREEMENT_ID; import static org.eclipse.edc.edr.spi.types.EndpointDataReferenceEntry.EDR_ENTRY_ASSET_ID; import static org.eclipse.edc.edr.spi.types.EndpointDataReferenceEntry.EDR_ENTRY_CONTRACT_NEGOTIATION_ID; diff --git a/extensions/control-plane/api/management-api/edr-cache-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/edr/v1/EdrCacheApiControllerTest.java b/extensions/control-plane/api/management-api/edr-cache-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/edr/v1/EdrCacheApiControllerTest.java deleted file mode 100644 index 50a254b5007..00000000000 --- a/extensions/control-plane/api/management-api/edr-cache-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/edr/v1/EdrCacheApiControllerTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.controlplane.api.management.edr.v1; - -import io.restassured.specification.RequestSpecification; -import org.eclipse.edc.connector.controlplane.api.management.edr.BaseEdrCacheApiControllerTest; -import org.eclipse.edc.junit.annotations.ApiTest; - -import static io.restassured.RestAssured.given; -import static org.mockito.Mockito.mock; - -@ApiTest -public class EdrCacheApiControllerTest extends BaseEdrCacheApiControllerTest { - - - @Override - protected Object controller() { - return new EdrCacheApiV1Controller(edrStore, transformerRegistry, validator, mock()); - } - - - protected RequestSpecification baseRequest() { - return given() - .baseUri("http://localhost:" + port + "/v1") - .when(); - } -} diff --git a/extensions/control-plane/api/management-api/policy-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/policy/PolicyDefinitionApiExtension.java b/extensions/control-plane/api/management-api/policy-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/policy/PolicyDefinitionApiExtension.java index e7ea3bd1b0f..29e74df099d 100644 --- a/extensions/control-plane/api/management-api/policy-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/policy/PolicyDefinitionApiExtension.java +++ b/extensions/control-plane/api/management-api/policy-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/policy/PolicyDefinitionApiExtension.java @@ -20,7 +20,6 @@ import org.eclipse.edc.connector.controlplane.api.management.policy.transform.JsonObjectFromPolicyValidationResultTransformer; import org.eclipse.edc.connector.controlplane.api.management.policy.transform.JsonObjectToPolicyDefinitionTransformer; import org.eclipse.edc.connector.controlplane.api.management.policy.transform.JsonObjectToPolicyEvaluationPlanRequestTransformer; -import org.eclipse.edc.connector.controlplane.api.management.policy.v2.PolicyDefinitionApiV2Controller; import org.eclipse.edc.connector.controlplane.api.management.policy.v3.PolicyDefinitionApiV3Controller; import org.eclipse.edc.connector.controlplane.api.management.policy.v31alpha.PolicyDefinitionApiV31AlphaController; import org.eclipse.edc.connector.controlplane.api.management.policy.validation.PolicyDefinitionValidator; @@ -83,7 +82,6 @@ public void initialize(ServiceExtensionContext context) { validatorRegistry.register(EDC_POLICY_EVALUATION_PLAN_REQUEST_TYPE, PolicyEvaluationPlanRequestValidator.instance()); var monitor = context.getMonitor(); - webService.registerResource(ApiContext.MANAGEMENT, new PolicyDefinitionApiV2Controller(monitor, managementApiTransformerRegistry, service, validatorRegistry)); webService.registerResource(ApiContext.MANAGEMENT, new PolicyDefinitionApiV3Controller(monitor, managementApiTransformerRegistry, service, validatorRegistry)); webService.registerResource(ApiContext.MANAGEMENT, new PolicyDefinitionApiV31AlphaController(monitor, managementApiTransformerRegistry, service, validatorRegistry)); } diff --git a/extensions/control-plane/api/management-api/policy-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/policy/v2/PolicyDefinitionApiV2.java b/extensions/control-plane/api/management-api/policy-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/policy/v2/PolicyDefinitionApiV2.java deleted file mode 100644 index bb3b10b6f65..00000000000 --- a/extensions/control-plane/api/management-api/policy-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/policy/v2/PolicyDefinitionApiV2.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * 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.controlplane.api.management.policy.v2; - -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.parameters.RequestBody; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.json.JsonArray; -import jakarta.json.JsonObject; -import org.eclipse.edc.api.management.schema.ManagementApiSchema; -import org.eclipse.edc.api.model.ApiCoreSchema; - -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; -import static org.eclipse.edc.connector.controlplane.policy.spi.PolicyDefinition.EDC_POLICY_DEFINITION_TYPE; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.CONTEXT; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; - -@OpenAPIDefinition(info = @Info(version = "v2")) -@Tag(name = "Policy Definition V2") -public interface PolicyDefinitionApiV2 { - - @Operation(description = "Returns all policy definitions according to a query", - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = ApiCoreSchema.QuerySpecSchema.class))), - responses = { - @ApiResponse(responseCode = "200", description = "The policy definitions matching the query", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = PolicyDefinitionOutputSchema.class)))), - @ApiResponse(responseCode = "400", description = "Request was malformed", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) }, - deprecated = true - ) - @Deprecated(since = "0.7.0") - JsonArray queryPolicyDefinitionsV2(JsonObject querySpecJson); - - @Operation(description = "Gets a policy definition with the given ID", - responses = { - @ApiResponse(responseCode = "200", description = "The policy definition", - content = @Content(schema = @Schema(implementation = PolicyDefinitionOutputSchema.class))), - @ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "An policy definition with the given ID does not exist", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }, - deprecated = true - ) - @Deprecated(since = "0.7.0") - JsonObject getPolicyDefinitionV2(String id); - - @Operation(description = "Creates a new policy definition", - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = PolicyDefinitionInputSchema.class))), - responses = { - @ApiResponse(responseCode = "200", description = "policy definition was created successfully. Returns the Policy Definition Id and created timestamp", - content = @Content(schema = @Schema(implementation = ApiCoreSchema.IdResponseSchema.class))), - @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 policy definition, because a contract definition with that ID already exists", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) }, - deprecated = true - ) - @Deprecated(since = "0.7.0") - JsonObject createPolicyDefinitionV2(JsonObject policyDefinition); - - @Operation(description = "Removes a policy definition with the given ID if possible. Deleting a policy definition is " + - "only possible if that policy definition is not yet referenced by a contract definition, in which case an error is returned. " + - "DANGER ZONE: Note that deleting policy definitions can have unexpected results, do this at your own risk!", - responses = { - @ApiResponse(responseCode = "204", description = "Policy definition was deleted successfully"), - @ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "An policy definition with the given ID does not exist", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "409", description = "The policy definition cannot be deleted, because it is referenced by a contract definition", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }, - deprecated = true - ) - @Deprecated(since = "0.7.0") - void deletePolicyDefinitionV2(String id); - - @Operation(description = "Updates an existing Policy, If the Policy is not found, an error is reported", - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = PolicyDefinitionInputSchema.class))), - responses = { - @ApiResponse(responseCode = "204", description = "policy definition was updated successfully."), - @ApiResponse(responseCode = "400", description = "Request body was malformed", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "policy definition could not be updated, because it does not exists", - content = @Content(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class))) - }, - deprecated = true - ) - @Deprecated(since = "0.7.0") - void updatePolicyDefinitionV2(String id, JsonObject policyDefinition); - - @Schema(name = "PolicyDefinitionInput", example = PolicyDefinitionInputSchema.POLICY_DEFINITION_INPUT_EXAMPLE) - record PolicyDefinitionInputSchema( - @Schema(name = CONTEXT, requiredMode = REQUIRED) - Object context, - @Schema(name = ID) - String id, - @Schema(name = TYPE, example = EDC_POLICY_DEFINITION_TYPE) - String type, - @Schema(requiredMode = REQUIRED) - ManagementApiSchema.PolicySchema policy) { - - // policy example took from https://w3c.github.io/odrl/bp/ - public static final String POLICY_DEFINITION_INPUT_EXAMPLE = """ - { - "@context": { "@vocab": "https://w3id.org/edc/v0.0.1/ns/" }, - "@id": "definition-id", - "policy": { - "@context": "http://www.w3.org/ns/odrl.jsonld", - "@type": "Set", - "uid": "http://example.com/policy:1010", - "permission": [{ - "target": "http://example.com/asset:9898.movie", - "action": "display", - "constraint": [{ - "leftOperand": "spatial", - "operator": "eq", - "rightOperand": "https://www.wikidata.org/wiki/Q183", - "comment": "i.e Germany" - }] - }] - } - } - """; - } - - @Schema(name = "PolicyDefinitionOutput", example = PolicyDefinitionOutputSchema.POLICY_DEFINITION_OUTPUT_EXAMPLE) - record PolicyDefinitionOutputSchema( - @Schema(name = ID) - String id, - @Schema(name = TYPE, example = EDC_POLICY_DEFINITION_TYPE) - String type, - ManagementApiSchema.PolicySchema policy) { - - // policy example took from https://w3c.github.io/odrl/bp/ - public static final String POLICY_DEFINITION_OUTPUT_EXAMPLE = """ - { - "@context": { "@vocab": "https://w3id.org/edc/v0.0.1/ns/" }, - "@id": "definition-id", - "policy": { - "@context": "http://www.w3.org/ns/odrl.jsonld", - "@type": "Set", - "uid": "http://example.com/policy:1010", - "permission": [{ - "target": "http://example.com/asset:9898.movie", - "action": "display", - "constraint": [{ - "leftOperand": "spatial", - "operator": "eq", - "rightOperand": "https://www.wikidata.org/wiki/Q183", - "comment": "i.e Germany" - }] - }] - }, - "createdAt": 1688465655 - } - """; - } - -} diff --git a/extensions/control-plane/api/management-api/policy-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/policy/v2/PolicyDefinitionApiV2Controller.java b/extensions/control-plane/api/management-api/policy-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/policy/v2/PolicyDefinitionApiV2Controller.java deleted file mode 100644 index d7b6d0d10f3..00000000000 --- a/extensions/control-plane/api/management-api/policy-definition-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/policy/v2/PolicyDefinitionApiV2Controller.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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.controlplane.api.management.policy.v2; - -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; -import jakarta.ws.rs.PUT; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.PathParam; -import jakarta.ws.rs.Produces; -import org.eclipse.edc.connector.controlplane.api.management.policy.BasePolicyDefinitionApiController; -import org.eclipse.edc.connector.controlplane.services.spi.policydefinition.PolicyDefinitionService; -import org.eclipse.edc.spi.monitor.Monitor; -import org.eclipse.edc.transform.spi.TypeTransformerRegistry; -import org.eclipse.edc.validator.spi.JsonObjectValidatorRegistry; - -import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON; -import static org.eclipse.edc.api.ApiWarnings.deprecationWarning; - -@Consumes(APPLICATION_JSON) -@Produces(APPLICATION_JSON) -@Path("/v2/policydefinitions") -public class PolicyDefinitionApiV2Controller extends BasePolicyDefinitionApiController implements PolicyDefinitionApiV2 { - public PolicyDefinitionApiV2Controller(Monitor monitor, TypeTransformerRegistry transformerRegistry, PolicyDefinitionService service, JsonObjectValidatorRegistry validatorRegistry) { - super(monitor, transformerRegistry, service, validatorRegistry); - } - - @POST - @Path("request") - @Override - public JsonArray queryPolicyDefinitionsV2(JsonObject querySpecJson) { - monitor.warning(deprecationWarning("/v2", "/v3")); - return queryPolicyDefinitions(querySpecJson); - } - - @GET - @Path("{id}") - @Override - public JsonObject getPolicyDefinitionV2(@PathParam("id") String id) { - monitor.warning(deprecationWarning("/v2", "/v3")); - return getPolicyDefinition(id); - } - - @POST - @Override - public JsonObject createPolicyDefinitionV2(JsonObject request) { - monitor.warning(deprecationWarning("/v2", "/v3")); - return createPolicyDefinition(request); - } - - @DELETE - @Path("{id}") - @Override - public void deletePolicyDefinitionV2(@PathParam("id") String id) { - monitor.warning(deprecationWarning("/v2", "/v3")); - deletePolicyDefinition(id); - } - - @PUT - @Path("{id}") - @Override - public void updatePolicyDefinitionV2(@PathParam("id") String id, JsonObject input) { - monitor.warning(deprecationWarning("/v2", "/v3")); - updatePolicyDefinition(id, input); - } -} diff --git a/extensions/control-plane/api/management-api/policy-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/policy/PolicyDefinitionApiExtensionTest.java b/extensions/control-plane/api/management-api/policy-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/policy/PolicyDefinitionApiExtensionTest.java index 26eb3c0ae91..6f33bc5fcaf 100644 --- a/extensions/control-plane/api/management-api/policy-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/policy/PolicyDefinitionApiExtensionTest.java +++ b/extensions/control-plane/api/management-api/policy-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/policy/PolicyDefinitionApiExtensionTest.java @@ -15,7 +15,6 @@ package org.eclipse.edc.connector.controlplane.api.management.policy; import org.eclipse.edc.boot.system.injection.ObjectFactory; -import org.eclipse.edc.connector.controlplane.api.management.policy.v2.PolicyDefinitionApiV2Controller; import org.eclipse.edc.connector.controlplane.api.management.policy.v3.PolicyDefinitionApiV3Controller; import org.eclipse.edc.connector.controlplane.api.management.policy.v31alpha.PolicyDefinitionApiV31AlphaController; import org.eclipse.edc.junit.extensions.DependencyInjectionExtension; @@ -63,7 +62,6 @@ void initialize_shouldRegisterValidatorForPolicyDefinition(ServiceExtensionConte void initialize_shouldRegisterControllers(ServiceExtensionContext context) { extension.initialize(context); - verify(webService).registerResource(any(), isA(PolicyDefinitionApiV2Controller.class)); verify(webService).registerResource(any(), isA(PolicyDefinitionApiV3Controller.class)); verify(webService).registerResource(any(), isA(PolicyDefinitionApiV31AlphaController.class)); } diff --git a/extensions/control-plane/api/management-api/policy-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/policy/PolicyDefinitionApiTest.java b/extensions/control-plane/api/management-api/policy-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/policy/PolicyDefinitionApiTest.java index e8d964be46d..0b284c9b204 100644 --- a/extensions/control-plane/api/management-api/policy-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/policy/PolicyDefinitionApiTest.java +++ b/extensions/control-plane/api/management-api/policy-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/policy/PolicyDefinitionApiTest.java @@ -35,8 +35,8 @@ import static org.eclipse.edc.connector.controlplane.api.management.policy.model.PolicyValidationResult.EDC_POLICY_VALIDATION_RESULT_ERRORS; import static org.eclipse.edc.connector.controlplane.api.management.policy.model.PolicyValidationResult.EDC_POLICY_VALIDATION_RESULT_IS_VALID; import static org.eclipse.edc.connector.controlplane.api.management.policy.model.PolicyValidationResult.EDC_POLICY_VALIDATION_RESULT_TYPE; -import static org.eclipse.edc.connector.controlplane.api.management.policy.v2.PolicyDefinitionApiV2.PolicyDefinitionInputSchema.POLICY_DEFINITION_INPUT_EXAMPLE; -import static org.eclipse.edc.connector.controlplane.api.management.policy.v2.PolicyDefinitionApiV2.PolicyDefinitionOutputSchema.POLICY_DEFINITION_OUTPUT_EXAMPLE; +import static org.eclipse.edc.connector.controlplane.api.management.policy.v3.PolicyDefinitionApiV3.PolicyDefinitionInputSchema.POLICY_DEFINITION_INPUT_EXAMPLE; +import static org.eclipse.edc.connector.controlplane.api.management.policy.v3.PolicyDefinitionApiV3.PolicyDefinitionOutputSchema.POLICY_DEFINITION_OUTPUT_EXAMPLE; import static org.eclipse.edc.connector.controlplane.api.management.policy.v31alpha.PolicyDefinitionApiV31Alpha.PolicyEvaluationPlanRequestSchema.POLICY_EVALUATION_PLAN_REQUEST_INPUT_EXAMPLE; import static org.eclipse.edc.connector.controlplane.api.management.policy.v31alpha.PolicyDefinitionApiV31Alpha.PolicyEvaluationPlanSchema.POLICY_EVALUATION_PLANE_OUTPUT_EXAMPLE; import static org.eclipse.edc.connector.controlplane.api.management.policy.v31alpha.PolicyDefinitionApiV31Alpha.PolicyValidationResultSchema.POLICY_VALIDATION_RESULT_OUTPUT_EXAMPLE; diff --git a/extensions/control-plane/api/management-api/policy-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/policy/v2/PolicyDefinitionApiV2ControllerTest.java b/extensions/control-plane/api/management-api/policy-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/policy/v2/PolicyDefinitionApiV2ControllerTest.java deleted file mode 100644 index 5dfa77a4f0b..00000000000 --- a/extensions/control-plane/api/management-api/policy-definition-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/policy/v2/PolicyDefinitionApiV2ControllerTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.controlplane.api.management.policy.v2; - -import io.restassured.specification.RequestSpecification; -import org.eclipse.edc.connector.controlplane.api.management.policy.BasePolicyDefinitionApiControllerTest; - -import static io.restassured.RestAssured.given; - -public class PolicyDefinitionApiV2ControllerTest extends BasePolicyDefinitionApiControllerTest { - - @Override - protected Object controller() { - return new PolicyDefinitionApiV2Controller(monitor, transformerRegistry, service, validatorRegistry); - } - - @Override - protected RequestSpecification baseRequest() { - return given() - .baseUri("http://localhost:%d/v2/policydefinitions".formatted(port)) - .port(port); - } - -} diff --git a/extensions/control-plane/api/management-api/secrets-api/src/main/java/org/eclipse/edc/connector/api/management/secret/SecretsApiExtension.java b/extensions/control-plane/api/management-api/secrets-api/src/main/java/org/eclipse/edc/connector/api/management/secret/SecretsApiExtension.java index bc662e774f1..69cc0acccbc 100644 --- a/extensions/control-plane/api/management-api/secrets-api/src/main/java/org/eclipse/edc/connector/api/management/secret/SecretsApiExtension.java +++ b/extensions/control-plane/api/management-api/secrets-api/src/main/java/org/eclipse/edc/connector/api/management/secret/SecretsApiExtension.java @@ -17,7 +17,6 @@ import jakarta.json.Json; import org.eclipse.edc.connector.api.management.secret.transform.JsonObjectFromSecretTransformer; import org.eclipse.edc.connector.api.management.secret.transform.JsonObjectToSecretTransformer; -import org.eclipse.edc.connector.api.management.secret.v1.SecretsApiV1Controller; import org.eclipse.edc.connector.api.management.secret.v3.SecretsApiV3Controller; import org.eclipse.edc.connector.api.management.secret.validation.SecretsValidator; import org.eclipse.edc.connector.spi.service.SecretService; @@ -66,7 +65,6 @@ public void initialize(ServiceExtensionContext context) { managementApiTransformerRegistry.register(new JsonObjectFromSecretTransformer(jsonBuilderFactory)); managementApiTransformerRegistry.register(new JsonObjectToSecretTransformer()); - webService.registerResource(ApiContext.MANAGEMENT, new SecretsApiV1Controller(secretService, managementApiTransformerRegistry, validator, context.getMonitor())); webService.registerResource(ApiContext.MANAGEMENT, new SecretsApiV3Controller(secretService, managementApiTransformerRegistry, validator)); } diff --git a/extensions/control-plane/api/management-api/secrets-api/src/main/java/org/eclipse/edc/connector/api/management/secret/v1/SecretsApiV1.java b/extensions/control-plane/api/management-api/secrets-api/src/main/java/org/eclipse/edc/connector/api/management/secret/v1/SecretsApiV1.java deleted file mode 100644 index e10aa2bb87d..00000000000 --- a/extensions/control-plane/api/management-api/secrets-api/src/main/java/org/eclipse/edc/connector/api/management/secret/v1/SecretsApiV1.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * 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.api.management.secret.v1; - -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.parameters.RequestBody; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.json.JsonObject; -import org.eclipse.edc.api.model.ApiCoreSchema; - -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.CONTEXT; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.spi.types.domain.secret.Secret.EDC_SECRET_TYPE; - -@OpenAPIDefinition( - info = @Info(description = "This contains the secret management API, which allows to add, remove and update secrets in the Vault.", title = "Secret API", version = "v1")) -@Tag(name = "Secret V1") -public interface SecretsApiV1 { - - @Operation(description = "Creates a new secret.", - deprecated = true, - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = SecretInputSchema.class))), - responses = { - @ApiResponse(responseCode = "200", description = "Secret was created successfully. Returns the secret Id and created timestamp", - content = @Content(schema = @Schema(implementation = ApiCoreSchema.IdResponseSchema.class))), - @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 secret, because a secret with that ID already exists", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) } - ) - @Deprecated(since = "0.7.0") - JsonObject createSecretV1(JsonObject secret); - - @Operation(description = "Gets a secret with the given ID", - deprecated = true, - responses = { - @ApiResponse(responseCode = "200", description = "The secret", - content = @Content(schema = @Schema(implementation = SecretOutputSchema.class))), - @ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "A secret with the given ID does not exist", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - } - ) - @Deprecated(since = "0.7.0") - JsonObject getSecretV1(String id); - - @Operation(description = "Removes a secret with the given ID if possible.", - deprecated = true, - responses = { - @ApiResponse(responseCode = "204", description = "Secret was deleted successfully"), - @ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "A secret with the given ID does not exist", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }) - @Deprecated(since = "0.7.0") - void removeSecretV1(String id); - - @Operation(description = "Updates a secret with the given ID if it exists. If the secret is not found, no further action is taken. ", - deprecated = true, - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = SecretInputSchema.class))), - responses = { - @ApiResponse(responseCode = "204", description = "Secret was updated successfully"), - @ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "Secret could not be updated, because it does not exist.") - }) - @Deprecated(since = "0.7.0") - void updateSecretV1(JsonObject secret); - - @Schema(name = "SecretInput", example = SecretInputSchema.SECRET_INPUT_EXAMPLE) - record SecretInputSchema( - @Schema(name = CONTEXT, requiredMode = REQUIRED) - Object context, - @Schema(name = ID) - String id, - @Schema(name = TYPE, example = EDC_SECRET_TYPE) - String type, - @Schema(requiredMode = REQUIRED) - String value - ) { - public static final String SECRET_INPUT_EXAMPLE = """ - { - "@context": { "@vocab": "https://w3id.org/edc/v0.0.1/ns/" }, - "@id": "secret-id", - "value" : "secret-value" - } - """; - } - - @ArraySchema() - @Schema(name = "SecretOutput", example = SecretOutputSchema.SECRET_OUTPUT_EXAMPLE) - record SecretOutputSchema( - @Schema(name = ID) - String id, - @Schema(name = TYPE, example = EDC_SECRET_TYPE) - String type, - @Schema(requiredMode = REQUIRED) - String value - ) { - public static final String SECRET_OUTPUT_EXAMPLE = """ - { - "@context": { "@vocab": "https://w3id.org/edc/v0.0.1/ns/" }, - "@id": "secret-id", - "@type": "https://w3id.org/edc/v0.0.1/ns/Secret", - "value": "secret-value" - } - """; - } - -} diff --git a/extensions/control-plane/api/management-api/secrets-api/src/main/java/org/eclipse/edc/connector/api/management/secret/v1/SecretsApiV1Controller.java b/extensions/control-plane/api/management-api/secrets-api/src/main/java/org/eclipse/edc/connector/api/management/secret/v1/SecretsApiV1Controller.java deleted file mode 100644 index c64791babc3..00000000000 --- a/extensions/control-plane/api/management-api/secrets-api/src/main/java/org/eclipse/edc/connector/api/management/secret/v1/SecretsApiV1Controller.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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.api.management.secret.v1; - -import jakarta.json.JsonObject; -import jakarta.ws.rs.Consumes; -import jakarta.ws.rs.DELETE; -import jakarta.ws.rs.GET; -import jakarta.ws.rs.POST; -import jakarta.ws.rs.PUT; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.PathParam; -import jakarta.ws.rs.Produces; -import org.eclipse.edc.connector.api.management.secret.BaseSecretsApiController; -import org.eclipse.edc.connector.spi.service.SecretService; -import org.eclipse.edc.spi.monitor.Monitor; -import org.eclipse.edc.transform.spi.TypeTransformerRegistry; -import org.eclipse.edc.validator.spi.JsonObjectValidatorRegistry; - -import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON; -import static org.eclipse.edc.api.ApiWarnings.deprecationWarning; - -@Consumes(APPLICATION_JSON) -@Produces(APPLICATION_JSON) -@Path("/v1/secrets") -public class SecretsApiV1Controller extends BaseSecretsApiController implements SecretsApiV1 { - private final Monitor monitor; - - public SecretsApiV1Controller(SecretService service, TypeTransformerRegistry transformerRegistry, JsonObjectValidatorRegistry validator, Monitor monitor) { - super(service, transformerRegistry, validator); - this.monitor = monitor; - } - - @POST - @Override - public JsonObject createSecretV1(JsonObject secretJson) { - monitor.warning(deprecationWarning("/v1", "/v3")); - return createSecret(secretJson); - } - - @GET - @Path("{id}") - @Override - public JsonObject getSecretV1(@PathParam("id") String id) { - monitor.warning(deprecationWarning("/v1", "/v3")); - return getSecret(id); - } - - @DELETE - @Path("{id}") - @Override - public void removeSecretV1(@PathParam("id") String id) { - monitor.warning(deprecationWarning("/v1", "/v3")); - removeSecret(id); - } - - @PUT - @Override - public void updateSecretV1(JsonObject secretJson) { - monitor.warning(deprecationWarning("/v1", "/v3")); - updateSecret(secretJson); - } -} diff --git a/extensions/control-plane/api/management-api/secrets-api/src/test/java/org/eclipse/edc/connector/api/management/secret/SecretsApiExtensionTest.java b/extensions/control-plane/api/management-api/secrets-api/src/test/java/org/eclipse/edc/connector/api/management/secret/SecretsApiExtensionTest.java index 8456280a293..ce5e0d4a863 100644 --- a/extensions/control-plane/api/management-api/secrets-api/src/test/java/org/eclipse/edc/connector/api/management/secret/SecretsApiExtensionTest.java +++ b/extensions/control-plane/api/management-api/secrets-api/src/test/java/org/eclipse/edc/connector/api/management/secret/SecretsApiExtensionTest.java @@ -16,7 +16,6 @@ import org.eclipse.edc.connector.api.management.secret.transform.JsonObjectFromSecretTransformer; import org.eclipse.edc.connector.api.management.secret.transform.JsonObjectToSecretTransformer; -import org.eclipse.edc.connector.api.management.secret.v1.SecretsApiV1Controller; import org.eclipse.edc.connector.api.management.secret.v3.SecretsApiV3Controller; import org.eclipse.edc.junit.extensions.DependencyInjectionExtension; import org.eclipse.edc.spi.system.ServiceExtensionContext; @@ -55,7 +54,6 @@ void setUp(ServiceExtensionContext context) { void initialize_shouldRegisterControllers(SecretsApiExtension extension, ServiceExtensionContext context) { extension.initialize(context); - verify(webService).registerResource(any(), isA(SecretsApiV1Controller.class)); verify(webService).registerResource(any(), isA(SecretsApiV3Controller.class)); } diff --git a/extensions/control-plane/api/management-api/secrets-api/src/test/java/org/eclipse/edc/connector/api/management/secret/SecretsApiTest.java b/extensions/control-plane/api/management-api/secrets-api/src/test/java/org/eclipse/edc/connector/api/management/secret/SecretsApiTest.java index 8c3a6cb3d15..5b78a7ce117 100644 --- a/extensions/control-plane/api/management-api/secrets-api/src/test/java/org/eclipse/edc/connector/api/management/secret/SecretsApiTest.java +++ b/extensions/control-plane/api/management-api/secrets-api/src/test/java/org/eclipse/edc/connector/api/management/secret/SecretsApiTest.java @@ -30,8 +30,8 @@ import org.junit.jupiter.api.Test; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static org.eclipse.edc.connector.api.management.secret.v1.SecretsApiV1.SecretInputSchema.SECRET_INPUT_EXAMPLE; -import static org.eclipse.edc.connector.api.management.secret.v1.SecretsApiV1.SecretOutputSchema.SECRET_OUTPUT_EXAMPLE; +import static org.eclipse.edc.connector.api.management.secret.v3.SecretsApiV3.SecretInputSchema.SECRET_INPUT_EXAMPLE; +import static org.eclipse.edc.connector.api.management.secret.v3.SecretsApiV3.SecretOutputSchema.SECRET_OUTPUT_EXAMPLE; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.VALUE; diff --git a/extensions/control-plane/api/management-api/secrets-api/src/test/java/org/eclipse/edc/connector/api/management/secret/v1/SecretsApiV1ControllerTest.java b/extensions/control-plane/api/management-api/secrets-api/src/test/java/org/eclipse/edc/connector/api/management/secret/v1/SecretsApiV1ControllerTest.java deleted file mode 100644 index 73476969cf8..00000000000 --- a/extensions/control-plane/api/management-api/secrets-api/src/test/java/org/eclipse/edc/connector/api/management/secret/v1/SecretsApiV1ControllerTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.api.management.secret.v1; - -import io.restassured.specification.RequestSpecification; -import org.eclipse.edc.connector.api.management.secret.BaseSecretsApiControllerTest; - -import static io.restassured.RestAssured.given; -import static org.mockito.Mockito.mock; - -class SecretsApiV1ControllerTest extends BaseSecretsApiControllerTest { - @Override - protected Object controller() { - return new SecretsApiV1Controller(service, transformerRegistry, validator, mock()); - } - - @Override - protected RequestSpecification baseRequest() { - return given() - .baseUri("http://localhost:" + port + "/v1") - .when(); - } -} \ No newline at end of file diff --git a/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/transferprocess/TransferProcessApiExtension.java b/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/transferprocess/TransferProcessApiExtension.java index ac9d78c3e29..705de0a9962 100644 --- a/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/transferprocess/TransferProcessApiExtension.java +++ b/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/transferprocess/TransferProcessApiExtension.java @@ -20,7 +20,6 @@ import org.eclipse.edc.connector.controlplane.api.management.transferprocess.transform.JsonObjectToSuspendTransferTransformer; import org.eclipse.edc.connector.controlplane.api.management.transferprocess.transform.JsonObjectToTerminateTransferTransformer; import org.eclipse.edc.connector.controlplane.api.management.transferprocess.transform.JsonObjectToTransferRequestTransformer; -import org.eclipse.edc.connector.controlplane.api.management.transferprocess.v2.TransferProcessApiV2Controller; import org.eclipse.edc.connector.controlplane.api.management.transferprocess.v3.TransferProcessApiV3Controller; import org.eclipse.edc.connector.controlplane.api.management.transferprocess.validation.TerminateTransferValidator; import org.eclipse.edc.connector.controlplane.api.management.transferprocess.validation.TransferRequestValidator; @@ -75,7 +74,6 @@ public void initialize(ServiceExtensionContext context) { validatorRegistry.register(TRANSFER_REQUEST_TYPE, TransferRequestValidator.instance(context.getMonitor())); validatorRegistry.register(TERMINATE_TRANSFER_TYPE, TerminateTransferValidator.instance()); - webService.registerResource(ApiContext.MANAGEMENT, new TransferProcessApiV2Controller(context.getMonitor(), service, managementApiTransformerRegistry, validatorRegistry)); webService.registerResource(ApiContext.MANAGEMENT, new TransferProcessApiV3Controller(context.getMonitor(), service, managementApiTransformerRegistry, validatorRegistry)); } } diff --git a/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/transferprocess/v2/TransferProcessApiV2.java b/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/transferprocess/v2/TransferProcessApiV2.java deleted file mode 100644 index 80fad828580..00000000000 --- a/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/transferprocess/v2/TransferProcessApiV2.java +++ /dev/null @@ -1,312 +0,0 @@ -/* - * 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.controlplane.api.management.transferprocess.v2; - -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.links.Link; -import io.swagger.v3.oas.annotations.links.LinkParameter; -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.parameters.RequestBody; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.json.JsonArray; -import jakarta.json.JsonObject; -import org.eclipse.edc.api.management.schema.ManagementApiSchema; -import org.eclipse.edc.api.model.ApiCoreSchema; -import org.eclipse.edc.connector.controlplane.api.management.transferprocess.model.SuspendTransfer; -import org.eclipse.edc.connector.controlplane.api.management.transferprocess.model.TerminateTransfer; -import org.eclipse.edc.connector.controlplane.api.management.transferprocess.model.TransferState; -import org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcess; - -import java.util.List; - -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; -import static org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcess.TRANSFER_PROCESS_TYPE; -import static org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferRequest.TRANSFER_REQUEST_TYPE; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.CONTEXT; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; - -@OpenAPIDefinition(info = @Info(version = "v2")) -@Tag(name = "Transfer Process V2") -public interface TransferProcessApiV2 { - - String ASYNC_WARNING = "Due to the asynchronous nature of transfers, a successful response only indicates that the " + - "request was successfully received. This may take a long time, so clients must poll the /{id}/state " + - "endpoint to track the state."; - - @Operation(description = "Returns all transfer process according to a query", - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = ApiCoreSchema.QuerySpecSchema.class))), - deprecated = true, - responses = { - @ApiResponse(responseCode = "200", description = "The transfer processes matching the query", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = TransferProcessSchema.class)))), - @ApiResponse(responseCode = "400", description = "Request was malformed", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) } - ) - @Deprecated(since = "0.7.0") - JsonArray queryTransferProcessesV2(JsonObject querySpecJson); - - @Operation(description = "Gets an transfer process with the given ID", - deprecated = true, - responses = { - @ApiResponse(responseCode = "200", description = "The transfer process", - content = @Content(schema = @Schema(implementation = TransferProcessSchema.class))), - @ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "A transfer process with the given ID does not exist", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - } - ) - @Deprecated(since = "0.7.0") - JsonObject getTransferProcessV2(String id); - - @Operation(description = "Gets the state of a transfer process with the given ID", - deprecated = true, - responses = { - @ApiResponse(responseCode = "200", description = "The transfer process's state", - content = @Content(schema = @Schema(implementation = TransferStateSchema.class))), - @ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "An transfer process with the given ID does not exist", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - } - ) - @Deprecated(since = "0.7.0") - JsonObject getTransferProcessStateV2(String id); - - @Operation(description = "Initiates a data transfer with the given parameters. " + ASYNC_WARNING, - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = TransferRequestSchema.class))), - deprecated = true, - responses = { - @ApiResponse(responseCode = "200", description = "The transfer was successfully initiated. Returns the transfer process ID and created timestamp", - content = @Content(schema = @Schema(implementation = ApiCoreSchema.IdResponseSchema.class)), - links = @Link(name = "poll-state", operationId = "getTransferProcessStateV2", parameters = { - @LinkParameter(name = "id", expression = "$response.body#/id") - }) - ), - @ApiResponse(responseCode = "400", description = "Request body was malformed", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - }) - @Deprecated(since = "0.7.0") - JsonObject initiateTransferProcessV2(JsonObject transferRequest); - - @Operation(description = "Requests the deprovisioning of resources associated with a transfer process. " + ASYNC_WARNING, - deprecated = true, - responses = { - @ApiResponse(responseCode = "204", description = "Request to deprovision the transfer process was successfully received", - links = @Link(name = "poll-state", operationId = "deprovisionTransferProcessV2")), - @ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "A transfer process with the given ID does not exist", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }) - @Deprecated(since = "0.7.0") - void deprovisionTransferProcessV2(String id); - - @Operation(description = "Requests the termination of a transfer process. " + ASYNC_WARNING, - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = TerminateTransferSchema.class))), - deprecated = true, - responses = { - @ApiResponse(responseCode = "204", description = "Request to terminate the transfer process was successfully received", - links = @Link(name = "poll-state", operationId = "terminateTransferProcessV2")), - @ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "A transfer process with the given ID does not exist", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "409", description = "Could not terminate transfer process, because it is already completed or terminated.", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }) - @Deprecated(since = "0.7.0") - void terminateTransferProcessV2(String id, JsonObject terminateTransfer); - - @Operation(description = "Requests the suspension of a transfer process. " + ASYNC_WARNING, - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = SuspendTransferSchema.class))), - deprecated = true, - responses = { - @ApiResponse(responseCode = "204", description = "Request to suspend the transfer process was successfully received", - links = @Link(name = "poll-state", operationId = "suspendTransferProcessV2")), - @ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "A transfer process with the given ID does not exist", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "409", description = "Could not suspend the transfer process, because it is already completed or terminated.", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }) - @Deprecated(since = "0.7.0") - void suspendTransferProcessV2(String id, JsonObject suspendTransfer); - - @Operation(description = "Requests the resumption of a suspended transfer process. " + ASYNC_WARNING, - deprecated = true, - responses = { - @ApiResponse(responseCode = "204", description = "Request to resume the transfer process was successfully received", - links = @Link(name = "poll-state", operationId = "resumeTransferProcessV2")), - @ApiResponse(responseCode = "400", description = "Request was malformed, e.g. id was null", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))), - @ApiResponse(responseCode = "404", description = "A transfer process with the given ID does not exist", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }) - @Deprecated(since = "0.7.0") - void resumeTransferProcessV2(String id); - - @Schema(name = "TransferRequest", example = TransferRequestSchema.TRANSFER_REQUEST_EXAMPLE) - record TransferRequestSchema( - @Schema(name = CONTEXT, requiredMode = REQUIRED) - Object context, - @Schema(name = TYPE, example = TRANSFER_REQUEST_TYPE) - String type, - @Schema(requiredMode = REQUIRED) - String protocol, - @Deprecated(since = "0.3.2") - @Schema(deprecated = true, description = "please use counterPartyAddress instead") - String connectorAddress, - @Schema(requiredMode = REQUIRED) - String counterPartyAddress, - @Deprecated(since = "0.3.2") - @Schema(deprecated = true, description = "Provider connector id is stored in the contract agreement") - String connectorId, - @Schema(requiredMode = REQUIRED) - String contractId, - @Schema(requiredMode = REQUIRED) - String assetId, - @Schema(requiredMode = REQUIRED) - String transferType, - ApiCoreSchema.DataAddressSchema dataDestination, - @Schema(additionalProperties = Schema.AdditionalPropertiesValue.TRUE) - ManagementApiSchema.FreeFormPropertiesSchema privateProperties, - List callbackAddresses) { - - public static final String TRANSFER_REQUEST_EXAMPLE = """ - { - "@context": { "@vocab": "https://w3id.org/edc/v0.0.1/ns/" }, - "@type": "https://w3id.org/edc/v0.0.1/ns/TransferRequest", - "protocol": "dataspace-protocol-http", - "counterPartyAddress": "http://provider-address", - "contractId": "contract-id", - "assetId": "asset-id", - "transferType": "transferType", - "dataDestination": { - "type": "data-destination-type" - }, - "privateProperties": { - "private-key": "private-value" - }, - "callbackAddresses": [{ - "transactional": false, - "uri": "http://callback/url", - "events": ["contract.negotiation", "transfer.process"], - "authKey": "auth-key", - "authCodeId": "auth-code-id" - }] - } - """; - } - - @Schema(name = "TransferProcess", example = TransferProcessSchema.TRANSFER_PROCESS_EXAMPLE) - record TransferProcessSchema( - @Schema(name = TYPE, example = TRANSFER_PROCESS_TYPE) - String ldType, - @Schema(name = ID) - String id, - TransferProcess.Type type, - String protocol, - String counterPartyId, - String counterPartyAddress, - String state, - String contractAgreementId, - String errorDetail, - ApiCoreSchema.DataAddressSchema dataDestination, - ManagementApiSchema.FreeFormPropertiesSchema privateProperties, - List callbackAddresses - ) { - public static final String TRANSFER_PROCESS_EXAMPLE = """ - { - "@context": { "@vocab": "https://w3id.org/edc/v0.0.1/ns/" }, - "@type": "https://w3id.org/edc/v0.0.1/ns/TransferProcess", - "@id": "process-id", - "correlationId": "correlation-id", - "type": "PROVIDER", - "state": "STARTED", - "stateTimestamp": 1688465655, - "assetId": "asset-id", - "contractId": "contractId", - "dataDestination": { - "type": "data-destination-type" - }, - "privateProperties": { - "private-key": "private-value" - }, - "errorDetail": "eventual-error-detail", - "createdAt": 1688465655, - "callbackAddresses": [{ - "transactional": false, - "uri": "http://callback/url", - "events": ["contract.negotiation", "transfer.process"], - "authKey": "auth-key", - "authCodeId": "auth-code-id" - }] - } - """; - } - - @Schema(name = "TransferState", example = TransferStateSchema.TRANSFER_STATE_EXAMPLE) - record TransferStateSchema( - @Schema(name = TYPE, example = TransferState.TRANSFER_STATE_TYPE) - String ldType, - String state - ) { - public static final String TRANSFER_STATE_EXAMPLE = """ - { - "@context": { "@vocab": "https://w3id.org/edc/v0.0.1/ns/" }, - "@type": "https://w3id.org/edc/v0.0.1/ns/TransferState", - "state": "STARTED" - } - """; - } - - @Schema(name = "TerminateTransfer", example = TerminateTransferSchema.TERMINATE_TRANSFER_EXAMPLE) - record TerminateTransferSchema( - @Schema(name = TYPE, example = TerminateTransfer.TERMINATE_TRANSFER_TYPE) - String ldType, - String state - ) { - public static final String TERMINATE_TRANSFER_EXAMPLE = """ - { - "@context": { "@vocab": "https://w3id.org/edc/v0.0.1/ns/" }, - "@type": "https://w3id.org/edc/v0.0.1/ns/TerminateTransfer", - "reason": "a reason to terminate" - } - """; - } - - @Schema(name = "SuspendTransfer", example = SuspendTransferSchema.SUSPEND_TRANSFER_EXAMPLE) - record SuspendTransferSchema( - @Schema(name = TYPE, example = SuspendTransfer.SUSPEND_TRANSFER_TYPE) - String ldType, - String state - ) { - public static final String SUSPEND_TRANSFER_EXAMPLE = """ - { - "@context": { "@vocab": "https://w3id.org/edc/v0.0.1/ns/" }, - "@type": "https://w3id.org/edc/v0.0.1/ns/SuspendTransfer", - "reason": "a reason to suspend" - } - """; - } -} diff --git a/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/transferprocess/v2/TransferProcessApiV2Controller.java b/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/transferprocess/v2/TransferProcessApiV2Controller.java deleted file mode 100644 index 4bb89612907..00000000000 --- a/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/transferprocess/v2/TransferProcessApiV2Controller.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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.controlplane.api.management.transferprocess.v2; - -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; -import jakarta.ws.rs.PathParam; -import jakarta.ws.rs.Produces; -import org.eclipse.edc.connector.controlplane.api.management.transferprocess.BaseTransferProcessApiController; -import org.eclipse.edc.connector.controlplane.services.spi.transferprocess.TransferProcessService; -import org.eclipse.edc.spi.monitor.Monitor; -import org.eclipse.edc.transform.spi.TypeTransformerRegistry; -import org.eclipse.edc.validator.spi.JsonObjectValidatorRegistry; - -import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON; -import static org.eclipse.edc.api.ApiWarnings.deprecationWarning; - -@Consumes(APPLICATION_JSON) -@Produces(APPLICATION_JSON) -@Path("/v2/transferprocesses") -public class TransferProcessApiV2Controller extends BaseTransferProcessApiController implements TransferProcessApiV2 { - public TransferProcessApiV2Controller(Monitor monitor, TransferProcessService service, TypeTransformerRegistry transformerRegistry, JsonObjectValidatorRegistry validatorRegistry) { - super(monitor, service, transformerRegistry, validatorRegistry); - } - - @POST - @Path("request") - @Override - public JsonArray queryTransferProcessesV2(JsonObject querySpecJson) { - monitor.warning(deprecationWarning("/v2", "/v3")); - return queryTransferProcesses(querySpecJson); - } - - @GET - @Path("{id}") - @Override - public JsonObject getTransferProcessV2(@PathParam("id") String id) { - monitor.warning(deprecationWarning("/v2", "/v3")); - return getTransferProcess(id); - } - - @GET - @Path("/{id}/state") - @Override - public JsonObject getTransferProcessStateV2(@PathParam("id") String id) { - monitor.warning(deprecationWarning("/v2", "/v3")); - return getTransferProcessState(id); - } - - @POST - @Override - public JsonObject initiateTransferProcessV2(JsonObject transferRequest) { - monitor.warning(deprecationWarning("/v2", "/v3")); - return initiateTransferProcess(transferRequest); - } - - @POST - @Path("/{id}/deprovision") - @Override - public void deprovisionTransferProcessV2(@PathParam("id") String id) { - monitor.warning(deprecationWarning("/v2", "/v3")); - deprovisionTransferProcess(id); - } - - @POST - @Path("/{id}/terminate") - @Override - public void terminateTransferProcessV2(@PathParam("id") String id, JsonObject terminateTransfer) { - monitor.warning(deprecationWarning("/v2", "/v3")); - terminateTransferProcess(id, terminateTransfer); - } - - @POST - @Path("/{id}/suspend") - @Override - public void suspendTransferProcessV2(@PathParam("id") String id, JsonObject suspendTransfer) { - monitor.warning(deprecationWarning("/v2", "/v3")); - suspendTransferProcess(id, suspendTransfer); - } - - @POST - @Path("/{id}/resume") - @Override - public void resumeTransferProcessV2(@PathParam("id") String id) { - monitor.warning(deprecationWarning("/v2", "/v3")); - resumeTransferProcess(id); - } -} diff --git a/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/transferprocess/TransferProcessApiExtensionTest.java b/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/transferprocess/TransferProcessApiExtensionTest.java index f32cab84ab4..30512189f56 100644 --- a/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/transferprocess/TransferProcessApiExtensionTest.java +++ b/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/transferprocess/TransferProcessApiExtensionTest.java @@ -14,7 +14,6 @@ package org.eclipse.edc.connector.controlplane.api.management.transferprocess; -import org.eclipse.edc.connector.controlplane.api.management.transferprocess.v2.TransferProcessApiV2Controller; import org.eclipse.edc.connector.controlplane.api.management.transferprocess.v3.TransferProcessApiV3Controller; import org.eclipse.edc.junit.extensions.DependencyInjectionExtension; import org.eclipse.edc.spi.system.ServiceExtensionContext; @@ -61,7 +60,6 @@ void initialize_shouldRegisterValidators(TransferProcessApiExtension extension, void initialize_shouldRegisterControllers(ServiceExtensionContext context, TransferProcessApiExtension extension) { extension.initialize(context); - verify(webService).registerResource(any(), isA(TransferProcessApiV2Controller.class)); verify(webService).registerResource(any(), isA(TransferProcessApiV3Controller.class)); } } diff --git a/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/transferprocess/v2/TransferProcessApiV2ControllerTest.java b/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/transferprocess/v2/TransferProcessApiV2ControllerTest.java deleted file mode 100644 index e50dc38a5aa..00000000000 --- a/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/transferprocess/v2/TransferProcessApiV2ControllerTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.controlplane.api.management.transferprocess.v2; - -import io.restassured.specification.RequestSpecification; -import org.eclipse.edc.connector.controlplane.api.management.transferprocess.BaseTransferProcessApiControllerTest; - -import static io.restassured.RestAssured.given; - -public class TransferProcessApiV2ControllerTest extends BaseTransferProcessApiControllerTest { - @Override - protected Object controller() { - return new TransferProcessApiV2Controller(monitor, service, transformerRegistry, validatorRegistry); - } - - @Override - protected RequestSpecification baseRequest() { - return given() - .port(port) - .baseUri("http://localhost:" + port + "/v2/transferprocesses"); - } -} diff --git a/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/DataPlaneSelectorApiExtension.java b/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/DataPlaneSelectorApiExtension.java index 665cd35393d..3928592a3f8 100644 --- a/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/DataPlaneSelectorApiExtension.java +++ b/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/DataPlaneSelectorApiExtension.java @@ -14,12 +14,9 @@ package org.eclipse.edc.connector.dataplane.selector; -import org.eclipse.edc.connector.dataplane.selector.api.v2.DataplaneSelectorApiV2Controller; import org.eclipse.edc.connector.dataplane.selector.api.v3.DataplaneSelectorApiV3Controller; import org.eclipse.edc.connector.dataplane.selector.api.v4.DataplaneSelectorApiV4Controller; -import org.eclipse.edc.connector.dataplane.selector.api.validation.DataPlaneInstanceValidator; import org.eclipse.edc.connector.dataplane.selector.spi.DataPlaneSelectorService; -import org.eclipse.edc.connector.dataplane.selector.transformer.JsonObjectToSelectionRequestTransformer; import org.eclipse.edc.runtime.metamodel.annotation.Extension; import org.eclipse.edc.runtime.metamodel.annotation.Inject; import org.eclipse.edc.spi.system.ServiceExtension; @@ -28,16 +25,12 @@ import org.eclipse.edc.transform.spi.TypeTransformerRegistry; import org.eclipse.edc.transform.transformer.edc.from.JsonObjectFromDataPlaneInstanceTransformer; import org.eclipse.edc.transform.transformer.edc.from.JsonObjectFromDataPlaneInstanceV3Transformer; -import org.eclipse.edc.transform.transformer.edc.to.JsonObjectToDataPlaneInstanceTransformer; -import org.eclipse.edc.validator.spi.JsonObjectValidatorRegistry; import org.eclipse.edc.web.spi.WebService; import org.eclipse.edc.web.spi.configuration.ApiContext; -import java.time.Clock; import java.util.Map; import static jakarta.json.Json.createBuilderFactory; -import static org.eclipse.edc.connector.dataplane.selector.spi.instance.DataPlaneInstance.DATAPLANE_INSTANCE_TYPE; import static org.eclipse.edc.spi.constants.CoreConstants.JSON_LD; @Extension(value = "DataPlane selector API") @@ -55,12 +48,6 @@ public class DataPlaneSelectorApiExtension implements ServiceExtension { @Inject private TypeTransformerRegistry transformerRegistry; - @Inject - private JsonObjectValidatorRegistry validatorRegistry; - - @Inject - private Clock clock; - @Override public void initialize(ServiceExtensionContext context) { var managementApiTransformerRegistry = transformerRegistry.forContext("management-api"); @@ -74,12 +61,5 @@ public void initialize(ServiceExtensionContext context) { managementApiTransformerRegistryV3.register(new JsonObjectFromDataPlaneInstanceV3Transformer(createBuilderFactory(Map.of()), typeManager.getMapper(JSON_LD))); webservice.registerResource(ApiContext.MANAGEMENT, new DataplaneSelectorApiV3Controller(selectionService, managementApiTransformerRegistryV3)); - // V2 - validatorRegistry.register(DATAPLANE_INSTANCE_TYPE, DataPlaneInstanceValidator.instance()); - var managementApiTransformerRegistryV2 = managementApiTransformerRegistry.forContext("v2"); - managementApiTransformerRegistryV2.register(new JsonObjectToSelectionRequestTransformer()); - managementApiTransformerRegistryV2.register(new JsonObjectToDataPlaneInstanceTransformer()); - managementApiTransformerRegistryV2.register(new JsonObjectFromDataPlaneInstanceV3Transformer(createBuilderFactory(Map.of()), typeManager.getMapper(JSON_LD))); - webservice.registerResource(ApiContext.MANAGEMENT, new DataplaneSelectorApiV2Controller(selectionService, managementApiTransformerRegistryV2, validatorRegistry, clock, context.getMonitor())); } } diff --git a/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/model/SelectionRequest.java b/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/model/SelectionRequest.java deleted file mode 100644 index dfbef391a22..00000000000 --- a/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/model/SelectionRequest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.model; - -import org.eclipse.edc.connector.dataplane.selector.api.v2.DataplaneSelectorApiV2; -import org.eclipse.edc.spi.types.domain.DataAddress; - -import static org.eclipse.edc.spi.constants.CoreConstants.EDC_NAMESPACE; - -/** - * Represents the request body that the {@link DataplaneSelectorApiV2#selectDataPlaneInstanceV2(jakarta.json.JsonObject)} endpoint requires - * Contains source and destination address and optionally the name of a selection strategy - */ -public class SelectionRequest { - public static final String SELECTION_REQUEST_TYPE = EDC_NAMESPACE + "SelectionRequest"; - public static final String SOURCE_ADDRESS = EDC_NAMESPACE + "source"; - public static final String DEST_ADDRESS = EDC_NAMESPACE + "destination"; - public static final String TRANSFER_TYPE = EDC_NAMESPACE + "transferType"; - public static final String STRATEGY = EDC_NAMESPACE + "strategy"; - private DataAddress source; - private DataAddress destination; - private String strategy; - - private String transferType; - - private SelectionRequest() { - } - - public DataAddress getSource() { - return source; - } - - public DataAddress getDestination() { - return destination; - } - - public String getStrategy() { - return strategy; - } - - public String getTransferType() { - return transferType; - } - - public static final class Builder { - private final SelectionRequest instance; - - private Builder() { - instance = new SelectionRequest(); - } - - public static Builder newInstance() { - return new Builder(); - } - - public Builder source(DataAddress source) { - this.instance.source = source; - return this; - } - - public Builder destination(DataAddress destination) { - this.instance.destination = destination; - return this; - } - - public Builder strategy(String strategy) { - this.instance.strategy = strategy; - return this; - } - - public Builder transferType(String transferType) { - this.instance.transferType = transferType; - return this; - } - - public SelectionRequest build() { - return instance; - } - } -} diff --git a/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/v2/DataPlaneInstanceSchemaV2.java b/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/v2/DataPlaneInstanceSchemaV2.java deleted file mode 100644 index e378d86d0ae..00000000000 --- a/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/v2/DataPlaneInstanceSchemaV2.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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.v2; - -import io.swagger.v3.oas.annotations.media.Schema; - -import java.net.URL; -import java.util.Set; - -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; -import static org.eclipse.edc.connector.dataplane.selector.spi.instance.DataPlaneInstance.DATAPLANE_INSTANCE_TYPE; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.CONTEXT; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; - -@Schema(example = DataPlaneInstanceSchemaV2.DATAPLANE_INSTANCE_EXAMPLE) -public record DataPlaneInstanceSchemaV2( - @Schema(name = CONTEXT, requiredMode = REQUIRED) - Object context, - @Schema(name = TYPE, example = DATAPLANE_INSTANCE_TYPE) - String type, - @Schema(name = ID) - String id, - @Schema(requiredMode = REQUIRED) - URL url, - @Schema(requiredMode = REQUIRED) - Set allowedSourceTypes, - @Schema(requiredMode = REQUIRED) - Set allowedDestTypes, - Integer turnCount, - Long lastActive, - String state, - Long stateTimestamp) { - public static final String DATAPLANE_INSTANCE_EXAMPLE = """ - { - "@context": { - "@vocab": "https://w3id.org/edc/v0.0.1/ns/" - }, - "@id": "your-dataplane-id", - "url": "http://somewhere.com:1234/api/v1", - "allowedSourceTypes": [ - "source-type1", - "source-type2" - ], - "allowedDestTypes": ["your-dest-type"], - "allowedTransferTypes": ["transfer-type"], - "state": "AVAILABLE", - "stateTimestamp": 1688465655 - } - """; -} diff --git a/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/v2/DataplaneSelectorApiV2.java b/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/v2/DataplaneSelectorApiV2.java deleted file mode 100644 index 405eb269b56..00000000000 --- a/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/v2/DataplaneSelectorApiV2.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2023 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.v2; - -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.parameters.RequestBody; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.json.JsonArray; -import jakarta.json.JsonObject; -import jakarta.ws.rs.GET; -import jakarta.ws.rs.POST; -import org.eclipse.edc.api.model.ApiCoreSchema; - -@OpenAPIDefinition(info = @Info(version = "v2")) -@Tag(name = "Dataplane Selector V2") -public interface DataplaneSelectorApiV2 { - - @Operation(method = "POST", - deprecated = true, - description = "Finds the best fitting data plane instance for a particular query", - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = SelectionRequestSchema.class))), - responses = { - @ApiResponse(responseCode = "200", description = "The DataPlane instance that fits best for the given selection request", - content = @Content(schema = @Schema(implementation = DataPlaneInstanceSchemaV2.class))), - @ApiResponse(responseCode = "204", description = "No suitable DataPlane instance was found"), - @ApiResponse(responseCode = "400", description = "Request body was malformed", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }) - @POST - JsonObject selectDataPlaneInstanceV2(JsonObject request); - - - @Operation(method = "POST", - description = "Adds one dataplane instance to the internal database of the selector. DEPRECATED: dataplanes should register themselves through control-api", - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = DataPlaneInstanceSchemaV2.class))), - responses = { - @ApiResponse(responseCode = "200", description = "Entry was added successfully to the database", content = @Content(schema = @Schema(implementation = ApiCoreSchema.IdResponseSchema.class))), - @ApiResponse(responseCode = "400", description = "Request body was malformed", content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiCoreSchema.ApiErrorDetailSchema.class)))) - }, - deprecated = true - ) - @POST - JsonObject addDataPlaneInstanceV2(JsonObject instance); - - @Operation(method = "GET", - 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 = DataPlaneInstanceSchemaV2.class)))) - }, - deprecated = true - ) - @GET - @Deprecated(since = "0.7.0") - JsonArray getAllDataPlaneInstancesV2(); - -} diff --git a/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/v2/DataplaneSelectorApiV2Controller.java b/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/v2/DataplaneSelectorApiV2Controller.java deleted file mode 100644 index 418f9d6f844..00000000000 --- a/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/v2/DataplaneSelectorApiV2Controller.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2023 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.v2; - -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; -import jakarta.ws.rs.Produces; -import jakarta.ws.rs.core.MediaType; -import org.eclipse.edc.api.model.IdResponse; -import org.eclipse.edc.connector.dataplane.selector.api.model.SelectionRequest; -import org.eclipse.edc.connector.dataplane.selector.spi.DataPlaneSelectorService; -import org.eclipse.edc.connector.dataplane.selector.spi.instance.DataPlaneInstance; -import org.eclipse.edc.spi.EdcException; -import org.eclipse.edc.spi.monitor.Monitor; -import org.eclipse.edc.spi.result.Result; -import org.eclipse.edc.transform.spi.TypeTransformerRegistry; -import org.eclipse.edc.validator.spi.JsonObjectValidatorRegistry; -import org.eclipse.edc.web.spi.exception.InvalidRequestException; -import org.eclipse.edc.web.spi.exception.ValidationFailureException; - -import java.time.Clock; - -import static jakarta.json.stream.JsonCollectors.toJsonArray; -import static org.eclipse.edc.api.ApiWarnings.deprecationWarning; -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 }) -@Path("/v2/dataplanes") -public class DataplaneSelectorApiV2Controller implements DataplaneSelectorApiV2 { - - private final DataPlaneSelectorService selectionService; - private final TypeTransformerRegistry transformerRegistry; - - private final JsonObjectValidatorRegistry validatorRegistry; - - private final Clock clock; - private final Monitor monitor; - - public DataplaneSelectorApiV2Controller(DataPlaneSelectorService selectionService, TypeTransformerRegistry transformerRegistry, - JsonObjectValidatorRegistry validatorRegistry, Clock clock, Monitor monitor) { - this.selectionService = selectionService; - this.transformerRegistry = transformerRegistry; - this.validatorRegistry = validatorRegistry; - this.clock = clock; - this.monitor = monitor; - } - - @Override - @POST - @Path("select") - public JsonObject selectDataPlaneInstanceV2(JsonObject requestObject) { - monitor.warning(deprecationWarning("/v2", "/v3")); - var request = transformerRegistry.transform(requestObject, SelectionRequest.class) - .orElseThrow(InvalidRequestException::new); - - var selection = selectionService.select(request.getSource(), request.getTransferType(), request.getStrategy()); - - if (selection.failed()) { - return null; - } - return transformerRegistry.transform(selection.getContent(), JsonObject.class) - .orElseThrow(f -> new EdcException(f.getFailureDetail())); - } - - @Override - @POST - public JsonObject addDataPlaneInstanceV2(JsonObject jsonObject) { - monitor.warning(deprecationWarning("/v2", "/v3")); - validatorRegistry.validate(DATAPLANE_INSTANCE_TYPE, jsonObject).orElseThrow(ValidationFailureException::new); - - var instance = transformerRegistry.transform(jsonObject, DataPlaneInstance.class) - .orElseThrow(InvalidRequestException::new); - - selectionService.addInstance(instance) - .orElseThrow(exceptionMapper(DataPlaneInstance.class, instance.getId())); - - var idResponse = IdResponse.Builder.newInstance() - .id(instance.getId()) - .createdAt(clock.millis()) - .build(); - - return transformerRegistry.transform(idResponse, JsonObject.class) - .orElseThrow(f -> new EdcException(f.getFailureDetail())); - } - - @Override - @GET - public JsonArray getAllDataPlaneInstancesV2() { - monitor.warning(deprecationWarning("/v2", "/v3")); - 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()); - } - -} diff --git a/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/v2/SelectionRequestSchema.java b/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/v2/SelectionRequestSchema.java deleted file mode 100644 index e6b113af82c..00000000000 --- a/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/v2/SelectionRequestSchema.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.v2; - -import io.swagger.v3.oas.annotations.media.Schema; -import org.eclipse.edc.api.model.ApiCoreSchema; - -import static org.eclipse.edc.connector.dataplane.selector.api.model.SelectionRequest.SELECTION_REQUEST_TYPE; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; - -@Schema(example = SelectionRequestSchema.SELECTION_REQUEST_INPUT_EXAMPLE) -public record SelectionRequestSchema( - @Schema(name = TYPE, example = SELECTION_REQUEST_TYPE) - String type, - String strategy, - String transferType, - ApiCoreSchema.DataAddressSchema source, - ApiCoreSchema.DataAddressSchema destination -) { - public static final String SELECTION_REQUEST_INPUT_EXAMPLE = """ - { - "@context": { - "@vocab": "https://w3id.org/edc/v0.0.1/ns/" - }, - "source": { - "@type": "https://w3id.org/edc/v0.0.1/ns/DataAddress", - "type": "test-src1" - }, - "destination": { - "@type": "https://w3id.org/edc/v0.0.1/ns/DataAddress", - "type": "test-dst2" - }, - "strategy": "you_custom_strategy", - "transferType": "you_custom_transfer_type" - } - """; -} diff --git a/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/v4/DataplaneSelectorApiV4.java b/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/v4/DataplaneSelectorApiV4.java index 851ef1241e7..0d919139a6f 100644 --- a/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/v4/DataplaneSelectorApiV4.java +++ b/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/api/v4/DataplaneSelectorApiV4.java @@ -26,7 +26,7 @@ import jakarta.ws.rs.GET; @OpenAPIDefinition(info = @Info(version = "v4")) -@Tag(name = "Dataplane Selector V4") +@Tag(name = "Dataplane Selector v4alpha") public interface DataplaneSelectorApiV4 { @Operation(method = "GET", diff --git a/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/transformer/JsonObjectToSelectionRequestTransformer.java b/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/transformer/JsonObjectToSelectionRequestTransformer.java deleted file mode 100644 index ad3800bb9a1..00000000000 --- a/extensions/data-plane-selector/data-plane-selector-api/src/main/java/org/eclipse/edc/connector/dataplane/selector/transformer/JsonObjectToSelectionRequestTransformer.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2023 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.transformer; - -import jakarta.json.JsonObject; -import org.eclipse.edc.connector.dataplane.selector.api.model.SelectionRequest; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; -import org.eclipse.edc.spi.types.domain.DataAddress; -import org.eclipse.edc.transform.spi.TransformerContext; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class JsonObjectToSelectionRequestTransformer extends AbstractJsonLdTransformer { - - public JsonObjectToSelectionRequestTransformer() { - super(JsonObject.class, SelectionRequest.class); - - } - - @Override - public @Nullable SelectionRequest transform(@NotNull JsonObject jsonObject, @NotNull TransformerContext context) { - - var builder = SelectionRequest.Builder.newInstance(); - - visitProperties(jsonObject, (key, jsonValue) -> { - switch (key) { - case SelectionRequest.DEST_ADDRESS -> - builder.destination(transformObject(jsonValue, DataAddress.class, context)); - case SelectionRequest.SOURCE_ADDRESS -> - builder.source(transformObject(jsonValue, DataAddress.class, context)); - case SelectionRequest.STRATEGY -> builder.strategy(transformString(jsonValue, context)); - case SelectionRequest.TRANSFER_TYPE -> builder.transferType(transformString(jsonValue, context)); - default -> throw new IllegalStateException("Unexpected value: " + key); - } - }); - - return builder.build(); - } - - -} diff --git a/extensions/data-plane-selector/data-plane-selector-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/DataPlaneSelectorApiExtensionTest.java b/extensions/data-plane-selector/data-plane-selector-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/DataPlaneSelectorApiExtensionTest.java index 65ff480f565..bab00058d37 100644 --- a/extensions/data-plane-selector/data-plane-selector-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/DataPlaneSelectorApiExtensionTest.java +++ b/extensions/data-plane-selector/data-plane-selector-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/DataPlaneSelectorApiExtensionTest.java @@ -16,7 +16,6 @@ import org.eclipse.edc.boot.system.DefaultServiceExtensionContext; import org.eclipse.edc.boot.system.injection.ObjectFactory; -import org.eclipse.edc.connector.dataplane.selector.api.v2.DataplaneSelectorApiV2Controller; import org.eclipse.edc.connector.dataplane.selector.api.v3.DataplaneSelectorApiV3Controller; import org.eclipse.edc.connector.dataplane.selector.service.EmbeddedDataPlaneSelectorService; import org.eclipse.edc.connector.dataplane.selector.spi.DataPlaneSelectorService; @@ -74,7 +73,6 @@ void shouldRegisterManagementContext() { extension.initialize(contextWithConfig(config)); - verify(webService).registerResource(eq(ApiContext.MANAGEMENT), isA(DataplaneSelectorApiV2Controller.class)); verify(managementApiTransformerRegistry).register(isA(JsonObjectFromDataPlaneInstanceTransformer.class)); } @@ -84,7 +82,6 @@ void shouldRegisterControllers() { extension.initialize(contextWithConfig(config)); - verify(webService).registerResource(eq(ApiContext.MANAGEMENT), isA(DataplaneSelectorApiV2Controller.class)); verify(webService).registerResource(eq(ApiContext.MANAGEMENT), isA(DataplaneSelectorApiV3Controller.class)); } diff --git a/extensions/data-plane-selector/data-plane-selector-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/api/v2/DataPlaneSelectorApiV2ControllerTest.java b/extensions/data-plane-selector/data-plane-selector-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/api/v2/DataPlaneSelectorApiV2ControllerTest.java deleted file mode 100644 index 1bc8466c3aa..00000000000 --- a/extensions/data-plane-selector/data-plane-selector-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/api/v2/DataPlaneSelectorApiV2ControllerTest.java +++ /dev/null @@ -1,284 +0,0 @@ -/* - * 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.v2; - -import io.restassured.specification.RequestSpecification; -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonObject; -import jakarta.json.JsonObjectBuilder; -import org.eclipse.edc.connector.dataplane.selector.api.model.SelectionRequest; -import org.eclipse.edc.connector.dataplane.selector.spi.instance.DataPlaneInstance; -import org.eclipse.edc.connector.dataplane.selector.spi.store.DataPlaneInstanceStore; -import org.eclipse.edc.connector.dataplane.selector.spi.strategy.SelectionStrategy; -import org.eclipse.edc.connector.dataplane.selector.spi.strategy.SelectionStrategyRegistry; -import org.eclipse.edc.junit.annotations.ApiTest; -import org.eclipse.edc.junit.extensions.EdcExtension; -import org.eclipse.edc.spi.types.domain.DataAddress; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; - -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static io.restassured.RestAssured.given; -import static io.restassured.http.ContentType.JSON; -import static jakarta.json.Json.createObjectBuilder; -import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.edc.connector.dataplane.selector.TestFunctions.createInstance; -import static org.eclipse.edc.connector.dataplane.selector.TestFunctions.createInstanceBuilder; -import static org.eclipse.edc.connector.dataplane.selector.TestFunctions.createInstanceJson; -import static org.eclipse.edc.connector.dataplane.selector.TestFunctions.createInstanceJsonBuilder; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.spi.constants.CoreConstants.EDC_NAMESPACE; -import static org.eclipse.edc.util.io.Ports.getFreePort; -import static org.hamcrest.Matchers.equalTo; - -@ApiTest -@ExtendWith(EdcExtension.class) -public class DataPlaneSelectorApiV2ControllerTest { - - private final int port = getFreePort(); - - @BeforeEach - void setup(EdcExtension extension) { - extension.setConfiguration(Map.of( - "web.http.port", String.valueOf(getFreePort()), - "web.http.management.port", String.valueOf(port), - "web.http.management.path", "/management" - )); - } - - @Test - void getAll(DataPlaneInstanceStore store) { - List.of(createInstance("test-id1"), createInstance("test-id2"), createInstance("test-id3")) - .forEach(store::save); - - var array = baseRequest() - .get() - .then() - .statusCode(200) - .extract().body().as(JsonArray.class); - - assertThat(array).hasSize(3) - .allSatisfy(jo -> assertThat(jo.asJsonObject().getString(ID)) - .isIn("test-id1", "test-id2", "test-id3")); - } - - @Test - void getAll_noneExist() { - var array = baseRequest() - .get() - .then() - .statusCode(200) - .extract().body().as(JsonArray.class); - - assertThat(array).isNotNull().isEmpty(); - } - - @Test - void addEntry(DataPlaneInstanceStore store) { - var dpi = createInstanceJson("test-id"); - - var result = baseRequest() - .body(dpi) - .contentType(JSON) - .post() - .then() - .statusCode(200) - .extract().body().as(JsonObject.class); - - assertThat(result.getString(ID)).isEqualTo("test-id"); - assertThat(store.getAll()).hasSize(1) - .allMatch(d -> d.getId().equals("test-id")); - } - - @Test - void addEntry_fails_whenMissingUrl() { - var dpi = createInstanceJsonBuilder("test-id").build(); - - baseRequest() - .body(dpi) - .contentType(JSON) - .post() - .then() - .statusCode(400); - } - - @Test - void addEntry_exists_shouldOverwrite(DataPlaneInstanceStore store) { - var dpi1 = createInstance("test-id1"); - var dpi2 = createInstance("test-id2"); - var dpi3 = createInstance("test-id3"); - List.of(dpi1, dpi2, dpi3).forEach(store::save); - - var newDpi = Json.createObjectBuilder(createInstanceJson("test-id2")) - .add(DataPlaneInstance.ALLOWED_SOURCE_TYPES, Json.createValue("test-src-type")) - .build(); - - baseRequest() - .body(newDpi) - .contentType(JSON) - .post() - .then() - .statusCode(200); - - assertThat(store.getAll()).hasSize(3) - .anyMatch(it -> it.getAllowedSourceTypes().contains("test-src-type")); - } - - @Test - void select(DataPlaneInstanceStore store) { - var dpi = createInstanceBuilder("test-id1") - .allowedSourceType("test-src1") - .allowedDestType("test-dst1") - .allowedTransferType("transfer-type-1") - .build(); - var dpi2 = createInstanceBuilder("test-id2") - .allowedSourceType("test-src2") - .allowedDestType("test-dst2") - .allowedTransferType("transfer-type-2") - .build(); - Stream.of(dpi, dpi2).peek(DataPlaneInstance::transitionToAvailable).forEach(store::save); - - var rq = createSelectionRequestJson("test-src1", "test-dst1", null, "transfer-type-1"); - - var result = baseRequest() - .body(rq) - .contentType(JSON) - .post("/select") - .then() - .statusCode(200) - .extract().body().as(JsonObject.class); - assertThat(result.getString(ID)).isEqualTo("test-id1"); - } - - @Test - void select_noneCanHandle_shouldReturnEmpty(DataPlaneInstanceStore store) { - var dpi = createInstanceBuilder("test-id") - .allowedSourceType("test-src1") - .allowedDestType("test-dst1") - .build(); - var dpi2 = createInstanceBuilder("test-id") - .allowedSourceType("test-src2") - .allowedDestType("test-dst2") - .build(); - List.of(dpi, dpi2).forEach(store::save); - - var rq = createSelectionRequestJson("notexist-src", "test-dst2", null, "transfer-type"); - - baseRequest() - .body(rq) - .contentType(JSON) - .post("/select") - .then() - .statusCode(204) - .body(equalTo("")); - } - - @Test - void select_selectionStrategyNotFound(DataPlaneInstanceStore store) { - var dpi = createInstanceBuilder("test-id") - .allowedSourceType("test-src1") - .allowedDestType("test-dst1") - .build(); - var dpi2 = createInstanceBuilder("test-id") - .allowedSourceType("test-src2") - .allowedDestType("test-dst2") - .build(); - List.of(dpi, dpi2).forEach(store::save); - - var rq = createSelectionRequestJson("test-src1", "test-dst2", "notexist", "transfer-type1"); - - baseRequest() - .body(rq) - .contentType(JSON) - .post("/select") - .then() - .statusCode(204); - } - - @Test - void select_withCustomStrategy(DataPlaneInstanceStore store, SelectionStrategyRegistry selectionStrategyRegistry) { - var dpi = createInstanceBuilder("test-id1") - .allowedSourceType("test-src1") - .allowedDestType("test-dst1") - .allowedTransferType("transfer-type-1") - .build(); - var dpi2 = createInstanceBuilder("test-id2") - .allowedSourceType("test-src1") - .allowedDestType("test-dst1") - .allowedTransferType("transfer-type-2") - .build(); - Stream.of(dpi, dpi2).peek(DataPlaneInstance::transitionToAvailable).forEach(store::save); - - var myCustomStrategy = new SelectionStrategy() { - @Override - public DataPlaneInstance apply(List instances) { - return instances.stream().filter(i -> i.getId().equals("test-id1")).findFirst().orElseThrow(); - } - - @Override - public String getName() { - return "myCustomStrategy"; - } - }; - - selectionStrategyRegistry.add(myCustomStrategy); - - var rq = createSelectionRequestJson("test-src1", "test-dst1", "myCustomStrategy", "transfer-type-1"); - - var result = baseRequest() - .body(rq) - .contentType(JSON) - .post("/select") - .then() - .log().ifValidationFails() - .statusCode(200) - .extract().body().as(JsonObject.class); - - assertThat(result).isNotNull(); - assertThat(result.getString(ID)).isEqualTo("test-id1"); - } - - private RequestSpecification baseRequest() { - return given() - .port(port) - .basePath("/management/v2/dataplanes") - .when(); - } - - private JsonObject createSelectionRequestJson(String srcType, String destType, String strategy, String transferType) { - var builder = createObjectBuilder() - .add(SelectionRequest.SOURCE_ADDRESS, createDataAddress(srcType)) - .add(SelectionRequest.DEST_ADDRESS, createDataAddress(destType)) - .add(SelectionRequest.TRANSFER_TYPE, transferType); - - if (strategy != null) { - builder.add(SelectionRequest.STRATEGY, strategy); - } - return builder.build(); - } - - private JsonObjectBuilder createDataAddress(String type) { - return createObjectBuilder() - .add(TYPE, EDC_NAMESPACE + "DataAddress") - .add(DataAddress.EDC_DATA_ADDRESS_TYPE_PROPERTY, type); - } - -} diff --git a/extensions/data-plane-selector/data-plane-selector-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/api/v3/DataPlaneApiSelectorV3Test.java b/extensions/data-plane-selector/data-plane-selector-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/api/v3/DataPlaneApiSelectorV3Test.java index 1500c793af2..a9d362b7431 100644 --- a/extensions/data-plane-selector/data-plane-selector-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/api/v3/DataPlaneApiSelectorV3Test.java +++ b/extensions/data-plane-selector/data-plane-selector-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/api/v3/DataPlaneApiSelectorV3Test.java @@ -18,7 +18,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.json.JsonObject; import org.eclipse.edc.connector.dataplane.selector.spi.instance.DataPlaneInstance; -import org.eclipse.edc.connector.dataplane.selector.transformer.JsonObjectToSelectionRequestTransformer; import org.eclipse.edc.jsonld.TitaniumJsonLd; import org.eclipse.edc.jsonld.spi.JsonLd; import org.eclipse.edc.jsonld.util.JacksonJsonLd; @@ -44,7 +43,6 @@ public class DataPlaneApiSelectorV3Test { @BeforeEach void setUp() { transformer.register(new JsonObjectToDataPlaneInstanceTransformer()); - transformer.register(new JsonObjectToSelectionRequestTransformer()); transformer.register(new JsonObjectToDataAddressTransformer()); transformer.register(new JsonValueToGenericTypeTransformer(objectMapper)); } diff --git a/extensions/data-plane-selector/data-plane-selector-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/api/v4/DataPlaneApiSelectorV4Test.java b/extensions/data-plane-selector/data-plane-selector-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/api/v4/DataPlaneApiSelectorV4Test.java index 2914906f7d3..36c4e96f729 100644 --- a/extensions/data-plane-selector/data-plane-selector-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/api/v4/DataPlaneApiSelectorV4Test.java +++ b/extensions/data-plane-selector/data-plane-selector-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/api/v4/DataPlaneApiSelectorV4Test.java @@ -18,7 +18,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.json.JsonObject; import org.eclipse.edc.connector.dataplane.selector.spi.instance.DataPlaneInstance; -import org.eclipse.edc.connector.dataplane.selector.transformer.JsonObjectToSelectionRequestTransformer; import org.eclipse.edc.jsonld.TitaniumJsonLd; import org.eclipse.edc.jsonld.spi.JsonLd; import org.eclipse.edc.jsonld.util.JacksonJsonLd; @@ -44,7 +43,6 @@ public class DataPlaneApiSelectorV4Test { @BeforeEach void setUp() { transformer.register(new JsonObjectToDataPlaneInstanceTransformer()); - transformer.register(new JsonObjectToSelectionRequestTransformer()); transformer.register(new JsonObjectToDataAddressTransformer()); transformer.register(new JsonValueToGenericTypeTransformer(objectMapper)); } diff --git a/extensions/data-plane-selector/data-plane-selector-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/transformer/JsonObjectToSelectionRequestTransformerTest.java b/extensions/data-plane-selector/data-plane-selector-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/transformer/JsonObjectToSelectionRequestTransformerTest.java deleted file mode 100644 index 956dc213ef0..00000000000 --- a/extensions/data-plane-selector/data-plane-selector-api/src/test/java/org/eclipse/edc/connector/dataplane/selector/transformer/JsonObjectToSelectionRequestTransformerTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2023 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.transformer; - -import jakarta.json.Json; -import jakarta.json.JsonObject; -import org.eclipse.edc.spi.types.domain.DataAddress; -import org.eclipse.edc.transform.spi.TransformerContext; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.NullSource; -import org.junit.jupiter.params.provider.ValueSource; - -import static jakarta.json.Json.createObjectBuilder; -import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.edc.connector.dataplane.selector.api.model.SelectionRequest.DEST_ADDRESS; -import static org.eclipse.edc.connector.dataplane.selector.api.model.SelectionRequest.SOURCE_ADDRESS; -import static org.eclipse.edc.connector.dataplane.selector.api.model.SelectionRequest.STRATEGY; -import static org.eclipse.edc.connector.dataplane.selector.api.model.SelectionRequest.TRANSFER_TYPE; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.isA; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -class JsonObjectToSelectionRequestTransformerTest { - - private final JsonObjectToSelectionRequestTransformer transformer = new JsonObjectToSelectionRequestTransformer(); - private final TransformerContext context = mock(); - - @BeforeEach - void setUp() { - when(context.transform(isA(JsonObject.class), eq(DataAddress.class))).thenReturn(DataAddress.Builder.newInstance().type("test-type").build()); - } - - @ParameterizedTest - @ValueSource(strings = "test-strategy") - @NullSource - void transform(String strategy) { - var builder = Json.createObjectBuilder() - .add(SOURCE_ADDRESS, createObjectBuilder() - .add(TYPE, DataAddress.EDC_DATA_ADDRESS_TYPE) - .add(DataAddress.EDC_DATA_ADDRESS_TYPE_PROPERTY, "test-type") - .add(DataAddress.EDC_DATA_ADDRESS_KEY_NAME, "test-key") - ) - .add(DEST_ADDRESS, createObjectBuilder() - .add(TYPE, DataAddress.EDC_DATA_ADDRESS_TYPE) - .add(DataAddress.EDC_DATA_ADDRESS_TYPE_PROPERTY, "test-type") - .add(DataAddress.EDC_DATA_ADDRESS_KEY_NAME, "test-key") - ) - .add(TRANSFER_TYPE, "transfer-type"); - if (strategy != null) { - builder.add(STRATEGY, strategy); - } - var jsonObject = builder.build(); - - var rq = transformer.transform(jsonObject, context); - assertThat(rq).isNotNull(); - assertThat(rq.getStrategy()).isEqualTo(strategy); - assertThat(rq.getDestination()).isNotNull(); - assertThat(rq.getSource()).isNotNull(); - assertThat(rq.getTransferType()).isEqualTo("transfer-type"); - } - -}