README optimserver-client-resttemplate 2.1


Maven users

Add this dependency to your project’s POM:


Gradle users

Add this dependency to your project’s build file:

compile "com.decisionbrain:optimserver-client-resttemplate:3.2.1-RC1"
compile "org.keycloak:keycloak-authz-client:4.6.0.Final"

Getting Started

First follow the installation instructions. Then create a spring boot application class like the following one:

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.apache.http.impl.client.HttpClients;
import org.keycloak.authorization.client.AuthzClient;
import org.keycloak.authorization.client.Configuration;
import java.util.Collections;

public class OptimserverSampleSpringClientApplication {

    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 ApiClient apiClient(@Value("${master.url}") String basePath) {
        ApiClient apiClient = new ApiClient();
            .addDefaultHeader("Authorization", "Bearer " + getToken());
        return apiClient;

    public static void main(String[] args) {, args);

    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);

Property “master.url” has to be defined in a spring properties file. Finally, the following java code is able to create a bucket, using spring beanw autowiring.


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.boot.CommandLineRunner;

public class BucketApiExampleService implements CommandLineRunner {

    private final BucketApi bucketClient;

    public BucketApiExampleService(
            BucketApi bucketClient
    ) {
        this.bucketClient = bucketClient;

    public void run(String... args) throws Exception {
        BucketCreation bucketCreation = new BucketCreation(); // BucketCreation | 
        BucketDefinition result = bucketClient.createBucket(bucketCreation);

Documentation for API Endpoints

All URIs are relative to https://dbos-master-host

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 getBucketDefinition GET /buckets/{bucketId}/definition Return a bucket definition object.
BucketApi getBuckets GET /buckets Returns requested bucket definitions.
BucketApi getBucketsContent GET /buckets/content Returns an archive containing the compressed content of requested buckets.
ConfigurationApi refreshOnDemandTasks PUT /configuration/on-demand/tasks/refresh Refresh on demand tasks
FileApi saveTemporaryFile POST /files Creates a temporary file on server side for later use.
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.

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:


  • Type: HTTP basic authentication


  • Type: HTTP basic authentication


It’s recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.