Class: Anthropic::Resources::Files
- Inherits:
-
Object
- Object
- Anthropic::Resources::Files
- Defined in:
- lib/anthropic/resources/files.rb,
sig/anthropic/resources/files.rbs
Instance Method Summary collapse
-
#delete(file_id, request_options: {}) ⇒ Anthropic::Models::DeletedFile
Delete File.
-
#download(file_id, request_options: {}) ⇒ StringIO
Download File.
-
#initialize(client:) ⇒ Files
constructor
private
A new instance of Files.
-
#list(ids: nil, limit: nil, page: nil, request_options: {}) ⇒ Anthropic::Internal::PageCursor<Anthropic::Models::FileMetadata>
List Files.
-
#retrieve_metadata(file_id, request_options: {}) ⇒ Anthropic::Models::FileMetadata
Get File Metadata.
-
#upload(file:, expires_in_seconds: nil, request_options: {}) ⇒ Anthropic::Models::FileMetadata
Upload File.
Constructor Details
#initialize(client:) ⇒ Files
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Files.
129 130 131 |
# File 'lib/anthropic/resources/files.rb', line 129 def initialize(client:) @client = client end |
Instance Method Details
#delete(file_id, request_options: {}) ⇒ Anthropic::Models::DeletedFile
Delete File
48 49 50 51 52 53 54 55 |
# File 'lib/anthropic/resources/files.rb', line 48 def delete(file_id, params = {}) @client.request( method: :delete, path: ["v1/files/%1$s", file_id], model: Anthropic::DeletedFile, options: params[:request_options] ) end |
#download(file_id, request_options: {}) ⇒ StringIO
Download File
68 69 70 71 72 73 74 75 76 |
# File 'lib/anthropic/resources/files.rb', line 68 def download(file_id, params = {}) @client.request( method: :get, path: ["v1/files/%1$s/content", file_id], headers: {"accept" => "application/binary"}, model: StringIO, options: params[:request_options] ) end |
#list(ids: nil, limit: nil, page: nil, request_options: {}) ⇒ Anthropic::Internal::PageCursor<Anthropic::Models::FileMetadata>
List Files
Some parameter documentations has been truncated, see Models::FileListParams for more details.
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/anthropic/resources/files.rb', line 24 def list(params = {}) parsed, = Anthropic::FileListParams.dump_request(params) query = Anthropic::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "v1/files", query: query, page: Anthropic::Internal::PageCursor, model: Anthropic::FileMetadata, options: ) end |
#retrieve_metadata(file_id, request_options: {}) ⇒ Anthropic::Models::FileMetadata
Get File Metadata
89 90 91 92 93 94 95 96 |
# File 'lib/anthropic/resources/files.rb', line 89 def (file_id, params = {}) @client.request( method: :get, path: ["v1/files/%1$s", file_id], model: Anthropic::FileMetadata, options: params[:request_options] ) end |
#upload(file:, expires_in_seconds: nil, request_options: {}) ⇒ Anthropic::Models::FileMetadata
Upload File
Some parameter documentations has been truncated, see Models::FileUploadParams for more details.
114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/anthropic/resources/files.rb', line 114 def upload(params) parsed, = Anthropic::FileUploadParams.dump_request(params) @client.request( method: :post, path: "v1/files", headers: {"content-type" => "multipart/form-data"}, body: parsed, model: Anthropic::FileMetadata, options: ) end |