Interacting with Red Hat Decision Manager using KIE APIs
Abstract
Preface Copy linkLink copied to clipboard!
As a business rules developer or systems administrator, you can use KIE APIs to interact with Decision Servers, KIE containers, and business assets in Red Hat Decision Manager. You can use the Decision Server REST API and Java client API to interact with KIE containers and business assets (such as business rules, processes, and solvers), the Decision Manager controller REST API and Java client API to interact with Decision Server templates and instances, and the Knowledge Store REST API to interact with spaces and projects in Business Central.
The lists of REST API endpoints for Decision Server and the Decision Manager controller are published separately from this document and maintained dynamically to ensure that endpoint options and data are as current as possible. Use this document to understand what the Decision Server and Decision Manager controller REST APIs enable you to do and how to use them, and use the separately maintained lists of REST API endpoints for specific endpoint details.
For the full list of Decision Server REST API endpoints and descriptions, use one of the following resources:
- Execution Server REST API on the jBPM Documentation page (static)
-
Swagger UI for the Decision Server REST API at
http://SERVER:PORT/kie-server/docs(dynamic, requires running Decision Server)
For the full list of Decision Manager controller REST API endpoints and descriptions, use one of the following resources:
- Controller REST API on the jBPM Documentation page (static)
-
Swagger UI for the Decision Manager controller REST API at
http://SERVER:PORT/CONTROLLER/docs(dynamic, requires running Decision Manager controller)
Prerequisites
- Red Hat Decision Manager is installed and running. For installation and startup options, see Planning a Red Hat Decision Manager installation.
You have access to Red Hat Decision Manager with the following user roles:
-
kie-server: For access to Decision Server API capabilities, and access to headless Decision Manager controller API capabilities without Business Central (if applicable) -
rest-all: For access to Business Central API capabilities for the built-in Decision Manager controller and for the Business Central Knowledge Store admin: For full administrative access to Red Hat Decision ManagerAlthough these user roles are not all required for every KIE API, consider acquiring all of them to ensure that you can access any KIE API without disruption. For more information about user roles, see Planning a Red Hat Decision Manager installation.
-
Chapter 1. Decision Server REST API for KIE containers and business assets Copy linkLink copied to clipboard!
Red Hat Decision Manager provides a Decision Server REST API that you can use to interact with your KIE containers and business assets (such as business rules, processes, and solvers) in Red Hat Decision Manager without using the Business Central user interface. This API support enables you to maintain your Red Hat Decision Manager resources more efficiently and optimize your integration and development with Red Hat Decision Manager.
With the Decision Server REST API, you can perform the following actions:
- Deploy or dispose KIE containers
- Retrieve and update KIE container information
- Return Decision Server status and basic information
- Retrieve and update business asset information
- Execute business assets (such as rules and processes)
Decision Server REST API requests require the following components:
- Authentication
The Decision Server REST API requires HTTP Basic authentication or token-based authentication for the user role
kie-server. To view configured user roles for your Red Hat Decision Manager distribution, navigate to~/$SERVER_HOME/standalone/configuration/application-roles.propertiesand~/application-users.properties.To add a user with the
kie-serverrole, navigate to~/$SERVER_HOME/binand run the following command:./add-user.sh -a --user <USERNAME> --password <PASSWORD> --role kie-server
$ ./add-user.sh -a --user <USERNAME> --password <PASSWORD> --role kie-serverCopy to Clipboard Copied! Toggle word wrap Toggle overflow For more information about user roles and Red Hat Decision Manager installation options, see Planning a Red Hat Decision Manager installation.
- HTTP headers
The Decision Server REST API requires the following HTTP headers for API requests:
Accept: Data format accepted by your requesting client:-
application/json(JSON) -
application/xml(XML, for JAXB or XSTREAM)
-
Content-Type: Data format of yourPOSTorPUTAPI request data:-
application/json(JSON) -
application/xml(XML, for JAXB or XSTREAM)
-
X-KIE-ContentType: Required header forapplication/xmlXSTREAM API requests and responses:-
XSTREAM
-
- HTTP methods
The Decision Server REST API supports the following HTTP methods for API requests:
-
GET: Retrieves specified information from a specified resource endpoint -
POST: Updates a resource or resource instance -
PUT: Updates or creates a resource or resource instance -
DELETE: Deletes a resource or resource instance
-
- Base URL
-
The base URL for Decision Server REST API requests is
http://SERVER:PORT/kie-server/services/rest/, such ashttp://localhost:8080/kie-server/services/rest/. - Endpoints
Decision Server REST API endpoints, such as
/server/containers/{containerId}for a specified KIE container, are the URIs that you append to the Decision Server REST API base URL to access the corresponding resource or type of resource in Red Hat Decision Manager.Example request URL for
/server/containers/{containerId}endpointhttp://localhost:8080/kie-server/services/rest/server/containers/MyContainer- Request parameters and request data
Many Decision Server REST API requests require specific parameters in the request URL path to identify or filter specific resources and to perform specific actions. You can append URL parameters to the endpoint in the format
?<PARAM>=<VALUE>&<PARAM>=<VALUE>.Example GET request URL with parameters
http://localhost:8080/kie-server/services/rest/server/containers?groupId=com.redhat&artifactId=Project1&version=1.0&status=STARTEDHTTP
POSTandPUTrequests may additionally require a request body or file with data to accompany the request.Example POST request URL and JSON request body data
http://localhost:8080/kie-server/services/rest/server/containers/MyContainer/release-idCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.1. Sending requests with the Decision Server REST API using a REST client or curl utility Copy linkLink copied to clipboard!
The Decision Server REST API enables you to interact with your KIE containers and business assets (such as business rules, processes, and solvers) in Red Hat Decision Manager without using the Business Central user interface. You can send Decision Server REST API requests using any REST client or curl utility.
Prerequisites
- Decision Server is installed and running.
-
You have
kie-serveruser role access to Decision Server.
Procedure
-
Identify the relevant API endpoint to which you want to send a request, such as
[GET] /server/containersto retrieve KIE containers from Decision Server. In a REST client or curl utility, enter the following components for a
GETrequest to/server/containers. Adjust any request details according to your use case.For REST client:
-
Authentication: Enter the user name and password of the Decision Server user with the
kie-serverrole. HTTP Headers: Set the following header:
-
Accept:application/json
-
-
HTTP method: Set to
GET. -
URL: Enter the Decision Server REST API base URL and endpoint, such as
http://localhost:8080/kie-server/services/rest/server/containers.
For curl utility:
-
-u: Enter the user name and password of the Decision Server user with thekie-serverrole. -H: Set the following header:-
Accept:application/json
-
-
-X: Set toGET. -
URL: Enter the Decision Server REST API base URL and endpoint, such as
http://localhost:8080/kie-server/services/rest/server/containers.
curl -u 'baAdmin:password@1' -H "Accept: application/json" -X GET "http://localhost:8080/kie-server/services/rest/server/containers"
curl -u 'baAdmin:password@1' -H "Accept: application/json" -X GET "http://localhost:8080/kie-server/services/rest/server/containers"Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Authentication: Enter the user name and password of the Decision Server user with the
Execute the request and review the Decision Server response.
Example server response (JSON):
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
For this example, copy or note the project
group-id,artifact-id, andversion(GAV) data from one of the deployed KIE containers returned in the response. In your REST client or curl utility, send another API request with the following components for a
PUTrequest to/server/containers/{containerId}to deploy a new KIE container with the copied project GAV data. Adjust any request details according to your use case.For REST client:
-
Authentication: Enter the user name and password of the Decision Server user with the
kie-serverrole. HTTP Headers: Set the following headers:
-
Accept:application/json -
Content-Type:application/json
-
-
HTTP method: Set to
PUT. -
URL: Enter the Decision Server REST API base URL and endpoint, such as
http://localhost:8080/kie-server/services/rest/server/containers/MyContainer. - Request body: Add a JSON request body with the configuration items for the new KIE container:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For curl utility:
-
-u: Enter the user name and password of the Decision Server user with thekie-serverrole. -H: Set the following headers:-
Accept:application/json -
Content-Type:application/json
-
-
-X: Set toPUT. -
URL: Enter the Decision Server REST API base URL and endpoint, such as
http://localhost:8080/kie-server/services/rest/server/containers/MyContainer. -
-d: Add a JSON request body or file (@file.json) with the configuration items for the new KIE container:
curl -u 'baAdmin:password@1' -H "Accept: application/json" -H "Content-Type: application/json" -X PUT "http://localhost:8080/kie-server/services/rest/server/containers/MyContainer" -d "{ \"config-items\": [ { \"itemName\": \"RuntimeStrategy\", \"itemValue\": \"SINGLETON\", \"itemType\": \"java.lang.String\" }, { \"itemName\": \"MergeMode\", \"itemValue\": \"MERGE_COLLECTIONS\", \"itemType\": \"java.lang.String\" }, { \"itemName\": \"KBase\", \"itemValue\": \"\", \"itemType\": \"java.lang.String\" }, { \"itemName\": \"KSession\", \"itemValue\": \"\", \"itemType\": \"java.lang.String\" } ], \"release-id\": { \"group-id\": \"itorders\", \"artifact-id\": \"itorders\", \"version\": \"1.0.0-SNAPSHOT\" }, \"scanner\": { \"poll-interval\": \"5000\", \"status\": \"STARTED\" }}"curl -u 'baAdmin:password@1' -H "Accept: application/json" -H "Content-Type: application/json" -X PUT "http://localhost:8080/kie-server/services/rest/server/containers/MyContainer" -d "{ \"config-items\": [ { \"itemName\": \"RuntimeStrategy\", \"itemValue\": \"SINGLETON\", \"itemType\": \"java.lang.String\" }, { \"itemName\": \"MergeMode\", \"itemValue\": \"MERGE_COLLECTIONS\", \"itemType\": \"java.lang.String\" }, { \"itemName\": \"KBase\", \"itemValue\": \"\", \"itemType\": \"java.lang.String\" }, { \"itemName\": \"KSession\", \"itemValue\": \"\", \"itemType\": \"java.lang.String\" } ], \"release-id\": { \"group-id\": \"itorders\", \"artifact-id\": \"itorders\", \"version\": \"1.0.0-SNAPSHOT\" }, \"scanner\": { \"poll-interval\": \"5000\", \"status\": \"STARTED\" }}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow curl -u 'baAdmin:password@1' -H "Accept: application/json" -H "Content-Type: application/json" -X PUT "http://localhost:8080/kie-server/services/rest/server/containers/MyContainer" -d @my-container-configs.json
curl -u 'baAdmin:password@1' -H "Accept: application/json" -H "Content-Type: application/json" -X PUT "http://localhost:8080/kie-server/services/rest/server/containers/MyContainer" -d @my-container-configs.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Authentication: Enter the user name and password of the Decision Server user with the
Execute the request and review the Decision Server response.
Example server response (JSON):
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you encounter request errors, review the returned error code messages and adjust your request accordingly.
1.2. Sending requests with the Decision Server REST API using the Swagger interface Copy linkLink copied to clipboard!
The Decision Server REST API supports a Swagger web interface that you can use instead of a standalone REST client or curl utility to interact with your KIE containers and business assets (such as business rules, processes, and solvers) in Red Hat Decision Manager without using the Business Central user interface.
By default, the Swagger web interface for Decision Server is enabled by the org.kie.swagger.server.ext.disabled=false system property. To disable the Swagger web interface in Decision Server, set this system property to true.
Prerequisites
- Decision Server is installed and running.
-
You have
kie-serveruser role access to Decision Server.
Procedure
-
In a web browser, navigate to
http://SERVER:PORT/kie-server/docs, such ashttp://localhost:8080/kie-server/docs, and log in with the user name and password of the Decision Server user with thekie-serverrole. - In the Swagger page, select the relevant API endpoint to which you want to send a request, such as KIE Server and KIE containers → [GET] /server/containers to retrieve KIE containers from Decision Server.
- Click Try it out and provide any optional parameters by which you want to filter results, if needed.
- In the Response content type drop-down menu, select the desired format of the server response, such as application/json for JSON format.
Click Execute and review the Decision Server response.
Example server response (JSON):
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
For this example, copy or note the project
group-id,artifact-id, andversion(GAV) data from one of the deployed KIE containers returned in the response. - In the Swagger page, navigate to the KIE Server and KIE containers → [PUT] /server/containers/{containerId} endpoint to send another request to deploy a new KIE container with the copied project GAV data. Adjust any request details according to your use case.
Click Try it out and enter the following components for the request:
-
containerId: Enter the ID of the new KIE container, such as
MyContainer. - body: Set the Parameter content type to the desired request body format, such as application/json for JSON format, and add a request body with the configuration items for the new KIE container:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
containerId: Enter the ID of the new KIE container, such as
- In the Response content type drop-down menu, select the desired format of the server response, such as application/json for JSON format.
Click Execute and review the Decision Server response.
Example server response (JSON):
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you encounter request errors, review the returned error code messages and adjust your request accordingly.
1.3. Supported Decision Server REST API endpoints Copy linkLink copied to clipboard!
The Decision Server REST API provides endpoints for the following types of resources in Red Hat Decision Manager:
- Decision Server and KIE containers
- KIE session assets (for runtime commands)
- DMN assets
- Planning solvers
The Decision Server REST API base URL is http://SERVER:PORT/kie-server/services/rest/. All requests require HTTP Basic authentication or token-based authentication for the kie-server user role.
For the full list of Decision Server REST API endpoints and descriptions, use one of the following resources:
- Execution Server REST API on the jBPM Documentation page (static)
Swagger UI for the Decision Server REST API at
http://SERVER:PORT/kie-server/docs(dynamic, requires running Decision Server)NoteBy default, the Swagger web interface for Decision Server is enabled by the
org.kie.swagger.server.ext.disabled=falsesystem property. To disable the Swagger web interface in Decision Server, set this system property totrue.
Chapter 2. Decision Server Java client API for KIE containers and business assets Copy linkLink copied to clipboard!
Red Hat Decision Manager provides a Decision Server Java client API that enables you to connect to Decision Server using REST protocol from your Java client application. You can use the Decision Server Java client API as an alternative to the Decision Server REST API to interact with your KIE containers and business assets (such as business rules, processes, and solvers) in Red Hat Decision Manager without using the Business Central user interface. This API support enables you to maintain your Red Hat Decision Manager resources more efficiently and optimize your integration and development with Red Hat Decision Manager.
With the Decision Server Java client API, you can perform the following actions also supported by the Decision Server REST API:
- Deploy or dispose KIE containers
- Retrieve and update KIE container information
- Return Decision Server status and basic information
- Retrieve and update business asset information
- Execute business assets (such as rules and processes)
Decision Server Java client API requests require the following components:
- Authentication
The Decision Server Java client API requires HTTP Basic authentication for the user role
kie-server. To view configured user roles for your Red Hat Decision Manager distribution, navigate to~/$SERVER_HOME/standalone/configuration/application-roles.propertiesand~/application-users.properties.To add a user with the
kie-serverrole, navigate to~/$SERVER_HOME/binand run the following command:./add-user.sh -a --user <USERNAME> --password <PASSWORD> --role kie-server
$ ./add-user.sh -a --user <USERNAME> --password <PASSWORD> --role kie-serverCopy to Clipboard Copied! Toggle word wrap Toggle overflow For more information about user roles and Red Hat Decision Manager installation options, see Planning a Red Hat Decision Manager installation.
- Project dependencies
The Decision Server Java client API requires the following dependencies on the relevant classpath of your Java project:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
<version>for Red Hat Decision Manager dependencies is the Maven artifact version for Red Hat Decision Manager currently used in your project (for example, 7.23.0.Final-redhat-00002).NoteInstead of specifying a Red Hat Decision Manager
<version>for individual dependencies, consider adding the Red Hat Business Automation bill of materials (BOM) dependency to your projectpom.xmlfile. The Red Hat Business Automation BOM applies to both Red Hat Decision Manager and Red Hat Process Automation Manager. When you add the BOM files, the correct versions of transitive dependencies from the provided Maven repositories are included in the project.Example BOM dependency:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For more information about the Red Hat Business Automation BOM, see What is the mapping between RHDM product and maven library version?.
- Client request configuration
All Java client requests with the Decision Server Java client API must define at least the following server communication components:
-
Credentials of the
kie-serveruser -
Decision Server location, such as
http://localhost:8080/kie-server/services/rest/server - Marshalling format for API requests and responses (JSON, JAXB, or XSTREAM)
-
A
KieServicesConfigurationobject and aKieServicesClientobject, which serve as the entry point for starting the server communication using the Java client API -
A
KieServicesFactoryobject defining REST protocol and user access -
Any other client services used, such as
RuleServicesClient,ProcessServicesClient, orQueryServicesClient
The following are examples of basic and advanced client configurations with these components:
Basic client configuration example
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Advanced client configuration example with additional client services
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Credentials of the
2.1. Sending requests with the Decision Server Java client API Copy linkLink copied to clipboard!
The Decision Server Java client API enables you to connect to Decision Server using REST protocol from your Java client application. You can use the Decision Server Java client API as an alternative to the Decision Server REST API to interact with your KIE containers and business assets (such as business rules, processes, and solvers) in Red Hat Decision Manager without using the Business Central user interface.
Prerequisites
- Decision Server is installed and running.
-
You have
kie-serveruser role access to Decision Server. - You have a Java project with Red Hat Decision Manager resources.
Procedure
In your client application, ensure that the following dependencies have been added to the relevant classpath of your Java project:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Download the Red Hat Decision Manager 7.4.0 Source Distribution from the Red Hat Customer Portal and navigate to
~/rhdm-7.4.0-sources/src/droolsjbpm-integration-$VERSION/kie-server-parent/kie-server-remote/kie-server-client/src/main/java/org/kie/server/clientto access the Decision Server Java clients. -
In the
~/kie/server/clientfolder , identify the relevant Java client for the request you want to send, such asKieServicesClientto access client services for KIE containers and other assets in Decision Server. In your client application, create a
.javaclass for the API request. The class must contain the necessary imports, Decision Server location and user credentials, aKieServicesClientobject, and the client method to execute, such ascreateContaineranddisposeContainerfrom theKieServicesClientclient. Adjust any configuration details according to your use case.Creating and disposing a container
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You define service responses using the
org.kie.server.api.model.ServiceResponse<T>object, whereTrepresents the type of returned response. TheServiceResponseobject has the following attributes:-
String message: Returns the response message -
ResponseType type: Returns eitherSUCCESSorFAILURE -
T result: Returns the requested object
In this example, when you dispose a container, the
ServiceResponsereturns aVoidresponse. When you create a container, theServiceResponsereturns aKieContainerResourceobject.NoteA conversation between a client and a specific Decision Server container in a clustered environment is secured by a unique
conversationID. TheconversationIDis transferred using theX-KIE-ConversationIdREST header. If you update the container, unset the previousconversationID. UseKieServiesClient.completeConversation()to unset theconversationIDfor Java API.-
Run the configured
.javaclass from your project directory to execute the request, and review the Decision Server response.If you enabled debug logging, Decision Server responds with a detailed response according to your configured marshalling format, such as JSON.
Example server response for a new KIE container (log):
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you encounter request errors, review the returned error code messages and adjust your Java configurations accordingly.
2.2. Supported Decision Server Java clients Copy linkLink copied to clipboard!
The following are some of the Java client services available in the org.kie.server.client package of your Red Hat Decision Manager distribution. You can use these services to interact with related resources in Decision Server similarly to the Decision Server REST API.
-
KieServicesClient: Used as the entry point for other Decision Server Java clients, and used to interact with KIE containers -
JobServicesClient: Used to schedule, cancel, re-queue, and get job requests -
RuleServicesClient: Used to send commands to the server to perform rule-related operations, such as executing rules or inserting objects into the KIE session -
SolverServicesClient: Used to perform all Red Hat Business Optimizer operations, such as getting the solver state and the best solution, or disposing a solver
The getServicesClient method provides access to any of these clients:
RuleServicesClient rulesClient = kieServicesClient.getServicesClient(RuleServicesClient.class);
RuleServicesClient rulesClient = kieServicesClient.getServicesClient(RuleServicesClient.class);
For the full list of available Decision Server Java clients, download the Red Hat Decision Manager 7.4.0 Source Distribution from the Red Hat Customer Portal and navigate to ~/rhdm-7.4.0-sources/src/droolsjbpm-integration-$VERSION/kie-server-parent/kie-server-remote/kie-server-client/src/main/java/org/kie/server/client.
2.3. Example requests with the Decision Server Java client API Copy linkLink copied to clipboard!
The following are examples of Decision Server Java client API requests for basic interactions with Decision Server. For the full list of available Decision Server Java clients, download the Red Hat Decision Manager 7.4.0 Source Distribution from the Red Hat Customer Portal and navigate to ~/rhdm-7.4.0-sources/src/droolsjbpm-integration-$VERSION/kie-server-parent/kie-server-remote/kie-server-client/src/main/java/org/kie/server/client.
- Listing Decision Server capabilities
You can use the
org.kie.server.api.model.KieServerInfoobject to identify server capabilities. TheKieServicesClientclient requires the server capability information to correctly produce service clients. You can specify the capabilities globally inKieServicesConfiguration; otherwise they are automatically retrieved from Decision Server.Example request to return Decision Server capabilities
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Listing KIE containers in Decision Server
KIE containers are represented by the
org.kie.server.api.model.KieContainerResourceobject. The list of resources is represented by theorg.kie.server.api.model.KieContainerResourceListobject.Example request to return KIE containers from Decision Server
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can optionally filter the KIE container results using an instance of the
org.kie.server.api.model.KieContainerResourceFilterclass, which is passed to theorg.kie.server.client.KieServicesClient.listContainers()method.Example request to return KIE containers by release ID and status
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Creating and disposing KIE containers in Decision Server
You can use the
createContaineranddisposeContainermethods in theKieServicesClientclient to dispose and create KIE containers. In this example, when you dispose a container, theServiceResponsereturns aVoidresponse. When you create a container, theServiceResponsereturns aKieContainerResourceobject.Example request to dispose and re-create a KIE container
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Executing runtime commands in Decision Server
Red Hat Decision Manager supports runtime commands that you can send to Decision Server for asset-related operations, such as inserting or retracting objects in a KIE session or firing all rules. The full list of supported runtime commands is located in the
org.drools.core.command.runtimepackage in your Red Hat Decision Manager instance.You can use the
org.kie.api.command.KieCommandsclass to insert commands, and useorg.kie.api.KieServices.get().getCommands()to instantiate theKieCommandsclass. If you want to add multiple commands, use theBatchExecutionCommandwrapper.Example request to insert an object and fire all rules
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteA conversation between a client and a specific Decision Server container in a clustered environment is secured by a unique
conversationID. TheconversationIDis transferred using theX-KIE-ConversationIdREST header. If you update the container, unset the previousconversationID. UseKieServiesClient.completeConversation()to unset theconversationIDfor Java API.
Chapter 3. Decision Server and KIE container commands in Red Hat Decision Manager Copy linkLink copied to clipboard!
Red Hat Decision Manager supports server commands that you can send to Decision Server for server-related or container-related operations, such as retrieving server information or creating or deleting a container. The full list of supported Decision Server configuration commands is located in the org.kie.server.api.commands package in your Red Hat Decision Manager instance.
In the Decision Server REST API, you use the org.kie.server.api.commands commands as the request body for POST requests to http://SERVER:PORT/kie-server/services/rest/server/config. For more information about using the Decision Server REST API, see Chapter 1, Decision Server REST API for KIE containers and business assets.
In the Decision Server Java client API, you use the corresponding method in the parent KieServicesClient Java client as an embedded API request in your Java application. All Decision Server commands are executed by methods provided in the Java client API, so you do not need to embed the actual Decision Server commands in your Java application. For more information about using the Decision Server Java client API, see Chapter 2, Decision Server Java client API for KIE containers and business assets.
3.1. Sample Decision Server and KIE container commands Copy linkLink copied to clipboard!
The following are sample Decision Server commands that you can use with the Decision Server REST API or Java client API for server-related or container-related operations in Decision Server:
-
GetServerInfoCommand -
GetServerStateCommand -
CreateContainerCommand -
GetContainerInfoCommand -
ListContainersCommand -
CallContainerCommand -
DisposeContainerCommand -
GetScannerInfoCommand -
UpdateScannerCommand -
UpdateReleaseIdCommand
For the full list of supported Decision Server configuration and management commands, see the org.kie.server.api.commands package in your Red Hat Decision Manager instance.
You can run Decision Server commands individually or together as a batch REST API request or batch Java API request:
Batch REST API request to create, call, and dispose a KIE container (JSON)
Batch Java API request to retrieve, dispose, and re-create a KIE container
Each command in this section includes a REST request body example (JSON) for the Decision Server REST API and an embedded method example from the KieServicesClient Java client for the Decision Server Java client API.
- GetServerInfoCommand
Returns information about the Decision Server.
Example REST request body (JSON)
{ "commands" : [ { "get-server-info" : { } } ] }{ "commands" : [ { "get-server-info" : { } } ] }Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java client method
KieServerInfo serverInfo = kieServicesClient.getServerInfo();
KieServerInfo serverInfo = kieServicesClient.getServerInfo();Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - GetServerStateCommand
Returns information about the current state and configurations of the Decision Server.
Example REST request body (JSON)
{ "commands" : [ { "get-server-state" : { } } ] }{ "commands" : [ { "get-server-state" : { } } ] }Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java client method
KieServerStateInfo serverStateInfo = kieServicesClient.getServerState();
KieServerStateInfo serverStateInfo = kieServicesClient.getServerState();Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - CreateContainerCommand
Creates a KIE container in the Decision Server.
Expand Table 3.1. Command attributes Name Description Requirement containerMap containing the
container-id,release-iddata (group ID, artifact ID, version),status, and any other components of the new KIE containerRequired
Example REST request body (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java client method
ServiceResponse<KieContainerResource> response = kieServicesClient.createContainer("command-script-container", resource);ServiceResponse<KieContainerResource> response = kieServicesClient.createContainer("command-script-container", resource);Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - GetContainerInfoCommand
Returns information about a specified KIE container in Decision Server.
Expand Table 3.2. Command attributes Name Description Requirement container-idID of the KIE container
Required
Example REST request body (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java client method
ServiceResponse<KieContainerResource> response = kieServicesClient.getContainerInfo("command-script-container");ServiceResponse<KieContainerResource> response = kieServicesClient.getContainerInfo("command-script-container");Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - ListContainersCommand
Returns a list of KIE containers that have been created in the Decision Server.
Expand Table 3.3. Command attributes Name Description Requirement kie-container-filterOptional map containing
release-id-filter,container-status-filter, and any other KIE container properties by which you want to filter resultsOptional
Example REST request body (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java client method
KieContainerResourceFilter filter = new KieContainerResourceFilter.Builder() .status(KieContainerStatus.FAILED) .build(); KieContainerResourceList containersList = kieServicesClient.listContainers(filter);KieContainerResourceFilter filter = new KieContainerResourceFilter.Builder() .status(KieContainerStatus.FAILED) .build(); KieContainerResourceList containersList = kieServicesClient.listContainers(filter);Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - CallContainerCommand
Calls a KIE container and executes one or more runtime commands. For information about Red Hat Decision Manager runtime commands, see Chapter 4, Runtime commands in Red Hat Decision Manager.
Expand Table 3.4. Command attributes Name Description Requirement container-idID of the KIE container to be called
Required
payloadOne or more commands in a
BatchExecutionCommandwrapper to be executed on the KIE containerRequired
Example REST request body (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java client method
List<Command<?>> commands = new ArrayList<Command<?>>(); BatchExecutionCommand batchExecution1 = commandsFactory.newBatchExecution(commands, "defaultKieSession"); commands.add(commandsFactory.newFireAllRules()); ServiceResponse<ExecutionResults> response1 = ruleClient.executeCommandsWithResults("command-script-container", batchExecution1);List<Command<?>> commands = new ArrayList<Command<?>>(); BatchExecutionCommand batchExecution1 = commandsFactory.newBatchExecution(commands, "defaultKieSession"); commands.add(commandsFactory.newFireAllRules()); ServiceResponse<ExecutionResults> response1 = ruleClient.executeCommandsWithResults("command-script-container", batchExecution1);Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - DisposeContainerCommand
Disposes a specified KIE container in the Decision Server.
Expand Table 3.5. Command attributes Name Description Requirement container-idID of the KIE container to be disposed
Required
Example REST request body (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java client method
ServiceResponse<Void> response = kieServicesClient.disposeContainer("command-script-container");ServiceResponse<Void> response = kieServicesClient.disposeContainer("command-script-container");Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - GetScannerInfoCommand
Returns information about the KIE scanner used for automatic updates in a specified KIE container, if applicable.
Expand Table 3.6. Command attributes Name Description Requirement container-idID of the KIE container where the KIE scanner is used
Required
Example REST request body (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java client method
ServiceResponse<KieScannerResource> response = kieServicesClient.getScannerInfo("command-script-container");ServiceResponse<KieScannerResource> response = kieServicesClient.getScannerInfo("command-script-container");Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - UpdateScannerCommand
Starts or stops a KIE scanner that controls polling for updated KIE container deployments.
NoteAvoid using a KIE scanner with business processes. Using a KIE scanner with processes can lead to unforeseen updates that can then cause errors in long-running processes when changes are not compatible with running process instances.
Expand Table 3.7. Command attributes Name Description Requirement container-idID of the KIE container where the KIE scanner is used
Required
statusStatus to be set on the KIE scanner (
STARTED,STOPPED)Required
poll-intervalPermitted polling duration in milliseconds
Required only when starting scanner
Example REST request body (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java client method
KieScannerResource scannerResource = new KieScannerResource(); scannerResource.setPollInterval(10000); scannerResource.setStatus(KieScannerStatus. STARTED); ServiceResponse<KieScannerResource> response = kieServicesClient.updateScanner("command-script-container", scannerResource);KieScannerResource scannerResource = new KieScannerResource(); scannerResource.setPollInterval(10000); scannerResource.setStatus(KieScannerStatus. STARTED); ServiceResponse<KieScannerResource> response = kieServicesClient.updateScanner("command-script-container", scannerResource);Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - UpdateReleaseIdCommand
Updates the release ID data (group ID, artifact ID, version) for a specified KIE container.
Expand Table 3.8. Command attributes Name Description Requirement container-idID of the KIE container to be updated
Required
releaseIdUpdated GAV (group ID, artifact ID, version) data to be applied to the KIE container
Required
Example REST request body (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java client method
ServiceResponse<ReleaseId> response = kieServicesClient.updateReleaseId("command-script-container", "com.redhat:Project1:1.1");ServiceResponse<ReleaseId> response = kieServicesClient.updateReleaseId("command-script-container", "com.redhat:Project1:1.1");Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 4. Runtime commands in Red Hat Decision Manager Copy linkLink copied to clipboard!
Red Hat Decision Manager supports runtime commands that you can send to Decision Server for asset-related operations, such as executing all rules or inserting or retracting objects in a KIE session. The full list of supported runtime commands is located in the org.drools.core.command.runtime package in your Red Hat Decision Manager instance.
In the Decision Server REST API, you use the global org.drools.core.command.runtime commands or the rule-specific org.drools.core.command.runtime.rule commands as the request body for POST requests to http://SERVER:PORT/kie-server/services/rest/server/containers/instances/{containerId}. For more information about using the Decision Server REST API, see Chapter 1, Decision Server REST API for KIE containers and business assets.
In the Decision Server Java client API, you can embed these commands in your Java application along with the relevant Java client. For example, for rule-related commands, you use the RuleServicesClient Java client with the embedded commands. For more information about using the Decision Server Java client API, see Chapter 2, Decision Server Java client API for KIE containers and business assets.
4.1. Sample runtime commands in Red Hat Decision Manager Copy linkLink copied to clipboard!
The following are sample runtime commands that you can use with the Decision Server REST API or Java client API for asset-related operations in Decision Server:
-
BatchExecutionCommand -
InsertObjectCommand -
RetractCommand -
ModifyCommand -
GetObjectCommand -
GetObjectsCommand -
InsertElementsCommand -
FireAllRulesCommand -
QueryCommand -
SetGlobalCommand -
GetGlobalCommand
For the full list of supported runtime commands, see the org.drools.core.command.runtime package in your Red Hat Decision Manager instance.
Each command in this section includes a REST request body example (JSON) for the Decision Server REST API and an embedded Java command example for the Decision Server Java client API. The Java examples use an object org.drools.compiler.test.Person with the fields name (String) and age (Integer).
- BatchExecutionCommand
Contains multiple commands to be executed together.
Expand Table 4.1. Command attributes Name Description Requirement commandsList of commands to be executed.
Required
lookupSets the KIE session ID on which the commands will be executed. For stateless KIE sessions, this attribute is required. For stateful KIE sessions, this attribute is optional and if not specified, the default KIE session is used.
Required for stateless KIE session, optional for stateful KIE session
NoteKIE session IDs are in the
kmodule.xmlfile of your Red Hat Decision Manager project. To view or add a KIE session ID in Business Central to use with thelookupcommand attribute, navigate to the relevant project in Business Central and go to project Settings → KIE bases → KIE sessions. If no KIE bases exist, click Add KIE base → KIE sessions to define the new KIE base and KIE sessions.Example JSON request body
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java command
InsertObjectCommand insertCommand = new InsertObjectCommand(new Person("john", 25)); FireAllRulesCommand fireCommand = new FireAllRulesCommand(); BatchExecutionCommand batch = new BatchExecutionCommandImpl(Arrays.asList(insertCommand, fireCommand), "ksession1");InsertObjectCommand insertCommand = new InsertObjectCommand(new Person("john", 25)); FireAllRulesCommand fireCommand = new FireAllRulesCommand(); BatchExecutionCommand batch = new BatchExecutionCommandImpl(Arrays.asList(insertCommand, fireCommand), "ksession1");Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - InsertObjectCommand
Inserts an object into the KIE session.
Expand Table 4.2. Command attributes Name Description Requirement objectThe object to be inserted
Required
out-identifierID of the
FactHandlecreated from the object insertion and added to the execution resultsOptional
return-objectBoolean to determine whether the object must be returned in the execution results (default:
true)Optional
entry-pointEntry point for the insertion
Optional
Example JSON request body
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java command
Command insertObjectCommand = CommandFactory.newInsert(new Person("john", 25), "john", false, null); ksession.execute(insertObjectCommand);Command insertObjectCommand = CommandFactory.newInsert(new Person("john", 25), "john", false, null); ksession.execute(insertObjectCommand);Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - RetractCommand
Retracts an object from the KIE session.
Expand Table 4.3. Command attributes Name Description Requirement fact-handleThe
FactHandleassociated with the object to be retractedRequired
Example JSON request body
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java command: Use
FactHandleFromStringRetractCommand retractCommand = new RetractCommand(); retractCommand.setFactHandleFromString("123:234:345:456:567");RetractCommand retractCommand = new RetractCommand(); retractCommand.setFactHandleFromString("123:234:345:456:567");Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java command: Use
FactHandlefrom inserted objectRetractCommand retractCommand = new RetractCommand(factHandle);
RetractCommand retractCommand = new RetractCommand(factHandle);Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - ModifyCommand
Modifies a previously inserted object in the KIE session.
Expand Table 4.4. Command attributes Name Description Requirement fact-handleThe
FactHandleassociated with the object to be modifiedRequired
settersList of setters for object modifications
Required
Example JSON request body
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java command
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - GetObjectCommand
Retrieves an object from a KIE session.
Expand Table 4.5. Command attributes Name Description Requirement fact-handleThe
FactHandleassociated with the object to be retrievedRequired
out-identifierID of the
FactHandlecreated from the object insertion and added to the execution resultsOptional
Example JSON request body
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java command
GetObjectCommand getObjectCommand = new GetObjectCommand(); getObjectCommand.setFactHandleFromString("123:234:345:456:567"); getObjectCommand.setOutIdentifier("john");GetObjectCommand getObjectCommand = new GetObjectCommand(); getObjectCommand.setFactHandleFromString("123:234:345:456:567"); getObjectCommand.setOutIdentifier("john");Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - GetObjectsCommand
Retrieves all objects from the KIE session as a collection.
Expand Table 4.6. Command attributes Name Description Requirement object-filterFilter for the objects returned from the KIE session
Optional
out-identifierIdentifier to be used in the execution results
Optional
Example JSON request body
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java command
GetObjectsCommand getObjectsCommand = new GetObjectsCommand(); getObjectsCommand.setOutIdentifier("objects");GetObjectsCommand getObjectsCommand = new GetObjectsCommand(); getObjectsCommand.setOutIdentifier("objects");Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - InsertElementsCommand
Inserts a list of objects into the KIE session.
Expand Table 4.7. Command attributes Name Description Requirement objectsThe list of objects to be inserted into the KIE session
Required
out-identifierID of the
FactHandlecreated from the object insertion and added to the execution resultsOptional
return-objectBoolean to determine whether the object must be returned in the execution results. Default value:
true.Optional
entry-pointEntry point for the insertion
Optional
Example JSON request body
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java command
List<Object> objects = new ArrayList<Object>(); objects.add(new Person("john", 25)); objects.add(new Person("sarah", 35)); Command insertElementsCommand = CommandFactory.newInsertElements(objects);List<Object> objects = new ArrayList<Object>(); objects.add(new Person("john", 25)); objects.add(new Person("sarah", 35)); Command insertElementsCommand = CommandFactory.newInsertElements(objects);Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - FireAllRulesCommand
Executes all rules in the KIE session.
Expand Table 4.8. Command attributes Name Description Requirement maxMaximum number of rules to be executed. The default is
-1and does not put any restriction on execution.Optional
out-identifierID to be used for retrieving the number of fired rules in execution results.
Optional
agenda-filterAgenda Filter to be used for rule execution.
Optional
Example JSON request body
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java command
FireAllRulesCommand fireAllRulesCommand = new FireAllRulesCommand(); fireAllRulesCommand.setMax(10); fireAllRulesCommand.setOutIdentifier("firedActivations");FireAllRulesCommand fireAllRulesCommand = new FireAllRulesCommand(); fireAllRulesCommand.setMax(10); fireAllRulesCommand.setOutIdentifier("firedActivations");Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - QueryCommand
Executes a query defined in the KIE base.
Expand Table 4.9. Command attributes Name Description Requirement nameQuery name.
Required
out-identifierID of the query results. The query results are added in the execution results with this identifier.
Optional
argumentsList of objects to be passed as a query parameter.
Optional
Example JSON request body
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java command
QueryCommand queryCommand = new QueryCommand(); queryCommand.setName("persons"); queryCommand.setOutIdentifier("persons");QueryCommand queryCommand = new QueryCommand(); queryCommand.setName("persons"); queryCommand.setOutIdentifier("persons");Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - SetGlobalCommand
Sets an object to a global state.
Expand Table 4.10. Command attributes Name Description Requirement identifierID of the global variable defined in the KIE base
Required
objectObject to be set into the global variable
Optional
outBoolean to exclude the global variable you set from the execution results
Optional
out-identifierID of the global execution result
Optional
Example JSON request body
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java command
SetGlobalCommand setGlobalCommand = new SetGlobalCommand(); setGlobalCommand.setIdentifier("helper"); setGlobalCommand.setObject(new Person("kyle", 30)); setGlobalCommand.setOut(true); setGlobalCommand.setOutIdentifier("output");SetGlobalCommand setGlobalCommand = new SetGlobalCommand(); setGlobalCommand.setIdentifier("helper"); setGlobalCommand.setObject(new Person("kyle", 30)); setGlobalCommand.setOut(true); setGlobalCommand.setOutIdentifier("output");Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - GetGlobalCommand
Retrieves a previously defined global object.
Expand Table 4.11. Command attributes Name Description Requirement identifierID of the global variable defined in the KIE base
Required
out-identifierID to be used in the execution results
Optional
Example JSON request body
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java command
GetGlobalCommand getGlobalCommand = new GetGlobalCommand(); getGlobalCommand.setIdentifier("helper"); getGlobalCommand.setOutIdentifier("helperOutput");GetGlobalCommand getGlobalCommand = new GetGlobalCommand(); getGlobalCommand.setIdentifier("helper"); getGlobalCommand.setOutIdentifier("helperOutput");Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 5. Decision Manager controller REST API for Decision Server templates and instances Copy linkLink copied to clipboard!
Red Hat Decision Manager provides a Decision Manager controller REST API that you can use to interact with your Decision Server templates (configurations), Decision Server instances (remote servers), and associated KIE containers (deployment units) in Red Hat Decision Manager without using the Business Central user interface. This API support enables you to maintain your Red Hat Decision Manager servers and resources more efficiently and optimize your integration and development with Red Hat Decision Manager.
With the Decision Manager controller REST API, you can perform the following actions:
- Retrieve information about Decision Server templates, instances, and associated KIE containers
- Update, start, or stop KIE containers associated with Decision Server templates and instances
- Create, update, or delete Decision Server templates
- Create, update, or delete Decision Server instances
Requests to the Decision Manager controller REST API require the following components:
- Authentication
The Decision Manager controller REST API requires HTTP Basic authentication or token-based authentication for the following user roles, depending on controller type:
-
rest-alluser role if you installed Business Central and you want to use the built-in Decision Manager controller -
kie-serveruser role if you installed the headless Decision Manager controller separately from Business Central
To view configured user roles for your Red Hat Decision Manager distribution, navigate to
~/$SERVER_HOME/standalone/configuration/application-roles.propertiesand~/application-users.properties.To add a user with the
kie-serverrole or therest-allrole or both, navigate to~/$SERVER_HOME/binand run the following command with the role or roles specified:./add-user.sh -a --user <USERNAME> --password <PASSWORD> --role kie-server,rest-all
$ ./add-user.sh -a --user <USERNAME> --password <PASSWORD> --role kie-server,rest-allCopy to Clipboard Copied! Toggle word wrap Toggle overflow To configure the
kie-serverorrest-alluser with Decision Manager controller access, navigate to~/$SERVER_HOME/standalone/configuration/standalone-full.xml, uncomment theorg.kie.serverproperties (if applicable), and add the controller user login credentials and controller location (if needed):<property name="org.kie.server.location" value="http://localhost:8080/kie-server/services/rest/server"/> <property name="org.kie.server.controller" value="http://localhost:8080/decision-central/rest/controller"/> <property name="org.kie.server.controller.user" value="baAdmin"/> <property name="org.kie.server.controller.pwd" value="password@1"/> <property name="org.kie.server.id" value="default-kieserver"/>
<property name="org.kie.server.location" value="http://localhost:8080/kie-server/services/rest/server"/> <property name="org.kie.server.controller" value="http://localhost:8080/decision-central/rest/controller"/> <property name="org.kie.server.controller.user" value="baAdmin"/> <property name="org.kie.server.controller.pwd" value="password@1"/> <property name="org.kie.server.id" value="default-kieserver"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For more information about user roles and Red Hat Decision Manager installation options, see Planning a Red Hat Decision Manager installation.
-
- HTTP headers
The Decision Manager controller REST API requires the following HTTP headers for API requests:
Accept: Data format accepted by your requesting client:-
application/json(JSON) -
application/xml(XML, for JAXB)
-
Content-Type: Data format of yourPOSTorPUTAPI request data:-
application/json(JSON) -
application/xml(XML, for JAXB)
-
- HTTP methods
The Decision Manager controller REST API supports the following HTTP methods for API requests:
-
GET: Retrieves specified information from a specified resource endpoint -
POST: Updates a resource or resource instance -
PUT: Creates a resource or resource instance -
DELETE: Deletes a resource or resource instance
-
- Base URL
-
The base URL for Decision Manager controller REST API requests is
http://SERVER:PORT/CONTROLLER/rest/, such ashttp://localhost:8080/decision-central/rest/if you are using the Decision Manager controller built in to Business Central. - Endpoints
Decision Manager controller REST API endpoints, such as
/controller/management/servers/{serverTemplateId}for a specified Decision Server template, are the URIs that you append to the Decision Manager controller REST API base URL to access the corresponding server resource or type of server resource in Red Hat Decision Manager.Example request URL for
/controller/management/servers/{serverTemplateId}endpointhttp://localhost:8080/decision-central/rest/controller/management/servers/default-kieserver- Request parameters and request data
Some Decision Manager controller REST API requests require specific parameters in the request URL path to identify or filter specific resources and to perform specific actions. You can append URL parameters to the endpoint in the format
?<PARAM>=<VALUE>&<PARAM>=<VALUE>.Example DELETE request URL with parameters
http://localhost:8080/decision-central/rest/controller/server/new-kieserver-instance?location=http://localhost:8080/kie-server/services/rest/serverHTTP
POSTandPUTrequests may additionally require a request body or file with data to accompany the request.Example PUT request URL and JSON request body data
http://localhost:8080/decision-central/rest/controller/management/servers/new-kieserverCopy to Clipboard Copied! Toggle word wrap Toggle overflow
5.1. Sending requests with the Decision Manager controller REST API using a REST client or curl utility Copy linkLink copied to clipboard!
The Decision Manager controller REST API enables you to interact with your Decision Server templates (configurations), Decision Server instances (remote servers), and associated KIE containers (deployment units) in Red Hat Decision Manager without using the Business Central user interface. You can send Decision Manager controller REST API requests using any REST client or curl utility.
Prerequisites
- Decision Server is installed and running.
- The Decision Manager controller or headless Decision Manager controller is installed and running.
-
You have
rest-alluser role access to the Decision Manager controller if you installed Business Central, orkie-serveruser role access to the headless Decision Manager controller installed separately from Business Central.
Procedure
-
Identify the relevant API endpoint to which you want to send a request, such as
[GET] /controller/management/serversto retrieve Decision Server templates from the Decision Manager controller. In a REST client or curl utility, enter the following components for a
GETrequest tocontroller/management/servers. Adjust any request details according to your use case.For REST client:
-
Authentication: Enter the user name and password of the Decision Manager controller user with the
rest-allrole or the headless Decision Manager controller user with thekie-serverrole. HTTP Headers: Set the following header:
-
Accept:application/json
-
-
HTTP method: Set to
GET. -
URL: Enter the Decision Manager controller REST API base URL and endpoint, such as
http://localhost:8080/decision-central/rest/controller/management/servers.
For curl utility:
-
-u: Enter the user name and password of the Decision Manager controller user with therest-allrole or the headless Decision Manager controller user with thekie-serverrole. -H: Set the following header:-
Accept:application/json
-
-
-X: Set toGET. -
URL: Enter the Decision Manager controller REST API base URL and endpoint, such as
http://localhost:8080/decision-central/rest/controller/management/servers.
curl -u 'baAdmin:password@1' -H "Accept: application/json" -X GET "http://localhost:8080/decision-central/rest/controller/management/servers"
curl -u 'baAdmin:password@1' -H "Accept: application/json" -X GET "http://localhost:8080/decision-central/rest/controller/management/servers"Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Authentication: Enter the user name and password of the Decision Manager controller user with the
Execute the request and review the Decision Manager controller response.
Example server response (JSON):
Copy to Clipboard Copied! Toggle word wrap Toggle overflow In your REST client or curl utility, send another API request with the following components for a
PUTrequest to/controller/management/servers/{serverTemplateId}to create a new Decision Server template. Adjust any request details according to your use case.For REST client:
-
Authentication: Enter the user name and password of the Decision Manager controller user with the
rest-allrole or the headless Decision Manager controller user with thekie-serverrole. HTTP Headers: Set the following headers:
-
Accept:application/json -
Content-Type:application/json
-
-
HTTP method: Set to
PUT. -
URL: Enter the Decision Manager controller REST API base URL and endpoint, such as
http://localhost:8080/decision-central/rest/controller/management/servers/new-kieserver. - Request body: Add a JSON request body with the configurations for the new Decision Server template:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For curl utility:
-
-u: Enter the user name and password of the Decision Manager controller user with therest-allrole or the headless Decision Manager controller user with thekie-serverrole. -H: Set the following headers:-
Accept:application/json -
Content-Type:application/json
-
-
-X: Set toPUT. -
URL: Enter the Decision Manager controller REST API base URL and endpoint, such as
http://localhost:8080/decision-central/rest/controller/management/servers/new-kieserver. -
-d: Add a JSON request body or file (@file.json) with the configurations for the new Decision Server template:
curl -u 'baAdmin:password@1' -H "Accept: application/json" -H "Content-Type: application/json" -X PUT "http://localhost:8080/decision-central/rest/controller/management/servers/new-kieserver" -d "{ \"server-id\": \"new-kieserver\", \"server-name\": \"new-kieserver\", \"container-specs\": [], \"server-config\": {}, \"capabilities\": [ \"RULE\", \"PROCESS\", \"PLANNING\" ]}"curl -u 'baAdmin:password@1' -H "Accept: application/json" -H "Content-Type: application/json" -X PUT "http://localhost:8080/decision-central/rest/controller/management/servers/new-kieserver" -d "{ \"server-id\": \"new-kieserver\", \"server-name\": \"new-kieserver\", \"container-specs\": [], \"server-config\": {}, \"capabilities\": [ \"RULE\", \"PROCESS\", \"PLANNING\" ]}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow curl -u 'baAdmin:password@1' -H "Accept: application/json" -H "Content-Type: application/json" -X PUT "http://localhost:8080/decision-central/rest/controller/management/servers/new-kieserver" -d @my-server-template-configs.json
curl -u 'baAdmin:password@1' -H "Accept: application/json" -H "Content-Type: application/json" -X PUT "http://localhost:8080/decision-central/rest/controller/management/servers/new-kieserver" -d @my-server-template-configs.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Authentication: Enter the user name and password of the Decision Manager controller user with the
Execute the request and confirm the successful Decision Manager controller response.
If you encounter request errors, review the returned error code messages and adjust your request accordingly.
5.2. Sending requests with the Decision Manager controller REST API using the Swagger interface Copy linkLink copied to clipboard!
The Decision Manager controller REST API supports a Swagger web interface that you can use instead of a standalone REST client or curl utility to interact with your Decision Server templates, instances, and associated KIE containers in Red Hat Decision Manager without using the Business Central user interface.
By default, the Swagger web interface for the Decision Manager controller is enabled by the org.kie.workbench.swagger.disabled=false system property. To disable the Swagger web interface for the Decision Manager controller, set this system property to true.
Prerequisites
- The Decision Manager controller is installed and running.
-
You have
rest-alluser role access to the Decision Manager controller if you installed Business Central, orkie-serveruser role access to the headless Decision Manager controller installed separately from Business Central.
Procedure
In a web browser, navigate to
http://SERVER:PORT/CONTROLLER/docs, such ashttp://localhost:8080/decision-central/docs, and log in with the user name and password of the Decision Manager controller user with therest-allrole or the headless Decision Manager controller user with thekie-serverrole.NoteIf you are using the Decision Manager controller built in to Business Central, the Swagger page associated with the Decision Manager controller is identified as the "Business Central API" for Business Central REST services. If you are using the headless Decision Manager controller without Business Central, the Swagger page associated with the headless Decision Manager controller is identified as the "Controller API". In both cases, the Decision Manager controller REST API endpoints are the same.
- In the Swagger page, select the relevant API endpoint to which you want to send a request, such as Controller :: KIE Server templates and KIE containers → [GET] /controller/management/servers to retrieve Decision Server templates from the Decision Manager controller.
- Click Try it out and provide any optional parameters by which you want to filter results, if applicable.
- In the Response content type drop-down menu, select the desired format of the server response, such as application/json for JSON format.
Click Execute and review the Decision Server response.
Example server response (JSON):
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - In the Swagger page, navigate to the Controller :: KIE Server templates and KIE containers → [GET] /controller/management/servers/{serverTemplateId} endpoint to send another request to create a new Decision Server template. Adjust any request details according to your use case.
Click Try it out and enter the following components for the request:
-
serverTemplateId: Enter the ID of the new Decision Server template, such as
new-kieserver. - body: Set the Parameter content type to the desired request body format, such as application/json for JSON format, and add a request body with the configurations for the new Decision Server template:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
serverTemplateId: Enter the ID of the new Decision Server template, such as
- In the Response content type drop-down menu, select the desired format of the server response, such as application/json for JSON format.
Click Execute and confirm the successful Decision Manager controller response.
If you encounter request errors, review the returned error code messages and adjust your request accordingly.
5.3. Supported Decision Manager controller REST API endpoints Copy linkLink copied to clipboard!
The Decision Manager controller REST API provides endpoints for interacting with Decision Server templates (configurations), Decision Server instances (remote servers), and associated KIE containers (deployment units). The Decision Manager controller REST API base URL is http://SERVER:PORT/CONTROLLER/rest/. All requests require HTTP Basic authentication or token-based authentication for the rest-all user role if you installed Business Central and you want to use the built-in Decision Manager controller, or the kie-server user role if you installed the headless Decision Manager controller separately from Business Central.
For the full list of Decision Manager controller REST API endpoints and descriptions, use one of the following resources:
- Controller REST API on the jBPM Documentation page (static)
Swagger UI for the Decision Manager controller REST API at
http://SERVER:PORT/CONTROLLER/docs(dynamic, requires running Decision Manager controller)NoteBy default, the Swagger web interface for the Decision Manager controller is enabled by the
org.kie.workbench.swagger.disabled=falsesystem property. To disable the Swagger web interface for the Decision Manager controller, set this system property totrue.If you are using the Decision Manager controller built in to Business Central, the Swagger page associated with the Decision Manager controller is identified as the "Business Central API" for Business Central REST services. If you are using the headless Decision Manager controller without Business Central, the Swagger page associated with the headless Decision Manager controller is identified as the "Controller API". In both cases, the Decision Manager controller REST API endpoints are the same.
Chapter 6. Decision Manager controller Java client API for Decision Server templates and instances Copy linkLink copied to clipboard!
Red Hat Decision Manager provides a Decision Manager controller Java client API that enables you to connect to the Decision Manager controller using REST or WebSocket protocol from your Java client application. You can use the Decision Manager controller Java client API as an alternative to the Decision Manager controller REST API to interact with your Decision Server templates (configurations), Decision Server instances (remote servers), and associated KIE containers (deployment units) in Red Hat Decision Manager without using the Business Central user interface. This API support enables you to maintain your Red Hat Decision Manager servers and resources more efficiently and optimize your integration and development with Red Hat Decision Manager.
With the Decision Manager controller Java client API, you can perform the following actions also supported by the Decision Manager controller REST API:
- Retrieve information about Decision Server templates, instances, and associated KIE containers
- Update, start, or stop KIE containers associated with Decision Server templates and instances
- Create, update, or delete Decision Server templates
- Create, update, or delete Decision Server instances
Decision Manager controller Java client API requests require the following components:
- Authentication
The Decision Manager controller Java client API requires HTTP Basic authentication for the following user roles, depending on controller type:
-
rest-alluser role if you installed Business Central and you want to use the built-in Decision Manager controller -
kie-serveruser role if you installed the headless Decision Manager controller separately from Business Central
To view configured user roles for your Red Hat Decision Manager distribution, navigate to
~/$SERVER_HOME/standalone/configuration/application-roles.propertiesand~/application-users.properties.To add a user with the
kie-serverrole or therest-allrole or both, navigate to~/$SERVER_HOME/binand run the following command with the role or roles specified:./add-user.sh -a --user <USERNAME> --password <PASSWORD> --role kie-server,rest-all
$ ./add-user.sh -a --user <USERNAME> --password <PASSWORD> --role kie-server,rest-allCopy to Clipboard Copied! Toggle word wrap Toggle overflow To configure the
kie-serverorrest-alluser with Decision Manager controller access, navigate to~/$SERVER_HOME/standalone/configuration/standalone-full.xml, uncomment theorg.kie.serverproperties (if applicable), and add the controller user login credentials and controller location (if needed):<property name="org.kie.server.location" value="http://localhost:8080/kie-server/services/rest/server"/> <property name="org.kie.server.controller" value="http://localhost:8080/decision-central/rest/controller"/> <property name="org.kie.server.controller.user" value="baAdmin"/> <property name="org.kie.server.controller.pwd" value="password@1"/> <property name="org.kie.server.id" value="default-kieserver"/>
<property name="org.kie.server.location" value="http://localhost:8080/kie-server/services/rest/server"/> <property name="org.kie.server.controller" value="http://localhost:8080/decision-central/rest/controller"/> <property name="org.kie.server.controller.user" value="baAdmin"/> <property name="org.kie.server.controller.pwd" value="password@1"/> <property name="org.kie.server.id" value="default-kieserver"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For more information about user roles and Red Hat Decision Manager installation options, see Planning a Red Hat Decision Manager installation.
-
- Project dependencies
The Decision Manager controller Java client API requires the following dependencies on the relevant classpath of your Java project:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
<version>for Red Hat Decision Manager dependencies is the Maven artifact version for Red Hat Decision Manager currently used in your project (for example, 7.23.0.Final-redhat-00002).NoteInstead of specifying a Red Hat Decision Manager
<version>for individual dependencies, consider adding the Red Hat Business Automation bill of materials (BOM) dependency to your projectpom.xmlfile. The Red Hat Business Automation BOM applies to both Red Hat Decision Manager and Red Hat Process Automation Manager. When you add the BOM files, the correct versions of transitive dependencies from the provided Maven repositories are included in the project.Example BOM dependency:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For more information about the Red Hat Business Automation BOM, see What is the mapping between RHDM product and maven library version?.
- Client request configuration
All Java client requests with the Decision Manager controller Java client API must define at least the following controller communication components:
-
Credentials of the
rest-alluser if you installed Business Central, or thekie-serveruser if you installed the headless Decision Manager controller separately from Business Central Decision Manager controller location for REST or WebSocket protocol:
-
Example REST URL:
http://localhost:8080/decision-central/rest/controller -
Example WebSocket URL:
ws://localhost:8080/headless-controller/websocket/controller
-
Example REST URL:
- Marshalling format for API requests and responses (JSON or JAXB)
-
A
KieServerControllerClientobject, which serves as the entry point for starting the server communication using the Java client API -
A
KieServerControllerClientFactorydefining REST or WebSocket protocol and user access -
The Decision Manager controller client service or services used, such as
listServerTemplates,getServerTemplate, orgetServerInstances
The following are examples of REST and WebSocket client configurations with these components:
Client configuration example with REST
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Client configuration example with WebSocket
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Credentials of the
6.1. Sending requests with the Decision Manager controller Java client API Copy linkLink copied to clipboard!
The Decision Manager controller Java client API enables you to connect to the Decision Manager controller using REST or WebSocket protocols from your Java client application. You can use the Decision Manager controller Java client API as an alternative to the Decision Manager controller REST API to interact with your Decision Server templates (configurations), Decision Server instances (remote servers), and associated KIE containers (deployment units) in Red Hat Decision Manager without using the Business Central user interface.
Prerequisites
- Decision Server is installed and running.
- The Decision Manager controller or headless Decision Manager controller is installed and running.
-
You have
rest-alluser role access to the Decision Manager controller if you installed Business Central, orkie-serveruser role access to the headless Decision Manager controller installed separately from Business Central. - You have a Java project with Red Hat Decision Manager resources.
Procedure
In your client application, ensure that the following dependencies have been added to the relevant classpath of your Java project:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Download the Red Hat Decision Manager 7.4.0 Source Distribution from the Red Hat Customer Portal and navigate to
~/rhdm-7.4.0-sources/src/droolsjbpm-integration-$VERSION/kie-server-parent/kie-server-controller/kie-server-controller-client/src/main/java/org/kie/server/controller/clientto access the Decision Manager controller Java clients. -
In the
~/kie/server/controller/clientfolder , identify the relevant Java client implementation for the request you want to send, such as theRestKieServerControllerClientimplementation to access client services for Decision Server templates and KIE containers in REST protocol. In your client application, create a
.javaclass for the API request. The class must contain the necessary imports, the Decision Manager controller location and user credentials, aKieServerControllerClientobject, and the client method to execute, such ascreateServerTemplateandcreateContainerfrom theRestKieServerControllerClientimplementation. Adjust any configuration details according to your use case.Creating and interacting with a Decision Server template and KIE containers
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the configured
.javaclass from your project directory to execute the request, and review the Decision Manager controller response.If you enabled debug logging, Decision Server responds with a detailed response according to your configured marshalling format, such as JSON. If you encounter request errors, review the returned error code messages and adjust your Java configurations accordingly.
6.2. Supported Decision Manager controller Java clients Copy linkLink copied to clipboard!
The following are some of the Java client services available in the org.kie.server.controller.client package of your Red Hat Decision Manager distribution. You can use these services to interact with related resources in the Decision Manager controller similarly to the Decision Manager controller REST API.
-
KieServerControllerClient: Used as the entry point for communicating with the Decision Manager controller -
RestKieServerControllerClient: Implementation used to interact with Decision Server templates and KIE containers in REST protocol (found in~/org/kie/server/controller/client/rest) -
WebSocketKieServerControllerClient: Implementation used to interact with Decision Server templates and KIE containers in WebSocket protocol (found in~/org/kie/server/controller/client/websocket)
For the full list of available Decision Manager controller Java clients, download the Red Hat Decision Manager 7.4.0 Source Distribution from the Red Hat Customer Portal and navigate to ~/rhdm-7.4.0-sources/src/droolsjbpm-integration-$VERSION/kie-server-parent/kie-server-controller/kie-server-controller-client/src/main/java/org/kie/server/controller/client.
6.3. Example requests with the Decision Manager controller Java client API Copy linkLink copied to clipboard!
The following are examples of Decision Manager controller Java client API requests for basic interactions with the Decision Manager controller. For the full list of available Decision Manager controller Java clients, download the Red Hat Decision Manager 7.4.0 Source Distribution from the Red Hat Customer Portal and navigate to ~/rhdm-7.4.0-sources/src/droolsjbpm-integration-$VERSION/kie-server-parent/kie-server-controller/kie-server-controller-client/src/main/java/org/kie/server/controller/client.
- Creating and interacting with Decision Server templates and KIE containers
You can use the
ServerTemplateandContainerSpecservices in the REST or WebSocket Decision Manager controller clients to create, dispose, and update Decision Server templates and KIE containers, and to start and stop KIE containers, as illustrated in this example.Example request to create and interact with a Decision Server template and KIE containers
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Listing Decision Server templates and specifying connection timeout (REST)
When you use REST protocol for Decision Manager controller Java client API requests, you can provide your own
javax.ws.rs.core.Configurationspecification to modify the underlying REST client API, such as connection timeout.Example REST request to return server templates and specify connection timeout
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Listing Decision Server templates and specifying event notifications (WebSocket)
When you use WebSocket protocol for Decision Manager controller Java client API requests, you can enable event notifications based on changes that happen in the particular Decision Manager controller to which the client API is connected. For example, you can receive notifications when Decision Server templates or instances are connected to or updated in the Decision Manager controller.
Example WebSocket request to return server templates and specify event notifications
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 7. Knowledge Store REST API for Business Central spaces and projects Copy linkLink copied to clipboard!
Red Hat Decision Manager provides a Knowledge Store REST API that you can use to interact with your projects and spaces in Red Hat Decision Manager without using the Business Central user interface. The Knowledge Store is the artifact repository for assets in Red Hat Decision Manager. This API support enables you to facilitate and automate maintenance of Business Central projects and spaces.
With the Knowledge Store REST API, you can perform the following actions:
- Retrieve information about all projects and spaces
- Create, update, or delete projects and spaces
- Build, deploy, and test projects
- Retrieve information about previous Knowledge Store REST API requests, or jobs
Knowledge Store REST API requests require the following components:
- Authentication
The Knowledge Store REST API requires HTTP Basic authentication or token-based authentication for the user role
rest-all. To view configured user roles for your Red Hat Decision Manager distribution, navigate to~/$SERVER_HOME/standalone/configuration/application-roles.propertiesand~/application-users.properties.To add a user with the
rest-allrole, navigate to~/$SERVER_HOME/binand run the following command:./add-user.sh -a --user <USERNAME> --password <PASSWORD> --role rest-all
$ ./add-user.sh -a --user <USERNAME> --password <PASSWORD> --role rest-allCopy to Clipboard Copied! Toggle word wrap Toggle overflow For more information about user roles and Red Hat Decision Manager installation options, see Planning a Red Hat Decision Manager installation.
- HTTP headers
The Knowledge Store REST API requires the following HTTP headers for API requests:
Accept: Data format accepted by your requesting client:-
application/json(JSON)
-
Content-Type: Data format of yourPOSTorPUTAPI request data:-
application/json(JSON)
-
- HTTP methods
The Knowledge Store REST API supports the following HTTP methods for API requests:
-
GET: Retrieves specified information from a specified resource endpoint -
POST: Creates or updates a resource -
DELETE: Deletes a resource
-
- Base URL
The base URL for Knowledge Store REST API requests is
http://SERVER:PORT/decision-central/rest/, such ashttp://localhost:8080/decision-central/rest/.NoteThe REST API base URL for the Knowledge Store and for the Decision Manager controller built in to Business Central are the same because both are considered part of Business Central REST services.
- Endpoints
Knowledge Store REST API endpoints, such as
/spaces/{spaceName}for a specified space, are the URIs that you append to the Knowledge Store REST API base URL to access the corresponding resource or type of resource in Red Hat Decision Manager.Example request URL for
/spaces/{spaceName}endpointhttp://localhost:8080/decision-central/rest/spaces/MySpace- Request data
HTTP
POSTrequests in the Knowledge Store REST API may require a JSON request body with data to accompany the request.Example POST request URL and JSON request body data
http://localhost:8080/decision-central/rest/spaces/MySpace/projectsCopy to Clipboard Copied! Toggle word wrap Toggle overflow
7.1. Sending requests with the Knowledge Store REST API using a REST client or curl utility Copy linkLink copied to clipboard!
The Knowledge Store REST API enables you to interact with your projects and spaces in Red Hat Decision Manager without using the Business Central user interface. You can send Knowledge Store REST API requests using any REST client or curl utility.
Prerequisites
- Business Central is installed and running.
-
You have
rest-alluser role access to Business Central.
Procedure
-
Identify the relevant API endpoint to which you want to send a request, such as
[GET] /spacesto retrieve spaces in Business Central. In a REST client or curl utility, enter the following components for a
GETrequest to/spaces. Adjust any request details according to your use case.For REST client:
-
Authentication: Enter the user name and password of the Business Central user with the
rest-allrole. HTTP Headers: Set the following header:
-
Accept:application/json
-
-
HTTP method: Set to
GET. -
URL: Enter the Knowledge Store REST API base URL and endpoint, such as
http://localhost:8080/decision-central/rest/spaces.
For curl utility:
-
-u: Enter the user name and password of the Business Central user with therest-allrole. -H: Set the following header:-
accept:application/json
-
-
-X: Set toGET. -
URL: Enter the Knowledge Store REST API base URL and endpoint, such as
http://localhost:8080/decision-central/rest/spaces.
curl -u 'baAdmin:password@1' -H "accept: application/json" -X GET "http://localhost:8080/decision-central/rest/spaces"
curl -u 'baAdmin:password@1' -H "accept: application/json" -X GET "http://localhost:8080/decision-central/rest/spaces"Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Authentication: Enter the user name and password of the Business Central user with the
Execute the request and review the Decision Server response.
Example server response (JSON):
Copy to Clipboard Copied! Toggle word wrap Toggle overflow In your REST client or curl utility, send another API request with the following components for a
POSTrequest to/spaces/{spaceName}/projectsto create a project within a space. Adjust any request details according to your use case.For REST client:
-
Authentication: Enter the user name and password of the Business Central user with the
rest-allrole. HTTP Headers: Set the following header:
-
Accept:application/json -
Accept-Language:en-US -
Content-Type:application/json
-
-
HTTP method: Set to
POST. -
URL: Enter the Knowledge Store REST API base URL and endpoint, such as
http://localhost:8080/decision-central/rest/spaces/MySpace/projects. - Request body: Add a JSON request body with the identification data for the new project:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For curl utility:
-
-u: Enter the user name and password of the Business Central user with therest-allrole. -H: Set the following headers:-
Accept:application/json -
Accept-Language:en-US(If not defined, the default locale from the JVM is reflected) -
Content-Type:application/json
-
-
-X: Set toPOST. -
URL: Enter the Knowledge Store REST API base URL and endpoint, such as
http://localhost:8080/decision-central/rest/spaces/MySpace/projects. -
-d: Add a JSON request body or file (@file.json) with the identification data for the new project:
curl -u 'baAdmin:password@1' -H "Accept: application/json" -H "Accept-Language: en-US" -H "Content-Type: application/json" -X POST "http://localhost:8080/decision-central/rest/spaces/MySpace/projects" -d "{ \"name\": \"Employee_Rostering\", \"groupId\": \"employeerostering\", \"version\": \"1.0.0-SNAPSHOT\", \"description\": \"Employee rostering problem optimisation using Planner. Assigns employees to shifts based on their skill.\"}"curl -u 'baAdmin:password@1' -H "Accept: application/json" -H "Accept-Language: en-US" -H "Content-Type: application/json" -X POST "http://localhost:8080/decision-central/rest/spaces/MySpace/projects" -d "{ \"name\": \"Employee_Rostering\", \"groupId\": \"employeerostering\", \"version\": \"1.0.0-SNAPSHOT\", \"description\": \"Employee rostering problem optimisation using Planner. Assigns employees to shifts based on their skill.\"}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow curl -u 'baAdmin:password@1' -H "Accept: application/json" -H "Accept-Language: en-US" -H "Content-Type: application/json" -X POST "http://localhost:8080/decision-central/rest/spaces/MySpace/projects" -d @my-project.json
curl -u 'baAdmin:password@1' -H "Accept: application/json" -H "Accept-Language: en-US" -H "Content-Type: application/json" -X POST "http://localhost:8080/decision-central/rest/spaces/MySpace/projects" -d @my-project.jsonCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Authentication: Enter the user name and password of the Business Central user with the
Execute the request and review the Decision Server response.
Example server response (JSON):
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you encounter request errors, review the returned error code messages and adjust your request accordingly.
7.2. Supported Knowledge Store REST API endpoints Copy linkLink copied to clipboard!
The Knowledge Store REST API provides endpoints for managing spaces and projects in Red Hat Decision Manager and for retrieving information about previous Knowledge Store REST API requests, or jobs.
7.2.1. Spaces Copy linkLink copied to clipboard!
The Knowledge Store REST API supports the following endpoints for managing spaces in Business Central. The Knowledge Store REST API base URL is http://SERVER:PORT/decision-central/rest/. All requests require HTTP Basic authentication or token-based authentication for the rest-all user role.
- [GET] /spaces
Returns all spaces in Business Central.
Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [GET] /spaces/{spaceName}
Returns information about a specified space.
Expand Table 7.1. Request parameters Name Description Type Requirement spaceNameName of the space to be retrieved
String
Required
Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [POST] /spaces
Creates a space in Business Central.
Expand Table 7.2. Request parameters Name Description Type Requirement body
The
name,description,owner,defaultGroupId, and any other components of the new spaceRequest body
Required
Example request body (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [DELETE] /spaces/{spaceName}
Deletes a specified space from Business Central.
Expand Table 7.3. Request parameters Name Description Type Requirement spaceNameName of the space to be deleted
String
Required
Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
7.2.2. Projects Copy linkLink copied to clipboard!
The Knowledge Store REST API supports the following endpoints for managing, building, and deploying projects in Business Central. The Knowledge Store REST API base URL is http://SERVER:PORT/decision-central/rest/. All requests require HTTP Basic authentication or token-based authentication for the rest-all user role.
- [GET] /spaces/{spaceName}/projects
Returns projects in a specified space.
Expand Table 7.4. Request parameters Name Description Type Requirement spaceNameName of the space for which you are retrieving projects
String
Required
Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [GET] /spaces/{spaceName}/projects/{projectName}
Returns information about a specified project in a specified space.
Expand Table 7.5. Request parameters Name Description Type Requirement spaceNameName of the space where the project is located
String
Required
projectNameName of the project to be retrieved
String
Required
Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [POST] /spaces/{spaceName}/projects
Creates a project in a specified space.
Expand Table 7.6. Request parameters Name Description Type Requirement spaceNameName of the space in which the new project will be created
String
Required
body
The
name,groupId,version,description, and any other components of the new projectRequest body
Required
Example request body (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [DELETE] /spaces/{spaceName}/projects/{projectName}
Deletes a specified project from a specified space.
Expand Table 7.7. Request parameters Name Description Type Requirement spaceNameName of the space where the project is located
String
Required
projectNameName of the project to be deleted
String
Required
Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [POST] /spaces/{spaceName}/git/clone
Clones a project into a specified space from a specified Git address.
Expand Table 7.8. Request parameters Name Description Type Requirement spaceNameName of the space to which you are cloning a project
String
Required
body
The
name,description, and Git repositoryuserName,password, andgitURLfor the project to be clonedRequest body
Required
Example request body (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [POST] /spaces/{spaceName}/projects/{projectName}/maven/compile
Compiles a specified project in a specified space (equivalent to
mvn compile).Expand Table 7.9. Request parameters Name Description Type Requirement spaceNameName of the space where the project is located
String
Required
projectNameName of the project to be compiled
String
Required
Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [POST] /spaces/{spaceName}/projects/{projectName}/maven/test
Tests a specified project in a specified space (equivalent to
mvn test).Expand Table 7.10. Request parameters Name Description Type Requirement spaceNameName of the space where the project is located
String
Required
projectNameName of the project to be tested
String
Required
Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [POST] /spaces/{spaceName}/projects/{projectName}/maven/install
Installs a specified project in a specified space (equivalent to
mvn install).Expand Table 7.11. Request parameters Name Description Type Requirement spaceNameName of the space where the project is located
String
Required
projectNameName of the project to be installed
String
Required
Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [POST] /spaces/{spaceName}/projects/{projectName}/maven/deploy
Deploys a specified project in a specified space (equivalent to
mvn deploy).Expand Table 7.12. Request parameters Name Description Type Requirement spaceNameName of the space where the project is located
String
Required
projectNameName of the project to be deployed
String
Required
Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
7.2.3. Jobs (API requests) Copy linkLink copied to clipboard!
All POST and DELETE requests in the Knowledge Store REST API return a job ID associated with each request, in addition to the returned request details. You can use a job ID to view the request status or delete a sent request.
Knowledge Store REST API requests, or jobs, can have the following statuses:
| Status | Description |
|---|---|
|
| The request was accepted and is being processed. |
|
| The request contained incorrect content and was not accepted. |
|
| The requested resource (path) does not exist. |
|
| The resource already exists. |
|
| An error occurred in Decision Server. |
|
| The request finished successfully. |
|
| The request failed. |
|
| The request was approved. |
|
| The request was denied. |
|
| The job ID for the request could not be found due to one of the following reasons:
|
The Knowledge Store REST API supports the following endpoints for retrieving or deleting sent API requests. The Knowledge Store REST API base URL is http://SERVER:PORT/decision-central/rest/. All requests require HTTP Basic authentication or token-based authentication for the rest-all user role.
- [GET] /jobs/{jobId}
Returns the status of a specified job (a previously sent API request).
Expand Table 7.14. Request parameters Name Description Type Requirement jobIdID of the job to be retrieved (example:
1541010216919-1)String
Required
Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - [DELETE] /jobs/{jobId}
Deletes a specified job (a previously sent API request). If the job is not being processed yet, this request removes the job from the job queue. This request does not cancel or stop an ongoing job.
Expand Table 7.15. Request parameters Name Description Type Requirement jobIdID of the job to be deleted (example:
1541010216919-1)String
Required
Example server response (JSON)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 8. Additional resources Copy linkLink copied to clipboard!
Appendix A. Versioning information Copy linkLink copied to clipboard!
Documentation last updated on Monday, March 01, 2021.