Class: Vellum::DocumentDocumentToDocumentIndex

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, document_index_id:, indexing_state: nil, additional_properties: nil) ⇒ DocumentDocumentToDocumentIndex

Parameters:

  • id (String)

    Vellum-generated ID that uniquely identifies this link.

  • document_index_id (String)

    Vellum-generated ID that uniquely identifies the index this document is included in.

  • indexing_state (INDEXING_STATE_ENUM) (defaults to: nil)

    An enum value representing where this document is along its indexing lifecycle for this index.

    • ‘AWAITING_PROCESSING` - Awaiting Processing

    • ‘QUEUED` - Queued

    • ‘INDEXING` - Indexing

    • ‘INDEXED` - Indexed

    • ‘FAILED` - Failed

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(id:, document_index_id:, indexing_state: nil, additional_properties: nil)
  # @type [String] Vellum-generated ID that uniquely identifies this link.
  @id = id
  # @type [String] Vellum-generated ID that uniquely identifies the index this document is included in.
  @document_index_id = document_index_id
  # @type [INDEXING_STATE_ENUM] An enum value representing where this document is along its indexing lifecycle for this index.
  #   - `AWAITING_PROCESSING` - Awaiting Processing
  #   - `QUEUED` - Queued
  #   - `INDEXING` - Indexing
  #   - `INDEXED` - Indexed
  #   - `FAILED` - Failed
  @indexing_state = indexing_state
  # @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.



8
9
10
# File 'lib/vellum_ai/types/document_document_to_document_index.rb', line 8

def additional_properties
  @additional_properties
end

#document_index_idObject (readonly)

Returns the value of attribute document_index_id.



8
9
10
# File 'lib/vellum_ai/types/document_document_to_document_index.rb', line 8

def document_index_id
  @document_index_id
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/vellum_ai/types/document_document_to_document_index.rb', line 8

def id
  @id
end

#indexing_stateObject (readonly)

Returns the value of attribute indexing_state.



8
9
10
# File 'lib/vellum_ai/types/document_document_to_document_index.rb', line 8

def indexing_state
  @indexing_state
end

Class Method Details

.from_json(json_object:) ⇒ DocumentDocumentToDocumentIndex

Deserialize a JSON object to an instance of DocumentDocumentToDocumentIndex

Parameters:

  • json_object (JSON)

Returns:



40
41
42
43
44
45
46
47
# File 'lib/vellum_ai/types/document_document_to_document_index.rb', line 40

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = struct.id
  document_index_id = struct.document_index_id
  indexing_state = INDEXING_STATE_ENUM.key(parsed_json["indexing_state"]) || parsed_json["indexing_state"]
  new(id: id, document_index_id: document_index_id, indexing_state: indexing_state, 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)


64
65
66
67
68
# File 'lib/vellum_ai/types/document_document_to_document_index.rb', line 64

def self.validate_raw(obj:)
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.document_index_id.is_a?(String) != false || raise("Passed value for field obj.document_index_id is not the expected type, validation failed.")
  obj.indexing_state&.is_a?(INDEXING_STATE_ENUM) != false || raise("Passed value for field obj.indexing_state is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of DocumentDocumentToDocumentIndex to a JSON object

Returns:

  • (JSON)


52
53
54
55
56
57
58
# File 'lib/vellum_ai/types/document_document_to_document_index.rb', line 52

def to_json(*_args)
  {
    "id": @id,
    "document_index_id": @document_index_id,
    "indexing_state": INDEXING_STATE_ENUM[@indexing_state] || @indexing_state
  }.to_json
end