Class: Vellum::AsyncFolderEntitiesClient

Inherits:
Object
  • Object
show all
Defined in:
lib/vellum_ai/folder_entities/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ AsyncFolderEntitiesClient

Parameters:



41
42
43
44
# File 'lib/vellum_ai/folder_entities/client.rb', line 41

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

Instance Attribute Details

#request_clientObject (readonly)

Returns the value of attribute request_client.



37
38
39
# File 'lib/vellum_ai/folder_entities/client.rb', line 37

def request_client
  @request_client
end

Instance Method Details

#add_entity_to_folder(folder_id:, entity_id:, request_options: nil) ⇒ Void

Add an entity to a specific folder or root directory.

Adding an entity to a folder will remove it from any other folders it might have been a member of.

Parameters:

  • folder_id (String)

    The ID of the folder to which the entity should be added. This can be a UUID of a folder, or the name of a root directory (e.g. “PROMPT_SANDBOX”).

  • entity_id (String)

    The ID of the entity you would like to move.

  • request_options (RequestOptions) (defaults to: nil)

Returns:

  • (Void)


54
55
56
57
58
59
60
61
62
63
64
# File 'lib/vellum_ai/folder_entities/client.rb', line 54

def add_entity_to_folder(folder_id:, entity_id:, request_options: nil)
  Async do
    @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 || {}), entity_id: entity_id }.compact
      req.url "#{@request_client.default_environment[:Default]}/v1/folders/#{folder_id}/add-entity"
    end
  end
end