Create and Manage Rules
Note:
Enterprise Edition only
This API creates new rules, updates existing rules, and deletes rules.
A ruleset is an array of rules where order matters. The most high priority rule is first, and so on. Through the WLM REST API, you interact with the ruleset, not any individual rules.
When you remove a rule from the ruleset (the array of rules) list, it is deleted.
Syntax
Method and URLPUT /api/v3/wlm/rule
Request Input
When new rules are added, acceptName
and id
do not need to be specified.
{
"tag": "0",
"rules": [
{
"name": "Rule name",
"conditions": "query condition",
"acceptId": "ID",
"acceptName": "Rule name",
"action": "PLACE",
"id": "ID"
}
]
}
Response Output
Response output{
"tag": "0",
"rules": [
{
"name": "Rule name",
"conditions": "query condition",
"acceptId": "ID",
"acceptName": "Rule name",
"action": "PLACE",
"id": "ID"
}
]
}
Response Codes
400
- Invalid body.
403
- User does not have permission to update this rule.
404
- Rule doesn’t exist.
409
- Conflict, rule has been modified (version conflict).
Request Example: Updating a rule
CURL
curl request examplecurl --request PUT \
--url http://localhost:9047/api/v3/wlm/rule \
--header 'authorization: _dremioha5lrg03obu07o4fkaev5e4r8n' \
--header 'content-type: application/json' \
--data '{ "tag": "0", "rules": [ { "name": "Users Rule", "conditions": "USER in ('\''user1'\'', '\''user2'\'')", "acceptId": "360fa7c1-a691-4d42-a045-8c066abb4990", "action": "PLACE" }, { "name": "UI Previews", "conditions": "query_type() = '\''UI Preview'\''", "acceptId": "a7606f6e-6240-4fd6-bfcd-dc191d8295d7", "acceptName": "UI Previews", "action": "PLACE", "id": "04dc84b0-a33d-41d1-8bf1-c9914b305d16" }, { "name": "High Cost Reflections", "conditions": "query_type() = '\''Reflections'\'' AND query_cost() >= 30000000", "acceptId": "3736910c-507b-4527-8aa1-41544ba7eb3a", "acceptName": "High Cost Reflections", "action": "PLACE", "id": "a02c33f0-8c34-4129-9a4f-1ca9daacf3b0" }, { "name": "Low Cost Reflections", "conditions": "query_type() = '\''Reflections'\'' AND query_cost() < 30000000", "acceptId": "54b6941b-6d3a-4b71-977b-1ec3029dda9a", "acceptName": "Low Cost Reflections", "action": "PLACE", "id": "e5844b2b-c6f8-4e95-abc5-f45818a09f78" }, { "name": "High Cost User Queries", "conditions": "query_cost() >= 30000000", "acceptId": "19f8fde2-66e8-403e-b0e1-c01c5d14b9b1", "acceptName": "New Queue", "action": "PLACE", "id": "1b8760dc-ecff-4429-9453-0a26719221bd" }, { "name": "Low Cost User Queries", "conditions": "query_cost() < 30000000", "acceptId": "360fa7c1-a691-4d42-a045-8c066abb4990", "acceptName": "Low Cost User Queries", "action": "PLACE", "id": "6eac41cc-811a-4a28-92f5-ca9fc0182186" } ] }'
Python
Python request exampleimport requests
url = "http://localhost:9047/api/v3/wlm/rule"
payload = "{ \"tag\": \"0\", \"rules\": [ { \"name\": \"Users Rule\", \"conditions\": \"USER in ('user1', 'user2')\", \"acceptId\": \"360fa7c1-a691-4d42-a045-8c066abb4990\", \"action\": \"PLACE\" }, { \"name\": \"UI Previews\", \"conditions\": \"query_type() = 'UI Preview'\", \"acceptId\": \"a7606f6e-6240-4fd6-bfcd-dc191d8295d7\", \"acceptName\": \"UI Previews\", \"action\": \"PLACE\", \"id\": \"04dc84b0-a33d-41d1-8bf1-c9914b305d16\" }, { \"name\": \"High Cost Reflections\", \"conditions\": \"query_type() = 'Reflections' AND query_cost() >= 30000000\", \"acceptId\": \"3736910c-507b-4527-8aa1-41544ba7eb3a\", \"acceptName\": \"High Cost Reflections\", \"action\": \"PLACE\", \"id\": \"a02c33f0-8c34-4129-9a4f-1ca9daacf3b0\" }, { \"name\": \"Low Cost Reflections\", \"conditions\": \"query_type() = 'Reflections' AND query_cost() < 30000000\", \"acceptId\": \"54b6941b-6d3a-4b71-977b-1ec3029dda9a\", \"acceptName\": \"Low Cost Reflections\", \"action\": \"PLACE\", \"id\": \"e5844b2b-c6f8-4e95-abc5-f45818a09f78\" }, { \"name\": \"High Cost User Queries\", \"conditions\": \"query_cost() >= 30000000\", \"acceptId\": \"19f8fde2-66e8-403e-b0e1-c01c5d14b9b1\", \"acceptName\": \"New Queue\", \"action\": \"PLACE\", \"id\": \"1b8760dc-ecff-4429-9453-0a26719221bd\" }, { \"name\": \"Low Cost User Queries\", \"conditions\": \"query_cost() < 30000000\", \"acceptId\": \"360fa7c1-a691-4d42-a045-8c066abb4990\", \"acceptName\": \"Low Cost User Queries\", \"action\": \"PLACE\", \"id\": \"6eac41cc-811a-4a28-92f5-ca9fc0182186\" } ] }"
headers = {
'authorization': "_dremioha5lrg03obu07o4fkaev5e4r8n",
'content-type': "application/json"
}
response = requests.request("PUT", url, data=payload, headers=headers)
print(response.text)
Response
Response output{
"tag": "1",
"rules": [
{
"name": "Users Rule",
"conditions": "USER in ('user1', 'user2')",
"acceptId": "360fa7c1-a691-4d42-a045-8c066abb4990",
"acceptName": "Low Cost User Queries",
"action": "PLACE",
"id": "6244459e-8c3f-4a2b-a900-530d0582d93c"
},
{
"name": "UI Previews",
"conditions": "query_type() = 'UI Preview'",
"acceptId": "a7606f6e-6240-4fd6-bfcd-dc191d8295d7",
"acceptName": "UI Previews",
"action": "PLACE",
"id": "04dc84b0-a33d-41d1-8bf1-c9914b305d16"
},
{
"name": "High Cost Reflections",
"conditions": "query_type() = 'Reflections' AND query_cost() >= 30000000",
"acceptId": "3736910c-507b-4527-8aa1-41544ba7eb3a",
"acceptName": "High Cost Reflections",
"action": "PLACE",
"id": "a02c33f0-8c34-4129-9a4f-1ca9daacf3b0"
},
{
"name": "Low Cost Reflections",
"conditions": "query_type() = 'Reflections' AND query_cost() < 30000000",
"acceptId": "54b6941b-6d3a-4b71-977b-1ec3029dda9a",
"acceptName": "Low Cost Reflections",
"action": "PLACE",
"id": "e5844b2b-c6f8-4e95-abc5-f45818a09f78"
},
{
"name": "High Cost User Queries",
"conditions": "query_cost() >= 30000000",
"acceptId": "19f8fde2-66e8-403e-b0e1-c01c5d14b9b1",
"acceptName": "New Queue",
"action": "PLACE",
"id": "1b8760dc-ecff-4429-9453-0a26719221bd"
},
{
"name": "Low Cost User Queries",
"conditions": "query_cost() < 30000000",
"acceptId": "360fa7c1-a691-4d42-a045-8c066abb4990",
"acceptName": "Low Cost User Queries",
"action": "PLACE",
"id": "6eac41cc-811a-4a28-92f5-ca9fc0182186"
}
]
}
Ruleset Example: Deleting a rule
In this Ruleset example, you delete the UI Previews
rule a lower priority by removing it from the array.
{
"tag": "0",
"rules": [
{
"name": "High Cost Reflections",
"conditions": "query_type() = 'Reflections' AND query_cost() >= 30000000",
"acceptId": "3736910c-507b-4527-8aa1-41544ba7eb3a",
"acceptName": "High Cost Reflections",
"action": "PLACE",
"id": "a02c33f0-8c34-4129-9a4f-1ca9daacf3b0"
},
{
"name": "Low Cost Reflections",
"conditions": "query_type() = 'Reflections' AND query_cost() < 30000000",
"acceptId": "54b6941b-6d3a-4b71-977b-1ec3029dda9a",
"acceptName": "Low Cost Reflections",
"action": "PLACE",
"id": "e5844b2b-c6f8-4e95-abc5-f45818a09f78"
},
{
"name": "High Cost User Queries",
"conditions": "query_cost() >= 30000000",
"acceptId": "19f8fde2-66e8-403e-b0e1-c01c5d14b9b1",
"acceptName": "New Queue",
"action": "PLACE",
"id": "1b8760dc-ecff-4429-9453-0a26719221bd"
},
{
"name": "Low Cost User Queries",
"conditions": "query_cost() < 30000000",
"acceptId": "360fa7c1-a691-4d42-a045-8c066abb4990",
"acceptName": "Low Cost User Queries",
"action": "PLACE",
"id": "6eac41cc-811a-4a28-92f5-ca9fc0182186"
}
]
}
Ruleset Example: Making a rule a lower priority
In this Ruleset example, you make the UI Previews
rule a lower priority by moving it to the bottom of the array.
{
"tag": "0",
"rules": [
{
"name": "High Cost Reflections",
"conditions": "query_type() = 'Reflections' AND query_cost() >= 30000000",
"acceptId": "3736910c-507b-4527-8aa1-41544ba7eb3a",
"acceptName": "High Cost Reflections",
"action": "PLACE",
"id": "a02c33f0-8c34-4129-9a4f-1ca9daacf3b0"
},
{
"name": "Low Cost Reflections",
"conditions": "query_type() = 'Reflections' AND query_cost() < 30000000",
"acceptId": "54b6941b-6d3a-4b71-977b-1ec3029dda9a",
"acceptName": "Low Cost Reflections",
"action": "PLACE",
"id": "e5844b2b-c6f8-4e95-abc5-f45818a09f78"
},
{
"name": "High Cost User Queries",
"conditions": "query_cost() >= 30000000",
"acceptId": "19f8fde2-66e8-403e-b0e1-c01c5d14b9b1",
"acceptName": "New Queue",
"action": "PLACE",
"id": "1b8760dc-ecff-4429-9453-0a26719221bd"
},
{
"name": "Low Cost User Queries",
"conditions": "query_cost() < 30000000",
"acceptId": "360fa7c1-a691-4d42-a045-8c066abb4990",
"acceptName": "Low Cost User Queries",
"action": "PLACE",
"id": "6eac41cc-811a-4a28-92f5-ca9fc0182186"
},
{
"name": "UI Previews",
"conditions": "query_type() = 'UI Preview'",
"acceptId": "a7606f6e-6240-4fd6-bfcd-dc191d8295d7",
"acceptName": "UI Previews",
"action": "PLACE",
"id": "04dc84b0-a33d-41d1-8bf1-c9914b305d16"
}
]
}