|
| 1 | +Executing a Decision |
| 2 | +==== |
| 3 | + |
| 4 | +# Overview |
| 5 | + |
| 6 | +Once a Decision has been published to a Decision Runtime, it is available for execution as a Decision Service. |
| 7 | + |
| 8 | +The base URL of the Decision Runtime will be the same URL used when the Decision was published. |
| 9 | + |
| 10 | +OpenAPI documents are available, which provide details of the URLs and JSON data structures for publishing and executing Decision Services. |
| 11 | + |
| 12 | +For example, if the base URL is: |
| 13 | + |
| 14 | + https://myorg-decisions.inrulecloud.com/ |
| 15 | + |
| 16 | +The OpenAPI 2.0 and 3.0 Specification documents for publishing would be: |
| 17 | + |
| 18 | + https://myorg-decisions.inrulecloud.com/api/openapi_v2.0.json |
| 19 | + https://myorg-decisions.inrulecloud.com/api/openapi_v3.0.json |
| 20 | + |
| 21 | +The OpenAPI 2.0 and 3.0 Specification documents for executing published Decision Services would be: |
| 22 | + |
| 23 | + https://myorg-decisions.inrulecloud.com/api/decisions/openapi_v2.0.json |
| 24 | + https://myorg-decisions.inrulecloud.com/api/decisions/openapi_v3.0.json |
| 25 | + |
| 26 | +These documents can be used by Swagger, Postman, or proxy generators for publishing and executing Decision Services. |
| 27 | + |
| 28 | +# Publication/Execution API via Swagger/OpenAPI Specification |
| 29 | + |
| 30 | +The Swagger test page would be accessed at the following URL: |
| 31 | + |
| 32 | + https://myorg-decisions.inrulecloud.com/openapi/ |
| 33 | + |
| 34 | +This explicitly lists all Decision Services available for execution, along with their associated schemas and example input/output JSON. |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | +The Decision Runtime uses OAuth 2.0 for authentication. Before using this interface, user credentials must be authenticated using the 'Authorize' button on the page. |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | +To authorize the Swagger page, a 'client_id' will be required before the authentication window appears. Please contact [InRule Support ](mailto:[email protected]) for this client id. |
| 43 | + |
| 44 | +In addition to the 'Execution API', there is also a 'Publishing API' Swagger page that can be found in the drop-down menu at the top-right of the page: |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | +The following operations are possible: |
| 49 | + |
| 50 | +- List published Decisions |
| 51 | +- Publish a Decision |
| 52 | +- Get a Decision (Only confirms the name - Does not permit download of rule application) |
| 53 | +- Delete a Decision |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | +*Note: This page also requires authorization.* |
| 58 | + |
| 59 | +# Execution API via Postman |
| 60 | + |
| 61 | +Postman offers an alternative mechanism for testing the Decision Services publication and execution API. |
| 62 | + |
| 63 | +## Import OpenAPI Configuration |
| 64 | + |
| 65 | +Using the Import functionality of the Postman application, the OpenAPI Specification document for executing Decision Services can be imported. |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | +Enable the 'Generate a Postman Collection' option: |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | +After importing the OpenAPI specification, the Decision Services will be available in the collections list: |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | +Double-clicking one of the Decisions will open the form for the POST request. |
| 78 | + |
| 79 | +## Authorization |
| 80 | + |
| 81 | +Before sending the request to execute the Decision Service, the authorization header must be configured with a bearer token. This is retrieved from the OAuth 2.0 authentication service. |
| 82 | + |
| 83 | +Click the 'Authorization' tab and then click the 'Get New Access Token' button. Fill out the new token form using the following values: |
| 84 | + |
| 85 | +- Token Name: `[Any friendly name for the auth token]` |
| 86 | +- Grant Type: `Implicit` |
| 87 | +- Callback URL: `https://www.getpostman.com/oauth2/callback` |
| 88 | +- Auth URL: `https://auth.inrulecloud.com/authorize` |
| 89 | +- Client ID: `[Contact InRule Support for the Client ID to use with Postman]` |
| 90 | +- Scope: `[Leave empty]` |
| 91 | +- State: `[Leave empty]` |
| 92 | +- Client Authentication: `Send as Basic Auth header` |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | +Clicking the 'Request Token' button should retrieve a valid bearer token for use in the POST request's authorization header. Scroll down the dialog window containing the bearer token, and click the 'Use Token' button to apply it to the request. |
| 97 | + |
| 98 | + |
| 99 | + |
| 100 | +## Configuring Inputs |
| 101 | + |
| 102 | +Click the 'Body' tab on the request and it will display a sample JSON data structure illustrating the data types to use for each input. |
| 103 | + |
| 104 | + { |
| 105 | + "PresentValue": "<number>", |
| 106 | + "InterestRate": "<number>", |
| 107 | + "Periods": "<integer>" |
| 108 | + } |
| 109 | + |
| 110 | +Change the values of the inputs to reflect the desired test values: |
| 111 | + |
| 112 | + { |
| 113 | + "PresentValue": 20000.00, |
| 114 | + "InterestRate": 0.05, |
| 115 | + "Periods": 5 |
| 116 | + } |
| 117 | + |
| 118 | +## Executing the Decision Service |
| 119 | + |
| 120 | +Once the authorization header is configured with the bearer token and the inputs are populated, simply click the 'Send' button to execute the Decision Service. |
| 121 | + |
| 122 | + |
| 123 | + |
| 124 | +The repsonse panel should contain the outputs of the Decision. |
| 125 | + |
| 126 | +If the response 'Status' says `200 OK` then the Decision Service was executed successfully. |
| 127 | + |
| 128 | +# Author-Publish-Execute Code Sample |
| 129 | + |
| 130 | +For an example application that programmatically authors, publishes, and executes a Decision Service, please see the [ExecuteDecisionSample](../../Developer%20Samples/ExecuteDecisionSample) developer sample. |
0 commit comments