Skip to content

Commit 11c603c

Browse files
author
Steven Kuhn
authored
Merge pull request InRule#56 from InRule/issue/1886-decision-docs
Add documentation for Decision Services
2 parents a05ccf3 + 8fb7771 commit 11c603c

33 files changed

+544
-0
lines changed

Authoring Samples/Decisions/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Decision Services
2+
====
3+
4+
Decision Services is the newest member of InRule®'s Decision Platform. It provides an improved decision-centric model for authoring and executing rules, as well as an integration model that is standards-based that does not require deep knowledge of our SDK.
5+
6+
A Decision in Decision Services is an entry point into rule exection. It consists of a set of inputs, rules that execute against those inputs, and a set of ouputs that reflect the result. Those inputs, outputs, and rules are author-defined, ultimately providing rule authors flexibility of shaping the input and output signature used during runtime execution.
7+
8+
Once authored is complete, Decisions can be tested in irVerify and subsequently published to a Decision Runtime for remote execution via a RESTful API. The Decision Runtime provides an OpenAPI (formerly known as Swagger) document which is a programming language-agnostic description on how to execute the published Decisions, including each Decision's required input and output result.
9+
10+
# Prerequisites
11+
12+
Before you get started, you'll need to make sure you have the following:
13+
14+
* For authoring and testing Decisions, [irAuthor 5.5.0](https://support.inrule.com/downloads.aspx) or greater.
15+
16+
* For publishing and executing Decisions, access to a [Decision Runtime Service](#decision-runtime-service) using [Centralized Authentication](#centralized-authentication). Please contact [InRule Support](mailto:[email protected]) to request access.
17+
18+
### Decision Runtime Service
19+
20+
The Decision Runtime Service is responsible for storing and executing published Decisions. It also provides several OpenAPI documents based on the [OpenAPI specification](https://www.openapis.org/) (both [2.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md) and [3.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md)) as well as a [SwaggerUI](https://swagger.io/tools/swagger-ui/) interface. This allows integration with 3rd party tools like [Postman](https://www.getpostman.com/) or generating client code based on your published decisions.
21+
22+
### Centralized Authentication
23+
24+
Instead of relying on an irCatalog instance for authentication, InRule's hosted Decision Runtime Service integrates with its Centralized Authentication solution (running on the [Auth0](https://auth0.com/) platform). This authentication solution provides customers the ability to authenticate using external authentication providers including Azure Active Directory or any OpenID Connect compatible provider.
25+
26+
# Getting Started
27+
28+
- [Authoring a Decision](author-decision.md)
29+
- [Testing a Decision](test-decision.md)
30+
- [Publishing a Decision](publish-decision.md)
31+
- [Executing a published Decision](execute-decision.md)
32+
33+
# Integrations
34+
35+
- [Power Automate (previously Microsoft Flow)](integrations/power-automate.md)
36+
37+
# Notes
38+
39+
InRule v5.5.0 includes additional classes in irSDK® to support Decisions. To make upgrading as painless as possible, the new data structures are persisted to files or irCatalog® in Attributes of the RuleApplicationDef.
40+
41+
This removes the need to running a feature version upgrade on irCatalog to use these new features.
42+
43+
Additionally the restriction on unique Entity Rule Set names has been removed, so long as they don't collide with existing Independent Rule Sets. This allows Rul eSets with the same names to exist under both Entities and Decisions.
44+
45+
# Limitations
46+
47+
* The majority of Rule Application authoring scenarios should inter-operate between versions 5.3.1-5.4.3 and 5.5.0 of irSDK/irAuthor/irCatalog. Howevever, there are [several edge cases](known-issues.md#mix-version-use-of-irsdkirauthorircatalog) that are not supported at this time.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Authoring a Decision in irAuthor
2+
====
3+
4+
# Adding a Decision
5+
6+
A Decision can be added from the Decisions navigation panel.
7+
8+
![Decision Navigation Panel](images/AuthorDecision-DecisionsNavPanel.png)
9+
10+
Every new decision contains a single Rule Set named 'DecisionStart'. Any rules added to that Rule Set will execute automatically when the that Decision is executed.
11+
12+
Additional explicit Rule Sets may be added to the Decision. These Rule Sets will execute only when called from the 'DecisionStart' Rule Set or from other Rule Sets within the same decision via the ExecuteRuleSet action. If an explicit Rule Set in a Decision is not explictly called via ExecuteRuleSet, then that Rule Set will not execute.
13+
14+
Entity based Rule Sets can also be called from a Decision based rule set. This preserves the ability to author rules in the context of an Entity.
15+
16+
# Editing a Decision
17+
18+
When a Decision is selected in the Decisions navigation panel, the irAuthor content panel displays the Decision editor.
19+
20+
![Decision Editor](images/AuthorDecision-DecisionEditor.png)
21+
22+
## Inputs and Outputs
23+
24+
Inputs and outputs may be added or removed using the ![Add](images/AuthorDecision-DecisionInputOutputAddButton.png) and ![Remove](images/AuthorDecision-DecisionInputOutputRemoveButton.png) buttons next to their data grids.
25+
26+
When an input or output is added to the Decision, its 'Name' and 'Data Type' may be assigned. The Data Type may be any primitive data type inrule supports (Boolean, Data, DateTime, Decimal, Integer, Text), or an Entity previously authored in the Rule Application. An Entity input or output may be defined as an Entity Collection by checking the 'Is Collection' checkbox in the right-hand column.
27+
28+
## Vocabulary
29+
30+
Authors can create a vocabulary that allows them to make rules that read like regular English. The vocabulary is a collection of English-language phrases, or more accurately, templates of English-language phrases, each connected to a value it will represent, or to an action it will take.
31+
32+
Vocabulary may be authored by clicking the 'Create vocabulary' hyperlink at the bottom of the Decision editor. This allows business language vocabulary to be authored in the context of this Decision, which is available to Rules in any of its Rule Sets.
33+
34+
# Rule Authoring
35+
36+
Rules and actions may be added to Decision Rule Sets the same way that they may be added to Entity Rule Sets or Independent Rule Sets.
37+
38+
All Decision Rule Sets are confined to explicit fire-mode. Any additional Rule Set added to the Decision may define parameters, however the 'DecisionStart' default Rule Set may not.
39+
40+
![DecisionRules](images/AuthorDecision-DecisionRules.png)
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
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+
![Execute Decision Swagger Operations](images/ExecuteDecision-SwaggerExecuteDecisions.png)
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+
![Execute Decision Authorize Button](images/ExecuteDecision-AuthorizeButton.png)
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+
![Select a definition drop down](images/ExecuteDecision-PublishedDecisionsDropDown.png)
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+
![Execute Decision Swagger Operations](images/ExecuteDecision-SwaggerOperations.png)
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+
![Execute Decision Postman Import OpenAPI](images/ExecuteDecision-PostmanImportOpenAPI.png)
68+
69+
Enable the 'Generate a Postman Collection' option:
70+
71+
![Execute Decision Postman Import OpenAPI](images/ExecuteDecision-PostmanImportOptions.png)
72+
73+
After importing the OpenAPI specification, the Decision Services will be available in the collections list:
74+
75+
![Execute Decision Postman CollectionsI](images/ExecuteDecision-PostmanCollections.png)
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+
![Execute Decision Postman New Token](images/ExecuteDecision-PostmanNewToken.png)
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+
![Execute Decision Postman Bearer Token](images/ExecuteDecision-PostmanBearerToken.png)
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+
![Execute Decision Postman Response](images/ExecuteDecision-PostmanResponse.png)
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.
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Integrate with Power Automate (previously Microsoft Flow)
2+
====
3+
4+
The Decision Runtime Service for Decisions Services provides an OpenAPI 2.0 document specific for Power Automate. That document can be found at a url similar to:
5+
6+
`https://myorg-decisions.inrulecloud.com/api/decisions/powerautomate.json`
7+
8+
With that document (either by using the URL or saving it locally) you can create a custom connector that can be used in Flows to execute Decisions.
9+
10+
You can find information on how to create a customer connector for Power Automate from Microsoft [here](https://docs.microsoft.com/en-us/connectors/custom-connectors/define-openapi-definition#import-the-openapi-definition-for-microsoft-flow-and-powerapps).
11+
12+
When you get to the step of "[Review authentication Type](https://docs.microsoft.com/en-us/connectors/custom-connectors/define-openapi-definition#import-the-openapi-definition-for-microsoft-flow-and-powerapps)", you can use the following settings (some will be populated automatically):
13+
14+
* **Authentication Type**: `OAuth 2.0`
15+
16+
* **OAuth 2.0**
17+
* **Identity Provider**: `Generic Oauth 2`
18+
* **Client id**: `CLIENT_ID_GOES_HERE`<br />
19+
This will provided to you when granted access to a Decision Runtime Service environment. Please contact [InRule Support](mailto:[email protected]) to request access.
20+
* **Client secret**: `CLIENT_SECRET_GOES_HERE`<br />
21+
This will provided to you when granted access to a Decision Runtime Service environment. Please contact [InRule Support](mailto:[email protected]) to request access.
22+
* **Authorization URL**: `https://auth.inrulecloud.com/authorize`<br />
23+
The API authorization endpoint to authenticate with the service.
24+
* **Token URL**: `https://auth.inrulecloud.com/oauth/token`<br />
25+
The API endpoint to get the access token after the authorization has been done.
26+
* **Refresh URL**: `https://auth.inrulecloud.com/oauth/token`<br />
27+
The API endpoint to refresh the access token once it has expired. (This is the same as the Token URL)
28+
* **Scope**: `offline`
29+
Requires `offline` in order to provide a refresh token.
30+
31+
Once those settings are in place, you should be able to create the connector and use that custom connector in your [logic apps](https://docs.microsoft.com/en-us/connectors/custom-connectors/use-custom-connector-logic-apps), [flows](https://docs.microsoft.com/en-us/connectors/custom-connectors/use-custom-connector-flow), or [PowerApps apps](https://docs.microsoft.com/en-us/connectors/custom-connectors/use-custom-connector-powerapps). Please refer to the [Microsoft documentation](https://docs.microsoft.com/en-us/connectors/custom-connectors/) for more information on custom connectors and Power Automate.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Known Issues
2+
====
3+
4+
# Mix Version Use of irSDK/irAuthor/irCatalog
5+
6+
The majority of Rule Application authoring scenarios should inter-operate between versions 5.3.1-5.4.3 and 5.5.0 of irSDK/irAuthor/irCatalog. However, the following edge cases exist where unexpected behavior may occur:
7+
8+
* Using v5.5.0 irAuthor/irSDK to check-in a Rule Application to a v5.5.0 irCatalog with duplicate RuleSet names under different Entities.
9+
10+
* Validation with v5.3.1 irAuthor/irSDK will fail with duplicate RuleSet error.
11+
12+
* Using v5.5.0 irAuthor/irSDK to check-in a Rule Application to a v5.3.1 irCatalog with duplicate RuleSet names under different Entities.
13+
14+
* Check-in will fail with duplicate RuleSet validation error.
15+
16+
* Using v5.5.0 irAuthor/irSDK to check-in a Rule Application to a v5.5.0 irCatalog with a Decision Input/Output referencing Entity 'Entity1'.
17+
18+
* irAuthor/irSDK v5.3.1 checks-out the Rule Application, renames 'Entity1' to 'Entity2', and attempts to check-in the Rule Application.
19+
20+
* Check-in will fail with error like "Unable to resolve Entity1 to an entity [Decision1.Input1]".
21+
22+
* Using v5.5.0 irAuthor/irSDK to check-in a Rule Application to a v5.3.1 irCatalog with a Decision Input/Output referencing Entity 'Entity1'.
23+
24+
* irAuthor/irSDK v5.3.1 checks-out the Rule Application, renames 'Entity1' to 'Entity2', and checks-in the Rule Application successfully.
25+
26+
* irAuthor/irSDK v5.5.0 gets latest Rule Application from irCatalog successfully, but irAuthor/irSDK validation fails with error like "Unable to resolve Entity1 to an entity [Decision1.Input1]".
27+
28+
* Using v5.5.0 irAuthor/irSDK to check-in a Rule Application to a v5.5.0 irCatalog with a Decision Input/Output referencing Entity 'Entity1' and a Decision rule referencing 'Field1' on that Entity.
29+
30+
* irAuthor/irSDK v5.3.1 checks-out the Rule Application, renames 'Field1' to 'Field2', and attempts to check-in the Rule Application.
31+
32+
* Check-in will fail with error like "Unable to resolve 'Input1.Field1' in context 'Decision1.DecisionStart.SetValue1' [--> Input1.Field1 <--] [Decision1.DecisionStart.SetValue1]"
33+
34+
* Using v5.5.0 irAuthor/irSDK to check-in a Rule Application to a v5.3.1 irCatalog with a Decision Input/Output referencing Entity 'Entity1' and a Decision rule referencing 'Field1' on that Entity.
35+
36+
* irAuthor/irSDK v5.3.1 checks-out the Rule Application, renames 'Field1' to 'Field2', and checks-in the Rule Application.
37+
38+
* irAuthor/irSDK v5.5.0 gets latest Rule Application from irCatalog successfully, but irAuthor/irSDK validation fails with error like "Unable to resolve 'Input1.Field1' in context 'Decision1.DecisionStart.SetValue1' [--> Input1.Field1 <--] [Decision1.DecisionStart.SetValue1]".
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Publishing a Decision
2+
====
3+
4+
irAuthor contains a feature to publish Decisions so they are available for remote execution on the Decision Runtime. The 'Publish Decision' button can be found in the 'Home' tab.
5+
6+
![Publish Decision Home Tab](images/PublishDecision-IrAuthorHomeTab.png)
7+
8+
This opens a dialog window to enter the Decision Runtime URL, and select a Decision from the Rule Application to publish.
9+
10+
![Publish Decision Dialog](images/PublishDecision-PublishDialog.png)
11+
12+
The Decision Runtime URL must be a valid URL of a Decision Runtime. Any URLs used here will be saved in the drop-down menu for future use. The last used URL will always be at the top of the list.
13+
14+
If a Decision or any of its Rule Sets or Rules are selected in the navigation panel, this will be the Decision selected by default in the 'Decision' drop-down menu, otherwise the first Decision will be selected.
15+
16+
In order to successfully publish a Decision, the user must first be authenticated with the Decision Runtime. If irAuthor is not currently logged in to the centralized authentication, a login window will prompt for the user's email address and password.
17+
18+
![Publish Decision Centralized Authentication](images/PublishDecision-CentralizedAuthentication.png)
19+
20+
When attempting to publish a Decision whose name already exists on the Decision Runtime, a confirmation dialog window will ask whether the existing Decision should be overwritten.
21+
22+
![Publish Decision Overwrite Existing Dialog](images/PublishDecision-OverwriteExistingDialog.png)
23+
24+
When a Decision is published successfully, a dialog window will confirm this.
25+
26+
![Publish Decision Success Dialog](images/PublishDecision-Success.png)

0 commit comments

Comments
 (0)