Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
The following code can be used.
EqualsOperator('environment', 'production')
:param field: The PuppetDB endpoint query field. See endpoint
documentation for valid values.
:type field: any
:param value: The value of the field to match, or not match.
:type value: any
"""
def __init__(self, field, value):
super(EqualsOperator, self).__init__("=", field, value)
class GreaterOperator(BinaryOperator):
"""
Builds a greater-than filter based on the supplied field-value pair as
described
https://docs.puppet.com/puppetdb/4.1/api/query/v4/ast.html#greater-than.
In order to create the following query:
[">", "catalog_timestamp", "2016-06-01 00:00:00"]
The following code can be used.
GreaterOperator('catalog_timestamp', datetime.datetime(2016, 06, 01))
:param field: The PuppetDB endpoint query field. See endpoint
documentation for valid values.
:type field: any
The following code can be used.
LessOperator('catalog_timestamp', datetime.datetime(2016, 06, 01))
:param field: The PuppetDB endpoint query field. See endpoint
documentation for valid values.
:type field: any
:param value: Matches if the field is less than this value.
:type value: Number, timestamp or array
"""
def __init__(self, field, value):
super(LessOperator, self).__init__("<", field, value)
class GreaterEqualOperator(BinaryOperator):
"""
Builds a greater-than or equal-to filter based on the supplied
field-value pair as described
https://docs.puppet.com/puppetdb/4.1/api/query/v4/ast.html#greater-than-or-equal-to.
In order to create the following query:
[">=", "facts_timestamp", "2016-06-01 00:00:00"]
The following code can be used.
GreaterEqualOperator('facts_timestamp', datetime.datetime(2016, 06, 01))
:param field: The PuppetDB endpoint query field. See endpoint
documentation for valid values.
:type field: any
The following code can be used.
RegexArrayOperator('path', ["networking", "eth.*", "macaddress"])
:param field: The PuppetDB endpoint query field. See endpoint
documentation for valid values.
:type field: any
:param value: Matches if the field matches this regular expression.
:type value: :obj:`list`
"""
def __init__(self, field, value):
super(RegexArrayOperator, self).__init__("~>", field, value)
class NullOperator(BinaryOperator):
"""
Builds a null filter based on the field and boolean value pair as
described
https://docs.puppet.com/puppetdb/4.1/api/query/v4/ast.html#null-is-null.
This filter only works on field that may be null. Value may only
be True or False.
In order to create the following query:
["null?", "deactivated", true]
The following code can be used.
NullOperator('deactivated', True)
:param field: The PuppetDB endpoint query field. See endpoint
The following code can be used.
LessEqualOperator('facts_timestamp', datetime.datetime(2016, 06, 01))
:param field: The PuppetDB endpoint query field. See endpoint
documentation for valid values.
:type field: any
:param value: Matches if the field is less than or equal to\
this value.
:type value: Number, timestamp or array
"""
def __init__(self, field, value):
super(LessEqualOperator, self).__init__("<=", field, value)
class RegexOperator(BinaryOperator):
"""
Builds a regular expression filter based on the supplied field-value
pair as described
https://docs.puppet.com/puppetdb/4.1/api/query/v4/ast.html#regexp-match.
In order to create the following query:
["~", "certname", "www\\d+\\.example\\.com"]
The following code can be used.
RegexOperator('certname', 'www\\d+\\.example\\.com')
:param field: The PuppetDB endpoint query field. See endpoint
documentation for valid values.
:type field: any
The following code can be used.
GreaterEqualOperator('facts_timestamp', datetime.datetime(2016, 06, 01))
:param field: The PuppetDB endpoint query field. See endpoint
documentation for valid values.
:type field: any
:param value: Matches if the field is greater than or equal to\
this value.
:type value: Number, timestamp or array
"""
def __init__(self, field, value):
super(GreaterEqualOperator, self).__init__(">=", field, value)
class LessEqualOperator(BinaryOperator):
"""
Builds a less-than or equal-to filter based on the supplied
field-value pair as described
https://docs.puppet.com/puppetdb/4.1/api/query/v4/ast.html#less-than-or-equal-to.
In order to create the following query:
["<=", "facts_timestamp", "2016-06-01 00:00:00"]
The following code can be used.
LessEqualOperator('facts_timestamp', datetime.datetime(2016, 06, 01))
:param field: The PuppetDB endpoint query field. See endpoint
documentation for valid values.
:type field: any
if self.query is None:
raise APIError("FromOperator needs one main query")
arr = ['from', self.endpoint, self.query]
if len(self.order_by) > 0:
arr.append(['order_by', self.order_by])
if self.limit is not None:
arr.append(['limit', self.limit])
if self.offset is not None:
arr.append(['offset', self.offset])
return arr
class EqualsOperator(BinaryOperator):
"""
Builds an equality filter based on the supplied field-value pair as
described
https://docs.puppet.com/puppetdb/4.1/api/query/v4/ast.html#equality.
In order to create the following query:
["=", "environment", "production"]
The following code can be used.
EqualsOperator('environment', 'production')
:param field: The PuppetDB endpoint query field. See endpoint
documentation for valid values.
:type field: any
The following code can be used.
RegexOperator('certname', 'www\\d+\\.example\\.com')
:param field: The PuppetDB endpoint query field. See endpoint
documentation for valid values.
:type field: any
:param value: Matches if the field matches this regular expression.
:type value: :obj:`string`
"""
def __init__(self, field, value):
super(RegexOperator, self).__init__("~", field, value)
class RegexArrayOperator(BinaryOperator):
"""
Builds a regular expression array filter based on the supplied
field-value pair. This query only works on fields with paths as
described
https://docs.puppet.com/puppetdb/4.1/api/query/v4/ast.html#regexp-array-match.
In order to create the following query:
["~", "path", ["networking", "eth.*", "macaddress"]]
The following code can be used.
RegexArrayOperator('path', ["networking", "eth.*", "macaddress"])
:param field: The PuppetDB endpoint query field. See endpoint
documentation for valid values.
The following code can be used.
GreaterOperator('catalog_timestamp', datetime.datetime(2016, 06, 01))
:param field: The PuppetDB endpoint query field. See endpoint
documentation for valid values.
:type field: any
:param value: Matches if the field is greater than this value.
:type value: Number, timestamp or array
"""
def __init__(self, field, value):
super(GreaterOperator, self).__init__(">", field, value)
class LessOperator(BinaryOperator):
"""
Builds a less-than filter based on the supplied field-value pair as
described
https://docs.puppet.com/puppetdb/4.1/api/query/v4/ast.html#less-than.
In order to create the following query:
["<", "catalog_timestamp", "2016-06-01 00:00:00"]
The following code can be used.
LessOperator('catalog_timestamp', datetime.datetime(2016, 06, 01))
:param field: The PuppetDB endpoint query field. See endpoint
documentation for valid values.
:type field: any