Prepare the Call to the HTTPs Endpoint
-
To use the Java client, you must add the following runtime dependencies.
For Gradle:
// Runtime dependencies runtimeOnly 'com.fasterxml.jackson.core:jackson-databind:2.13.2.2' runtimeOnly 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.2' runtimeOnly 'org.openapitools:jackson-databind-nullable:0.2.2' runtimeonly 'com.exalead.apollo:data-factory-client-apache:sgi-v3.4' runtimeonly 'com.fasterxml.jackson.core:jackson-core:2.13.4' runtimeonly 'com.fasterxml.jackson.core:jackson-annotations:2.13.4' runtimeonly 'org.apache.httpcomponents:httpclient:4.5.13' runtimeonly 'org.apache.httpcomponents:httpcore:4.4.16' runtimeonly 'commons-logging:commons-logging:1.2'For Maven:
<dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.13.2.2</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-jsr310</artifactId> <version>2.13.2</version> </dependency> <dependency> <groupId>org.openapitools</groupId> <artifactId>jackson-databind-nullable</artifactId> <version>0.2.2</version> </dependency> <dependency> <groupId>com.exalead.apollo</groupId> <artifactId>data-factory-client-apache</artifactId> <version>sgi-v3.4</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.13.4</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>2.13.4</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.5.13</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> <version>4.4.16</version> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.2</version> </dependency> -
Initialize the Java client as shown in the following code sample:
package org.example; import com.ds.apollo.dfs.client.apache.generated.invoke.ApiClient; import com.ds.apollo.dfs.client.apache.generated.invoke.ServerConfiguration; import org.apache.http.impl.client.HttpClientBuilder; import java.nio.charset.StandardCharsets; import java.util.Base64; import java.util.List; import java.util.Map; public class DataFactoryClient { private static final String url = "https://devopsf4xzesw2613048-euw1-devprol36-sgi.3dx-staging.3ds.com/data-factory/resources/v1:443"; // CLM Credentials private static final String cmlAgentID = "7cd3a65c-ada3-4729-a6d4-6bd6b918927a"; private static final String cmlAgentPassword = "D(~VD<L\\z->(g;awr5vJmc0@"; public static ApiClient build() { ApiClient apiClient = new ApiClient(); apiClient.setServers(List.of( new ServerConfiguration(url, "Data Factory endpoint", Map.of()) )); apiClient.setServerIndex(0); apiClient.addDefaultHeader("Authorization", "Basic " + Base64.getEncoder().encodeToString((cmlAgentID + ":" + cmlAgentPassword) .getBytes(StandardCharsets.UTF_8))); apiClient.setHttpClient(HttpClientBuilder .create() .addInterceptorLast(new HttpResponseInterceptor() { @Override public void process(HttpResponse response, HttpContext context) throws HttpException, IOException { if (500 <= response.getStatusLine().getStatusCode() && response.getStatusLine().getStatusCode() < 600) { throw new IOException("HTTP 5XX error code, will be retried"); } } }) .setRetryHandler(new DefaultHttpRequestRetryHandler(3, true)) .build()); return apiClient; } } public class Example { // Then access API for example : var apiClient = DataFactoryClient.build(); StorageApi storageApi = new StorageApi(apiClient); PipelineApi pipelineApi = new PipelineApi(apiClient); }In the first lines, define the host, the CLM agent ID, and the CLM Agent password. You then create the client node of the API.