Skip to content

Latest commit

 

History

History

README.md

nativebpm-java-client

NativeBPM Engine REST API

  • API version: 1.0.1
    • Generator version: 7.24.0-SNAPSHOT

REST API for managing, executing, and monitoring workflows, human tasks, incidents, and outgoing webhooks inside the NativeBPM Cloud-Native engine.

Authentication

Requests must include a session cookie or a Bearer API token: Authorization: Bearer <API_TOKEN>

Automatically generated by the OpenAPI Generator

Requirements

Building the API client library requires:

  1. Java 1.8+
  2. Maven (3.8.3+)/Gradle (7.2+)

Installation

To install the API client library to your local Maven repository, simply execute:

mvn clean install

To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:

mvn clean deploy

Refer to the OSSRH Guide for more information.

Maven users

Add this dependency to your project's POM:

<dependency>
  <groupId>com.nativebpm</groupId>
  <artifactId>nativebpm-java-client</artifactId>
  <version>1.0.0</version>
  <scope>compile</scope>
</dependency>

Gradle users

Add this dependency to your project's build file:

  repositories {
    mavenCentral()     // Needed if the 'nativebpm-java-client' jar has been published to maven central.
    mavenLocal()       // Needed if the 'nativebpm-java-client' jar has been published to the local maven repo.
  }

  dependencies {
     implementation "com.nativebpm:nativebpm-java-client:1.0.0"
  }

Others

At first generate the JAR by executing:

mvn clean package

Then manually install the following JARs:

  • target/nativebpm-java-client-1.0.0.jar
  • target/lib/*.jar

Getting Started

Please follow the installation instruction and execute the following Java code:

// Import classes:
import com.nativebpm.client.ApiClient;
import com.nativebpm.client.ApiException;
import com.nativebpm.client.Configuration;
import com.nativebpm.client.model.*;
import com.nativebpm.client.api.DefaultApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("http://localhost");

    DefaultApi apiInstance = new DefaultApi(defaultClient);
    String id = "id_example"; // String | 
    ClaimTaskRequest claimTaskRequest = new ClaimTaskRequest(); // ClaimTaskRequest | 
    try {
      TaskRecord result = apiInstance.claimTask(id, claimTaskRequest);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DefaultApi#claimTask");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Documentation for API Endpoints

All URIs are relative to http://localhost

Class Method HTTP request Description
DefaultApi claimTask POST /api/tasks/{id}/claim Claim human task
DefaultApi completeInstanceTask POST /api/instances/{id}/complete Complete a wait state / task activity in process instance
DefaultApi completeTask POST /api/tasks/{id}/complete Complete human task
DefaultApi createWebhook POST /api/webhooks Create webhook target
DefaultApi deleteWebhook DELETE /api/webhooks/{id} Delete webhook target
DefaultApi deployDefinition POST /api/deploy Deploy process definition
DefaultApi getInstance GET /api/instances/{id} Get process instance
DefaultApi getInstanceHistory GET /api/instances/{id}/history Get process instance execution history
DefaultApi getInstanceVisualization GET /api/instances/{id}/visualization Get process instance visualization data
DefaultApi getInstanceVisualizationWidget GET /api/instances/{id}/visualization/widget Get process instance visualization widget HTML
DefaultApi getSMTPConfig GET /api/smtp-config Get SMTP configuration
DefaultApi getUserGroups GET /api/users/{username}/groups Get user groups
DefaultApi listDefinitions GET /api/definitions List process definitions
DefaultApi listIncidents GET /api/instances/{id}/incidents List incidents for process instance
DefaultApi listInstances GET /api/instances List process instances
DefaultApi listTasks GET /api/tasks List human/user tasks
DefaultApi listWebhookDeliveries GET /api/webhooks/{id}/deliveries List deliveries for webhook
DefaultApi listWebhooks GET /api/webhooks List configured outgoing webhooks
DefaultApi resolveIncident POST /api/instances/{id}/incidents/{incidentId}/resolve Resolve process incident
DefaultApi resumeInstance POST /api/instances/{id}/resume Resume process instance
DefaultApi startInstance POST /api/definitions/{id}/start Start process instance
DefaultApi testWebhook POST /api/webhooks/{id}/test Test webhook target
DefaultApi updateWebhook PUT /api/webhooks/{id} Update webhook target

Documentation for Models

Documentation for Authorization

Endpoints do not require authorization.

Recommendation

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

Fluent API & Workflow-as-Code

The SDK provides a high-level Fluent Client API and a type-safe Workflow-as-Code builder.

Fluent Client Initialization

import com.nativebpm.client.ApiClient;
import com.nativebpm.client.Configuration;
import com.nativebpm.client.api.DefaultApi;

ApiClient client = Configuration.getDefaultApiClient();
client.setBasePath("http://localhost:8080");
client.addDefaultHeader("Authorization", "Bearer your-api-token");

DefaultApi apiInstance = new DefaultApi(client);

Defining a Workflow (Workflow-as-Code)

import com.nativebpm.client.builder.Workflow;
import static com.nativebpm.client.builder.Workflow.V;

Workflow workflow = new Workflow("my-process", "My Process");
workflow
    .when(V("isPremium").eq(true)).then(b -> {
        b.user("vipService", "VIP Support", ut -> {
            ut.assignee("vip_manager");
        });
    })
    .Else(b -> {
        b.service("notify", "Send Email", "email_topic");
    });

Deploying & Starting Workflows

import com.nativebpm.client.model.ProcessDefinition;
import com.nativebpm.client.model.ProcessInstance;
import com.nativebpm.client.model.StartInstanceRequest;

// Deploy (by sending serialized workflow JSON)
String workflowJson = workflow.toJson();
// Use apiInstance.deployDefinition(...)

Author