class Nexpose::Criteria
Join search criteria for an asset filter search or dynamic asset group.
Attributes
criteria[RW]
Array of criteria to match against.
match[RW]
Whether to match any or all filters. One of 'OR' or 'AND'.
Public Class Methods
new(criteria = [], match = 'AND')
click to toggle source
# File lib/nexpose/filter.rb, line 321 def initialize(criteria = [], match = 'AND') @criteria = Array(criteria) @match = match.upcase end
parse(json)
click to toggle source
# File lib/nexpose/filter.rb, line 352 def self.parse(json) # The call returns empty JSON, so default to 'AND' if not present. operator = json['operator'] || 'AND' ret = Criteria.new([], operator) json['criteria'].each do |c| ret.criteria << Criterion.parse(c) end ret end
Public Instance Methods
<<(criterion)
click to toggle source
# File lib/nexpose/filter.rb, line 348 def <<(criterion) criteria << criterion end
_to_payload()
click to toggle source
to_h()
click to toggle source
# File lib/nexpose/filter.rb, line 326 def to_h { 'operator' => @match, 'criteria' => @criteria.map(&:to_h) } end
to_json()
click to toggle source
Convert this object into the format expected by Nexpose
.
# File lib/nexpose/filter.rb, line 333 def to_json JSON.generate(to_h) end