Este conteúdo não está disponível no idioma selecionado.
Chapter 13. Configure the Red Hat Business Optimizer REST API
The Decision Server supports the following Red Hat Business Optimizer REST APIs. These APIs are also available through JMS and the Java client API.
Prerequisite
Red Hat Decision Manager has been installed and configured with basic HTTP Authentication for the kie-server
role. You have identified the server endpoint base URL, for example, http://SERVER:PORT/CONTEXT/services/rest/server/
.
-
To get a specific marshalling format, add the HTTP headers
Content-Type
and optionalX-KIE-ContentType
in the HTTP request. For example:
Content-Type: application/xml X-KIE-ContentType: xstream
Content-Type: application/xml
X-KIE-ContentType: xstream
X-KIE-ContentType
supports the following values: xstream
, xml
, json
.
The requests and responses in the example below assume that a KIE container is built using the Employee Rostering example in Decision Central, by calling a PUT
on /services/rest/server/containers/employee-rostering
with this content:
13.1. [GET] /containers Copiar o linkLink copiado para a área de transferência!
Returns the list of created containers.
Example 13.1. Example Server Response (XStream)
13.2. [PUT] /containers/{containerId}/solvers/{solverId} Copiar o linkLink copiado para a área de transferência!
Creates a new solver with the given {solverId}
in the container {containerId}
. The request’s body is a marshalled SolverInstance
entity that must specify the solver configuration file.
The following is an example of the request and the corresponding response.
Example 13.2. Example Server Request (XStream)
<solver-instance> <solver-config-file>employeerostering/employeerostering/EmployeeRosteringSolverConfig.solver.xml</solver-config-file> </solver-instance>
<solver-instance>
<solver-config-file>employeerostering/employeerostering/EmployeeRosteringSolverConfig.solver.xml</solver-config-file>
</solver-instance>
Example 13.3. Example Server Response (XStream)
13.3. [GET] /containers/{containerId}/solvers Copiar o linkLink copiado para a área de transferência!
Returns the list of solvers created in the container.
Example 13.4. Example Server Response (XStream)
13.4. [GET] /containers/{containerId}/solvers/{solverId} Copiar o linkLink copiado para a área de transferência!
Returns the current state of the solver {solverId}
in container {containerId}
.
Example 13.5. Example Server Response (XStream)
13.5. [POST] /containers/{containerId}/solvers/{solverId}/state/solving Copiar o linkLink copiado para a área de transferência!
Starts the solver {solverId} in container {containerId} if it is not executing yet. The request’s body is a marshalled PlanningSolution
to be optimized.
The following is an example to solve the OptaCloud problem with 2 computers and 6 processes. The solver runs asynchronously. Send a request to the bestsolution URL to get the best solution.
Example 13.6. Example Server Request (XStream)
13.6. [POST] /containers/{containerId}/solvers/{solverId}/state/terminating-early Copiar o linkLink copiado para a área de transferência!
Requests the solver to terminate early, if it is running. This does not delete the solver, the best solution can still be retrieved.
13.7. [GET] /containers/{containerId}/solvers/{solverId}/bestsolution Copiar o linkLink copiado para a área de transferência!
Returns the best solution found at the time the request is made. If the solver has not terminated yet (so the status
field is still SOLVING
), it will return the best solution found up to then, but later calls can return a better solution.
Example 13.7. Example Server Response (XStream)
13.8. [POST] /containers/{containerId}/solvers/{solverId}/problemfactchanges Copiar o linkLink copiado para a área de transferência!
Real-time planning feature. Submits one or multiple ProblemFactChanges to update the dataset the solver currently optimizes.
13.9. [GET] /containers/{containerId}/solvers/{solverId}/problemfactchanges/processed Copiar o linkLink copiado para a área de transferência!
Real-time planning feature. Returns true if the solver processed all ProblemFactChanges that had been submitted. Returns false otherwise.
13.10. [DELETE] /containers/{containerId}/solvers/{solverId} Copiar o linkLink copiado para a área de transferência!
Disposes the solver {solverId}
in container {containerId}
. If it has not terminated yet, it terminates it first.