Class: Vellum::DocumentIndexesClient
- Inherits:
-
Object
- Object
- Vellum::DocumentIndexesClient
- Defined in:
- lib/vellum_ai/document_indexes/client.rb
Instance Attribute Summary collapse
-
#request_client ⇒ Object
readonly
Returns the value of attribute request_client.
Instance Method Summary collapse
-
#create(label:, name:, indexing_config:, status: nil, environment: nil, copy_documents_from_index_id: nil, request_options: nil) ⇒ DocumentIndexRead
Creates a new document index.
-
#destroy(id:, request_options: nil) ⇒ Void
Used to delete a Document Index given its ID.
- #initialize(request_client:) ⇒ DocumentIndexesClient constructor
-
#list(limit: nil, offset: nil, ordering: nil, status: nil, request_options: nil) ⇒ PaginatedDocumentIndexReadList
Used to retrieve a list of Document Indexes.
-
#partial_update(id:, label: nil, status: nil, environment: nil, request_options: nil) ⇒ DocumentIndexRead
Used to partial update a Document Index given its ID.
-
#retrieve(id:, request_options: nil) ⇒ DocumentIndexRead
Used to retrieve a Document Index given its ID or name.
-
#update(id:, label:, status: nil, environment: nil, request_options: nil) ⇒ DocumentIndexRead
Used to fully update a Document Index given its ID.
Constructor Details
#initialize(request_client:) ⇒ DocumentIndexesClient
17 18 19 20 |
# File 'lib/vellum_ai/document_indexes/client.rb', line 17 def initialize(request_client:) # @type [RequestClient] @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Object (readonly)
Returns the value of attribute request_client.
13 14 15 |
# File 'lib/vellum_ai/document_indexes/client.rb', line 13 def request_client @request_client end |
Instance Method Details
#create(label:, name:, indexing_config:, status: nil, environment: nil, copy_documents_from_index_id: nil, request_options: nil) ⇒ DocumentIndexRead
Creates a new document index.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/vellum_ai/document_indexes/client.rb', line 64 def create(label:, name:, indexing_config:, status: nil, environment: nil, copy_documents_from_index_id: nil, request_options: nil) response = @request_client.conn.post do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X_API_KEY"] = .api_key unless &.api_key.nil? req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.body = { **(&.additional_body_parameters || {}), label: label, name: name, status: status, environment: environment, indexing_config: indexing_config, copy_documents_from_index_id: copy_documents_from_index_id }.compact req.url "#{@request_client.default_environment[:Default]}/v1/document-indexes" end DocumentIndexRead.from_json(json_object: response.body) end |
#destroy(id:, request_options: nil) ⇒ Void
Used to delete a Document Index given its ID.
133 134 135 136 137 138 139 140 |
# File 'lib/vellum_ai/document_indexes/client.rb', line 133 def destroy(id:, request_options: nil) @request_client.conn.delete do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X_API_KEY"] = .api_key unless &.api_key.nil? req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.url "#{@request_client.default_environment[:Default]}/v1/document-indexes/#{id}" end end |
#list(limit: nil, offset: nil, ordering: nil, status: nil, request_options: nil) ⇒ PaginatedDocumentIndexReadList
Used to retrieve a list of Document Indexes.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/vellum_ai/document_indexes/client.rb', line 32 def list(limit: nil, offset: nil, ordering: nil, status: nil, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X_API_KEY"] = .api_key unless &.api_key.nil? req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "limit": limit, "offset": offset, "ordering": ordering, "status": status }.compact req.url "#{@request_client.default_environment[:Default]}/v1/document-indexes" end PaginatedDocumentIndexReadList.from_json(json_object: response.body) end |
#partial_update(id:, label: nil, status: nil, environment: nil, request_options: nil) ⇒ DocumentIndexRead
Used to partial update a Document Index given its ID.
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/vellum_ai/document_indexes/client.rb', line 155 def partial_update(id:, label: nil, status: nil, environment: nil, request_options: nil) response = @request_client.conn.patch do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X_API_KEY"] = .api_key unless &.api_key.nil? req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.body = { **(&.additional_body_parameters || {}), label: label, status: status, environment: environment }.compact req.url "#{@request_client.default_environment[:Default]}/v1/document-indexes/#{id}" end DocumentIndexRead.from_json(json_object: response.body) end |
#retrieve(id:, request_options: nil) ⇒ DocumentIndexRead
Used to retrieve a Document Index given its ID or name.
89 90 91 92 93 94 95 96 97 |
# File 'lib/vellum_ai/document_indexes/client.rb', line 89 def retrieve(id:, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X_API_KEY"] = .api_key unless &.api_key.nil? req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.url "#{@request_client.default_environment[:Default]}/v1/document-indexes/#{id}" end DocumentIndexRead.from_json(json_object: response.body) end |
#update(id:, label:, status: nil, environment: nil, request_options: nil) ⇒ DocumentIndexRead
Used to fully update a Document Index given its ID.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/vellum_ai/document_indexes/client.rb', line 112 def update(id:, label:, status: nil, environment: nil, request_options: nil) response = @request_client.conn.put do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X_API_KEY"] = .api_key unless &.api_key.nil? req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.body = { **(&.additional_body_parameters || {}), label: label, status: status, environment: environment }.compact req.url "#{@request_client.default_environment[:Default]}/v1/document-indexes/#{id}" end DocumentIndexRead.from_json(json_object: response.body) end |