Saved Searches ============== .. code-block:: http /api/repositories/{repository}/savedsearches .. csv-table:: :header: Parameter, Type, Purpose :widths: 20, 20, 60 :stub-columns: 1 repository, string, the name of the :doc:`repository` .. _ss_show_all: Show all saved searches ~~~~~~~~~~~~~~~~~~~~~~~ .. http:get:: /api/repositories/(string:repository)/savedsearches :synopsis: List all saved searches in a repository Returns a list of all saved searches in a :doc:`repository`. The GET request supports page and pageSize parameters on the URL. If you require a subset of this data (filtering, sorting, or columns), POST to this url with the :doc:`standard request ` body. .. code-block:: http GET /api/repositories/jupiter/savedsearches HTTP/1.1 Accept: application/json .. csv-table:: :header: Response Code, Reason :widths: 25, 75 200, No error The response will be a :doc:`standard-response`. The columns displayed for each saved search are: .. csv-table:: :header: Human Name, Column Name, Description :widths: 25, 25, 50 "ID", "ID", "Internal search reference" "Name", "NAME", "The name for the saved search" "Description", "DESCRIPTION", "Business Description" "Target", "TARGET", "Target table name" "Target Type", "TARGETTYPE", "Target type of the search" "Expression", "EXPRESSION", "Expression of the search" "Created By", "CREATED_BY", "User who created the library" "Date Created", "_created_date", "When the library was created" "Edited By", "EDITED_BY", "The user who last edited the library" "Edited Date", "_edited_date", "When the library was last edited" The ``rows`` array will contain one element for each saved search: .. code-block:: json { "dataRow": [ "1", "search1", "search description", "business_rules", "table", "'Aggregate First Error'>0_aggregate_first_error0\ \ \ ", "bob", "2015/01/02 10:13:19", "", "" ], "metadata": { "url": "/api/repositories/jupiter/savedsearches/1" } } .. _ss_show_search: Show a specific saved search ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. http:get:: /api/repositories/(string:repository)/savedsearches/(int:savedSearchId) :synopsis: Return a specific saved search in a repository Returns a specific saved search in a :doc:`repository`. If you require a subset of this data (filtering, sorting, or columns), POST to this url with 'get' option defined as documented in the :doc:`standard request ` body. .. code-block:: http GET /api/repositories/jupiter/savedsearches/1 HTTP/1.1 Accept: application/json The response will same as shown above with a single element returned in the ``rows`` array. If the specified saved search does not exist, then an empty ``rows`` will be returned. Commands ~~~~~~~~ .. http:post:: /api/repositories/(string:repository)/savedsearches :synopsis: Allows to post various commands to manage and execute saved searches Allows to post various commands to manage and execute saved searches. :jsonparam body: The request body .. code-block:: http POST /api/repositories/(string:repository)/savedsearches HTTP/1.1 Content-Type: application/json { "command": "", "data": {} } The commands that can be performed against saved searches are as follows: .. csv-table:: :header: Command, Purpose :widths: 20, 80 `add`_, Add a new saved search `edit`_, Edit an existing saved search `copy`_, Copy an existing saved search `run`_, Run a saved search / Get a list of saved search expression attributes The response depends on which operation was performed. .. csv-table:: :header: Command, Response :widths: 20, 80 `add`_, Returns the url of the newly added saved search `edit`_, Returns the url of the updated saved search `copy`_, Returns the url of newly created copy of saved search `run`_, Returns a list of business rules or just the column names. See `run`_ command for more information A post 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 saved search details given 400, Invalid command 400, No data received 500, Other errors 500, Server error .. _ss_add: Add --- To add a saved search, the request may contain the fields below: .. code-block:: json { "command": "add", "data": { "name": "Test1", "description": "List all rule where threshold is equal to 25.", "expression": "'Threshold' = \"25\"" } } The required fields for adding a saved search are: + name + expression The ``description`` field is optional; it is possible to add a saved search without specifying it. .. _ss_edit: Edit ---- To edit a saved search, the request may contain the fields below: .. code-block:: json { "command": "edit", "data": { "id": "1", "name": "Test New Threshold", "description": "List all rule where threshold is greater than 25.", "expression": "'Threshold' >= \"25\"" } } The required fields for editing a saved search are: + id + name + expression The ``description`` field is optional; it is possible to add a saved search without specifying it. .. _ss_copy: Copy ---- To copy a saved search, the request may contain the fields below: .. code-block:: json { "command": "copy", "data": { "id": "1" } } The id field is required for copying an exiting saved search. .. _ss_run: Run --- The run commands can be performed against saved searches as follows: .. csv-table:: :header: Command, Data, Purpose :widths: 20, 20, 80 `run`_, id, Run a saved search `run`_, , List saved search column data The saved searches run command response is a :doc:`standard-response` with the following columns: .. csv-table:: :header: Human Name, Column Name, Description :widths: 25, 25, 50 Rule Name, actual_name, Test name. Entity Name, _ename, Entity Name. Attribute Name, _aname, Attribute name Library Rule, _model, Rule exists in libray Derived Entity, _derivedename, The associated library entity containing this rule. Derived Attibute, _derivedaname, The associated library attribute containing this rule. Entity ID, entity_id, Entity ID. Attribute ID, attribute_id, Attribute ID. Rule ID, seqno, Rule ID. Priority, actual_priority, Priority of the rule. Result, _result, Result of the test. Passing Fraction, _actual_fraction, Percentage of rows that pass the test. Status, _dirty_flag, Indicates whether the test is out of date. Description, actual_description, Test Description. Threshold, _actual_threshold, Compliance Threshold Percentage. Enabled, _check, True if the test is enabled. Priority Description, _priority_description, Description of the priority Index Control, _index_control, Compliance Threshold Percentage. Index Threshold, _index_threshold, Compliance Threshold Percentage. Expression, _predicate, The Business Rule Test. Filtering, _is_filtering, Are the rows being filtered. Filter Expression, _filter_predicate, Business Rule Filter. Filter Error Count, _filter_error_count, Number of rows that caused an error while running the filter. Filter First Error Row, _filter_first_error_row, First row that caused a filter error. Filter First Error, _filter_first_error, Error message for first row failing the filter. Grouping, _is_grouping, Are the rows being grouped. Group Count, _group_count, Number of groups found. Group Function, _group_function, Business Rule Group-by function. Group Error Count, _group_error_count, Number of rows that caused an error in the group function. Group First Error Row, _group_first_error_row, First row that caused a group function error. Group First Error, _group_first_error, Error message for first row failing the group function. Aggregating, _is_aggregating, Are the rows being aggregated. Passing Aggregate, _aggregate_pass, Aggregate value across the passing rows. Failing Aggregate, _aggregate_fail, Aggregate value across the failng rows. Aggregate Method, _aggregate_method, Method used to aggregate. Aggregate Function, _aggregate_function, Business Rule Aggregate function. Aggregate Error Count, _aggregate_error_count, Number of rows that caused an error in the aggregate function. Aggregate First Error Row, _aggregate_first_error_row, First row that caused an aggregate function error. Aggregate First Error, _aggregate_first_error, Error message for first row failing the aggregate function. Fail Count, _row_fail_count, Number of Rows that Fail the Test. Pass Count, _row_pass_count, Number of Rows that Pass the Test. Rows Processed, _row_total, Number of Rows processed. Row Total, row_total, Total Number of Rows. Created By, CREATED_BY, Who created this business rule. Created Date, _created_date, When this business rule was created. Edited By, EDITED_BY, Who changed this business rule. Edited Date, _edited_date, When this business rule was changed. Error Count, _row_error_count, Number of rows that caused an error while running the Test. First Error Row, _first_fail_row, First row that caused an error. First Error, _first_error, Error message for first failing row. Referenced Attributes, refd_atts, A list of the attributes referenced by this rule. XML, actual_predicate, Business Rule represented in XML. Library Rule (boolean), model, Is rule located in library Identifier, actual_uuid, The rule identifier. Local identifier, _local_identifier, A unique identifier for the rule. Rule Categories, _rule_categories, Business Rule categories. Associations, _associations, Are there any associations for this rule. NOTE: - The Associations column displays number of associations for a :doc:`libraryentitybusinessrule` only. - Empty Associations column will be displayed for all other business rules. Run Saved Search ++++++++++++++++ To run saved search, the request contain the fields below: .. code-block:: json { "command": "run", "data": { "id": "1" } } The ``id`` field is required to run a specific saved search. If you require a subset of this data (filtering, sorting, or columns), specify the required options as defined as documented in the :doc:`standard request ` body. The response is a :doc:`standard-response`, with the rows array containing list of all the business rules in the :doc:`repository` that matches the saved search criteria. List Saved Search Columns +++++++++++++++++++++++++ To retrieving a list of saved search column names; these column names are required to build humanised expressions for the saved search; the request contain the fields below: .. code-block:: json { "command": "run" } The response is a :doc:`standard-response`, with an empty rows array. .. _ss_delete: Delete ~~~~~~ .. http:delete:: /api/repositories/(string:repository)/savedsearches/(int:savedSearchId) :synopsis: Delete a specific saved search in a repository Delete a specific saved search in a :doc:`repository` .. code-block:: http DELETE /api/repositories/jupiter/savedsearches/1 HTTP/1.1 Accept: application/json .. csv-table:: :header: Response Code, Reason :widths: 25, 75 200, Success 500, Invalid parameters 500, Server error If the delete is successful, the response will contain a URL to list all the remaining saved searches.