Skip to content

Think-iT-Labs/edc-connector-client-java

Repository files navigation

EDC Connector Client - Java 👩‍🚀 ☕

A HTTP client to communicate with the EDC Connector for Java.

Tests status

Built with ❤️ at Think-it.

Description

The EDC Connector Client library for Java is a simple, easy and with minimum dependencies amount library to interact with EDC Connector Management API

Features:

  • JSON-LD expansion/compaction processes done under the hood of the class model.
  • Straightforward error handling.
  • Configurable http interceptors to customize the calls made to the connector.

Requirements

  • Java 17 or higher

Installation

The library is published on maven central Choose the latest version and add it as a dependency in your favorite build automation tool.

Usage

Everything evolves around the EdcConnectorClient that can be instantiated through the Builder:

var client = EdcConnectorClient.newBuilder()
    .managementUrl("http://your.connector/management/api")
    .build();

From that client object the context specific endpoint services can be obtained:

  • assets()
  • policyDefinitions()
  • contractDefinitions()
  • contractNegotiations()
  • contractAgreements()
  • transferProcesses()
  • dataplanes()
  • applicationObservability()
  • catalogs()

Extending the client

The client provides a way to be extended to permit to cover additional APIs that could be added by extension on your EDC runtime.

An extension can be implemented by extending the io.thinkit.edc.client.connector.resource.EdcResource class, e.g:

private static class ExtensionResource extends EdcResource {

    protected ExtensionResource(EdcClientContext context) {
        super(context);
    }

    public String doStuff() {
        // here you can call your endpoint by using the HTTP client and other components available in the `context` object
        return context.httpClient().send(requestBuilder()).map(JsonLdUtil::expand).map(body -> extractDataFrom(body));
    }
}

To make the extension available in the client it can be added on the builder using the with method:

var client = EdcConnectorClient.newBuilder()
        .with(ExtensionResource.class, ExtensionResource::new)
        .build();

and it can be obtained from the client using the resource method:

var extension = client.resource(ExtensionResource.class);

var result = extension.doStuff();

Contributing

Contributions to this library are always welcome and highly encouraged

See CONTRIBUTING documentation for more information on how to get started.

License

Copyright 2022-2024 Think.iT GmbH.

Licensed under the Apache License, Version 2.0. Files in the project may not be copied, modified, or distributed except according to those terms.