Library Entity Business Rules ============================= .. code-block:: http /api/repositories/{repository}/businessrules/library .. csv-table:: :header: Parameter, Type, Purpose :widths: 20, 20, 60 :stub-columns: 1 repository, string, The name of the :doc:`repository ` .. _lbr_count: Count ~~~~~~~~ .. http:get:: /api/repositories/(string:repository)/businessrules/library/count :synopsis: Get the number of business rules in the library Returns the number of business rules in the library. .. csv-table:: :header: Response Code, Reason :widths: 25, 75 200, No error 500, Server error The response contains the number of business rules in the library. .. code-block:: json { "count": "405" } .. _lbr_show_all: Show ~~~~ .. http:get:: /api/repositories/(string:repository)/businessrules/library :synopsis: List library business rules in the repository Get a list of library business rules in the :doc:`repository `. :ref:`Paging ` is supported for this GET request using :doc:`standard-url-query-string`. .. code-block:: http GET /api/repositories/jupiter/businessrules/library HTTP/1.1 Accept: application/json .. csv-table:: :header: Response Code, Reason :widths: 25, 75 200, No error 500, Server error The underlying data rows 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 a list of all the library business rules in the :doc:`repository `; this includes all :doc:`library entity business rule `. If :ref:`external JSON format ` parameter was set then the row details of all :doc:`library entity business rule ` will be returned in a :ref:`JSON key/value pair ` format. Commands ---------- .. code-block:: http POST /api/repositories/jupiter/businessrules/library HTTP/1.1 Content-Type: application/json { "command": "run", "data": { "rules": [ { "library": "2", "rule": "5" }, { "library": "2" } ] } } .. 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 request requires a :doc:`standard-request` packet. Available commands are: .. csv-table:: :header: Command, Description :widths: 30, 70 run, Run business rules belonging to any :doc:`libraryentity` list, Returns list of library business rules belonging to any library entity .. _lbr_run: Run ~~~ .. http:post:: /api/repositories/(string:repository)/businessrules/library :synopsis: Run a list of library business rules belonging to any library entity Run a list of library business rules belonging to any library entity :jsonparam body: The request body .. code-block:: http POST /api/repositories/{string:repository}/businessrules/library Content-Type: application/json { "command" : "run", "data" : { "rules": [ { "library": "2", "rule": "5" }, { "library": "2" } ] } } The request requires a :doc:`standard-request` packet. Available commands are: .. csv-table:: :header: Command, Description :widths: 30, 70 run, Run business rules belonging to any :doc:`libraryentity` .. 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 ``command``, ``rules`` and ``library`` fields are required. The ``rule`` field is optional. ``library`` should contain the library ID of the :doc:`library entity ` that the :doc:`rules ` belongs to. ``rule`` should contain the rule ID of the :doc:`library entity business rule ` that is to be run. If no ``rule`` field is passed, all business rules of the library entity ``library`` are run. .. _lbr_list: List ~~~~ .. http:post:: /api/repositories/(string:repository)/businessrules/library :synopsis: returns list of library business rules belonging to any library entity Returns list of library business rules belonging to any library entity :jsonparam body: The request body .. code-block:: http POST /api/repositories/{string:repository}/businessrules/library Content-Type: application/json { "command" : "list", "data" : { "rules": [ { "library": "2", "rule": "5" }, { "library": "2" } ] } } .. 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 ``command``, ``rules`` and ``library`` fields are required. The ``rule`` field is optional. ``library`` should contain the library ID of the :doc:`library entity ` that the :doc:`rules ` belongs to. ``rule`` should contain the rule ID of the :doc:`library entity business rule ` to get the associated business rules for a specific library rule. If no ``rule`` field is passed, all associated business rules of the library entity ``library`` will be returned. The response is a :doc:`standard-response`, with a list of all the asociated business rules in the :doc:`repository`; this includes all :doc:`entity-businessrules`. .. _lbr_export_all: Export ~~~~~~~ Some or all of the rows may be exported as a scheduled task. .. code-block:: http POST /api/repositories/jupiter/businessrules/library HTTP/1.1 Content-Type: application/json { "command": "export", "data": { "filename": "filename.csv", "filetype": "csv", "encoding": "utf-8" }, "options": { "columns": ["entity_id", "actual_name", "_associations"], "where": "'Actual Threshold' >= 10" } } .. csv-table:: :header: Response Code, Reason :widths: 25, 75 200, No error 400, Invalid data passed with request 500, Server error The request packet must contain the ``command`` and ``data`` elements. The ``options`` element is not required, but may specify the columns to export, and/or the rows to filter. The following table shows which fields are required in the ``data`` element: .. csv-table:: :header: Field, Required :widths: 20, 10 filename, Y filetype, N encoding, N If ``filetype`` is not specified, it defaults to csv. If ``encoding`` is not specified, it defaults to the server native encoding. The response will contain the URL of the scheduled task and the link to download the exported file. .. code-block:: json { "job": "/api/repositories/jupiter/scheduler/1", "file": "/api/repositories/jupiter/download/filename.csv" }