Java API Client Library to be imported and used in arbitrary applications like use-case backends.
An example project using this client can be found here.
Installation
<!-- Requires the GitHub Maven Registry --><dependency> <groupId>de.sovity.edc</groupId> <artifactId>client</artifactId> <version>${sovity-edc-ce.version}</version></dependency>
Usage
Example Consuming and Providing a Data Offer
A full example providing and consuming a data offer using the API Wrapper Client Library can be found in ApiWrapperDemoTest.java.
Example Using API Key Auth
importde.sovity.edc.client.EdcClient;importde.sovity.edc.client.gen.model.KpiResult;/** * Example using a sovity Community Edition EDC Connector */publicclassWrapperClientExample {publicstaticfinalString MANAGEMENT_API_URL ="http://localhost:11002/api/management";publicstaticfinalString MANAGEMENT_API_KEY ="...";publicstaticvoidmain(String[] args) {// Configure ClientEdcClient client =EdcClient.builder().managementApiUrl(MANAGEMENT_API_URL).managementApiKey(MANAGEMENT_API_KEY).build();// EDC API Wrapper APIs are now available for useKpiResult kpiResult =client.useCaseApi().getKpis();System.out.println(kpiResult); }}
Example Using OAuth2 Client Credentials
importde.sovity.edc.client.EdcClient;importde.sovity.edc.client.gen.model.KpiResult;importde.sovity.edc.client.oauth2.Oauth2ClientCredentials;importde.sovity.edc.client.oauth2.SovityKeycloakUrl;/** * Example using a productive Connector-as-a-Service (CaaS) EDC Connector */publicclassWrapperClientExample {publicstaticfinalString MANAGEMENT_API_URL ="https://{{your-connector}}.prod-sovity.azure.sovity.io/control/api/management";publicstaticfinalString CLIENT_ID ="{{your-connector}}-app";publicstaticfinalString CLIENT_SECRET ="...";publicstaticvoidmain(String[] args) {// Configure ClientEdcClient client =EdcClient.builder().managementApiUrl(MANAGEMENT_API_URL).oauth2ClientCredentials(OAuth2ClientCredentials.builder().tokenUrl(SovityKeycloakUrl.PRODUCTION).clientId(CLIENT_ID).clientSecret(CLIENT_SECRET).build()).build();// EDC API Wrapper APIs are now available for useKpiResult kpiResult =client.useCaseApi().getKpis();System.out.println(kpiResult); }}
Further Examples
Below are the examples of various tasks and the corresponding methods to be used from the Java-client.
These methods facilitate various operations such as creating policies, assets, contract definitions, browsing offers, accepting contracts, and initiating data transfers.
Example Creating a Catena-Policy using operators (AND/OR/XONE)
The following example demonstrates how to create a Catena-Policy with linked conditions using the Java-client.