Skip to content

Latest commit

 

History

History

README.md

Rust API client for nativebpm-client

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>

Overview

This API client was generated by the OpenAPI Generator project. By using the openapi-spec from a remote server, you can easily generate an API client.

  • API version: 1.0.1
  • Package version: 1.0.1
  • Generator version: 7.24.0-SNAPSHOT
  • Build package: org.openapitools.codegen.languages.RustClientCodegen

Installation

Put the package under your project folder in a directory named nativebpm-client and add the following to Cargo.toml under [dependencies]:

nativebpm-client = { path = "./nativebpm-client" }

Documentation for API Endpoints

All URIs are relative to http://localhost

Class Method HTTP request Description
DefaultApi claim_task POST /api/tasks/{id}/claim Claim human task
DefaultApi complete_instance_task POST /api/instances/{id}/complete Complete a wait state / task activity in process instance
DefaultApi complete_task POST /api/tasks/{id}/complete Complete human task
DefaultApi create_webhook POST /api/webhooks Create webhook target
DefaultApi delete_webhook DELETE /api/webhooks/{id} Delete webhook target
DefaultApi deploy_definition POST /api/deploy Deploy process definition
DefaultApi get_instance GET /api/instances/{id} Get process instance
DefaultApi get_instance_history GET /api/instances/{id}/history Get process instance execution history
DefaultApi get_instance_visualization GET /api/instances/{id}/visualization Get process instance visualization data
DefaultApi get_instance_visualization_widget GET /api/instances/{id}/visualization/widget Get process instance visualization widget HTML
DefaultApi get_smtp_config GET /api/smtp-config Get SMTP configuration
DefaultApi get_user_groups GET /api/users/{username}/groups Get user groups
DefaultApi list_definitions GET /api/definitions List process definitions
DefaultApi list_incidents GET /api/instances/{id}/incidents List incidents for process instance
DefaultApi list_instances GET /api/instances List process instances
DefaultApi list_tasks GET /api/tasks List human/user tasks
DefaultApi list_webhook_deliveries GET /api/webhooks/{id}/deliveries List deliveries for webhook
DefaultApi list_webhooks GET /api/webhooks List configured outgoing webhooks
DefaultApi resolve_incident POST /api/instances/{id}/incidents/{incidentId}/resolve Resolve process incident
DefaultApi resume_instance POST /api/instances/{id}/resume Resume process instance
DefaultApi start_instance POST /api/definitions/{id}/start Start process instance
DefaultApi test_webhook POST /api/webhooks/{id}/test Test webhook target
DefaultApi update_webhook PUT /api/webhooks/{id} Update webhook target

Documentation For Models

To get access to the crate's generated documentation, use:

cargo doc --open

Fluent API & Workflow-as-Code

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

Fluent Client Configuration

use nativebpm_client::apis::configuration::Configuration;

let mut config = Configuration::new();
config.base_path = "http://localhost:8080".to_string();
config.bearer_access_token = Some("your-api-token".to_string());

Defining a Workflow (Workflow-as-Code)

use nativebpm_client::{Workflow, v};

let mut workflow = Workflow::new("my-process", "My Process");
workflow
    .when(v("isPremium").eq(true))
    .then(|b| {
        b.user("vipService", "VIP Support", serde_json::json!({ "assignee": "vip_manager" }));
    })
    .Else(|b| {
        b.service("notify", "Send Email", "email_topic", serde_json::json!({}));
    });

Deploying & Starting Workflows

use nativebpm_client::deploy_workflow;
use nativebpm_client::apis::default_api;

// Deploy
let definition = deploy_workflow(&config, &workflow).await.unwrap();

// Start process instance
let mut variables = std::collections::HashMap::new();
variables.insert("isPremium".to_string(), serde_json::json!(true));

let start_request = nativebpm_client::models::StartInstanceRequest {
    instance_id: None,
    business_key: Some("BIZ-101".to_string()),
    variables: Some(variables),
};
let instance = default_api::start_instance(&config, "my-process", Some(start_request)).await.unwrap();

Author