Query parameter manipulation
Functions that aid in the parsing, serialization, and manipulation of PuppetDB queries embedded in HTTP parameters.
Query parameter manipulation Functions that aid in the parsing, serialization, and manipulation of PuppetDB queries embedded in HTTP parameters.
(add-criteria crit query)Add a criteria to the given query, taking top-level 'extract' and 'from' forms into account.
Add a criteria to the given query, taking top-level 'extract' and 'from' forms into account.
(coerce-to-boolean b)Parses b to a boolean unless it's already a boolean
Parses `b` to a boolean unless it's already a boolean
(convert-query-params full-query param-spec)Inputs: [full-query param-spec] Returns: puppetdb-query-schema
This will update a query map to contain the parsed and validated query parameters
Inputs: [full-query param-spec] Returns: puppetdb-query-schema This will update a query map to contain the parsed and validated query parameters
(create-query-map req param-spec parse-fn)Inputs: [req param-spec parse-fn] Returns: puppetdb-query-schema
Takes a ring request map and extracts the puppetdb query from the request. GET and POST are accepted, all other requests throw an exception
Inputs: [req param-spec parse-fn] Returns: puppetdb-query-schema Takes a ring request map and extracts the puppetdb query from the request. GET and POST are accepted, all other requests throw an exception
(find-active-node-restriction-criteria query)Find the first criteria in the given query that explicitly deals with active/deactivated nodes. Return nil if the query has no such criteria.
Find the first criteria in the given query that explicitly deals with active/deactivated nodes. Return nil if the query has no such criteria.
(get-req->query
{:keys [params globals] query-uuid :puppetdb-query-uuid :as _req}
parse-fn)Converts parameters of a GET request to a pdb query map
Converts parameters of a GET request to a pdb query map
(narrow-globals globals)Reduces the number of globals to limit their reach in the codebase
Reduces the number of globals to limit their reach in the codebase
(parse-json-or-pql-query query query-uuid log-queries?)Parse a query string either as JSON or PQL to transform it to AST
Parse a query string either as JSON or PQL to transform it to AST
(parse-json-query query query-uuid log-queries?)Parse a query string as JSON. Multiple queries or any other data, after the query, will result in a bad-query-ex.
Parse a query string as JSON. Multiple queries or any other data, after the query, will result in a bad-query-ex.
(parse-json-sequence query)Parse a query string as JSON. Parse errors will result in an bad-query-ex Should not be used as a parse-fn directly. Use parse-json-query instead
Parse a query string as JSON. Parse errors will result in an bad-query-ex Should not be used as a parse-fn directly. Use parse-json-query instead
(post-req->query {query-uuid :puppetdb-query-uuid :as req} parse-fn)Takes a POST body and parses the JSON to create a pdb query map
Takes a POST body and parses the JSON to create a pdb query map
This schema defines a PuppetDB query and its available parameters. In a GET request this is contained in various query parameters, for POST requests this should be contained in the body of the request
This schema defines a PuppetDB query and its available parameters. In a GET request this is contained in various query parameters, for POST requests this should be contained in the body of the request
(query-criteria query)Extract the 'criteria' (select) part of the given query
Extract the 'criteria' (select) part of the given query
(restrict-fact-query-to-name req)Restrict the query parameter of the supplied request so that it only returns facts with the given name
Restrict the query parameter of the supplied request so that it only returns facts with the given name
(restrict-fact-query-to-value req)Restrict the query parameter of the supplied request so that it only returns facts with the given name
Restrict the query parameter of the supplied request so that it only returns facts with the given name
(restrict-query restriction req)Given a criteria that will restrict a query, modify the supplied
request so that its query parameter is now restricted according to
restriction
Given a criteria that will restrict a query, modify the supplied request so that its query parameter is now restricted according to `restriction`
(restrict-query-to-active-nodes req)Restrict the query parameter of the supplied request so that it only returns results for the supplied node, unless a node-active criteria is already explicitly specified.
Restrict the query parameter of the supplied request so that it only returns results for the supplied node, unless a node-active criteria is already explicitly specified.
(restrict-query-to-entity entity)Inputs: [entity :- String]
Restrict the query to a particular entity, by wrapping the query in a from.
Inputs: [entity :- String] Restrict the query to a particular entity, by wrapping the query in a from.
(restrict-query-to-environment req)Restrict the query parameter of the supplied request so that it only returns results for the supplied environment
Restrict the query parameter of the supplied request so that it only returns results for the supplied environment
(restrict-query-to-node req)Restrict the query parameter of the supplied request so that it only returns results for the supplied node
Restrict the query parameter of the supplied request so that it only returns results for the supplied node
(restrict-query-to-producer req)Restrict the query parameter of the supplied request so that it only returns results for the supplied producer
Restrict the query parameter of the supplied request so that it only returns results for the supplied producer
(restrict-query-to-report req)Restrict the query parameter of the supplied request so that it only returns results for the supplied active node
Restrict the query parameter of the supplied request so that it only returns results for the supplied active node
(restrict-resource-query-to-title req)Restrict the query parameter of the supplied request so that it only returns resources with the given title
Restrict the query parameter of the supplied request so that it only returns resources with the given title
(restrict-resource-query-to-type req)Restrict the query parameter of the supplied request so that it only returns resources with the given type
Restrict the query parameter of the supplied request so that it only returns resources with the given type
(time-and-parse-pql query query-uuid log-queries?)Time how long it takes to transform a PQL query to AST, if the time is greater than 1s, a warning is logged. Returns the transformed query.
Time how long it takes to transform a PQL query to AST, if the time is greater than 1s, a warning is logged. Returns the transformed query.
(validate-distinct-options!
{:keys [distinct_start_time distinct_end_time distinct_resources] :as params})Validate the HTTP query params related to a distinct_resources query. Return a
map containing the validated distinct_resources options, parsed to the correct
data types. Throws bad-query-ex if any arguments are missing
or invalid.
Validate the HTTP query params related to a `distinct_resources` query. Return a map containing the validated `distinct_resources` options, parsed to the correct data types. Throws `bad-query-ex` if any arguments are missing or invalid.
(validate-query-params params param-spec)Inputs: [params param-spec :- param-spec-schema]
Given a set of params and a param spec, throw an error if required params are missing or unsupported params are present, otherwise return the params.
Inputs: [params param-spec :- param-spec-schema] Given a set of params and a param spec, throw an error if required params are missing or unsupported params are present, otherwise return the params.
(wrap-typical-query handler param-spec)(wrap-typical-query handler param-spec parse-fn)Wrap a query endpoint request handler with the normal behaviors. Augment the query handler with code to extract the query from the incoming GET or POST and include it in the request as a pdb query map, and handle query timeouts.
Wrap a query endpoint request handler with the normal behaviors. Augment the query handler with code to extract the query from the incoming GET or POST and include it in the request as a pdb query map, and handle query timeouts.
(wrap-with-from entity query)Wrap a query in a from, using the entity and any provided query
Wrap a query in a from, using the entity and any provided query
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |