Business Rule ============= .. code-block:: http /api/repositories/{repository}/entities/{entityID}/businessrules/{ruleID} .. csv-table:: :header: Parameter, Type, Purpose :widths: 20, 20, 60 :stub-columns: 1 repository, string, The name of the :doc:`repository` the entity is in entityID, int, The ID of the :doc:`entity` the rule belongs to ruleID, int, The ID of the desired rule .. http:get:: /api/repositories/(string:repository)/entities/(int:entityID)/businessrules/(int:ruleID) :synopsis: Show a specific business rule Get the details of the business rule from the :doc:`repository` .. http:post:: /api/repositories/(string:repository)/entities/(int:entityID)/businessrules/(int:ruleID) :synopsis: Edit or run the business rule Edit or run the business rule :jsonparam body: The request body .. http:delete:: /api/repositories/(string:repository)/entities/(int:entityID)/businessrules/(int:ruleID) :synopsis: Delete the business rule Delete the business rule .. _br_show: Show ~~~~ .. code-block:: http GET /api/repositories/jupiter/entities/1/businessrules/1 HTTP/1.1 Accept: application/json .. csv-table:: :header: Response Code, Reason :widths: 25, 75 200, No error 500, Server error The underlying row data of a business rule for the :doc:`entity` can be returned in a :ref:`JSON key/value pair ` by setting the :ref:`external JSON format ` parameter. This allows access by different external tools that requires the JSON data in a key/value pair instead of standard array of row data with columns names defined separately. The response is a :doc:`standard-response`, with the details of the business rule. If :ref:`external JSON format ` parameter was set then the details of the business rule will be returned in a :ref:`JSON key/value pair ` format. .. _br_edit: Edit ~~~~ The request requires a :doc:`standard-request` packet. The ``command`` field must be ``edit``; see the :ref:`edit command ` for the contents of the request. The request may return any of the following status codes: .. csv-table:: :header: Response Code, Reason :widths: 25, 75 200, Success 400, Invalid request body 400, No rule details given 400, Invalid command 400, No data received 500, Server error .. code-block:: http POST /api/repositories/jupiter/entities/1/businessrules/1 HTTP/1.1 Content-Type: application/json { "command": "edit", "data": { "NAME" : "Rule4", "DESCRIPTION" : "description", "ENABLED" : "1", "EXPRESSION" : "attr2>0", "FILTER_EXPRESSION" : "new2>9", "GROUP_EXPRESSION" : "new5=0", "GROUP_LIMIT" : "0", "AGGREGATE_EXPRESSION" : "acc_id<0", "AGGREGATE_METHOD" : "0", "PRIORITY" : "1", "THRESHOLD" : "100", "INDEX_CONTROL":"", "INDEX_THRESHOLD":"", "RULE_KEYWORD_ID_LIST":"1 0:2 1" } } The table below shows all the fields that are available for edit. .. csv-table:: :header: Field, Description, Values :widths: 20, 25, 55 EXPRESSION, "Humanized expression" THRESHOLD, "Numerical threshold value", Between 0 to 100 ENABLED, "Rule is enabled or disabled", 0 (Disabled) or 1 (Enabled) DESCRIPTION, "Description of the library rule" FILTER_EXPRESSION, "Humanized expression for filter" AGGREGATE_EXPRESSION, "Humanized aggregate expression" GROUP_EXPRESSION, "Humanized group expression" GROUP_LIMIT, "Numerical value for group limit" AGGREGATE_METHOD, "Name of aggregate method", See :ref:`below ` for values INDEX_CONTROL, "Numeric value", See :ref:`below ` for values INDEX_THRESHOLD, "Valid only if `INDEX_CONTROL` is 2" PRIORITY, "Numeric value between 1 and 10" RULE_KEYWORD_ID_LIST, "Array of keyword IDs", List of separated by colon. A value of 0 in keyword_id fields specify that the rule is attached to all the keywords of that category. All the fields are optional. .. _br_agg_meth_table: **Aggregate Method** .. csv-table:: :header: Value, Method 0, Sum 1, Average 2, Maximum 3, Minimum 4, Count .. _br_index_ctrl_table: **Index Control** .. csv-table:: :header: Value, Method 0, Normal 1, Unlimited 2, Limited If the request is successful, the response will contain the URL of the updated business rule. .. _br_run: Run ~~~ .. code-block:: http POST /api/repositories/jupiter/entities/1/businessrules/1 HTTP/1.1 Content-Type: application/json { "command": "run", "data": { "ENTITY": "EID", "OPTION": "Analysis options (See below)", "RULE_IDS": [ "EID AID RID" ] } } The request requires a :doc:`standard-request` packet. The ``command`` field must be ``run``; see the :ref:`run command ` for the contents of the request. The request may return any of the following status codes: .. csv-table:: :header: Response Code, Reason :widths: 25, 75 200, Success 400, Invalid request body 400, No rule details given 400, Invalid command 400, No data received 500, Server error The response will contain the URL of the :doc:`scheduled job `. .. _br_delete: Delete ~~~~~~ .. code-block:: http DELETE /api/repositories/jupiter/entities/1/businessrules/1 HTTP/1.1 The business rule will be deleted. The request may return any of the following status codes: .. csv-table:: :header: Response Code, Reason :widths: 25, 75 200, Success 400, Expected array of rules(s) within request body 400, No rule(s) found within request body 400, No data received 500, Invalid parameters 500, Server error If the delete is successful, the response will contain a url pointing at the :doc:`entity` that owned the rule.