class Vellum::AsyncDocumentsClient

def destroy(id:, request_options: nil)

Returns:
  • (Void) -

Parameters:
  • request_options (RequestOptions) --
  • id (String) -- A UUID string identifying this document.
def destroy(id:, request_options: nil)
  Async do
    @request_client.conn.delete do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
      req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
      req.url "#{@request_client.default_environment[:Default]}/v1/documents/#{id}"
    end
  end
end

def initialize(request_client:)

Returns:
  • (AsyncDocumentsClient) -

Parameters:
  • request_client (AsyncRequestClient) --
def initialize(request_client:)
  # @type [AsyncRequestClient]
  @request_client = request_client
end

def list(document_index_id: nil, limit: nil, offset: nil, ordering: nil, request_options: nil)

Returns:
  • (PaginatedSlimDocumentList) -

Parameters:
  • request_options (RequestOptions) --
  • ordering (String) -- Which field to use when ordering the results.
  • offset (Integer) -- The initial index from which to return the results.
  • limit (Integer) -- Number of results to return per page.
  • document_index_id (String) -- Filter down to only those documents that are included in the specified index. You may provide either the Vellum-generated ID or the unique name of the index specified upon initial creation.
def list(document_index_id: nil, limit: nil, offset: nil, ordering: nil, request_options: nil)
  Async do
    response = @request_client.conn.get do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
      req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
      req.params = {
        **(request_options&.additional_query_parameters || {}),
        "document_index_id": document_index_id,
        "limit": limit,
        "offset": offset,
        "ordering": ordering
      }.compact
      req.url "#{@request_client.default_environment[:Default]}/v1/documents"
    end
    PaginatedSlimDocumentList.from_json(json_object: response.body)
  end
end

def partial_update(id:, label: nil, status: nil, metadata: nil, request_options: nil)

Returns:
  • (DocumentRead) -

Parameters:
  • request_options (RequestOptions) --
  • metadata (Hash{String => String}) -- A JSON object containing any metadata associated with the document that you'd like to filter upon later.
  • status (DOCUMENT_STATUS) -- The current status of the document
  • label (String) -- A human-readable label for the document. Defaults to the originally uploaded file's file name.
  • id (String) -- A UUID string identifying this document.
def partial_update(id:, label: nil, status: nil, metadata: nil, request_options: nil)
  Async do
    response = @request_client.conn.patch do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
      req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
      req.body = {
        **(request_options&.additional_body_parameters || {}),
        label: label,
        status: status,
        metadata: metadata
      }.compact
      req.url "#{@request_client.default_environment[:Default]}/v1/documents/#{id}"
    end
    DocumentRead.from_json(json_object: response.body)
  end
end

def upload(label:, contents:, add_to_index_names: nil, external_id: nil, keywords: nil, metadata: nil,

Returns:
  • (UploadDocumentResponse) -

Parameters:
  • request_options (RequestOptions) --
  • metadata (String) -- A stringified JSON object containing any metadata associated with the document that you'd like to filter upon later.
  • keywords (Array) -- Optionally include a list of keywords that'll be associated with this document. Used when performing keyword searches.
  • contents (String, IO) --
  • label (String) -- A human-friendly name for this document. Typically the filename.
  • external_id (String) -- Optionally include an external ID for this document. This is useful if you want to re-upload the same document later when its contents change and would like it to be re-indexed.
  • add_to_index_names (Array) -- Optionally include the names of all indexes that you'd like this document to be included in
def upload(label:, contents:, add_to_index_names: nil, external_id: nil, keywords: nil, metadata: nil,
           request_options: nil)
  Async do
    response = @request_client.conn.post do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
      req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
      req.body = {
        **(request_options&.additional_body_parameters || {}),
        add_to_index_names: add_to_index_names,
        external_id: external_id,
        label: label,
        contents: FileUtilities.as_faraday_multipart(file_like: contents),
        keywords: keywords,
        metadata: metadata
      }.compact
      req.url "#{@request_client.default_environment[:Documents]}/v1/upload-document"
    end
    UploadDocumentResponse.from_json(json_object: response.body)
  end
end