Open topic with navigation

# Use a Request Cooker

A request cooker is similar to a query cooker, but it modifies the whole action, rather than only the query text. For example, you can use a request cooker to add extra parameters to the query that users send to HPE QMS.

You can configure the request cooker to be an external service, or you can use a Lua script.

When you use a request cooker, HPE QMS sends the original action to the cooker. The cooker returns the modified request, and HPE QMS applies whitelist, then blacklist, and then query text processing to it as necessary.

The cooker must specify the whole action to use.

## Request Cooker Lua Scripts

The Lua script must provide a globally accessible `cook_request` function, which accepts a string representation of the request as its only argument. The function must return a Lua table. The keys of this table are the parameter names to use in the action (the parameter names must be in lower case). The table values are the corresponding request values.

QMS loads the Lua script for every request that it cooks. This means that any changes to the script are reflected immediately in the query behavior.

The following example request cooker Lua script sets `MaxResults` to `10` for all queries:

    -- load module that provides string to table request parser
    aci = require "autn_aci"
    -- Set maxresults to 10 on every query
    function cook_request(request_string)
      cooked_request = aci.parse_request_string(request_string)
      cooked_request["maxresults"] = 10
      return cooked_request
    end

## Configure the Request Cooker

The following procedure describes how to configure HPE QMS to use a request cooker from an external service, or a Lua script.

To use a request cooker

1. Open the HPE QMS configuration file in a text editor.

2. Add a `[RequestCooker]` section to the HPE QMS configuration file.

3. If you want to use a request cooker on an external server, specify the host and port information of the server and set `Mode` to `legacy` in the `[RequestCooker]` section of the configuration file. For example:

       [RequestCooker]
       Host=12.3.4.56
       Port=8080
       Mode=legacy

4. If you want to use a custom Lua script for request cooking, set `Mode` to `lua` in the `[RequestCooker]` section of the configuration file, and set `Script` to the path to the script that you want to use. For example:

       [RequestCooker]
       Script=qms\lua\cookrequest-maxresults.lua
       Mode=lua

5. Send queries to HPE QMS with the `CookRequest` parameter set to `True`.

   If you want to cook all requests that you send to HPE QMS, set the `CookAllRequests` configuration parameter to `True`.

Refer to the QMS Reference for more information on how to configure query cooking.

© 2017 Hewlett Packard Enterprise Development LP | Send documentation feedback to HPE Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a web mail client, and send this email to AutonomyTPFeedback@hpe.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_HP_HTML5_bannerTitle.htm