diff --git a/core/common/validator-core/src/main/java/org/eclipse/edc/validator/jsonobject/JsonWalkers.java b/core/common/validator-core/src/main/java/org/eclipse/edc/validator/jsonobject/JsonWalkers.java index 56b4d5b215b..ec225357525 100644 --- a/core/common/validator-core/src/main/java/org/eclipse/edc/validator/jsonobject/JsonWalkers.java +++ b/core/common/validator-core/src/main/java/org/eclipse/edc/validator/jsonobject/JsonWalkers.java @@ -33,7 +33,7 @@ public Stream extract(JsonObject object, JsonLdPath path) { public Stream extract(JsonObject object, JsonLdPath path) { var array = object.getJsonArray(path.last()); - if (array == null) { + if (array == null || array.isEmpty()) { return Stream.empty(); } else { return Stream.of(array.getJsonObject(0)); diff --git a/docs/developer/custom_validation.md b/docs/developer/custom_validation.md index b4dd416800f..a0b6038f309 100644 --- a/docs/developer/custom_validation.md +++ b/docs/developer/custom_validation.md @@ -9,7 +9,7 @@ themselves. ## When to use it This feature is intended for use cases where the standard DTO validation, that ships with EDC's APIs is not sufficient. -Please check out the [OpenAPI spec](../../resources/openapi/openapi.yaml) to find out more about the object schema. +Please check out the [OpenAPI spec](../../resources/openapi/yaml) to find out more about the object schema. EDC features various data types that do not have a strict schema but are *extensible*, for example `Asset`/`AssetDto`, or a `DataRequest`/`DataRequestDto`. This was done by design, to allow for maximum flexibility and openness. However, diff --git a/extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/model/ApiCoreSchema.java b/extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/model/ApiCoreSchema.java index 9ec433489df..7cf0291e7b0 100644 --- a/extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/model/ApiCoreSchema.java +++ b/extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/model/ApiCoreSchema.java @@ -37,6 +37,7 @@ record CriterionSchema( public static final String CRITERION_EXAMPLE = """ { "@context": { "edc": "https://w3id.org/edc/v0.0.1/ns/" }, + "@type": "Criterion", "operandLeft": "fieldName", "operator": "=", "operandRight": "some value" @@ -57,11 +58,12 @@ record QuerySpecSchema( public static final String QUERY_SPEC_EXAMPLE = """ { "@context": { "edc": "https://w3id.org/edc/v0.0.1/ns/" }, + "@type": "QuerySpec", "offset": 5, "limit": 10, "sortOrder": "DESC", "sortField": "fieldName", - "criterion": [] + "filterExpression": [] } """; } diff --git a/extensions/common/api/management-api-configuration/src/main/java/org/eclipse/edc/connector/api/management/configuration/ManagementApiSchema.java b/extensions/common/api/management-api-configuration/src/main/java/org/eclipse/edc/connector/api/management/configuration/ManagementApiSchema.java index ddcaad3b706..d63e625b995 100644 --- a/extensions/common/api/management-api-configuration/src/main/java/org/eclipse/edc/connector/api/management/configuration/ManagementApiSchema.java +++ b/extensions/common/api/management-api-configuration/src/main/java/org/eclipse/edc/connector/api/management/configuration/ManagementApiSchema.java @@ -40,7 +40,7 @@ record ContractAgreementSchema( long contractSigningDate, String assetId, @Schema(description = "ODRL policy") - Object policy + PolicySchema policy ) { public static final String CONTRACT_AGREEMENT_EXAMPLE = """ { @@ -81,5 +81,30 @@ record DataAddressSchema( String type, @Schema(name = "type") String typeProperty - ) { } + ) { + } + + @Schema(description = "ODRL policy", example = PolicySchema.POLICY_EXAMPLE) + record PolicySchema() { + public static final String POLICY_EXAMPLE = """ + { + "@context": "http://www.w3.org/ns/odrl.jsonld", + "@id": "0949ba30-680c-44e6-bc7d-1688cbe1847e", + "@type": "odrl:Set", + "permission": { + "target": "http://example.com/asset:9898.movie", + "action": { + "type": "http://www.w3.org/ns/odrl/2/use" + }, + "constraint": { + "leftOperand": "https://w3id.org/edc/v0.0.1/ns/left", + "operator": "eq", + "rightOperand": "value" + } + }, + "prohibition": [], + "obligation": [] + } + """; + } } diff --git a/extensions/common/api/management-api-configuration/src/test/java/org/eclipse/edc/connector/api/management/configuration/ManagementApiSchemaTest.java b/extensions/common/api/management-api-configuration/src/test/java/org/eclipse/edc/connector/api/management/configuration/ManagementApiSchemaTest.java index e123fa4b85c..330a8095e3c 100644 --- a/extensions/common/api/management-api-configuration/src/test/java/org/eclipse/edc/connector/api/management/configuration/ManagementApiSchemaTest.java +++ b/extensions/common/api/management-api-configuration/src/test/java/org/eclipse/edc/connector/api/management/configuration/ManagementApiSchemaTest.java @@ -24,6 +24,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat; import static org.eclipse.edc.connector.api.management.configuration.ManagementApiSchema.ContractAgreementSchema.CONTRACT_AGREEMENT_EXAMPLE; +import static org.eclipse.edc.connector.api.management.configuration.ManagementApiSchema.PolicySchema.POLICY_EXAMPLE; import static org.eclipse.edc.connector.contract.spi.types.agreement.ContractAgreement.CONTRACT_AGREEMENT_ASSET_ID; import static org.eclipse.edc.connector.contract.spi.types.agreement.ContractAgreement.CONTRACT_AGREEMENT_CONSUMER_ID; import static org.eclipse.edc.connector.contract.spi.types.agreement.ContractAgreement.CONTRACT_AGREEMENT_POLICY; @@ -33,6 +34,7 @@ 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; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_PERMISSION_ATTRIBUTE; import static org.eclipse.edc.junit.assertions.AbstractResultAssert.assertThat; import static org.eclipse.edc.junit.extensions.TestServiceExtensionContext.testServiceExtensionContext; @@ -57,4 +59,16 @@ void contractAgreementExample() throws JsonProcessingException { }); } + @Test + void policyExample() throws JsonProcessingException { + var jsonObject = objectMapper.readValue(POLICY_EXAMPLE, JsonObject.class); + var expanded = jsonLd.expand(jsonObject); + + assertThat(expanded).isSucceeded().satisfies(content -> { + assertThat(content.getString(ID)).isNotBlank(); + assertThat(content.getJsonArray(TYPE).getString(0)).isNotBlank(); + assertThat(content.getJsonArray(ODRL_PERMISSION_ATTRIBUTE).size()).isGreaterThan(0); + }); + } + } diff --git a/extensions/control-plane/api/management-api/catalog-api/build.gradle.kts b/extensions/control-plane/api/management-api/catalog-api/build.gradle.kts index 4466436546c..1c227efd8d0 100644 --- a/extensions/control-plane/api/management-api/catalog-api/build.gradle.kts +++ b/extensions/control-plane/api/management-api/catalog-api/build.gradle.kts @@ -25,12 +25,12 @@ dependencies { implementation(libs.jakarta.rsApi) - testImplementation(project(":extensions:common:http")) - testImplementation(project(":extensions:common:iam:iam-mock")) - testImplementation(project(":core:common:junit")) + testImplementation(project(":core:common:transform-core")) testImplementation(project(":core:control-plane:control-plane-core")) testImplementation(project(":core:data-plane-selector:data-plane-selector-core")) + testImplementation(project(":extensions:common:http")) + testImplementation(project(":extensions:common:iam:iam-mock")) testImplementation(testFixtures(project(":extensions:common:http:jersey-core"))) testImplementation(libs.restAssured) } diff --git a/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/CatalogApi.java b/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/CatalogApi.java index 4358c4d73e2..82c831d49ee 100644 --- a/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/CatalogApi.java +++ b/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/CatalogApi.java @@ -24,21 +24,118 @@ import jakarta.json.JsonObject; import jakarta.ws.rs.container.AsyncResponse; import jakarta.ws.rs.container.Suspended; -import org.eclipse.edc.catalog.spi.Catalog; -import org.eclipse.edc.connector.api.management.catalog.model.CatalogRequestDto; +import org.eclipse.edc.api.model.ApiCoreSchema; + +import static org.eclipse.edc.catalog.spi.CatalogRequest.CATALOG_REQUEST_TYPE; +import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; @OpenAPIDefinition @Tag(name = "Catalog") public interface CatalogApi { @Operation( - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = CatalogRequestDto.class))), + requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = CatalogRequestSchema.class))), responses = { @ApiResponse( content = @Content( mediaType = "application/json", - schema = @Schema(implementation = Catalog.class) + schema = @Schema(implementation = CatalogSchema.class) ), description = "Gets contract offers (=catalog) of a single connector") } ) - void requestCatalog(JsonObject requestDto, @Suspended AsyncResponse response); + void requestCatalog(JsonObject request, @Suspended AsyncResponse response); + + @Schema(example = CatalogRequestSchema.CATALOG_REQUEST_EXAMPLE) + record CatalogRequestSchema( + @Schema(name = TYPE, example = CATALOG_REQUEST_TYPE) + String providerUrl, + String protocol, + ApiCoreSchema.QuerySpecSchema querySpec) { + + public static final String CATALOG_REQUEST_EXAMPLE = """ + { + "@context": { "edc": "https://w3id.org/edc/v0.0.1/ns/" }, + "@type": "CatalogRequest", + "providerUrl": "http://provider-address", + "protocol": "dataspace-protocol-http", + "querySpec": { + "offset": 0, + "limit": 50, + "sortOrder": "DESC", + "sortField": "fieldName", + "filterExpression": [] + } + } + """; + } + + @Schema(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": [], + "odrl:target": "bcca61be-e82e-4da6-bfec-9716a56cef35" + }, + "dcat:distribution": [ + { + "@type": "dcat:Distribution", + "dct:format": { + "@id": "HttpData" + }, + "dcat:accessService": "5e839777-d93e-4785-8972-1005f51cf367" + } + ], + "edc:description": "description", + "edc: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" + }, + "edc:participantId": "urn:connector:provider", + "@context": { + "dct": "https://purl.org/dc/terms/", + "edc": "https://w3id.org/edc/v0.0.1/ns/", + "dcat": "https://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/api/management/catalog/CatalogApiController.java b/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/CatalogApiController.java index ea7f7d5a9a5..57d48d4e2e7 100644 --- a/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/CatalogApiController.java +++ b/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/CatalogApiController.java @@ -22,7 +22,6 @@ import jakarta.ws.rs.container.AsyncResponse; import jakarta.ws.rs.container.Suspended; import org.eclipse.edc.catalog.spi.CatalogRequest; -import org.eclipse.edc.connector.api.management.catalog.model.CatalogRequestDto; import org.eclipse.edc.connector.spi.catalog.CatalogService; import org.eclipse.edc.spi.EdcException; import org.eclipse.edc.transform.spi.TypeTransformerRegistry; @@ -32,7 +31,7 @@ import org.eclipse.edc.web.spi.exception.ValidationFailureException; import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON; -import static org.eclipse.edc.catalog.spi.CatalogRequest.EDC_CATALOG_REQUEST_TYPE; +import static org.eclipse.edc.catalog.spi.CatalogRequest.CATALOG_REQUEST_TYPE; @Path("/v2/catalog") @Consumes(APPLICATION_JSON) @@ -54,10 +53,9 @@ public CatalogApiController(CatalogService service, TypeTransformerRegistry tran @POST @Path("/request") public void requestCatalog(JsonObject requestBody, @Suspended AsyncResponse response) { - validatorRegistry.validate(EDC_CATALOG_REQUEST_TYPE, requestBody).orElseThrow(ValidationFailureException::new); + validatorRegistry.validate(CATALOG_REQUEST_TYPE, requestBody).orElseThrow(ValidationFailureException::new); - var request = transformerRegistry.transform(requestBody, CatalogRequestDto.class) - .compose(dto -> transformerRegistry.transform(dto, CatalogRequest.class)) + var request = transformerRegistry.transform(requestBody, CatalogRequest.class) .orElseThrow(InvalidRequestException::new); service.request(request.getProviderUrl(), request.getProtocol(), request.getQuerySpec()) diff --git a/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/CatalogApiExtension.java b/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/CatalogApiExtension.java index cf0cf77ed93..916e4aa94a7 100644 --- a/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/CatalogApiExtension.java +++ b/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/CatalogApiExtension.java @@ -15,8 +15,7 @@ package org.eclipse.edc.connector.api.management.catalog; import org.eclipse.edc.catalog.spi.CatalogRequest; -import org.eclipse.edc.connector.api.management.catalog.transform.CatalogRequestDtoToCatalogRequestTransformer; -import org.eclipse.edc.connector.api.management.catalog.transform.JsonObjectToCatalogRequestDtoTransformer; +import org.eclipse.edc.connector.api.management.catalog.transform.JsonObjectToCatalogRequestTransformer; import org.eclipse.edc.connector.api.management.catalog.validation.CatalogRequestValidator; import org.eclipse.edc.connector.api.management.configuration.ManagementApiConfiguration; import org.eclipse.edc.connector.api.management.configuration.transform.ManagementApiTypeTransformerRegistry; @@ -55,11 +54,10 @@ public String name() { @Override public void initialize(ServiceExtensionContext context) { - transformerRegistry.register(new CatalogRequestDtoToCatalogRequestTransformer()); - transformerRegistry.register(new JsonObjectToCatalogRequestDtoTransformer()); + transformerRegistry.register(new JsonObjectToCatalogRequestTransformer()); webService.registerResource(config.getContextAlias(), new CatalogApiController(service, transformerRegistry, validatorRegistry)); - validatorRegistry.register(CatalogRequest.EDC_CATALOG_REQUEST_TYPE, CatalogRequestValidator.instance()); + validatorRegistry.register(CatalogRequest.CATALOG_REQUEST_TYPE, CatalogRequestValidator.instance()); } } diff --git a/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/model/CatalogRequestDto.java b/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/model/CatalogRequestDto.java deleted file mode 100644 index 850dc83c0bb..00000000000 --- a/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/model/CatalogRequestDto.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2022 Microsoft Corporation - * - * 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: - * Microsoft Corporation - initial API and implementation - * - */ - -package org.eclipse.edc.connector.api.management.catalog.model; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; -import org.eclipse.edc.api.model.BaseDto; -import org.eclipse.edc.api.model.QuerySpecDto; - -import static java.util.Objects.requireNonNull; - -@JsonDeserialize(builder = CatalogRequestDto.Builder.class) -public class CatalogRequestDto extends BaseDto { - - private QuerySpecDto querySpec; - private String providerUrl; - private String protocol; - - private CatalogRequestDto() { - } - - public String getProviderUrl() { - return providerUrl; - } - - public QuerySpecDto getQuerySpec() { - return querySpec; - } - - public String getProtocol() { - return protocol; - } - - @JsonPOJOBuilder(withPrefix = "") - public static final class Builder { - private final CatalogRequestDto instance; - - private Builder() { - instance = new CatalogRequestDto(); - } - - @JsonCreator - public static Builder newInstance() { - return new Builder(); - } - - public Builder querySpec(QuerySpecDto querySpecDto) { - instance.querySpec = querySpecDto; - return this; - } - - public Builder providerUrl(String providerUrl) { - instance.providerUrl = providerUrl; - return this; - } - - public Builder protocol(String protocol) { - instance.protocol = protocol; - return this; - } - - public CatalogRequestDto build() { - requireNonNull(instance.providerUrl, "providerUrl"); - return instance; - } - } -} diff --git a/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/transform/CatalogRequestDtoToCatalogRequestTransformer.java b/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/transform/CatalogRequestDtoToCatalogRequestTransformer.java deleted file mode 100644 index 0de9155927d..00000000000 --- a/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/transform/CatalogRequestDtoToCatalogRequestTransformer.java +++ /dev/null @@ -1,44 +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.api.management.catalog.transform; - -import org.eclipse.edc.catalog.spi.CatalogRequest; -import org.eclipse.edc.connector.api.management.catalog.model.CatalogRequestDto; -import org.eclipse.edc.spi.query.QuerySpec; -import org.eclipse.edc.transform.spi.TransformerContext; -import org.eclipse.edc.transform.spi.TypeTransformer; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class CatalogRequestDtoToCatalogRequestTransformer implements TypeTransformer { - @Override - public Class getInputType() { - return CatalogRequestDto.class; - } - - @Override - public Class getOutputType() { - return CatalogRequest.class; - } - - @Override - public @Nullable CatalogRequest transform(@NotNull CatalogRequestDto dto, @NotNull TransformerContext context) { - return CatalogRequest.Builder.newInstance() - .providerUrl(dto.getProviderUrl()) - .protocol(dto.getProtocol()) - .querySpec(context.transform(dto.getQuerySpec(), QuerySpec.class)) - .build(); - } -} diff --git a/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/transform/JsonObjectToCatalogRequestDtoTransformer.java b/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/transform/JsonObjectToCatalogRequestDtoTransformer.java deleted file mode 100644 index 611aba96ca6..00000000000 --- a/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/transform/JsonObjectToCatalogRequestDtoTransformer.java +++ /dev/null @@ -1,55 +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.api.management.catalog.transform; - -import jakarta.json.JsonObject; -import org.eclipse.edc.api.model.QuerySpecDto; -import org.eclipse.edc.connector.api.management.catalog.model.CatalogRequestDto; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; -import org.eclipse.edc.transform.spi.TransformerContext; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import static org.eclipse.edc.catalog.spi.CatalogRequest.EDC_CATALOG_REQUEST_PROTOCOL; -import static org.eclipse.edc.catalog.spi.CatalogRequest.EDC_CATALOG_REQUEST_PROVIDER_URL; -import static org.eclipse.edc.catalog.spi.CatalogRequest.EDC_CATALOG_REQUEST_QUERY_SPEC; - -public class JsonObjectToCatalogRequestDtoTransformer extends AbstractJsonLdTransformer { - - public JsonObjectToCatalogRequestDtoTransformer() { - super(JsonObject.class, CatalogRequestDto.class); - } - - @Override - public @Nullable CatalogRequestDto transform(@NotNull JsonObject object, @NotNull TransformerContext context) { - var builder = CatalogRequestDto.Builder.newInstance(); - - visitProperties(object, key -> { - switch (key) { - case EDC_CATALOG_REQUEST_PROTOCOL: - return v -> builder.protocol(transformString(v, context)); - case EDC_CATALOG_REQUEST_PROVIDER_URL: - return v -> builder.providerUrl(transformString(v, context)); - case EDC_CATALOG_REQUEST_QUERY_SPEC: - return v -> builder.querySpec(transformObject(v, QuerySpecDto.class, context)); - default: - return doNothing(); - } - }); - - return builder.build(); - } - -} diff --git a/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/transform/JsonObjectToCatalogRequestTransformer.java b/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/transform/JsonObjectToCatalogRequestTransformer.java new file mode 100644 index 00000000000..6b7484e3d4d --- /dev/null +++ b/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/transform/JsonObjectToCatalogRequestTransformer.java @@ -0,0 +1,49 @@ +/* + * 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.api.management.catalog.transform; + +import jakarta.json.JsonObject; +import org.eclipse.edc.catalog.spi.CatalogRequest; +import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.spi.query.QuerySpec; +import org.eclipse.edc.transform.spi.TransformerContext; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import static org.eclipse.edc.catalog.spi.CatalogRequest.CATALOG_REQUEST_PROTOCOL; +import static org.eclipse.edc.catalog.spi.CatalogRequest.CATALOG_REQUEST_PROVIDER_URL; +import static org.eclipse.edc.catalog.spi.CatalogRequest.CATALOG_REQUEST_QUERY_SPEC; + +public class JsonObjectToCatalogRequestTransformer extends AbstractJsonLdTransformer { + + public JsonObjectToCatalogRequestTransformer() { + super(JsonObject.class, CatalogRequest.class); + } + + @Override + public @Nullable CatalogRequest transform(@NotNull JsonObject object, @NotNull TransformerContext context) { + var builder = CatalogRequest.Builder.newInstance(); + + visitProperties(object, key -> switch (key) { + case CATALOG_REQUEST_PROTOCOL -> v -> builder.protocol(transformString(v, context)); + case CATALOG_REQUEST_PROVIDER_URL -> v -> builder.providerUrl(transformString(v, context)); + case CATALOG_REQUEST_QUERY_SPEC -> v -> builder.querySpec(transformObject(v, QuerySpec.class, context)); + default -> doNothing(); + }); + + return builder.build(); + } + +} diff --git a/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/validation/CatalogRequestValidator.java b/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/validation/CatalogRequestValidator.java index e10c9ba66b1..adb1ae8e1f2 100644 --- a/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/validation/CatalogRequestValidator.java +++ b/extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/api/management/catalog/validation/CatalogRequestValidator.java @@ -20,17 +20,17 @@ import org.eclipse.edc.validator.jsonobject.validators.MandatoryValue; import org.eclipse.edc.validator.spi.Validator; -import static org.eclipse.edc.catalog.spi.CatalogRequest.EDC_CATALOG_REQUEST_PROTOCOL; -import static org.eclipse.edc.catalog.spi.CatalogRequest.EDC_CATALOG_REQUEST_PROVIDER_URL; -import static org.eclipse.edc.catalog.spi.CatalogRequest.EDC_CATALOG_REQUEST_QUERY_SPEC; +import static org.eclipse.edc.catalog.spi.CatalogRequest.CATALOG_REQUEST_PROTOCOL; +import static org.eclipse.edc.catalog.spi.CatalogRequest.CATALOG_REQUEST_PROVIDER_URL; +import static org.eclipse.edc.catalog.spi.CatalogRequest.CATALOG_REQUEST_QUERY_SPEC; public class CatalogRequestValidator { public static Validator instance() { return JsonObjectValidator.newValidator() - .verify(EDC_CATALOG_REQUEST_PROVIDER_URL, MandatoryValue::new) - .verify(EDC_CATALOG_REQUEST_PROTOCOL, MandatoryValue::new) - .verifyObject(EDC_CATALOG_REQUEST_QUERY_SPEC, QuerySpecDtoValidator::instance) + .verify(CATALOG_REQUEST_PROVIDER_URL, MandatoryValue::new) + .verify(CATALOG_REQUEST_PROTOCOL, MandatoryValue::new) + .verifyObject(CATALOG_REQUEST_QUERY_SPEC, QuerySpecDtoValidator::instance) .build(); } } diff --git a/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/CatalogApiControllerTest.java b/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/CatalogApiControllerTest.java index 25912ac8a5d..bbbe73405a2 100644 --- a/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/CatalogApiControllerTest.java +++ b/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/CatalogApiControllerTest.java @@ -14,13 +14,11 @@ package org.eclipse.edc.connector.api.management.catalog; -import org.eclipse.edc.api.model.QuerySpecDto; +import jakarta.json.Json; import org.eclipse.edc.catalog.spi.CatalogRequest; -import org.eclipse.edc.connector.api.management.catalog.model.CatalogRequestDto; import org.eclipse.edc.connector.spi.catalog.CatalogService; import org.eclipse.edc.junit.annotations.ApiTest; import org.eclipse.edc.spi.EdcException; -import org.eclipse.edc.spi.query.SortOrder; import org.eclipse.edc.spi.response.StatusResult; import org.eclipse.edc.spi.result.Result; import org.eclipse.edc.transform.spi.TypeTransformerRegistry; @@ -30,8 +28,6 @@ import org.eclipse.edc.web.jersey.testfixtures.RestControllerTestBase; import org.junit.jupiter.api.Test; -import java.util.List; - import static io.restassured.RestAssured.given; import static io.restassured.http.ContentType.JSON; import static java.util.concurrent.CompletableFuture.completedFuture; @@ -58,85 +54,49 @@ protected Object controller() { @Test void requestCatalog() { - var dto = CatalogRequestDto.Builder.newInstance().providerUrl("http://url").build(); var request = CatalogRequest.Builder.newInstance().providerUrl("http://url").build(); when(validatorRegistry.validate(any(), any())).thenReturn(ValidationResult.success()); - when(transformerRegistry.transform(any(), eq(CatalogRequestDto.class))).thenReturn(Result.success(dto)); when(transformerRegistry.transform(any(), eq(CatalogRequest.class))).thenReturn(Result.success(request)); when(service.request(any(), any(), any())).thenReturn(completedFuture(StatusResult.success("{}".getBytes()))); - - var requestDto = CatalogRequestDto.Builder.newInstance() - .protocol("protocol") - .querySpec(QuerySpecDto.Builder.newInstance() - .limit(29) - .offset(13) - .filterExpression(List.of(TestFunctions.createCriterionDto("fooProp", "", "bar"), TestFunctions.createCriterionDto("bazProp", "in", List.of("blip", "blup", "blop")))) - .sortField("someField") - .sortOrder(SortOrder.DESC).build()) - .providerUrl("some.provider.url") - - .build(); + var requestBody = Json.createObjectBuilder().add(CatalogRequest.CATALOG_REQUEST_PROTOCOL, "any").build(); given() .port(port) .contentType(JSON) - .body(requestDto) + .body(requestBody) .post("/v2/catalog/request") .then() .statusCode(200) .contentType(JSON); - verify(transformerRegistry).transform(any(), eq(CatalogRequestDto.class)); - verify(transformerRegistry).transform(dto, CatalogRequest.class); + verify(transformerRegistry).transform(any(), eq(CatalogRequest.class)); } @Test void catalogRequest_shouldReturnBadRequest_whenValidationFails() { when(validatorRegistry.validate(any(), any())).thenReturn(ValidationResult.failure(Violation.violation("error", "path"))); - - var requestDto = CatalogRequestDto.Builder.newInstance() - .protocol("protocol") - .querySpec(QuerySpecDto.Builder.newInstance() - .limit(29) - .offset(13) - .filterExpression(List.of(TestFunctions.createCriterionDto("fooProp", "", "bar"), TestFunctions.createCriterionDto("bazProp", "in", List.of("blip", "blup", "blop")))) - .sortField("someField") - .sortOrder(SortOrder.DESC).build()) - .providerUrl("some.provider.url") - - .build(); + var requestBody = Json.createObjectBuilder().add(CatalogRequest.CATALOG_REQUEST_PROTOCOL, "any").build(); given() .port(port) .contentType(JSON) - .body(requestDto) + .body(requestBody) .post("/v2/catalog/request") .then() .statusCode(400); - verify(validatorRegistry).validate(eq(CatalogRequest.EDC_CATALOG_REQUEST_TYPE), any()); + verify(validatorRegistry).validate(eq(CatalogRequest.CATALOG_REQUEST_TYPE), any()); verifyNoInteractions(transformerRegistry, service); } @Test void catalogRequest_shouldReturnBadRequest_whenTransformFails() { when(validatorRegistry.validate(any(), any())).thenReturn(ValidationResult.success()); - when(transformerRegistry.transform(any(), eq(CatalogRequestDto.class))).thenReturn(Result.failure("error")); - - var requestDto = CatalogRequestDto.Builder.newInstance() - .protocol("protocol") - .querySpec(QuerySpecDto.Builder.newInstance() - .limit(29) - .offset(13) - .filterExpression(List.of(TestFunctions.createCriterionDto("fooProp", "", "bar"), TestFunctions.createCriterionDto("bazProp", "in", List.of("blip", "blup", "blop")))) - .sortField("someField") - .sortOrder(SortOrder.DESC).build()) - .providerUrl("some.provider.url") - - .build(); + when(transformerRegistry.transform(any(), eq(CatalogRequest.class))).thenReturn(Result.failure("error")); + var requestBody = Json.createObjectBuilder().add(CatalogRequest.CATALOG_REQUEST_PROTOCOL, "any").build(); given() .port(port) .contentType(JSON) - .body(requestDto) + .body(requestBody) .post("/v2/catalog/request") .then() .statusCode(400); @@ -145,29 +105,17 @@ void catalogRequest_shouldReturnBadRequest_whenTransformFails() { @Test void requestCatalog_shouldReturnBadGateway_whenServiceFails() { - var dto = CatalogRequestDto.Builder.newInstance().providerUrl("http://url").build(); var request = CatalogRequest.Builder.newInstance().providerUrl("http://url").build(); when(validatorRegistry.validate(any(), any())).thenReturn(ValidationResult.success()); - when(transformerRegistry.transform(any(), eq(CatalogRequestDto.class))).thenReturn(Result.success(dto)); when(transformerRegistry.transform(any(), eq(CatalogRequest.class))).thenReturn(Result.success(request)); when(service.request(any(), any(), any())).thenReturn(completedFuture(StatusResult.failure(FATAL_ERROR, "error"))); - var requestDto = CatalogRequestDto.Builder.newInstance() - .protocol("protocol") - .querySpec(QuerySpecDto.Builder.newInstance() - .limit(29) - .offset(13) - .filterExpression(List.of(TestFunctions.createCriterionDto("fooProp", "", "bar"), TestFunctions.createCriterionDto("bazProp", "in", List.of("blip", "blup", "blop")))) - .sortField("someField") - .sortOrder(SortOrder.DESC).build()) - .providerUrl("some.provider.url") - - .build(); + var requestBody = Json.createObjectBuilder().add(CatalogRequest.CATALOG_REQUEST_PROTOCOL, "any").build(); given() .port(port) .contentType(JSON) - .body(requestDto) + .body(requestBody) .post("/v2/catalog/request") .then() .statusCode(502); @@ -175,29 +123,16 @@ void requestCatalog_shouldReturnBadGateway_whenServiceFails() { @Test void requestCatalog_shouldReturnBadGateway_whenServiceThrowsException() { - var dto = CatalogRequestDto.Builder.newInstance().providerUrl("http://url").build(); var request = CatalogRequest.Builder.newInstance().providerUrl("http://url").build(); when(validatorRegistry.validate(any(), any())).thenReturn(ValidationResult.success()); - when(transformerRegistry.transform(any(), eq(CatalogRequestDto.class))).thenReturn(Result.success(dto)); when(transformerRegistry.transform(any(), eq(CatalogRequest.class))).thenReturn(Result.success(request)); when(service.request(any(), any(), any())).thenReturn(failedFuture(new EdcException("error"))); - - var requestDto = CatalogRequestDto.Builder.newInstance() - .protocol("protocol") - .querySpec(QuerySpecDto.Builder.newInstance() - .limit(29) - .offset(13) - .filterExpression(List.of(TestFunctions.createCriterionDto("fooProp", "", "bar"), TestFunctions.createCriterionDto("bazProp", "in", List.of("blip", "blup", "blop")))) - .sortField("someField") - .sortOrder(SortOrder.DESC).build()) - .providerUrl("some.provider.url") - - .build(); + var requestBody = Json.createObjectBuilder().add(CatalogRequest.CATALOG_REQUEST_PROTOCOL, "any").build(); given() .port(port) .contentType(JSON) - .body(requestDto) + .body(requestBody) .post("/v2/catalog/request") .then() .statusCode(502); diff --git a/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/CatalogApiExtensionTest.java b/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/CatalogApiExtensionTest.java index 7a02d31a2c1..765a8c893b1 100644 --- a/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/CatalogApiExtensionTest.java +++ b/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/CatalogApiExtensionTest.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import static org.eclipse.edc.catalog.spi.CatalogRequest.EDC_CATALOG_REQUEST_TYPE; +import static org.eclipse.edc.catalog.spi.CatalogRequest.CATALOG_REQUEST_TYPE; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; @@ -41,6 +41,6 @@ void setUp(ServiceExtensionContext context) { void initiate_shouldRegisterValidator(CatalogApiExtension extension, ServiceExtensionContext context) { extension.initialize(context); - verify(validatorRegistry).register(eq(EDC_CATALOG_REQUEST_TYPE), any()); + verify(validatorRegistry).register(eq(CATALOG_REQUEST_TYPE), any()); } } diff --git a/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/CatalogApiTest.java b/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/CatalogApiTest.java new file mode 100644 index 00000000000..1c6ee33de58 --- /dev/null +++ b/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/CatalogApiTest.java @@ -0,0 +1,84 @@ +/* + * 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.api.management.catalog; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.json.JsonObject; +import org.eclipse.edc.catalog.spi.CatalogRequest; +import org.eclipse.edc.connector.api.management.catalog.transform.JsonObjectToCatalogRequestTransformer; +import org.eclipse.edc.connector.api.management.catalog.validation.CatalogRequestValidator; +import org.eclipse.edc.core.transform.TypeTransformerRegistryImpl; +import org.eclipse.edc.core.transform.transformer.to.JsonObjectToQuerySpecTransformer; +import org.eclipse.edc.jsonld.JsonLdExtension; +import org.eclipse.edc.jsonld.spi.JsonLd; +import org.eclipse.edc.jsonld.util.JacksonJsonLd; +import org.eclipse.edc.transform.spi.TypeTransformerRegistry; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.eclipse.edc.connector.api.management.catalog.CatalogApi.CatalogRequestSchema.CATALOG_REQUEST_EXAMPLE; +import static org.eclipse.edc.connector.api.management.catalog.CatalogApi.CatalogSchema.CATALOG_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.PropertyAndTypeNames.DCAT_CATALOG_TYPE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCAT_DATASET_ATTRIBUTE; +import static org.eclipse.edc.junit.assertions.AbstractResultAssert.assertThat; +import static org.eclipse.edc.junit.extensions.TestServiceExtensionContext.testServiceExtensionContext; + +class CatalogApiTest { + + private final ObjectMapper objectMapper = JacksonJsonLd.createObjectMapper(); + private final JsonLd jsonLd = new JsonLdExtension().createJsonLdService(testServiceExtensionContext()); + private final TypeTransformerRegistry transformer = new TypeTransformerRegistryImpl(); + + @BeforeEach + void setUp() { + transformer.register(new JsonObjectToCatalogRequestTransformer()); + transformer.register(new JsonObjectToQuerySpecTransformer()); + } + + @Test + void catalogRequestExample() throws JsonProcessingException { + var validator = CatalogRequestValidator.instance(); + + var jsonObject = objectMapper.readValue(CATALOG_REQUEST_EXAMPLE, JsonObject.class); + assertThat(jsonObject).isNotNull(); + + var expanded = jsonLd.expand(jsonObject); + assertThat(expanded).isSucceeded() + .satisfies(exp -> assertThat(validator.validate(exp)).isSucceeded()) + .extracting(e -> transformer.transform(e, CatalogRequest.class)) + .satisfies(transformResult -> assertThat(transformResult).isSucceeded() + .satisfies(transformed -> { + assertThat(transformed.getProtocol()).isNotBlank(); + assertThat(transformed.getProviderUrl()).isNotBlank(); + assertThat(transformed.getQuerySpec()).isNotNull(); + })); + } + + @Test + void catalogExample() throws JsonProcessingException { + var jsonObject = objectMapper.readValue(CATALOG_EXAMPLE, JsonObject.class); + var expanded = jsonLd.expand(jsonObject); + + assertThat(expanded).isSucceeded().satisfies(content -> { + assertThat(content.getString(ID)).isNotBlank(); + assertThat(content.getJsonArray(TYPE).getString(0)).isEqualTo(DCAT_CATALOG_TYPE); + assertThat(content.getJsonArray(DCAT_DATASET_ATTRIBUTE).size()).isGreaterThan(0); + }); + } +} diff --git a/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/TestFunctions.java b/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/TestFunctions.java deleted file mode 100644 index 7c5e887fa05..00000000000 --- a/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/TestFunctions.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2022 Microsoft Corporation - * - * 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: - * Microsoft Corporation - initial API and implementation - * - */ - -package org.eclipse.edc.connector.api.management.catalog; - -import org.eclipse.edc.api.model.CriterionDto; - -public class TestFunctions { - public static CriterionDto createCriterionDto(String left, String op, Object right) { - return CriterionDto.Builder.newInstance().operandLeft(left).operator(op).operandRight(right).build(); - } - -} diff --git a/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/model/CatalogRequestMessageDtoTest.java b/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/model/CatalogRequestMessageDtoTest.java deleted file mode 100644 index 7ec8b011e30..00000000000 --- a/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/model/CatalogRequestMessageDtoTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2022 Microsoft Corporation - * - * 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: - * Microsoft Corporation - initial API and implementation - * - */ - -package org.eclipse.edc.connector.api.management.catalog.model; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.eclipse.edc.api.model.QuerySpecDto; -import org.eclipse.edc.spi.query.SortOrder; -import org.eclipse.edc.spi.types.TypeManager; -import org.junit.jupiter.api.Test; - -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.edc.connector.api.management.catalog.TestFunctions.createCriterionDto; - -class CatalogRequestMessageDtoTest { - - private static final ObjectMapper MAPPER = new TypeManager().getMapper(); - - @Test - void verifySerdes() throws JsonProcessingException { - var dto = CatalogRequestDto.Builder.newInstance() - .providerUrl("https://some.provider/path") - .querySpec(QuerySpecDto.Builder.newInstance() - .limit(420) - .offset(69) - .sortField("someField") - .sortOrder(SortOrder.DESC) - .filterExpression(List.of(createCriterionDto("foo", "=", "bar"), createCriterionDto("bar", "<", "baz"))) - .build()) - .build(); - - var json = MAPPER.writeValueAsString(dto); - assertThat(json).isNotNull(); - - var deser = MAPPER.readValue(json, CatalogRequestDto.class); - assertThat(deser).usingRecursiveComparison().isEqualTo(dto); - } -} diff --git a/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/transform/CatalogRequestDtoToCatalogRequestTransformerTest.java b/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/transform/CatalogRequestDtoToCatalogRequestTransformerTest.java deleted file mode 100644 index 05bd87e9684..00000000000 --- a/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/transform/CatalogRequestDtoToCatalogRequestTransformerTest.java +++ /dev/null @@ -1,59 +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.api.management.catalog.transform; - -import org.eclipse.edc.api.model.QuerySpecDto; -import org.eclipse.edc.catalog.spi.CatalogRequest; -import org.eclipse.edc.connector.api.management.catalog.model.CatalogRequestDto; -import org.eclipse.edc.spi.query.QuerySpec; -import org.eclipse.edc.transform.spi.TransformerContext; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -class CatalogRequestDtoToCatalogRequestTransformerTest { - - private final CatalogRequestDtoToCatalogRequestTransformer transformer = new CatalogRequestDtoToCatalogRequestTransformer(); - private final TransformerContext context = mock(TransformerContext.class); - - @Test - void types() { - assertThat(transformer.getInputType()).isEqualTo(CatalogRequestDto.class); - assertThat(transformer.getOutputType()).isEqualTo(CatalogRequest.class); - } - - @Test - void transform() { - var querySpecDto = QuerySpecDto.Builder.newInstance().build(); - var querySpec = QuerySpec.Builder.newInstance().build(); - var dto = CatalogRequestDto.Builder.newInstance() - .providerUrl("http://provider/url") - .protocol("protocol") - .querySpec(querySpecDto) - .build(); - when(context.transform(any(), eq(QuerySpec.class))).thenReturn(querySpec); - - var result = transformer.transform(dto, context); - - assertThat(result).isNotNull(); - assertThat(result.getProtocol()).isEqualTo("protocol"); - assertThat(result.getProviderUrl()).isEqualTo("http://provider/url"); - assertThat(result.getQuerySpec()).isSameAs(querySpec); - } -} diff --git a/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/transform/JsonObjectToCatalogRequestDtoTransformerTest.java b/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/transform/JsonObjectToCatalogRequestTransformerTest.java similarity index 57% rename from extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/transform/JsonObjectToCatalogRequestDtoTransformerTest.java rename to extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/transform/JsonObjectToCatalogRequestTransformerTest.java index d6081895b0e..3c06ce5b4fa 100644 --- a/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/transform/JsonObjectToCatalogRequestDtoTransformerTest.java +++ b/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/transform/JsonObjectToCatalogRequestTransformerTest.java @@ -16,16 +16,16 @@ import jakarta.json.Json; import jakarta.json.JsonObject; -import org.eclipse.edc.api.model.QuerySpecDto; -import org.eclipse.edc.connector.api.management.catalog.model.CatalogRequestDto; +import org.eclipse.edc.catalog.spi.CatalogRequest; +import org.eclipse.edc.spi.query.QuerySpec; import org.eclipse.edc.transform.spi.TransformerContext; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.edc.catalog.spi.CatalogRequest.EDC_CATALOG_REQUEST_PROTOCOL; -import static org.eclipse.edc.catalog.spi.CatalogRequest.EDC_CATALOG_REQUEST_PROVIDER_URL; -import static org.eclipse.edc.catalog.spi.CatalogRequest.EDC_CATALOG_REQUEST_QUERY_SPEC; -import static org.eclipse.edc.catalog.spi.CatalogRequest.EDC_CATALOG_REQUEST_TYPE; +import static org.eclipse.edc.catalog.spi.CatalogRequest.CATALOG_REQUEST_PROTOCOL; +import static org.eclipse.edc.catalog.spi.CatalogRequest.CATALOG_REQUEST_PROVIDER_URL; +import static org.eclipse.edc.catalog.spi.CatalogRequest.CATALOG_REQUEST_QUERY_SPEC; +import static org.eclipse.edc.catalog.spi.CatalogRequest.CATALOG_REQUEST_TYPE; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; @@ -33,27 +33,27 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -class JsonObjectToCatalogRequestDtoTransformerTest { +class JsonObjectToCatalogRequestTransformerTest { - private final JsonObjectToCatalogRequestDtoTransformer transformer = new JsonObjectToCatalogRequestDtoTransformer(); + private final JsonObjectToCatalogRequestTransformer transformer = new JsonObjectToCatalogRequestTransformer(); private final TransformerContext context = mock(TransformerContext.class); @Test void types() { assertThat(transformer.getInputType()).isEqualTo(JsonObject.class); - assertThat(transformer.getOutputType()).isEqualTo(CatalogRequestDto.class); + assertThat(transformer.getOutputType()).isEqualTo(CatalogRequest.class); } @Test void transform() { - var querySpecDto = QuerySpecDto.Builder.newInstance().build(); + var querySpec = QuerySpec.Builder.newInstance().build(); var querySpecJson = Json.createObjectBuilder().build(); - when(context.transform(any(), eq(QuerySpecDto.class))).thenReturn(querySpecDto); + when(context.transform(any(), eq(QuerySpec.class))).thenReturn(querySpec); var json = Json.createObjectBuilder() - .add(TYPE, EDC_CATALOG_REQUEST_TYPE) - .add(EDC_CATALOG_REQUEST_PROTOCOL, "protocol") - .add(EDC_CATALOG_REQUEST_PROVIDER_URL, "http://provider/url") - .add(EDC_CATALOG_REQUEST_QUERY_SPEC, querySpecJson) + .add(TYPE, CATALOG_REQUEST_TYPE) + .add(CATALOG_REQUEST_PROTOCOL, "protocol") + .add(CATALOG_REQUEST_PROVIDER_URL, "http://provider/url") + .add(CATALOG_REQUEST_QUERY_SPEC, querySpecJson) .build(); var result = transformer.transform(json, context); @@ -61,8 +61,8 @@ void transform() { assertThat(result).isNotNull(); assertThat(result.getProtocol()).isEqualTo("protocol"); assertThat(result.getProviderUrl()).isEqualTo("http://provider/url"); - assertThat(result.getQuerySpec()).isEqualTo(querySpecDto); - verify(context).transform(querySpecJson, QuerySpecDto.class); + assertThat(result.getQuerySpec()).isEqualTo(querySpec); + verify(context).transform(querySpecJson, QuerySpec.class); } } diff --git a/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/validation/CatalogRequestValidatorTest.java b/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/validation/CatalogRequestValidatorTest.java index fa0f2616957..8695021a16a 100644 --- a/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/validation/CatalogRequestValidatorTest.java +++ b/extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/api/management/catalog/validation/CatalogRequestValidatorTest.java @@ -27,9 +27,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.InstanceOfAssertFactories.list; import static org.eclipse.edc.api.model.QuerySpecDto.EDC_QUERY_SPEC_SORT_FIELD; -import static org.eclipse.edc.catalog.spi.CatalogRequest.EDC_CATALOG_REQUEST_PROTOCOL; -import static org.eclipse.edc.catalog.spi.CatalogRequest.EDC_CATALOG_REQUEST_PROVIDER_URL; -import static org.eclipse.edc.catalog.spi.CatalogRequest.EDC_CATALOG_REQUEST_QUERY_SPEC; +import static org.eclipse.edc.catalog.spi.CatalogRequest.CATALOG_REQUEST_PROTOCOL; +import static org.eclipse.edc.catalog.spi.CatalogRequest.CATALOG_REQUEST_PROVIDER_URL; +import static org.eclipse.edc.catalog.spi.CatalogRequest.CATALOG_REQUEST_QUERY_SPEC; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.VALUE; import static org.eclipse.edc.junit.assertions.AbstractResultAssert.assertThat; @@ -40,8 +40,8 @@ class CatalogRequestValidatorTest { @Test void shouldSucceed_whenInputIsValid() { var input = Json.createObjectBuilder() - .add(EDC_CATALOG_REQUEST_PROVIDER_URL, value("http://any")) - .add(EDC_CATALOG_REQUEST_PROTOCOL, value("protocol")) + .add(CATALOG_REQUEST_PROVIDER_URL, value("http://any")) + .add(CATALOG_REQUEST_PROTOCOL, value("protocol")) .build(); var result = validator.validate(input); @@ -57,16 +57,16 @@ void shouldFail_whenMandatoryFieldsAreMissing() { assertThat(result).isFailed().extracting(ValidationFailure::getViolations).asInstanceOf(list(Violation.class)) .hasSize(2) - .anySatisfy(v -> assertThat(v.path()).isEqualTo(EDC_CATALOG_REQUEST_PROVIDER_URL)) - .anySatisfy(v -> assertThat(v.path()).isEqualTo(EDC_CATALOG_REQUEST_PROTOCOL)); + .anySatisfy(v -> assertThat(v.path()).isEqualTo(CATALOG_REQUEST_PROVIDER_URL)) + .anySatisfy(v -> assertThat(v.path()).isEqualTo(CATALOG_REQUEST_PROTOCOL)); } @Test void shouldFail_whenOptionalQuerySpecIsInvalid() { var input = Json.createObjectBuilder() - .add(EDC_CATALOG_REQUEST_PROVIDER_URL, value("http://any")) - .add(EDC_CATALOG_REQUEST_PROTOCOL, value("protocol")) - .add(EDC_CATALOG_REQUEST_QUERY_SPEC, createArrayBuilder().add(createObjectBuilder() + .add(CATALOG_REQUEST_PROVIDER_URL, value("http://any")) + .add(CATALOG_REQUEST_PROTOCOL, value("protocol")) + .add(CATALOG_REQUEST_QUERY_SPEC, createArrayBuilder().add(createObjectBuilder() .add(EDC_QUERY_SPEC_SORT_FIELD, value(" ")))) .build(); @@ -74,7 +74,7 @@ void shouldFail_whenOptionalQuerySpecIsInvalid() { assertThat(result).isFailed().extracting(ValidationFailure::getViolations).asInstanceOf(list(Violation.class)) .hasSize(1) - .anySatisfy(v -> assertThat(v.path()).startsWith(EDC_CATALOG_REQUEST_QUERY_SPEC)); + .anySatisfy(v -> assertThat(v.path()).startsWith(CATALOG_REQUEST_QUERY_SPEC)); } private JsonArrayBuilder value(String value) { diff --git a/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/api/management/contractnegotiation/ContractNegotiationApi.java b/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/api/management/contractnegotiation/ContractNegotiationApi.java index a3eccf03102..14cb1948a18 100644 --- a/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/api/management/contractnegotiation/ContractNegotiationApi.java +++ b/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/api/management/contractnegotiation/ContractNegotiationApi.java @@ -239,7 +239,7 @@ record ContractOfferDescriptionSchema( String offerId, String assetId, @Schema(description = "ODRL policy") - Object policy + ManagementApiSchema.PolicySchema policy ) { } diff --git a/extensions/control-plane/api/management-api/policy-definition-api/src/main/java/org/eclipse/edc/connector/api/management/policy/PolicyDefinitionApi.java b/extensions/control-plane/api/management-api/policy-definition-api/src/main/java/org/eclipse/edc/connector/api/management/policy/PolicyDefinitionApi.java index 5eef633ed03..375fc7a0a8d 100644 --- a/extensions/control-plane/api/management-api/policy-definition-api/src/main/java/org/eclipse/edc/connector/api/management/policy/PolicyDefinitionApi.java +++ b/extensions/control-plane/api/management-api/policy-definition-api/src/main/java/org/eclipse/edc/connector/api/management/policy/PolicyDefinitionApi.java @@ -25,6 +25,7 @@ import jakarta.json.JsonArray; import jakarta.json.JsonObject; import org.eclipse.edc.api.model.ApiCoreSchema; +import org.eclipse.edc.connector.api.management.configuration.ManagementApiSchema; import org.eclipse.edc.web.spi.ApiErrorDetail; import static org.eclipse.edc.connector.policy.spi.PolicyDefinition.EDC_POLICY_DEFINITION_TYPE; @@ -101,7 +102,8 @@ record PolicyDefinitionInputSchema( @Schema(name = ID) String id, @Schema(name = TYPE, example = EDC_POLICY_DEFINITION_TYPE) - String type) { + String type, + ManagementApiSchema.PolicySchema policy) { // policy example took from https://w3c.github.io/odrl/bp/ public static final String POLICY_DEFINITION_INPUT_EXAMPLE = """ @@ -132,7 +134,8 @@ record PolicyDefinitionOutputSchema( @Schema(name = ID) String id, @Schema(name = TYPE, example = EDC_POLICY_DEFINITION_TYPE) - String type) { + String type, + ManagementApiSchema.PolicySchema policy) { // policy example took from https://w3c.github.io/odrl/bp/ public static final String POLICY_DEFINITION_OUTPUT_EXAMPLE = """ diff --git a/resources/openapi/openapi.yaml b/resources/openapi/openapi.yaml deleted file mode 100644 index 9d9a7d03854..00000000000 --- a/resources/openapi/openapi.yaml +++ /dev/null @@ -1,3079 +0,0 @@ -openapi: 3.0.1 -info: - title: EDC REST API - description: EDC REST APIs - merged by OpenApiMerger - version: 0.1.4-SNAPSHOT -servers: -- url: / -tags: -- name: Data Plane control API - description: 'Api targeted by the Control Plane to delegate a data transfer (Provider - Push or Streaming) to the Data Plane after the contract has been successfully - negotiated and agreed between the two participants. ' -- name: Data Plane public API - description: "The public API of the Data Plane is a data proxy enabling a data consumer\ - \ to actively querydata from the provider data source (e.g. backend Rest API,\ - \ internal database...) through its Data Planeinstance. Thus the Data Plane is\ - \ the only entry/output door for the data, which avoids the provider to exposedirectly\ - \ its data externally.The Data Plane public API being a proxy, it supports all\ - \ verbs (i.e. GET, POST, PUT, PATCH, DELETE), whichcan then conveyed until the\ - \ data source is required. This is especially useful when the actual data sourceis\ - \ a Rest API itself.In the same manner, any set of arbitrary query parameters,\ - \ path parameters and request body are supported (in the limits fixed by the HTTP\ - \ server) and can also conveyed to the actual data source." -paths: - /callback/{processId}/deprovision: - post: - tags: - - HTTP Provisioner Webhook - operationId: callDeprovisionWebhook - parameters: - - name: processId - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/DeprovisionedResource' - responses: - default: - description: default response - content: - application/json: {} - /callback/{processId}/provision: - post: - tags: - - HTTP Provisioner Webhook - operationId: callProvisionWebhook - parameters: - - name: processId - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ProvisionerWebhookRequest' - responses: - default: - description: default response - content: - application/json: {} - /check/health: - get: - tags: - - Application Observability - description: Performs a liveness probe to determine whether the runtime is working - properly. - operationId: checkHealth - responses: - "200": - description: The runtime is working properly. - content: - application/json: - schema: - $ref: '#/components/schemas/HealthStatus' - /check/liveness: - get: - tags: - - Application Observability - description: Performs a liveness probe to determine whether the runtime is working - properly. - operationId: getLiveness - responses: - "200": - description: The runtime is working properly. - content: - application/json: - schema: - $ref: '#/components/schemas/HealthStatus' - /check/readiness: - get: - tags: - - Application Observability - description: Performs a readiness probe to determine whether the runtime is - able to accept requests. - operationId: getReadiness - responses: - "200": - description: The runtime is able to accept requests. - content: - application/json: - schema: - $ref: '#/components/schemas/HealthStatus' - /check/startup: - get: - tags: - - Application Observability - description: Performs a startup probe to determine whether the runtime has completed - startup. - operationId: getStartup - responses: - "200": - description: The runtime has completed startup. - content: - application/json: - schema: - $ref: '#/components/schemas/HealthStatus' - /instances: - get: - tags: - - Dataplane Selector - operationId: getAll - responses: - default: - description: default response - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/DataPlaneInstance' - post: - tags: - - Dataplane Selector - operationId: addEntry - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/DataPlaneInstance' - responses: - default: - description: default response - content: - application/json: {} - /instances/select: - post: - tags: - - Dataplane Selector - operationId: find - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/SelectionRequest' - responses: - default: - description: default response - content: - application/json: - schema: - $ref: '#/components/schemas/DataPlaneInstance' - /token: - get: - tags: - - Consumer Pull Token Validation - description: "Checks that the provided token has been signed by the present\ - \ entity and asserts its validity. If token is valid, then the data address\ - \ contained in its claims is decrypted and returned back to the caller." - operationId: validate - parameters: - - name: Authorization - in: header - required: false - style: simple - explode: false - schema: - type: string - example: null - responses: - "200": - description: Token is valid - "400": - description: Request was malformed - "403": - description: Token is invalid - /transfer: - post: - tags: - - Data Plane control API - description: Initiates a data transfer for the given request. The transfer will - be performed asynchronously. - operationId: initiateTransfer - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/DataFlowRequest' - responses: - "200": - description: Data transfer initiated - "400": - description: Failed to validate request - /transfer/{processId}: - get: - tags: - - Data Plane control API - description: Get the current state of a data transfer. - operationId: getTransferState - parameters: - - name: processId - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - responses: - "200": - description: Missing access token - /transferprocess/{processId}/complete: - post: - tags: - - Transfer Process Control Api - description: "Requests completion of the transfer process. Due to the asynchronous\ - \ nature of transfers, a successful response only indicates that the request\ - \ was successfully received" - operationId: complete - parameters: - - name: processId - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - responses: - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /transferprocess/{processId}/fail: - post: - tags: - - Transfer Process Control Api - description: "Requests completion of the transfer process. Due to the asynchronous\ - \ nature of transfers, a successful response only indicates that the request\ - \ was successfully received" - operationId: fail - parameters: - - name: processId - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/TransferProcessFailStateDto' - responses: - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v2/assets: - put: - tags: - - Asset - description: "Updates an asset with the given ID if it exists. If the asset\ - \ is not found, no further action is taken. DANGER ZONE: Note that updating\ - \ assets can have unexpected results, especially for contract offers that\ - \ have been sent out or are ongoing in contract negotiations." - operationId: updateAsset - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/AssetUpdateRequestDto' - responses: - "200": - description: Asset was updated successfully - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: "Asset could not be updated, because it does not exist." - deprecated: true - post: - tags: - - Asset - description: Creates a new asset together with a data address - operationId: createAsset - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/AssetEntryNewDto' - responses: - "200": - description: Asset was created successfully. Returns the asset Id and created - timestamp - content: - application/json: - schema: - $ref: '#/components/schemas/IdResponseDto' - "400": - description: Request body was malformed - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "409": - description: "Could not create asset, because an asset with that ID already\ - \ exists" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - deprecated: true - /v2/assets/request: - post: - tags: - - Asset - description: ' all assets according to a particular query' - operationId: requestAssets - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/QuerySpecDto' - responses: - "200": - description: The assets matching the query - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/AssetResponseDto' - "400": - description: Request body was malformed - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - deprecated: true - /v2/assets/{assetId}/dataaddress: - put: - tags: - - Asset - description: Updates a DataAddress for an asset with the given ID. - operationId: updateDataAddress - parameters: - - name: assetId - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/AssetUpdateRequestDto' - responses: - "200": - description: Asset was updated successfully - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: An asset with the given ID does not exist - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - deprecated: true - /v2/assets/{id}: - get: - tags: - - Asset - description: Gets an asset with the given ID - operationId: getAsset - parameters: - - name: id - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - responses: - "200": - description: The asset - content: - application/json: - schema: - $ref: '#/components/schemas/AssetResponseDto' - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: An asset with the given ID does not exist - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - deprecated: true - delete: - tags: - - Asset - description: "Removes an asset with the given ID if possible. Deleting an asset\ - \ is only possible if that asset is not yet referenced by a contract agreement,\ - \ in which case an error is returned. DANGER ZONE: Note that deleting assets\ - \ can have unexpected results, especially for contract offers that have been\ - \ sent out or ongoing or contract negotiations." - operationId: removeAsset - parameters: - - name: id - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - responses: - "200": - description: Asset was deleted successfully - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: An asset with the given ID does not exist - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "409": - description: "The asset cannot be deleted, because it is referenced by a\ - \ contract agreement" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - deprecated: true - /v2/assets/{id}/dataaddress: - get: - tags: - - Asset - description: Gets a data address of an asset with the given ID - operationId: getAssetDataAddress - parameters: - - name: id - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - responses: - "200": - description: The data address - content: - application/json: - schema: - $ref: '#/components/schemas/DataAddressDto' - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: An asset with the given ID does not exist - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - deprecated: true - /v2/catalog/request: - post: - tags: - - Catalog - operationId: requestCatalog - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/CatalogRequestDto' - responses: - default: - description: Gets contract offers (=catalog) of a single connector - content: - application/json: - schema: - $ref: '#/components/schemas/Catalog' - /v2/contractagreements/request: - post: - tags: - - Contract Agreement - description: Gets all contract agreements according to a particular query - operationId: queryAllAgreements - requestBody: - content: - '*/*': - schema: - $ref: '#/components/schemas/QuerySpecSchema' - responses: - "200": - description: The contract agreements matching the query - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ContractAgreementSchema' - "400": - description: Request body was malformed - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v2/contractagreements/{id}: - get: - tags: - - Contract Agreement - description: Gets an contract agreement with the given ID - operationId: getAgreementById - parameters: - - name: id - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - responses: - "200": - description: The contract agreement - content: - application/json: - schema: - $ref: '#/components/schemas/ContractAgreementSchema' - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: An contract agreement with the given ID does not exist - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v2/contractdefinitions: - put: - tags: - - Contract Definition - description: Updated a contract definition with the given ID. The supplied JSON - structure must be a valid JSON-LD object - operationId: updateContractDefinition - requestBody: - content: - '*/*': - schema: - $ref: '#/components/schemas/ContractDefinitionInputSchema' - responses: - "204": - description: Contract definition was updated successfully - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: A contract definition with the given ID does not exist - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - post: - tags: - - Contract Definition - description: Creates a new contract definition - operationId: createContractDefinition - requestBody: - content: - '*/*': - schema: - $ref: '#/components/schemas/ContractDefinitionInputSchema' - responses: - "200": - description: contract definition was created successfully. Returns the Contract - Definition Id and created timestamp - content: - application/json: - schema: - $ref: '#/components/schemas/IdResponseSchema' - "400": - description: Request body was malformed - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "409": - description: "Could not create contract definition, because a contract definition\ - \ with that ID already exists" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v2/contractdefinitions/request: - post: - tags: - - Contract Definition - description: Returns all contract definitions according to a query - operationId: queryAllContractDefinitions - requestBody: - content: - '*/*': - schema: - $ref: '#/components/schemas/QuerySpecSchema' - responses: - "200": - description: The contract definitions matching the query - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ContractDefinitionOutputSchema' - "400": - description: Request was malformed - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v2/contractdefinitions/{id}: - get: - tags: - - Contract Definition - description: Gets an contract definition with the given ID - operationId: getContractDefinition - parameters: - - name: id - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - responses: - "200": - description: The contract definition - content: - application/json: - schema: - $ref: '#/components/schemas/ContractDefinitionOutputSchema' - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: An contract agreement with the given ID does not exist - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - delete: - tags: - - Contract Definition - 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." - operationId: deleteContractDefinition - parameters: - - name: id - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - responses: - "200": - description: Contract definition was deleted successfully - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: A contract definition with the given ID does not exist - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v2/contractnegotiations: - post: - tags: - - Contract Negotiation - 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" - operationId: initiateContractNegotiation - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ContractRequestSchema' - responses: - "200": - description: The negotiation was successfully initiated. Returns the contract - negotiation ID and created timestamp - content: - application/json: - schema: - $ref: '#/components/schemas/IdResponseSchema' - links: - poll-state: - operationId: getNegotiationState - parameters: - id: $response.body#/id - "400": - description: Request body was malformed - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v2/contractnegotiations/request: - post: - tags: - - Contract Negotiation - description: Returns all contract negotiations according to a query - operationId: queryNegotiations - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/QuerySpecSchema' - responses: - "200": - description: The contract negotiations that match the query - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ContractNegotiationSchema' - "400": - description: Request was malformed - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v2/contractnegotiations/{id}: - get: - tags: - - Contract Negotiation - description: Gets a contract negotiation with the given ID - operationId: getNegotiation - parameters: - - name: id - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - responses: - "200": - description: The contract negotiation - content: - application/json: - schema: - $ref: '#/components/schemas/ContractNegotiationSchema' - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: An contract negotiation with the given ID does not exist - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v2/contractnegotiations/{id}/agreement: - get: - tags: - - Contract Negotiation - description: Gets a contract agreement for a contract negotiation with the given - ID - operationId: getAgreementForNegotiation - parameters: - - name: id - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - responses: - "200": - description: "The contract agreement that is attached to the negotiation,\ - \ or null" - content: - application/json: - schema: - $ref: '#/components/schemas/ContractAgreementSchema' - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: An contract negotiation with the given ID does not exist - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v2/contractnegotiations/{id}/cancel: - post: - tags: - - Contract Negotiation - description: "Requests aborting the contract negotiation. Due to the asynchronous\ - \ nature of contract negotiations, a successful response only indicates that\ - \ the request was successfully received. Clients must poll the /{id}/state\ - \ endpoint to track the state." - operationId: cancelNegotiation - parameters: - - name: id - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - responses: - "200": - description: Request to cancel the Contract negotiation was successfully - received - links: - poll-state: - operationId: getNegotiationState - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: A contract negotiation with the given ID does not exist - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v2/contractnegotiations/{id}/decline: - post: - tags: - - Contract Negotiation - description: "Requests cancelling the contract negotiation. Due to the asynchronous\ - \ nature of contract negotiations, a successful response only indicates that\ - \ the request was successfully received. Clients must poll the /{id}/state\ - \ endpoint to track the state." - operationId: declineNegotiation - parameters: - - name: id - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - responses: - "200": - description: Request to decline the Contract negotiation was successfully - received - links: - poll-state: - operationId: getNegotiationState - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: A contract negotiation with the given ID does not exist - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v2/contractnegotiations/{id}/state: - get: - tags: - - Contract Negotiation - description: Gets the state of a contract negotiation with the given ID - operationId: getNegotiationState - parameters: - - name: id - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - responses: - "200": - description: The contract negotiation's state - content: - application/json: - schema: - $ref: '#/components/schemas/NegotiationState' - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: An contract negotiation with the given ID does not exist - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v2/policydefinitions: - post: - tags: - - Policy Definition - description: Creates a new policy definition - operationId: createPolicyDefinition - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/PolicyDefinitionInputSchema' - responses: - "200": - description: policy definition was created successfully. Returns the Policy - Definition Id and created timestamp - content: - application/json: - schema: - $ref: '#/components/schemas/IdResponseSchema' - "400": - description: Request body was malformed - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "409": - description: "Could not create policy definition, because a contract definition\ - \ with that ID already exists" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v2/policydefinitions/request: - post: - tags: - - Policy Definition - description: Returns all policy definitions according to a query - operationId: queryPolicyDefinitions - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/QuerySpecSchema' - responses: - "200": - description: The policy definitions matching the query - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/PolicyDefinitionOutputSchema' - "400": - description: Request was malformed - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v2/policydefinitions/{id}: - get: - tags: - - Policy Definition - description: Gets a policy definition with the given ID - operationId: getPolicyDefinition - parameters: - - name: id - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - responses: - "200": - description: The policy definition - content: - application/json: - schema: - $ref: '#/components/schemas/PolicyDefinitionOutputSchema' - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: An policy definition with the given ID does not exist - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - put: - tags: - - Policy Definition - description: "Updates an existing Policy, If the Policy is not found, an error\ - \ is reported" - operationId: updatePolicyDefinition - parameters: - - name: id - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/PolicyDefinitionInputSchema' - responses: - "200": - description: policy definition was updated successfully. Returns the Policy - Definition Id and updated timestamp - "400": - description: Request body was malformed - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: "policy definition could not be updated, because it does not\ - \ exists" - content: - application/json: - schema: - $ref: '#/components/schemas/ApiErrorDetail' - delete: - tags: - - Policy Definition - 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!" - operationId: deletePolicyDefinition - parameters: - - name: id - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - responses: - "200": - description: Policy definition was deleted successfully - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: An policy definition with the given ID does not exist - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "409": - description: "The policy definition cannot be deleted, because it is referenced\ - \ by a contract definition" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v2/transferprocesses: - post: - tags: - - Transfer Process - description: "Initiates a data transfer with the given parameters. Please note\ - \ that successfully invoking this endpoint only means that the transfer was\ - \ initiated. Clients must poll the /{id}/state endpoint to track the state" - operationId: initiateTransferProcess - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/TransferRequestSchema' - responses: - "200": - description: The transfer was successfully initiated. Returns the transfer - process ID and created timestamp - content: - application/json: - schema: - $ref: '#/components/schemas/IdResponseSchema' - links: - poll-state: - operationId: getTransferProcessState - parameters: - id: $response.body#/id - "400": - description: Request body was malformed - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v2/transferprocesses/request: - post: - tags: - - Transfer Process - description: Returns all transfer process according to a query - operationId: queryTransferProcesses - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/QuerySpecSchema' - responses: - "200": - description: The transfer processes matching the query - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/TransferProcessSchema' - "400": - description: Request was malformed - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v2/transferprocesses/{id}: - get: - tags: - - Transfer Process - description: Gets an transfer process with the given ID - operationId: getTransferProcess - parameters: - - name: id - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - responses: - "200": - description: The transfer process - content: - application/json: - schema: - $ref: '#/components/schemas/TransferProcessSchema' - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: A transfer process with the given ID does not exist - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v2/transferprocesses/{id}/deprovision: - post: - tags: - - Transfer Process - description: "Requests the deprovisioning of resources associated with a transfer\ - \ process. 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." - operationId: deprovisionTransferProcess - parameters: - - name: id - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - responses: - "200": - description: Request to deprovision the transfer process was successfully - received - links: - poll-state: - operationId: getTransferProcessState - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: A contract negotiation with the given ID does not exist - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v2/transferprocesses/{id}/state: - get: - tags: - - Transfer Process - description: Gets the state of a transfer process with the given ID - operationId: getTransferProcessState - parameters: - - name: id - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - responses: - "200": - description: The transfer process's state - content: - application/json: - schema: - $ref: '#/components/schemas/TransferStateSchema' - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: An transfer process with the given ID does not exist - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v2/transferprocesses/{id}/terminate: - post: - tags: - - Transfer Process - description: "Requests the termination of a transfer process. Due to the asynchronous\ - \ nature of transfers, a successful response only indicates that the request\ - \ was successfully received. Clients must poll the /{id}/state endpoint to\ - \ track the state." - operationId: terminateTransferProcess - parameters: - - name: id - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/TerminateTransferSchema' - responses: - "200": - description: Request to cancel the transfer process was successfully received - links: - poll-state: - operationId: getTransferProcessState - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: A contract negotiation with the given ID does not exist - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "409": - description: "Could not terminate transfer process, because it is already\ - \ completed or terminated." - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v3/assets: - put: - tags: - - Asset - description: "Updates an asset with the given ID if it exists. If the asset\ - \ is not found, no further action is taken. DANGER ZONE: Note that updating\ - \ assets can have unexpected results, especially for contract offers that\ - \ have been sent out or are ongoing in contract negotiations." - operationId: updateAsset_1 - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/AssetInputSchema' - responses: - "200": - description: Asset was updated successfully - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: "Asset could not be updated, because it does not exist." - post: - tags: - - Asset - description: Creates a new asset together with a data address - operationId: createAsset_1 - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/AssetInputSchema' - responses: - "200": - description: Asset was created successfully. Returns the asset Id and created - timestamp - content: - application/json: - schema: - $ref: '#/components/schemas/IdResponseSchema' - "400": - description: Request body was malformed - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "409": - description: "Could not create asset, because an asset with that ID already\ - \ exists" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v3/assets/request: - post: - tags: - - Asset - description: ' all assets according to a particular query' - operationId: requestAssets_1 - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/QuerySpecSchema' - responses: - "200": - description: The assets matching the query - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/AssetOutputSchema' - "400": - description: Request body was malformed - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /v3/assets/{id}: - get: - tags: - - Asset - description: Gets an asset with the given ID - operationId: getAsset_1 - parameters: - - name: id - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - responses: - "200": - description: The asset - content: - application/json: - schema: - $ref: '#/components/schemas/AssetOutputSchema' - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: An asset with the given ID does not exist - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - delete: - tags: - - Asset - description: "Removes an asset with the given ID if possible. Deleting an asset\ - \ is only possible if that asset is not yet referenced by a contract agreement,\ - \ in which case an error is returned. DANGER ZONE: Note that deleting assets\ - \ can have unexpected results, especially for contract offers that have been\ - \ sent out or ongoing or contract negotiations." - operationId: removeAsset_1 - parameters: - - name: id - in: path - required: true - style: simple - explode: false - schema: - type: string - example: null - responses: - "200": - description: Asset was deleted successfully - "400": - description: "Request was malformed, e.g. id was null" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "404": - description: An asset with the given ID does not exist - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - "409": - description: "The asset cannot be deleted, because it is referenced by a\ - \ contract agreement" - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - /{any}: - get: - tags: - - Data Plane public API - description: Send `GET` data query to the Data Plane. - operationId: get - responses: - "400": - description: Missing access token - "403": - description: Access token is expired or invalid - "500": - description: Failed to transfer data - put: - tags: - - Data Plane public API - description: Send `PUT` data query to the Data Plane. - operationId: put - responses: - "400": - description: Missing access token - "403": - description: Access token is expired or invalid - "500": - description: Failed to transfer data - post: - tags: - - Data Plane public API - description: Send `POST` data query to the Data Plane. - operationId: post - responses: - "400": - description: Missing access token - "403": - description: Access token is expired or invalid - "500": - description: Failed to transfer data - delete: - tags: - - Data Plane public API - description: Send `DELETE` data query to the Data Plane. - operationId: delete - responses: - "400": - description: Missing access token - "403": - description: Access token is expired or invalid - "500": - description: Failed to transfer data - patch: - tags: - - Data Plane public API - description: Send `PATCH` data query to the Data Plane. - operationId: patch - responses: - "400": - description: Missing access token - "403": - description: Access token is expired or invalid - "500": - description: Failed to transfer data -components: - schemas: - Action: - type: object - properties: - constraint: - $ref: '#/components/schemas/Constraint' - includedIn: - type: string - example: null - type: - type: string - example: null - example: null - ApiErrorDetail: - type: object - properties: - invalidValue: - type: object - example: null - message: - type: string - example: null - path: - type: string - example: null - type: - type: string - example: null - example: null - Asset: - type: object - properties: - createdAt: - type: integer - format: int64 - example: null - dataAddress: - $ref: '#/components/schemas/DataAddress' - id: - type: string - example: null - privateProperties: - type: object - additionalProperties: - type: object - example: null - example: null - properties: - type: object - additionalProperties: - type: object - example: null - example: null - example: null - AssetEntryNewDto: - type: object - properties: - asset: - $ref: '#/components/schemas/Asset' - dataAddress: - $ref: '#/components/schemas/DataAddress' - example: null - AssetInputSchema: - type: object - properties: - '@id': - type: string - example: null - '@type': - type: string - example: https://w3id.org/edc/v0.0.1/ns/Asset - dataAddress: - $ref: '#/components/schemas/DataAddressSchema' - privateProperties: - type: object - additionalProperties: - type: object - example: null - example: null - properties: - type: object - additionalProperties: - type: object - example: null - example: null - example: - '@context': - edc: https://w3id.org/edc/v0.0.1/ns/ - '@id': definition-id - properties: - key: value - privateProperties: - privateKey: privateValue - dataAddress: - type: HttpData - AssetOutputSchema: - type: object - properties: - '@id': - type: string - example: null - '@type': - type: string - example: https://w3id.org/edc/v0.0.1/ns/Asset - createdAt: - type: integer - format: int64 - example: null - dataAddress: - $ref: '#/components/schemas/DataAddressSchema' - privateProperties: - type: object - additionalProperties: - type: object - example: null - example: null - properties: - type: object - additionalProperties: - type: object - example: null - example: null - example: - '@context': - edc: https://w3id.org/edc/v0.0.1/ns/ - '@id': definition-id - edc:properties: - edc:key: value - edc:privateProperties: - edc:privateKey: privateValue - edc:dataAddress: - edc:type: HttpData - edc:createdAt: 1688465655 - AssetResponseDto: - type: object - properties: - '@context': - type: object - example: null - '@id': - type: string - example: null - '@type': - type: string - example: null - createdAt: - type: integer - format: int64 - example: null - privateProperties: - type: object - additionalProperties: - type: object - example: null - example: null - properties: - type: object - additionalProperties: - type: object - example: null - example: null - example: null - AssetUpdateRequestDto: - type: object - properties: - '@context': - type: object - example: null - '@type': - type: string - example: null - privateProperties: - type: object - additionalProperties: - type: object - example: null - example: null - properties: - type: object - additionalProperties: - type: object - example: null - example: null - example: null - CallbackAddressSchema: - type: object - properties: - '@type': - type: string - example: https://w3id.org/edc/v0.0.1/ns/CallbackAddress - authCodeId: - type: string - example: null - authKey: - type: string - example: null - events: - uniqueItems: true - type: array - example: null - items: - type: string - example: null - transactional: - type: boolean - example: null - uri: - type: string - example: null - example: null - Catalog: - type: object - properties: - contractOffers: - type: array - example: null - items: - $ref: '#/components/schemas/ContractOffer' - dataServices: - type: array - example: null - items: - $ref: '#/components/schemas/DataService' - datasets: - type: array - example: null - items: - $ref: '#/components/schemas/Dataset' - id: - type: string - example: null - properties: - type: object - additionalProperties: - type: object - example: null - example: null - example: null - CatalogRequestDto: - type: object - properties: - '@context': - type: object - example: null - '@type': - type: string - example: null - protocol: - type: string - example: null - providerUrl: - type: string - example: null - querySpec: - $ref: '#/components/schemas/QuerySpecDto' - example: null - Constraint: - required: - - edctype - type: object - properties: - edctype: - type: string - example: null - example: null - discriminator: - propertyName: edctype - ContractAgreementSchema: - type: object - properties: - '@id': - type: string - example: null - '@type': - type: string - example: https://w3id.org/edc/v0.0.1/ns/ContractAgreement - assetId: - type: string - example: null - consumerId: - type: string - example: null - contractSigningDate: - type: integer - format: int64 - example: null - policy: - type: object - description: ODRL policy - example: null - providerId: - type: string - example: null - example: - '@context': - edc: https://w3id.org/edc/v0.0.1/ns/ - '@type': https://w3id.org/edc/v0.0.1/ns/ContractAgreement - '@id': negotiation-id - providerId: provider-id - consumerId: consumer-id - assetId: asset-id - contractSigningDate: 1688465655 - policy: - '@context': http://www.w3.org/ns/odrl.jsonld - '@type': Set - '@id': offer-id - permission: - - target: asset-id - action: display - ContractDefinitionInputSchema: - type: object - properties: - '@id': - type: string - example: null - '@type': - type: string - example: https://w3id.org/edc/v0.0.1/ns/ContractDefinition - accessPolicyId: - type: string - example: null - assetsSelector: - type: array - example: null - items: - $ref: '#/components/schemas/CriterionSchema' - contractPolicyId: - type: string - example: null - example: - '@context': - edc: https://w3id.org/edc/v0.0.1/ns/ - '@id': definition-id - accessPolicyId: asset-policy-id - contractPolicyId: contract-policy-id - assetsSelector: [] - ContractDefinitionOutputSchema: - type: object - properties: - '@id': - type: string - example: null - '@type': - type: string - example: https://w3id.org/edc/v0.0.1/ns/ContractDefinition - accessPolicyId: - type: string - example: null - assetsSelector: - type: array - example: null - items: - $ref: '#/components/schemas/CriterionSchema' - contractPolicyId: - type: string - example: null - createdAt: - type: integer - format: int64 - example: null - example: - '@context': - edc: https://w3id.org/edc/v0.0.1/ns/ - '@id': definition-id - edc:accessPolicyId: asset-policy-id - edc:contractPolicyId: contract-policy-id - edc:assetsSelector: [] - edc:createdAt: 1688465655 - ContractNegotiationSchema: - type: object - properties: - '@id': - type: string - example: null - '@type': - type: string - example: https://w3id.org/edc/v0.0.1/ns/ContractNegotiation - callbackAddresses: - type: array - example: null - items: - $ref: '#/components/schemas/CallbackAddressSchema' - contractAgreementId: - type: string - example: null - counterPartyAddress: - type: string - example: null - counterPartyId: - type: string - example: null - errorDetail: - type: string - example: null - protocol: - type: string - example: null - state: - type: string - example: null - type: - type: string - example: null - enum: - - CONSUMER - - PROVIDER - example: - '@context': - edc: https://w3id.org/edc/v0.0.1/ns/ - '@type': https://w3id.org/edc/v0.0.1/ns/ContractNegotiation - '@id': negotiation-id - type: PROVIDER - protocol: dataspace-protocol-http - counterPartyId: counter-party-id - counterPartyAddress: http://counter/party/address - state: VERIFIED - contractAgreementId: contract:agreement:id - 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 - ContractOffer: - type: object - properties: - assetId: - type: string - example: null - id: - type: string - example: null - policy: - $ref: '#/components/schemas/Policy' - example: null - ContractOfferDescriptionSchema: - type: object - properties: - '@type': - type: string - example: https://w3id.org/edc/v0.0.1/ns/ContractOfferDescription - assetId: - type: string - example: null - offerId: - type: string - example: null - policy: - type: object - description: ODRL policy - example: null - example: null - ContractRequestSchema: - type: object - properties: - '@type': - type: string - example: https://w3id.org/edc/v0.0.1/ns/ContractRequest - callbackAddresses: - type: array - example: null - items: - $ref: '#/components/schemas/CallbackAddressSchema' - connectorAddress: - type: string - example: null - connectorId: - type: string - description: please use providerId instead - example: null - deprecated: true - consumerId: - type: string - description: this field is not used anymore - example: null - deprecated: true - offer: - $ref: '#/components/schemas/ContractOfferDescriptionSchema' - protocol: - type: string - example: null - providerId: - type: string - example: null - example: - '@context': - edc: https://w3id.org/edc/v0.0.1/ns/ - '@type': https://w3id.org/edc/v0.0.1/ns/ContractRequest - connectorAddress: http://provider-address - protocol: dataspace-protocol-http - providerId: provider-id - offer: - offerId: offer-id - assetId: asset-id - policy: - '@context': http://www.w3.org/ns/odrl.jsonld - '@type': Set - '@id': offer-id - permission: - - target: asset-id - action: display - callbackAddresses: - - transactional: false - uri: http://callback/url - events: - - contract.negotiation - - transfer.process - authKey: auth-key - authCodeId: auth-code-id - CriterionDto: - type: object - properties: - '@context': - type: object - example: null - '@type': - type: string - example: null - operandLeft: - type: object - example: null - operandRight: - type: object - example: null - operator: - type: string - example: null - example: null - CriterionSchema: - type: object - properties: - '@type': - type: string - example: https://w3id.org/edc/v0.0.1/ns/CriterionDto - operandLeft: - type: object - example: null - operandRight: - type: object - example: null - operator: - type: string - example: null - example: - '@context': - edc: https://w3id.org/edc/v0.0.1/ns/ - operandLeft: fieldName - operator: = - operandRight: some value - DataAddress: - type: object - properties: - properties: - type: object - additionalProperties: - type: string - example: null - example: null - example: null - DataAddressDto: - type: object - properties: - '@context': - type: object - example: null - '@type': - type: string - example: null - properties: - type: object - additionalProperties: - type: string - example: null - example: null - example: null - DataAddressSchema: - type: object - properties: - '@type': - type: string - example: https://w3id.org/edc/v0.0.1/ns/DataAddress - type: - type: string - example: null - example: null - DataFlowRequest: - type: object - properties: - callbackAddress: - type: string - format: url - example: null - destinationDataAddress: - $ref: '#/components/schemas/DataAddress' - id: - type: string - example: null - processId: - type: string - example: null - properties: - type: object - additionalProperties: - type: string - example: null - example: null - sourceDataAddress: - $ref: '#/components/schemas/DataAddress' - traceContext: - type: object - additionalProperties: - type: string - example: null - example: null - trackable: - type: boolean - example: null - example: null - DataPlaneInstance: - type: object - properties: - allowedDestTypes: - uniqueItems: true - type: array - example: null - items: - type: string - example: null - allowedSourceTypes: - uniqueItems: true - type: array - example: null - items: - type: string - example: null - id: - type: string - example: null - lastActive: - type: integer - format: int64 - example: null - properties: - type: object - additionalProperties: - type: object - example: null - example: null - turnCount: - type: integer - format: int32 - example: null - url: - type: string - format: url - example: null - example: null - DataService: - type: object - properties: - endpointUrl: - type: string - example: null - id: - type: string - example: null - terms: - type: string - example: null - example: null - Dataset: - type: object - properties: - distributions: - type: array - example: null - items: - $ref: '#/components/schemas/Distribution' - id: - type: string - example: null - offers: - type: object - additionalProperties: - $ref: '#/components/schemas/Policy' - example: null - properties: - type: object - additionalProperties: - type: object - example: null - example: null - example: null - DeprovisionedResource: - type: object - properties: - error: - type: boolean - example: null - errorMessage: - type: string - example: null - inProcess: - type: boolean - example: null - provisionedResourceId: - type: string - example: null - example: null - Distribution: - type: object - properties: - dataService: - $ref: '#/components/schemas/DataService' - format: - type: string - example: null - example: null - Duty: - type: object - properties: - action: - $ref: '#/components/schemas/Action' - assignee: - type: string - example: null - assigner: - type: string - example: null - consequence: - $ref: '#/components/schemas/Duty' - constraints: - type: array - example: null - items: - $ref: '#/components/schemas/Constraint' - parentPermission: - $ref: '#/components/schemas/Permission' - target: - type: string - example: null - example: null - Failure: - type: object - properties: - failureDetail: - type: string - example: null - messages: - type: array - example: null - items: - type: string - example: null - example: null - HealthCheckResult: - type: object - properties: - component: - type: string - example: null - failure: - $ref: '#/components/schemas/Failure' - isHealthy: - type: boolean - example: null - example: null - HealthStatus: - type: object - properties: - componentResults: - type: array - example: null - items: - $ref: '#/components/schemas/HealthCheckResult' - isSystemHealthy: - type: boolean - example: null - example: null - IdResponseDto: - type: object - properties: - '@context': - type: object - example: null - '@id': - type: string - example: null - '@type': - type: string - example: null - createdAt: - type: integer - format: int64 - example: null - example: null - IdResponseSchema: - type: object - properties: - '@id': - type: string - example: null - createdAt: - type: integer - format: int64 - example: null - example: - '@context': - edc: https://w3id.org/edc/v0.0.1/ns/ - '@id': id-value - createdAt: 1688465655 - JsonArray: - type: array - properties: - empty: - type: boolean - example: null - valueType: - type: string - example: null - enum: - - ARRAY - - OBJECT - - STRING - - NUMBER - - "TRUE" - - "FALSE" - - "NULL" - example: null - items: - $ref: '#/components/schemas/JsonValue' - JsonObject: - type: object - properties: - empty: - type: boolean - example: null - valueType: - type: string - example: null - enum: - - ARRAY - - OBJECT - - STRING - - NUMBER - - "TRUE" - - "FALSE" - - "NULL" - additionalProperties: - $ref: '#/components/schemas/JsonValue' - example: null - JsonValue: - type: object - properties: - valueType: - type: string - example: null - enum: - - ARRAY - - OBJECT - - STRING - - NUMBER - - "TRUE" - - "FALSE" - - "NULL" - example: null - NegotiationState: - type: object - properties: - '@context': - type: object - example: null - '@type': - type: string - example: null - state: - type: string - example: null - example: null - Permission: - type: object - properties: - action: - $ref: '#/components/schemas/Action' - assignee: - type: string - example: null - assigner: - type: string - example: null - constraints: - type: array - example: null - items: - $ref: '#/components/schemas/Constraint' - duties: - type: array - example: null - items: - $ref: '#/components/schemas/Duty' - target: - type: string - example: null - example: null - Policy: - type: object - properties: - '@type': - type: string - example: null - enum: - - SET - - OFFER - - CONTRACT - assignee: - type: string - example: null - assigner: - type: string - example: null - extensibleProperties: - type: object - additionalProperties: - type: object - example: null - example: null - inheritsFrom: - type: string - example: null - obligations: - type: array - example: null - items: - $ref: '#/components/schemas/Duty' - permissions: - type: array - example: null - items: - $ref: '#/components/schemas/Permission' - prohibitions: - type: array - example: null - items: - $ref: '#/components/schemas/Prohibition' - target: - type: string - example: null - example: null - PolicyDefinitionInputSchema: - type: object - properties: - '@id': - type: string - example: null - '@type': - type: string - example: https://w3id.org/edc/v0.0.1/ns/PolicyDefinition - example: - '@context': - edc: 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 - PolicyDefinitionOutputSchema: - type: object - properties: - '@id': - type: string - example: null - '@type': - type: string - example: https://w3id.org/edc/v0.0.1/ns/PolicyDefinition - example: - '@context': - edc: 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 - Prohibition: - type: object - properties: - action: - $ref: '#/components/schemas/Action' - assignee: - type: string - example: null - assigner: - type: string - example: null - constraints: - type: array - example: null - items: - $ref: '#/components/schemas/Constraint' - target: - type: string - example: null - example: null - ProvisionerWebhookRequest: - type: object - properties: - apiKeyJwt: - type: string - example: null - assetId: - type: string - example: null - contentDataAddress: - $ref: '#/components/schemas/DataAddress' - hasToken: - type: boolean - example: null - resourceDefinitionId: - type: string - example: null - resourceName: - type: string - example: null - example: null - QuerySpecDto: - type: object - properties: - '@context': - type: object - example: null - '@type': - type: string - example: null - filterExpression: - type: array - example: null - items: - $ref: '#/components/schemas/CriterionDto' - limit: - type: integer - format: int32 - example: null - offset: - type: integer - format: int32 - example: null - sortField: - type: string - example: null - sortOrder: - type: string - example: null - enum: - - ASC - - DESC - example: null - QuerySpecSchema: - type: object - properties: - '@type': - type: string - example: https://w3id.org/edc/v0.0.1/ns/QuerySpecDto - filterExpression: - type: array - example: null - items: - $ref: '#/components/schemas/CriterionSchema' - limit: - type: integer - format: int32 - example: null - offset: - type: integer - format: int32 - example: null - sortField: - type: string - example: null - sortOrder: - type: string - example: null - enum: - - ASC - - DESC - example: - '@context': - edc: https://w3id.org/edc/v0.0.1/ns/ - offset: 5 - limit: 10 - sortOrder: DESC - sortField: fieldName - criterion: [] - SelectionRequest: - type: object - properties: - destination: - $ref: '#/components/schemas/DataAddress' - source: - $ref: '#/components/schemas/DataAddress' - strategy: - type: string - example: null - example: null - TerminateTransferSchema: - type: object - properties: - '@type': - type: string - example: https://w3id.org/edc/v0.0.1/ns/TransferState - state: - type: string - example: null - example: - '@context': - edc: https://w3id.org/edc/v0.0.1/ns/ - '@type': https://w3id.org/edc/v0.0.1/ns/TerminateTransfer - reason: a reason to terminate - TransferProcessFailStateDto: - type: object - properties: - errorMessage: - type: string - example: null - example: null - TransferProcessSchema: - type: object - properties: - '@id': - type: string - example: null - '@type': - type: string - example: https://w3id.org/edc/v0.0.1/ns/TransferProcess - callbackAddresses: - type: array - example: null - items: - $ref: '#/components/schemas/CallbackAddressSchema' - contractAgreementId: - type: string - example: null - counterPartyAddress: - type: string - example: null - counterPartyId: - type: string - example: null - errorDetail: - type: string - example: null - protocol: - type: string - example: null - state: - type: string - example: null - type: - type: string - example: null - enum: - - CONSUMER - - PROVIDER - example: - '@context': - edc: 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 - connectorId: connectorId - contractId: contractId - dataDestination: - type: data-destination-type - properties: - key: value - 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 - TransferRequestSchema: - type: object - properties: - '@type': - type: string - example: https://w3id.org/edc/v0.0.1/ns/TransferRequest - assetId: - type: string - example: null - callbackAddresses: - type: array - example: null - items: - $ref: '#/components/schemas/CallbackAddressSchema' - connectorAddress: - type: string - example: null - connectorId: - type: string - example: null - contractId: - type: string - example: null - dataDestination: - $ref: '#/components/schemas/DataAddressSchema' - privateProperties: - type: object - additionalProperties: - type: string - example: null - example: null - properties: - type: object - additionalProperties: - type: string - example: null - example: null - protocol: - type: string - example: null - example: - '@context': - edc: https://w3id.org/edc/v0.0.1/ns/ - '@type': https://w3id.org/edc/v0.0.1/ns/TransferRequest - protocol: dataspace-protocol-http - connectorAddress: http://provider-address - connectorId: provider-id - contractId: contract-id - assetId: asset-id - dataDestination: - type: data-destination-type - properties: - key: value - privateProperties: - private-key: private-value - callbackAddresses: - - transactional: false - uri: http://callback/url - events: - - contract.negotiation - - transfer.process - authKey: auth-key - authCodeId: auth-code-id - TransferStateSchema: - type: object - properties: - '@type': - type: string - example: https://w3id.org/edc/v0.0.1/ns/TransferState - state: - type: string - example: null - example: - '@context': - edc: https://w3id.org/edc/v0.0.1/ns/ - '@type': https://w3id.org/edc/v0.0.1/ns/TransferState - state: STARTED diff --git a/resources/openapi/yaml/management-api/asset-api.yaml b/resources/openapi/yaml/management-api/asset-api.yaml index ad2a303d947..96eb23f8f2b 100644 --- a/resources/openapi/yaml/management-api/asset-api.yaml +++ b/resources/openapi/yaml/management-api/asset-api.yaml @@ -648,6 +648,7 @@ components: example: '@context': edc: https://w3id.org/edc/v0.0.1/ns/ + '@type': Criterion operandLeft: fieldName operator: = operandRight: some value @@ -824,11 +825,12 @@ components: example: '@context': edc: https://w3id.org/edc/v0.0.1/ns/ + '@type': QuerySpec offset: 5 limit: 10 sortOrder: DESC sortField: fieldName - criterion: [] + filterExpression: [] properties: '@type': type: string diff --git a/resources/openapi/yaml/management-api/catalog-api.yaml b/resources/openapi/yaml/management-api/catalog-api.yaml index 5d601bc5049..e68d2cc079c 100644 --- a/resources/openapi/yaml/management-api/catalog-api.yaml +++ b/resources/openapi/yaml/management-api/catalog-api.yaml @@ -7,109 +7,102 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/CatalogRequestDto' + $ref: '#/components/schemas/CatalogRequestSchema' responses: default: content: application/json: schema: - $ref: '#/components/schemas/Catalog' + $ref: '#/components/schemas/CatalogSchema' description: Gets contract offers (=catalog) of a single connector tags: - Catalog components: schemas: - Action: + CatalogRequestSchema: type: object - example: null - properties: - constraint: - $ref: '#/components/schemas/Constraint' - includedIn: - type: string - example: null - type: - type: string - example: null - Catalog: - type: object - example: null - properties: - contractOffers: - type: array - example: null - items: - $ref: '#/components/schemas/ContractOffer' - dataServices: - type: array - example: null - items: - $ref: '#/components/schemas/DataService' - datasets: - type: array - example: null - items: - $ref: '#/components/schemas/Dataset' - id: - type: string - example: null - properties: - type: object - additionalProperties: - type: object - example: null - example: null - CatalogRequestDto: - type: object - example: null - properties: + example: '@context': - type: object - example: null + edc: https://w3id.org/edc/v0.0.1/ns/ + '@type': CatalogRequest + providerUrl: http://provider-address + protocol: dataspace-protocol-http + querySpec: + offset: 0 + limit: 50 + sortOrder: DESC + sortField: fieldName + filterExpression: [] + properties: '@type': type: string - example: null + example: https://w3id.org/edc/v0.0.1/ns/CatalogRequest protocol: type: string example: null - providerUrl: - type: string - example: null querySpec: - $ref: '#/components/schemas/QuerySpecDto' - Constraint: - type: object - discriminator: - propertyName: edctype - example: null - properties: - edctype: - type: string - example: null - required: - - edctype - ContractOffer: - type: object - example: null - properties: - assetId: - type: string - example: null - id: - type: string - example: null - policy: - $ref: '#/components/schemas/Policy' - CriterionDto: - type: object - example: null - properties: + $ref: '#/components/schemas/QuerySpecSchema' + CatalogSchema: + type: object + description: DCAT 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: [] + odrl:target: bcca61be-e82e-4da6-bfec-9716a56cef35 + dcat:distribution: + - '@type': dcat:Distribution + dct:format: + '@id': HttpData + dcat:accessService: 5e839777-d93e-4785-8972-1005f51cf367 + edc:description: description + edc: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 + edc:participantId: urn:connector:provider '@context': - type: object - example: null + dct: https://purl.org/dc/terms/ + edc: https://w3id.org/edc/v0.0.1/ns/ + dcat: https://www.w3.org/ns/dcat/ + odrl: http://www.w3.org/ns/odrl/2/ + dspace: https://w3id.org/dspace/v0.8/ + CriterionSchema: + type: object + example: + '@context': + edc: https://w3id.org/edc/v0.0.1/ns/ + '@type': Criterion + operandLeft: fieldName + operator: = + operandRight: some value + properties: '@type': type: string - example: null + example: https://w3id.org/edc/v0.0.1/ns/CriterionDto operandLeft: type: object example: null @@ -119,75 +112,6 @@ components: operator: type: string example: null - DataService: - type: object - example: null - properties: - endpointUrl: - type: string - example: null - id: - type: string - example: null - terms: - type: string - example: null - Dataset: - type: object - example: null - properties: - distributions: - type: array - example: null - items: - $ref: '#/components/schemas/Distribution' - id: - type: string - example: null - offers: - type: object - additionalProperties: - $ref: '#/components/schemas/Policy' - example: null - properties: - type: object - additionalProperties: - type: object - example: null - example: null - Distribution: - type: object - example: null - properties: - dataService: - $ref: '#/components/schemas/DataService' - format: - type: string - example: null - Duty: - type: object - example: null - properties: - action: - $ref: '#/components/schemas/Action' - assignee: - type: string - example: null - assigner: - type: string - example: null - consequence: - $ref: '#/components/schemas/Duty' - constraints: - type: array - example: null - items: - $ref: '#/components/schemas/Constraint' - parentPermission: - $ref: '#/components/schemas/Permission' - target: - type: string - example: null JsonObject: type: object additionalProperties: @@ -223,110 +147,26 @@ components: - "FALSE" - "NULL" example: null - Permission: - type: object - example: null - properties: - action: - $ref: '#/components/schemas/Action' - assignee: - type: string - example: null - assigner: - type: string - example: null - constraints: - type: array - example: null - items: - $ref: '#/components/schemas/Constraint' - duties: - type: array - example: null - items: - $ref: '#/components/schemas/Duty' - target: - type: string - example: null - Policy: - type: object - example: null - properties: - '@type': - type: string - enum: - - SET - - OFFER - - CONTRACT - example: null - assignee: - type: string - example: null - assigner: - type: string - example: null - extensibleProperties: - type: object - additionalProperties: - type: object - example: null - example: null - inheritsFrom: - type: string - example: null - obligations: - type: array - example: null - items: - $ref: '#/components/schemas/Duty' - permissions: - type: array - example: null - items: - $ref: '#/components/schemas/Permission' - prohibitions: - type: array - example: null - items: - $ref: '#/components/schemas/Prohibition' - target: - type: string - example: null - Prohibition: + QuerySpecSchema: type: object - example: null - properties: - action: - $ref: '#/components/schemas/Action' - assignee: - type: string - example: null - assigner: - type: string - example: null - constraints: - type: array - example: null - items: - $ref: '#/components/schemas/Constraint' - target: - type: string - example: null - QuerySpecDto: - type: object - example: null - properties: + example: '@context': - type: object - example: null + edc: https://w3id.org/edc/v0.0.1/ns/ + '@type': QuerySpec + offset: 5 + limit: 10 + sortOrder: DESC + sortField: fieldName + filterExpression: [] + properties: '@type': type: string - example: null + example: https://w3id.org/edc/v0.0.1/ns/QuerySpecDto filterExpression: type: array example: null items: - $ref: '#/components/schemas/CriterionDto' + $ref: '#/components/schemas/CriterionSchema' limit: type: integer format: int32 diff --git a/resources/openapi/yaml/management-api/contract-agreement-api.yaml b/resources/openapi/yaml/management-api/contract-agreement-api.yaml index fa07eb80952..5cd8701901b 100644 --- a/resources/openapi/yaml/management-api/contract-agreement-api.yaml +++ b/resources/openapi/yaml/management-api/contract-agreement-api.yaml @@ -122,9 +122,7 @@ components: format: int64 example: null policy: - type: object - description: ODRL policy - example: null + $ref: '#/components/schemas/PolicySchema' providerId: type: string example: null @@ -133,6 +131,7 @@ components: example: '@context': edc: https://w3id.org/edc/v0.0.1/ns/ + '@type': Criterion operandLeft: fieldName operator: = operandRight: some value @@ -204,16 +203,34 @@ components: - "FALSE" - "NULL" example: null + PolicySchema: + type: object + description: ODRL policy + example: + '@context': http://www.w3.org/ns/odrl.jsonld + '@id': 0949ba30-680c-44e6-bc7d-1688cbe1847e + '@type': odrl:Set + permission: + target: http://example.com/asset:9898.movie + action: + type: http://www.w3.org/ns/odrl/2/use + constraint: + leftOperand: https://w3id.org/edc/v0.0.1/ns/left + operator: eq + rightOperand: value + prohibition: [] + obligation: [] QuerySpecSchema: type: object example: '@context': edc: https://w3id.org/edc/v0.0.1/ns/ + '@type': QuerySpec offset: 5 limit: 10 sortOrder: DESC sortField: fieldName - criterion: [] + filterExpression: [] properties: '@type': type: string diff --git a/resources/openapi/yaml/management-api/contract-definition-api.yaml b/resources/openapi/yaml/management-api/contract-definition-api.yaml index d4fd537af16..6c890de66cb 100644 --- a/resources/openapi/yaml/management-api/contract-definition-api.yaml +++ b/resources/openapi/yaml/management-api/contract-definition-api.yaml @@ -256,6 +256,7 @@ components: example: '@context': edc: https://w3id.org/edc/v0.0.1/ns/ + '@type': Criterion operandLeft: fieldName operator: = operandRight: some value @@ -347,11 +348,12 @@ components: example: '@context': edc: https://w3id.org/edc/v0.0.1/ns/ + '@type': QuerySpec offset: 5 limit: 10 sortOrder: DESC sortField: fieldName - criterion: [] + filterExpression: [] properties: '@type': type: string diff --git a/resources/openapi/yaml/management-api/contract-negotiation-api.yaml b/resources/openapi/yaml/management-api/contract-negotiation-api.yaml index e3ac141ae42..403d8557226 100644 --- a/resources/openapi/yaml/management-api/contract-negotiation-api.yaml +++ b/resources/openapi/yaml/management-api/contract-negotiation-api.yaml @@ -344,9 +344,7 @@ components: format: int64 example: null policy: - type: object - description: ODRL policy - example: null + $ref: '#/components/schemas/PolicySchema' providerId: type: string example: null @@ -423,9 +421,7 @@ components: type: string example: null policy: - type: object - description: ODRL policy - example: null + $ref: '#/components/schemas/PolicySchema' ContractRequestSchema: type: object example: @@ -488,6 +484,7 @@ components: example: '@context': edc: https://w3id.org/edc/v0.0.1/ns/ + '@type': Criterion operandLeft: fieldName operator: = operandRight: some value @@ -587,16 +584,34 @@ components: state: type: string example: null + PolicySchema: + type: object + description: ODRL policy + example: + '@context': http://www.w3.org/ns/odrl.jsonld + '@id': 0949ba30-680c-44e6-bc7d-1688cbe1847e + '@type': odrl:Set + permission: + target: http://example.com/asset:9898.movie + action: + type: http://www.w3.org/ns/odrl/2/use + constraint: + leftOperand: https://w3id.org/edc/v0.0.1/ns/left + operator: eq + rightOperand: value + prohibition: [] + obligation: [] QuerySpecSchema: type: object example: '@context': edc: https://w3id.org/edc/v0.0.1/ns/ + '@type': QuerySpec offset: 5 limit: 10 sortOrder: DESC sortField: fieldName - criterion: [] + filterExpression: [] properties: '@type': type: string diff --git a/resources/openapi/yaml/management-api/policy-definition-api.yaml b/resources/openapi/yaml/management-api/policy-definition-api.yaml index a0530bdcdde..9a53e51cfe2 100644 --- a/resources/openapi/yaml/management-api/policy-definition-api.yaml +++ b/resources/openapi/yaml/management-api/policy-definition-api.yaml @@ -214,6 +214,7 @@ components: example: '@context': edc: https://w3id.org/edc/v0.0.1/ns/ + '@type': Criterion operandLeft: fieldName operator: = operandRight: some value @@ -325,6 +326,8 @@ components: '@type': type: string example: https://w3id.org/edc/v0.0.1/ns/PolicyDefinition + policy: + $ref: '#/components/schemas/PolicySchema' PolicyDefinitionOutputSchema: type: object example: @@ -351,16 +354,36 @@ components: '@type': type: string example: https://w3id.org/edc/v0.0.1/ns/PolicyDefinition + policy: + $ref: '#/components/schemas/PolicySchema' + PolicySchema: + type: object + description: ODRL policy + example: + '@context': http://www.w3.org/ns/odrl.jsonld + '@id': 0949ba30-680c-44e6-bc7d-1688cbe1847e + '@type': odrl:Set + permission: + target: http://example.com/asset:9898.movie + action: + type: http://www.w3.org/ns/odrl/2/use + constraint: + leftOperand: https://w3id.org/edc/v0.0.1/ns/left + operator: eq + rightOperand: value + prohibition: [] + obligation: [] QuerySpecSchema: type: object example: '@context': edc: https://w3id.org/edc/v0.0.1/ns/ + '@type': QuerySpec offset: 5 limit: 10 sortOrder: DESC sortField: fieldName - criterion: [] + filterExpression: [] properties: '@type': type: string diff --git a/resources/openapi/yaml/management-api/transfer-process-api.yaml b/resources/openapi/yaml/management-api/transfer-process-api.yaml index 557aae20f01..6a41ea7798d 100644 --- a/resources/openapi/yaml/management-api/transfer-process-api.yaml +++ b/resources/openapi/yaml/management-api/transfer-process-api.yaml @@ -287,6 +287,7 @@ components: example: '@context': edc: https://w3id.org/edc/v0.0.1/ns/ + '@type': Criterion operandLeft: fieldName operator: = operandRight: some value @@ -388,11 +389,12 @@ components: example: '@context': edc: https://w3id.org/edc/v0.0.1/ns/ + '@type': QuerySpec offset: 5 limit: 10 sortOrder: DESC sortField: fieldName - criterion: [] + filterExpression: [] properties: '@type': type: string diff --git a/spi/common/catalog-spi/src/main/java/org/eclipse/edc/catalog/spi/CatalogRequest.java b/spi/common/catalog-spi/src/main/java/org/eclipse/edc/catalog/spi/CatalogRequest.java index 6a0f55ffcf9..d344ba4ef2f 100644 --- a/spi/common/catalog-spi/src/main/java/org/eclipse/edc/catalog/spi/CatalogRequest.java +++ b/spi/common/catalog-spi/src/main/java/org/eclipse/edc/catalog/spi/CatalogRequest.java @@ -23,10 +23,10 @@ public class CatalogRequest { - public static final String EDC_CATALOG_REQUEST_TYPE = EDC_NAMESPACE + "CatalogRequest"; - public static final String EDC_CATALOG_REQUEST_PROTOCOL = EDC_NAMESPACE + "protocol"; - public static final String EDC_CATALOG_REQUEST_PROVIDER_URL = EDC_NAMESPACE + "providerUrl"; - public static final String EDC_CATALOG_REQUEST_QUERY_SPEC = EDC_NAMESPACE + "querySpec"; + public static final String CATALOG_REQUEST_TYPE = EDC_NAMESPACE + "CatalogRequest"; + public static final String CATALOG_REQUEST_PROTOCOL = EDC_NAMESPACE + "protocol"; + public static final String CATALOG_REQUEST_PROVIDER_URL = EDC_NAMESPACE + "providerUrl"; + public static final String CATALOG_REQUEST_QUERY_SPEC = EDC_NAMESPACE + "querySpec"; private QuerySpec querySpec; private String providerUrl; diff --git a/system-tests/e2e-test-fixtures/src/testFixtures/java/org/eclipse/edc/test/system/utils/Participant.java b/system-tests/e2e-test-fixtures/src/testFixtures/java/org/eclipse/edc/test/system/utils/Participant.java index 5d0a3fc37cd..f1839fd5a7f 100644 --- a/system-tests/e2e-test-fixtures/src/testFixtures/java/org/eclipse/edc/test/system/utils/Participant.java +++ b/system-tests/e2e-test-fixtures/src/testFixtures/java/org/eclipse/edc/test/system/utils/Participant.java @@ -179,6 +179,7 @@ public JsonArray getCatalogDatasets(Participant provider) { .body(requestBody) .post("/v2/catalog/request") .then() + .log().all() .statusCode(200) .extract().body().asString(); diff --git a/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/CatalogApiEndToEndTest.java b/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/CatalogApiEndToEndTest.java index 2113214c111..c24695957f0 100644 --- a/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/CatalogApiEndToEndTest.java +++ b/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/CatalogApiEndToEndTest.java @@ -63,9 +63,6 @@ void shouldReturnCatalog_withoutQuerySpec() { @Test void shouldReturnCatalog_withQuerySpec() { - var asset = createAsset("id-1").dataAddress(createDataAddress()); - var asset1 = createAsset("id-2").dataAddress(createDataAddress()); - var assetIndex = controlPlane.getContext().getService(AssetIndex.class); var policyDefinitionStore = controlPlane.getContext().getService(PolicyDefinitionStore.class); var contractDefinitionStore = controlPlane.getContext().getService(ContractDefinitionStore.class); @@ -84,8 +81,8 @@ void shouldReturnCatalog_withQuerySpec() { policyDefinitionStore.create(PolicyDefinition.Builder.newInstance().id(policyId).policy(policy).build()); contractDefinitionStore.save(cd); - assetIndex.create(asset.build()); - assetIndex.create(asset1.build()); + assetIndex.create(createAsset("id-1").build()); + assetIndex.create(createAsset("id-2").build()); var criteria = createArrayBuilder() .add(createObjectBuilder() @@ -118,16 +115,12 @@ void shouldReturnCatalog_withQuerySpec() { .statusCode(200) .contentType(JSON) .body(TYPE, is("dcat:Catalog")) - .body("'dcat:dataset'.'edc:id'", is("id-2")) - .extract().body().asString(); - } - - private DataAddress createDataAddress() { - return DataAddress.Builder.newInstance().type("test-type").build(); + .body("'dcat:dataset'.'edc:id'", is("id-2")); } private Asset.Builder createAsset(String id) { return Asset.Builder.newInstance() + .dataAddress(DataAddress.Builder.newInstance().type("test-type").build()) .id(id); } diff --git a/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/PolicyDefinitionApiEndToEndTest.java b/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/PolicyDefinitionApiEndToEndTest.java index 9612ecba108..b5c8ae94b11 100644 --- a/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/PolicyDefinitionApiEndToEndTest.java +++ b/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/PolicyDefinitionApiEndToEndTest.java @@ -120,7 +120,6 @@ void shouldDelete() { .add("policy", sampleOdrlPolicy()) .build(); - var id = baseRequest() .body(requestBody) .contentType(JSON) diff --git a/system-tests/telemetry/telemetry-test-runner/src/test/java/org/eclipse/edc/test/e2e/tracing/MicrometerEndToEndTest.java b/system-tests/telemetry/telemetry-test-runner/src/test/java/org/eclipse/edc/test/e2e/tracing/MicrometerEndToEndTest.java index 52815243217..891eed21df3 100644 --- a/system-tests/telemetry/telemetry-test-runner/src/test/java/org/eclipse/edc/test/e2e/tracing/MicrometerEndToEndTest.java +++ b/system-tests/telemetry/telemetry-test-runner/src/test/java/org/eclipse/edc/test/e2e/tracing/MicrometerEndToEndTest.java @@ -21,7 +21,7 @@ import static io.restassured.RestAssured.given; import static io.restassured.http.ContentType.JSON; import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.edc.catalog.spi.CatalogRequest.EDC_CATALOG_REQUEST_TYPE; +import static org.eclipse.edc.catalog.spi.CatalogRequest.CATALOG_REQUEST_TYPE; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; import static org.eclipse.edc.spi.CoreConstants.EDC_NAMESPACE; @@ -34,7 +34,7 @@ public class MicrometerEndToEndTest extends BaseTelemetryEndToEndTest { void testMicrometerMetrics() { // will request the catalog to itself, just to trigger okhttp metrics var requestBody = Json.createObjectBuilder() - .add(TYPE, EDC_CATALOG_REQUEST_TYPE) + .add(TYPE, CATALOG_REQUEST_TYPE) .add(EDC_NAMESPACE + "providerUrl", "http://localhost:" + PROTOCOL_PORT + "/protocol") .add(EDC_NAMESPACE + "protocol", "dataspace-protocol-http") .build();