Class: Vellum::MetadataFilterRuleRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/vellum_ai/types/metadata_filter_rule_request.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(combinator: nil, negated: nil, rules: nil, field: nil, operator: nil, value: nil, additional_properties: nil) ⇒ MetadataFilterRuleRequest

Parameters:

  • combinator (METADATA_FILTER_RULE_COMBINATOR) (defaults to: nil)
  • negated (Boolean) (defaults to: nil)
  • rules (Array<MetadataFilterRuleRequest>) (defaults to: nil)
  • field (String) (defaults to: nil)
  • operator (LOGICAL_OPERATOR) (defaults to: nil)
  • value (String) (defaults to: nil)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 19

def initialize(combinator: nil, negated: nil, rules: nil, field: nil, operator: nil, value: nil,
               additional_properties: nil)
  # @type [METADATA_FILTER_RULE_COMBINATOR]
  @combinator = combinator
  # @type [Boolean]
  @negated = negated
  # @type [Array<MetadataFilterRuleRequest>]
  @rules = rules
  # @type [String]
  @field = field
  # @type [LOGICAL_OPERATOR]
  @operator = operator
  # @type [String]
  @value = value
  # @type [OpenStruct] Additional properties unmapped to the current class definition
  @additional_properties = additional_properties
end

Instance Attribute Details

#additional_propertiesObject (readonly)

Returns the value of attribute additional_properties.



9
10
11
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 9

def additional_properties
  @additional_properties
end

#combinatorObject (readonly)

Returns the value of attribute combinator.



9
10
11
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 9

def combinator
  @combinator
end

#fieldObject (readonly)

Returns the value of attribute field.



9
10
11
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 9

def field
  @field
end

#negatedObject (readonly)

Returns the value of attribute negated.



9
10
11
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 9

def negated
  @negated
end

#operatorObject (readonly)

Returns the value of attribute operator.



9
10
11
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 9

def operator
  @operator
end

#rulesObject (readonly)

Returns the value of attribute rules.



9
10
11
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 9

def rules
  @rules
end

#valueObject (readonly)

Returns the value of attribute value.



9
10
11
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 9

def value
  @value
end

Class Method Details

.from_json(json_object:) ⇒ MetadataFilterRuleRequest

Deserialize a JSON object to an instance of MetadataFilterRuleRequest

Parameters:

  • json_object (JSON)

Returns:



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 41

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  combinator = METADATA_FILTER_RULE_COMBINATOR.key(parsed_json["combinator"]) || parsed_json["combinator"]
  negated = struct.negated
  rules = parsed_json["rules"].map do |v|
    v = v.to_json
    MetadataFilterRuleRequest.from_json(json_object: v)
  end
  field = struct.field
  operator = LOGICAL_OPERATOR.key(parsed_json["operator"]) || parsed_json["operator"]
  value = struct.value
  new(combinator: combinator, negated: negated, rules: rules, field: field, operator: operator, value: value,
      additional_properties: struct)
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


75
76
77
78
79
80
81
82
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 75

def self.validate_raw(obj:)
  obj.combinator&.is_a?(METADATA_FILTER_RULE_COMBINATOR) != false || raise("Passed value for field obj.combinator is not the expected type, validation failed.")
  obj.negated&.is_a?(Boolean) != false || raise("Passed value for field obj.negated is not the expected type, validation failed.")
  obj.rules&.is_a?(Array) != false || raise("Passed value for field obj.rules is not the expected type, validation failed.")
  obj.field&.is_a?(String) != false || raise("Passed value for field obj.field is not the expected type, validation failed.")
  obj.operator&.is_a?(LOGICAL_OPERATOR) != false || raise("Passed value for field obj.operator is not the expected type, validation failed.")
  obj.value&.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of MetadataFilterRuleRequest to a JSON object

Returns:

  • (JSON)


60
61
62
63
64
65
66
67
68
69
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 60

def to_json(*_args)
  {
    "combinator": METADATA_FILTER_RULE_COMBINATOR[@combinator] || @combinator,
    "negated": @negated,
    "rules": @rules,
    "field": @field,
    "operator": LOGICAL_OPERATOR[@operator] || @operator,
    "value": @value
  }.to_json
end