Add this dependency to your project’s POM:
<dependency>
<groupId>com.decisionbrain</groupId>
<artifactId>optimserver-client-api</artifactId>
<version>2.5.0</version>
<scope>compile</scope>
</dependency>
Add this dependency to your project’s build file:
compile "com.decisionbrain:optimserver-client-api:2.5.0"
compile "org.keycloak:keycloak-authz-client:4.6.0.Final"
Please follow the installation instruction and execute the following Java code:
import com.decisionbrain.optimserver.client.java.jersey2.*;
import com.decisionbrain.optimserver.client.java.jersey2.auth.*;
import com.decisionbrain.optimserver.client.java.jersey2.model.*;
import com.decisionbrain.optimserver.client.java.jersey2.api.BucketApi;
import java.io.File;
import java.util.*;
import org.apache.http.impl.client.HttpClients;
import org.keycloak.authorization.client.AuthzClient;
import org.keycloak.authorization.client.Configuration;
public class BucketApiExample {
private static final String API_URL = "https://OPTIMSERVER/";
private static final String KEYCLOAK_URL = "https://OPTIMSERVER_AUTHENTICATION/auth";
private static final String KEYCLOAK_REALM = "decisionbrain";
private static final String KEYCLOAK_CLIENT = "optimserver";
private static final String KEYCLOAK_USER = "optimserver";
private static final String KEYCLOAK_PASSWORD = "optimserver";
public static void main(String[] args) {
ApiClient apiClient = new ApiClient()
.setBasePath(API_URL)
.addDefaultHeader("Authorization", "Bearer " + getToken());
BucketApi apiInstance = new BucketApi(apiClient);
BucketCreation bucketCreation = new BucketCreation(); // BucketCreation |
try {
BucketDefinition result = apiInstance.createBucket(bucketCreation);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling BucketApi#createBucket");
e.printStackTrace();
}
}
private static String getToken() {
final Configuration configuration = new Configuration(KEYCLOAK_URL, KEYCLOAK_REALM, KEYCLOAK_CLIENT, Collections.singletonMap("secret", ""), HttpClients.createDefault());
try {
return AuthzClient.create(configuration).obtainAccessToken(KEYCLOAK_USER, KEYCLOAK_PASSWORD).getToken();
} catch (Exception e) {
throw new IllegalArgumentException("Token can't be obtained", e);
}
}
}
All URIs are relative to https://dbos
Class | Method | HTTP request | Description |
---|---|---|---|
BucketApi | createBucket | POST /buckets | Creates a new Bucket, and returns its ID for later use. |
BucketApi | deleteBucket | DELETE /buckets/{bucketId} | Deletes this bucket. |
BucketApi | getBucket | GET /buckets/{bucketId} | Return a bucket object. |
BucketApi | getBucketContent | GET /buckets/{bucketId}/content | Returns the content of the requested bucket. |
BucketApi | getBuckets | GET /buckets | Returns requested bucket definitions. |
BucketApi | getBucketsContent | GET /buckets/content | Returns an archive containing the compressed content of requested buckets. |
FlowApi | createFlow | POST /jobFlows | Creates a new Flow, and returns its ID for later use. |
FlowApi | getJobDefinitionsByFlow | GET /jobFlows/{flowId}/jobs | Returns job definitions for the given flow ID. |
FlowApi | getJobFlow | GET /jobFlows/{flowId} | Returns a Flow with the given ID, if any. |
FlowApi | getJobFlows | GET /jobFlows | Returns all known flows. |
JobApi | createJob | POST /jobs | Creates a new asyncron Job (without starting it), and returns its ID for later use. |
JobApi | deleteJob | DELETE /jobs/{jobId} | Deletes this job and cleans all related data. |
JobApi | getJobDefinition | GET /jobs/{jobId} | Returns a job definition. |
JobApi | getJobs | GET /jobs | Returns all current job definitions. |
JobExecutionApi | getJobExecutionStatus | GET /jobs/{jobId}/execution | Gets the job execution status. |
JobExecutionApi | startAsyncJobExecution | POST /jobs/{jobId}/execution | Schedule an already created job for an asyncronous execution. |
JobExecutionApi | startSyncJobExecution | POST /jobs/execution | Schedule a syncron job execution. |
JobExecutionApi | stopJobExecution | DELETE /jobs/{jobId}/execution | Request this job to stop its execution. |
ProjectInformationApi | getProject | GET /project | Gets the project information. |
TaskApi | getTask | GET /tasks/{taskId} | Get a specific task details. |
TaskApi | getTasks | GET /tasks | Get all known tasks. |
TaskExecutionApi | getTaskExecution | GET /tasks/{taskId}/execution | Gets all the jobs execution status for this task. |
Authentication schemes defined for the API:
It’s recommended to create an instance of ApiClient
per thread in a multithreaded environment to avoid any potential issues.
optim-server@decisionbrain.com