Regula v0.1.0 Regula.Client View Source
A low-level Regula client that performs HTTP requests on the server API while providing a retry mechanism.
Retry attempts can be configured by adjusting client.max_attempts
.
Link to this section Summary
Functions
Evaluates a ruleset against given parameters and (optional) version
Returns the headers carried by http requests to the server api
Lists all rulesets that matches the given prefix
. Returns server’s response as a map
Link to this section Types
Link to this section Functions
Evaluates a ruleset against given parameters and (optional) version.
Returns {:ok, %Regula.EvalResult{}}
.
If there is an error, if will be retried if possible. After client.max_attemtps
the error {:error, reason}
is returned.
Returns the headers carried by http requests to the server api.
Lists all rulesets that matches the given prefix
. Returns server’s response as a map.
Options:
limit
: max rulesets being returnedcontinue
: token used when browsing further pages, allows to list the nextlimit
rulesets
continue
token can be found in the response of a list/3
call, given there are rulesets left.
If there is an error, if will be retried if possible. After client.max_attemtps
the error {:error, reason}
is returned.
Example
# Grab the first ten rulesets that start with "foo"
iex> Regula.list(client, "foo", limit: 10)
[
%{
"continue" => "Zm9vL2Jhci8xOG1OMGx5aWRLZEpibkZXQktGdDZBRmpGaDMA",
"revision" => "6",
"rulesets" => [...]
}
]
# Grab the next ten rulesets that start with "foo"
iex> Regula.list(client, "foo", limit: 10, continue: "Zm9vL2Jhci8xOG1OMGx5aWRLZEpibkZXQktGdDZBRmpGaDMA")
[
%{ # no "continue" key, meaning we reached the end
"revision" => "6",
"rulesets" => [...]
}
]