Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): align management api to v3 #1422

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
maven/mavencentral/com.apicatalog/carbon-did/0.3.0, Apache-2.0, approved, clearlydefined

Check warning on line 1 in DEPENDENCIES

View workflow job for this annotation

GitHub Actions / verify / verify-dependencies / Dash-Verify-Licenses

Restricted Dependencies found

Some dependencies are marked 'restricted' - please review them
maven/mavencentral/com.apicatalog/copper-multibase/0.5.0, Apache-2.0, approved, #14501
maven/mavencentral/com.apicatalog/copper-multicodec/0.1.1, Apache-2.0, approved, #14500
maven/mavencentral/com.apicatalog/iron-ed25519-cryptosuite-2020/0.14.0, Apache-2.0, approved, #14503
Expand Down Expand Up @@ -109,7 +109,7 @@
maven/mavencentral/com.nimbusds/nimbus-jose-jwt/9.40, Apache-2.0, approved, #15156
maven/mavencentral/com.nimbusds/oauth2-oidc-sdk/11.9.1, Apache-2.0, approved, #12667
maven/mavencentral/com.puppycrawl.tools/checkstyle/10.17.0, LGPL-2.1-or-later AND (Apache-2.0 AND LGPL-2.1-or-later) AND Apache-2.0, approved, #15077
maven/mavencentral/com.samskivert/jmustache/1.15, BSD-2-Clause, approved, clearlydefined
maven/mavencentral/com.samskivert/jmustache/1.15, BSD-2-Clause AND BSD-3-Clause, approved, clearlydefined
maven/mavencentral/com.squareup.okhttp3/okhttp-dnsoverhttps/4.12.0, Apache-2.0, approved, #11159
maven/mavencentral/com.squareup.okhttp3/okhttp/4.12.0, Apache-2.0, approved, #15227
maven/mavencentral/com.squareup.okhttp3/okhttp/4.9.3, Apache-2.0 AND MPL-2.0, approved, #3225
Expand Down Expand Up @@ -311,7 +311,7 @@
maven/mavencentral/org.apache.maven.doxia/doxia-sink-api/1.12.0, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.apache.velocity.tools/velocity-tools-generic/3.1, Apache-2.0, approved, #9331
maven/mavencentral/org.apache.velocity/velocity-engine-core/2.3, Apache-2.0, approved, #2478
maven/mavencentral/org.apache.velocity/velocity-engine-scripting/2.3, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.apache.velocity/velocity-engine-scripting/2.3, Apache-2.0, restricted, clearlydefined
maven/mavencentral/org.apache.xbean/xbean-reflect/3.7, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.apiguardian/apiguardian-api/1.1.2, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.assertj/assertj-core/3.26.0, Apache-2.0, approved, #14886
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ spec:
"@id": "tx:BPN000001234",
"tx:groups": ["group1", "group2", "group3"]
}' ]
args: [ '{{- printf "http://%s-controlplane:%v%s/business-partner-groups" (include "txdc.fullname" $ ) $.Values.controlplane.endpoints.management.port $.Values.controlplane.endpoints.management.path -}}' ]
args: [ '{{- printf "http://%s-controlplane:%v%s/v3/business-partner-groups" (include "txdc.fullname" $ ) $.Values.controlplane.endpoints.management.port $.Values.controlplane.endpoints.management.path -}}' ]
restartPolicy: Never
securityContext:
fsGroup: 101 # curl_group
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ spec:
"@id": "tx:BPN000001234",
"tx:groups": ["group1", "group2", "group3"]
}' ]
args: [ '{{- printf "http://%s-runtime:%v%s/business-partner-groups" (include "txdc.fullname" $ ) $.Values.runtime.endpoints.management.port $.Values.runtime.endpoints.management.path -}}' ]
args: [ '{{- printf "http://%s-runtime:%v%s/v3/business-partner-groups" (include "txdc.fullname" $ ) $.Values.runtime.endpoints.management.port $.Values.runtime.endpoints.management.path -}}' ]
restartPolicy: Never
securityContext:
fsGroup: 101 # curl_group
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ spec:
"@id": "tx:BPN000001234",
"tx:groups": ["group1", "group2", "group3"]
}' ]
args: [ '{{- printf "http://%s-controlplane:%v%s/business-partner-groups" (include "txdc.fullname" $ ) $.Values.controlplane.endpoints.management.port $.Values.controlplane.endpoints.management.path -}}' ]
args: [ '{{- printf "http://%s-controlplane:%v%s/v3/business-partner-groups" (include "txdc.fullname" $ ) $.Values.controlplane.endpoints.management.port $.Values.controlplane.endpoints.management.path -}}' ]
restartPolicy: Never
securityContext:
fsGroup: 101 # curl_group
Expand Down
4 changes: 2 additions & 2 deletions docs/usage/management-api-walkthrough/02_policies.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impacting policy definitions.
Policies can be created in the EDC as follows:

```http request
POST /v2/policydefinitions HTTP/1.1
POST /v3/policydefinitions HTTP/1.1
Host: https://provider-control.plane/api/management
X-Api-Key: password
Content-Type: application/json
Expand Down Expand Up @@ -492,4 +492,4 @@ example could have also used `Policy` type instead of `Set` type (**as they are

- SPDX-License-Identifier: CC-BY-4.0
- SPDX-FileCopyrightText: 2023 Contributors of the Eclipse Foundation
- Source URL: [https://github.com/eclipse-tractusx/tractusx-edc](https://github.com/eclipse-tractusx/tractusx-edc)
- Source URL: [https://github.com/eclipse-tractusx/tractusx-edc](https://github.com/eclipse-tractusx/tractusx-edc)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Policy. The two policies are both policies as explained [previously](02_policies
stages of communication between Data Provider and Data Consumer. The creation request looks like this:

```http request
POST /v2/contractdefinitions HTTP/1.1
POST /v3/contractdefinitions HTTP/1.1
Host: https://provider-control.plane/api/management
X-Api-Key: password
Content-Type: application/json
Expand Down Expand Up @@ -85,8 +85,8 @@ The `edc:Criterion` mechanism is used as well in the provider-internal request-e
part of the `edc:QuerySpec` objects that also allow pagination:

- `POST /v3/assets/request`
- `POST /v2/policydefinitions/request`
- `POST /v2/contractdefinitions/request`
- `POST /v3/policydefinitions/request`
- `POST /v3/contractdefinitions/request`

## Side-Effects

Expand All @@ -106,4 +106,4 @@ This work is licensed under the [CC-BY-4.0](https://creativecommons.org/licenses

- SPDX-License-Identifier: CC-BY-4.0
- SPDX-FileCopyrightText: 2023 Contributors of the Eclipse Foundation
- Source URL: [https://github.com/eclipse-tractusx/tractusx-edc](https://github.com/eclipse-tractusx/tractusx-edc)
- Source URL: [https://github.com/eclipse-tractusx/tractusx-edc](https://github.com/eclipse-tractusx/tractusx-edc)
6 changes: 3 additions & 3 deletions docs/usage/management-api-walkthrough/04_catalog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Consumer against their own Control Plane and triggers the retrieval of a catalog
looks like this:

```http request
POST /v2/catalog/request HTTP/1.1
POST /v3/catalog/request HTTP/1.1
Host: https://consumer-control.plane/api/management
X-Api-Key: password
Content-Type: application/json
Expand Down Expand Up @@ -173,7 +173,7 @@ policies included.
- `dcat:hasPolicy` holds the Data Offer that is relevant for the Consumer.
- `@id` is the identifier for the Data Offer. The EDC composes this id by concatenating three identifiers in base64-encoding.
separated with `:` (colons). The format is `base64(contractDefinitionId):base64(assetId):base64(newUuidV4)`. The last
of three UUIDs changes with every request as every /v2/catalog/request call yields a new catalog with new Data Offers.
of three UUIDs changes with every request as every /v3/catalog/request call yields a new catalog with new Data Offers.
- The `odrl:permission`, `odrl:prohibition` and `odrl:obligation` will hold the content of the contractPolicy configured
in the [Contract Definition](03_contractdefinitions.md) the Contract Offer was derived from.

Expand All @@ -183,4 +183,4 @@ This work is licensed under the [CC-BY-4.0](https://creativecommons.org/licenses

- SPDX-License-Identifier: CC-BY-4.0
- SPDX-FileCopyrightText: 2023 Contributors of the Eclipse Foundation
- Source URL: [https://github.com/eclipse-tractusx/tractusx-edc](https://github.com/eclipse-tractusx/tractusx-edc)
- Source URL: [https://github.com/eclipse-tractusx/tractusx-edc](https://github.com/eclipse-tractusx/tractusx-edc)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ It includes
To trigger the process, the Data Consumer POSTs against their own Control Plane.

```http request
POST /v2/contractnegotiations HTTP/1.1
POST /v3/contractnegotiations HTTP/1.1
Host: https://consumer-control.plane/api/management
X-Api-Key: password
Content-Type: application/json
Expand Down Expand Up @@ -92,7 +92,7 @@ the `@id` property.
### Polling

```http request
GET /v2/contractnegotiation/773b8795-45f2-4c57-a020-dc04e639baf3 HTTP/1.1
GET /v3/contractnegotiation/773b8795-45f2-4c57-a020-dc04e639baf3 HTTP/1.1
Host: https://consumer-control.plane/api/management
X-Api-Key: password
Content-Type: application/json
Expand Down Expand Up @@ -245,4 +245,4 @@ This work is licensed under the [CC-BY-4.0](https://creativecommons.org/licenses

- SPDX-License-Identifier: CC-BY-4.0
- SPDX-FileCopyrightText: 2023 Contributors of the Eclipse Foundation
- Source URL: [https://github.com/eclipse-tractusx/tractusx-edc](https://github.com/eclipse-tractusx/tractusx-edc)
- Source URL: [https://github.com/eclipse-tractusx/tractusx-edc](https://github.com/eclipse-tractusx/tractusx-edc)
6 changes: 3 additions & 3 deletions docs/usage/management-api-walkthrough/06_transferprocesses.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ terminated/suspended or terminated by the policy monitor depending on the config

To trigger this process, the Consumer app makes a request to its EDC's Control Plane:
```http request
POST /v2/transferprocesses HTTP/1.1
POST /v3/transferprocesses HTTP/1.1
Host: https://consumer-control.plane/api/management
X-Api-Key: password
Content-Type: application/json
Expand Down Expand Up @@ -110,7 +110,7 @@ the Consumer Control Plane. How to handle EDRs consumption check [here](07_edrs.
The state of a given Transfer Process can be requested like this:

```http request
GET /v2/transferprocesses/177aba51-52d7-44dc-beab-fd6151147024 HTTP/1.1
GET /v3/transferprocesses/177aba51-52d7-44dc-beab-fd6151147024 HTTP/1.1
Host: https://consumer-control.plane/api/management
X-Api-Key: password
Content-Type: application/json
Expand Down Expand Up @@ -168,4 +168,4 @@ This work is licensed under the [CC-BY-4.0](https://creativecommons.org/licenses

- SPDX-License-Identifier: CC-BY-4.0
- SPDX-FileCopyrightText: 2023 Contributors of the Eclipse Foundation
- Source URL: [https://github.com/eclipse-tractusx/tractusx-edc](https://github.com/eclipse-tractusx/tractusx-edc)
- Source URL: [https://github.com/eclipse-tractusx/tractusx-edc](https://github.com/eclipse-tractusx/tractusx-edc)
16 changes: 8 additions & 8 deletions docs/usage/management-api-walkthrough/07_edrs.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Alternatively TractusX-EDC provides a single API to collapse those two processes
Example of negotiating a contract for an asset with a framework agreement policy:

```http request
POST /v2/edrs HTTP/1.1
POST /v3/edrs HTTP/1.1
Host: https://consumer-control.plane/management
X-Api-Key: password
Content-Type: application/json
Expand Down Expand Up @@ -123,7 +123,7 @@ The Consumer Control Plane can be queried for EDRs by the
Here's an example of querying with `assetId`:

```http request
POST /v2/edrs/request HTTP/1.1
POST /v3/edrs/request HTTP/1.1
Host: https://consumer-control.plane/management
X-Api-Key: password
Content-Type: application/json
Expand All @@ -148,7 +148,7 @@ Content-Type: application/json

It returns a set of EDR entries holding meta-data including:
- `transferProcessId`: The ID of the [Transfer Process](06_transferprocesses.md) that was implicitly initiated
by the POST `/v2/edrs` request.
by the POST `/v3/edrs` request.
- `agreementId`: The ID of the agreement that the two EDCs have made in the [Contract Negotiation](05_contractnegotiations.md)
phase of their EDR-interaction.
- `providerId`: The ID of the provider.
Expand All @@ -161,7 +161,7 @@ Finally, after first obtaining them from the Provider Control Plane and
then locating in the Consumer Control Plane's cache, they can be retrieved using the `transferProcessId`.

```http request
GET /v2/edrs/myTransferProcessId/dataaddress HTTP/1.1
GET /v3/edrs/myTransferProcessId/dataaddress HTTP/1.1
Host: https://consumer-control.plane/management
X-Api-Key: password
Content-Type: application/json
Expand Down Expand Up @@ -208,7 +208,7 @@ By using the same API described above and passing a query parameter `auto_refres
will be done automatically if necessary transparently.

```http request
GET /v2/edrs/myTransferProcessId/dataaddress?auto_refresh=true HTTP/1.1
GET /v3/edrs/myTransferProcessId/dataaddress?auto_refresh=true HTTP/1.1
Host: https://consumer-control.plane/management
X-Api-Key: password
Content-Type: application/json
Expand All @@ -221,7 +221,7 @@ In this way, always a valid token is returned.
A explicit refresh API is available for users;

```http
POST /v2/edrs/myTransferProcessId/refresh HTTP/1.1
POST /v3/edrs/myTransferProcessId/refresh HTTP/1.1
Host: https://consumer-control.plane/management
X-Api-Key: password
Content-Type: application/json
Expand All @@ -240,7 +240,7 @@ However, if needed this endpoint will delete the EDR entry associated with the `
from the vault.

```http request
DELETE /v2/edrs/myTransferProcessId HTTP/1.1
DELETE /v3/edrs/myTransferProcessId HTTP/1.1
Host: https://consumer-control.plane/management
X-Api-Key: password
Content-Type: application/json
Expand Down Expand Up @@ -325,4 +325,4 @@ This work is licensed under the [CC-BY-4.0](https://creativecommons.org/licenses

- SPDX-License-Identifier: CC-BY-4.0
- SPDX-FileCopyrightText: 2023 Contributors of the Eclipse Foundation
- Source URL: [https://github.com/eclipse-tractusx/tractusx-edc](https://github.com/eclipse-tractusx/tractusx-edc)
- Source URL: [https://github.com/eclipse-tractusx/tractusx-edc](https://github.com/eclipse-tractusx/tractusx-edc)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ endpoint (to be used with the previously explained `QuerySpec` object) but allow
like this:

```http request
GET /v2/contractagreements/{{AGREEMENT_ID}} HTTP/1.1
GET /v3/contractagreements/{{AGREEMENT_ID}} HTTP/1.1
Host: https://consumer-control.plane/api/management
X-Api-Key: password
Content-Type: application/json
Expand Down Expand Up @@ -66,4 +66,4 @@ This work is licensed under the [CC-BY-4.0](https://creativecommons.org/licenses

- SPDX-License-Identifier: CC-BY-4.0
- SPDX-FileCopyrightText: 2023 Contributors of the Eclipse Foundation
- Source URL: [https://github.com/eclipse-tractusx/tractusx-edc](https://github.com/eclipse-tractusx/tractusx-edc)
- Source URL: [https://github.com/eclipse-tractusx/tractusx-edc](https://github.com/eclipse-tractusx/tractusx-edc)
16 changes: 8 additions & 8 deletions docs/usage/management-api-walkthrough/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ endpoints are currently versioned independently of each other.
| Resource | Endpoint | Involved Actors |
|----------------------------------------------------|--------------------------------------------|-------------------------------------------|
| [Asset](01_assets.md) | `<MANAGEMENT_URL>/v3/assets` | Provider Admin & Provider EDC |
| [Policy Definition](02_policies.md) | `<MANAGEMENT_URL>/v2/policydefinitions` | Provider Admin & Provider EDC |
| [Contract Definition](03_contractdefinitions.md) | `<MANAGEMENT_URL>/v2/contractdefinitions` | Provider Admin & Provider EDC |
| [Catalog](04_catalog.md) | `<MANAGEMENT_URL>/v2/catalog` | Consumer App, Consumer EDC & Provider EDC |
| [Contract Negotiation](05_contractnegotiations.md) | `<MANAGEMENT_URL>/v2/contractnegotiations` | Consumer App, Consumer EDC & Provider EDC |
| [Contract Agreement](08_contractagreements.md) | `<MANAGEMENT_URL>/v2/contractagreements` | Provider Admin & Provider EDC |
| [Transfer Process](06_transferprocesses.md) | `<MANAGEMENT_URL>/v2/transferprocesses` | Consumer App, Consumer EDC & Provider EDC |
| [EDR](07_edrs.md) | `<MANAGEMENT_URL>/edrs` | Consumer App, Consumer EDC & Provider EDC |
| [Policy Definition](02_policies.md) | `<MANAGEMENT_URL>/v3/policydefinitions` | Provider Admin & Provider EDC |
| [Contract Definition](03_contractdefinitions.md) | `<MANAGEMENT_URL>/v3/contractdefinitions` | Provider Admin & Provider EDC |
| [Catalog](04_catalog.md) | `<MANAGEMENT_URL>/v3/catalog` | Consumer App, Consumer EDC & Provider EDC |
| [Contract Negotiation](05_contractnegotiations.md) | `<MANAGEMENT_URL>/v3/contractnegotiations` | Consumer App, Consumer EDC & Provider EDC |
| [Contract Agreement](08_contractagreements.md) | `<MANAGEMENT_URL>/v3/contractagreements` | Provider Admin & Provider EDC |
| [Transfer Process](06_transferprocesses.md) | `<MANAGEMENT_URL>/v3/transferprocesses` | Consumer App, Consumer EDC & Provider EDC |
| [EDR](07_edrs.md) | `<MANAGEMENT_URL>/v3/edrs` | Consumer App, Consumer EDC & Provider EDC |
| Data Plane | `<DATAPLANE_URL>` | Consumer App & Provider EDC |

## OpenAPI
Expand Down Expand Up @@ -116,4 +116,4 @@ This work is licensed under the [CC-BY-4.0](https://creativecommons.org/licenses

- SPDX-License-Identifier: CC-BY-4.0
- SPDX-FileCopyrightText: 2023 Contributors of the Eclipse Foundation
- Source URL: [https://github.com/eclipse-tractusx/tractusx-edc](https://github.com/eclipse-tractusx/tractusx-edc)
- Source URL: [https://github.com/eclipse-tractusx/tractusx-edc](https://github.com/eclipse-tractusx/tractusx-edc)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
/*
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand All @@ -15,23 +15,15 @@
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
*/

package org.eclipse.tractusx.edc.api.bpn;

import io.swagger.v3.oas.annotations.parameters.RequestBody;
import jakarta.json.Json;
import jakarta.json.JsonObject;
import jakarta.json.JsonString;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.eclipse.edc.web.spi.exception.InvalidRequestException;
import org.eclipse.edc.web.spi.exception.ObjectConflictException;
import org.eclipse.edc.web.spi.exception.ObjectNotFoundException;
Expand All @@ -45,22 +37,15 @@
import static org.eclipse.tractusx.edc.edr.spi.CoreConstants.TX_NAMESPACE;


@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
@Path("/business-partner-groups")
public class BusinessPartnerGroupApiController implements BusinessPartnerGroupApi {
public abstract class BaseBusinessPartnerGroupApiController {

private final BusinessPartnerStore businessPartnerService;


public BusinessPartnerGroupApiController(BusinessPartnerStore businessPartnerService) {
public BaseBusinessPartnerGroupApiController(BusinessPartnerStore businessPartnerService) {
this.businessPartnerService = businessPartnerService;
}

@GET
@Path("/{bpn}")
@Override
public JsonObject resolve(@PathParam("bpn") String bpn) {
public JsonObject resolve(String bpn) {

// StoreResult does not support the .map() operator, because it does not override newInstance()
var result = businessPartnerService.resolveForBpn(bpn);
Expand All @@ -71,25 +56,18 @@ public JsonObject resolve(@PathParam("bpn") String bpn) {
throw new ObjectNotFoundException(List.class, result.getFailureDetail());
}

@DELETE
@Path("/{bpn}")
@Override
public void deleteEntry(@PathParam("bpn") String bpn) {
businessPartnerService.delete(bpn)
.orElseThrow(f -> new ObjectNotFoundException(List.class, f.getFailureDetail()));
}

@PUT
@Override
public void updateEntry(@RequestBody JsonObject object) {
var bpn = getBpn(object);
var groups = getGroups(object);
businessPartnerService.update(bpn, groups)
.orElseThrow(f -> new ObjectNotFoundException(List.class, f.getFailureDetail()));
}

@POST
@Override
public void createEntry(@RequestBody JsonObject object) {
var bpn = getBpn(object);
var groups = getGroups(object);
Expand All @@ -104,7 +82,6 @@ private JsonObject createObject(String bpn, List<String> list) {
.build();
}


private String getBpn(JsonObject object) {
try {
return object.getString(ID);
Expand Down
Loading
Loading