Class: Vellum::DocumentIndexRead

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, created:, label:, name:, indexing_config:, status: nil, environment: nil, additional_properties: nil) ⇒ DocumentIndexRead

Parameters:

  • id (String)
  • created (DateTime)
  • label (String)

    A human-readable label for the document index

  • name (String)

    A name that uniquely identifies this index within its workspace

  • status (ENTITY_STATUS) (defaults to: nil)

    The current status of the document index

    • ‘ACTIVE` - Active

    • ‘ARCHIVED` - Archived

  • environment (ENVIRONMENT_ENUM) (defaults to: nil)

    The environment this document index is used in

    • ‘DEVELOPMENT` - Development

    • ‘STAGING` - Staging

    • ‘PRODUCTION` - Production

  • indexing_config (Hash{String => String})

    Configuration representing how documents should be indexed

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/vellum_ai/types/document_index_read.rb', line 26

def initialize(id:, created:, label:, name:, indexing_config:, status: nil, environment: nil,
               additional_properties: nil)
  # @type [String]
  @id = id
  # @type [DateTime]
  @created = created
  # @type [String] A human-readable label for the document index
  @label = label
  # @type [String] A name that uniquely identifies this index within its workspace
  @name = name
  # @type [ENTITY_STATUS] The current status of the document index
  #   - `ACTIVE` - Active
  #   - `ARCHIVED` - Archived
  @status = status
  # @type [ENVIRONMENT_ENUM] The environment this document index is used in
  #   - `DEVELOPMENT` - Development
  #   - `STAGING` - Staging
  #   - `PRODUCTION` - Production
  @environment = environment
  # @type [Hash{String => String}] Configuration representing how documents should be indexed
  @indexing_config = indexing_config
  # @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.



10
11
12
# File 'lib/vellum_ai/types/document_index_read.rb', line 10

def additional_properties
  @additional_properties
end

#createdObject (readonly)

Returns the value of attribute created.



10
11
12
# File 'lib/vellum_ai/types/document_index_read.rb', line 10

def created
  @created
end

#environmentObject (readonly)

Returns the value of attribute environment.



10
11
12
# File 'lib/vellum_ai/types/document_index_read.rb', line 10

def environment
  @environment
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/vellum_ai/types/document_index_read.rb', line 10

def id
  @id
end

#indexing_configObject (readonly)

Returns the value of attribute indexing_config.



10
11
12
# File 'lib/vellum_ai/types/document_index_read.rb', line 10

def indexing_config
  @indexing_config
end

#labelObject (readonly)

Returns the value of attribute label.



10
11
12
# File 'lib/vellum_ai/types/document_index_read.rb', line 10

def label
  @label
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/vellum_ai/types/document_index_read.rb', line 10

def name
  @name
end

#statusObject (readonly)

Returns the value of attribute status.



10
11
12
# File 'lib/vellum_ai/types/document_index_read.rb', line 10

def status
  @status
end

Class Method Details

.from_json(json_object:) ⇒ DocumentIndexRead

Deserialize a JSON object to an instance of DocumentIndexRead

Parameters:

  • json_object (JSON)

Returns:



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/vellum_ai/types/document_index_read.rb', line 55

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = struct.id
  created = DateTime.parse(parsed_json["created"])
  label = struct.label
  name = struct.name
  status = ENTITY_STATUS.key(parsed_json["status"]) || parsed_json["status"]
  environment = ENVIRONMENT_ENUM.key(parsed_json["environment"]) || parsed_json["environment"]
  indexing_config = struct.indexing_config
  new(id: id, created: created, label: label, name: name, status: status, environment: environment,
      indexing_config: indexing_config, 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)


88
89
90
91
92
93
94
95
96
# File 'lib/vellum_ai/types/document_index_read.rb', line 88

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.created.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
  obj.label.is_a?(String) != false || raise("Passed value for field obj.label is not the expected type, validation failed.")
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.status&.is_a?(ENTITY_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
  obj.environment&.is_a?(ENVIRONMENT_ENUM) != false || raise("Passed value for field obj.environment is not the expected type, validation failed.")
  obj.indexing_config.is_a?(Hash) != false || raise("Passed value for field obj.indexing_config is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of DocumentIndexRead to a JSON object

Returns:

  • (JSON)


72
73
74
75
76
77
78
79
80
81
82
# File 'lib/vellum_ai/types/document_index_read.rb', line 72

def to_json(*_args)
  {
    "id": @id,
    "created": @created,
    "label": @label,
    "name": @name,
    "status": ENTITY_STATUS[@status] || @status,
    "environment": ENVIRONMENT_ENUM[@environment] || @environment,
    "indexing_config": @indexing_config
  }.to_json
end