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, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::DeletedFile
Delete File.
-
#download(file_id, workspace_id: nil, request_options: {}) ⇒ StringIO
Download File.
-
#initialize(client:) ⇒ Files
constructor
private
A new instance of Files.
-
#list(ids: nil, limit: nil, page: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Internal::PageCursor<Anthropic::Models::FileMetadata>
List Files.
-
#retrieve_metadata(file_id, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::FileMetadata
Get File Metadata.
-
#upload(file:, expires_in_seconds: nil, workspace_id: 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.
164 165 166 |
# File 'lib/anthropic/resources/files.rb', line 164 def initialize(client:) @client = client end |
Instance Method Details
#delete(file_id, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::DeletedFile
Delete File
Some parameter documentations has been truncated, see Models::FileDeleteParams for more details.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/anthropic/resources/files.rb', line 57 def delete(file_id, params = {}) parsed, = Anthropic::FileDeleteParams.dump_request(params) @client.request( method: :delete, path: ["v1/files/%1$s", file_id], headers: parsed.transform_keys(workspace_id: "anthropic-workspace-id"), model: Anthropic::DeletedFile, options: ) end |
#download(file_id, workspace_id: nil, request_options: {}) ⇒ StringIO
Download File
Some parameter documentations has been truncated, see Models::FileDownloadParams for more details.
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/anthropic/resources/files.rb', line 84 def download(file_id, params = {}) parsed, = Anthropic::FileDownloadParams.dump_request(params) @client.request( method: :get, path: ["v1/files/%1$s/content", file_id], headers: { "accept" => "application/binary", **parsed }.transform_keys(workspace_id: "anthropic-workspace-id"), model: StringIO, options: ) end |
#list(ids: nil, limit: nil, page: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Internal::PageCursor<Anthropic::Models::FileMetadata>
List Files
Some parameter documentations has been truncated, see Models::FileListParams for more details.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/anthropic/resources/files.rb', line 26 def list(params = {}) query_params = [:ids, :limit, :page] parsed, = Anthropic::FileListParams.dump_request(params) query = Anthropic::Internal::Util.encode_query_params(parsed.slice(*query_params)) @client.request( method: :get, path: "v1/files", query: query, headers: parsed.except(*query_params).transform_keys(workspace_id: "anthropic-workspace-id"), page: Anthropic::Internal::PageCursor, model: Anthropic::FileMetadata, options: ) end |
#retrieve_metadata(file_id, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::FileMetadata
Get File Metadata
Some parameter documentations has been truncated, see Models::FileRetrieveMetadataParams for more details.
114 115 116 117 118 119 120 121 122 123 |
# File 'lib/anthropic/resources/files.rb', line 114 def (file_id, params = {}) parsed, = Anthropic::FileRetrieveMetadataParams.dump_request(params) @client.request( method: :get, path: ["v1/files/%1$s", file_id], headers: parsed.transform_keys(workspace_id: "anthropic-workspace-id"), model: Anthropic::FileMetadata, options: ) end |
#upload(file:, expires_in_seconds: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::FileMetadata
Upload File
Some parameter documentations has been truncated, see Models::FileUploadParams for more details.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/anthropic/resources/files.rb', line 143 def upload(params) parsed, = Anthropic::FileUploadParams.dump_request(params) header_params = {workspace_id: "anthropic-workspace-id"} @client.request( method: :post, path: "v1/files", headers: { "content-type" => "multipart/form-data", **parsed.slice(*header_params.keys) }.transform_keys( header_params ), body: parsed.except(*header_params.keys), model: Anthropic::FileMetadata, options: ) end |