Class: Anthropic::Resources::Beta::Files
- Inherits:
-
Object
- Object
- Anthropic::Resources::Beta::Files
- Defined in:
- lib/anthropic/resources/beta/files.rb,
sig/anthropic/resources/beta/files.rbs
Instance Method Summary collapse
-
#delete(file_id, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::BetaDeletedFile
Delete File.
-
#download(file_id, betas: nil, 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, scope_id: nil, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Internal::PageCursor<Anthropic::Models::Beta::BetaFileMetadata>
List Files.
-
#retrieve_metadata(file_id, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::BetaFileMetadata
Get File Metadata.
-
#upload(file:, expires_in_seconds: nil, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::BetaFileMetadata
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.
180 181 182 |
# File 'lib/anthropic/resources/beta/files.rb', line 180 def initialize(client:) @client = client end |
Instance Method Details
#delete(file_id, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::BetaDeletedFile
Delete File
Some parameter documentations has been truncated, see Models::Beta::FileDeleteParams for more details.
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/anthropic/resources/beta/files.rb', line 67 def delete(file_id, params = {}) parsed, = Anthropic::Beta::FileDeleteParams.dump_request(params) @client.request( method: :delete, path: ["v1/files/%1$s?beta=true", file_id], headers: parsed.transform_keys(betas: "anthropic-beta", workspace_id: "anthropic-workspace-id"), model: Anthropic::Beta::BetaDeletedFile, options: ) end |
#download(file_id, betas: nil, workspace_id: nil, request_options: {}) ⇒ StringIO
Download File
Some parameter documentations has been truncated, see Models::Beta::FileDownloadParams for more details.
96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/anthropic/resources/beta/files.rb', line 96 def download(file_id, params = {}) parsed, = Anthropic::Beta::FileDownloadParams.dump_request(params) @client.request( method: :get, path: ["v1/files/%1$s/content?beta=true", file_id], headers: {"accept" => "application/binary", **parsed}.transform_keys( betas: "anthropic-beta", workspace_id: "anthropic-workspace-id" ), model: StringIO, options: ) end |
#list(ids: nil, limit: nil, page: nil, scope_id: nil, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Internal::PageCursor<Anthropic::Models::Beta::BetaFileMetadata>
List Files
Some parameter documentations has been truncated, see Models::Beta::FileListParams for more details.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/anthropic/resources/beta/files.rb', line 31 def list(params = {}) query_params = [:ids, :limit, :page, :scope_id] parsed, = Anthropic::Beta::FileListParams.dump_request(params) query = Anthropic::Internal::Util.encode_query_params(parsed.slice(*query_params)) @client.request( method: :get, path: "v1/files?beta=true", query: query, headers: parsed.except(*query_params).transform_keys( betas: "anthropic-beta", workspace_id: "anthropic-workspace-id" ), page: Anthropic::Internal::PageCursor, model: Anthropic::Beta::BetaFileMetadata, options: ) end |
#retrieve_metadata(file_id, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::BetaFileMetadata
Get File Metadata
Some parameter documentations has been truncated, see Models::Beta::FileRetrieveMetadataParams for more details.
128 129 130 131 132 133 134 135 136 137 |
# File 'lib/anthropic/resources/beta/files.rb', line 128 def (file_id, params = {}) parsed, = Anthropic::Beta::FileRetrieveMetadataParams.dump_request(params) @client.request( method: :get, path: ["v1/files/%1$s?beta=true", file_id], headers: parsed.transform_keys(betas: "anthropic-beta", workspace_id: "anthropic-workspace-id"), model: Anthropic::Beta::BetaFileMetadata, options: ) end |
#upload(file:, expires_in_seconds: nil, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::BetaFileMetadata
Upload File
Some parameter documentations has been truncated, see Models::Beta::FileUploadParams for more details.
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/anthropic/resources/beta/files.rb', line 159 def upload(params) parsed, = Anthropic::Beta::FileUploadParams.dump_request(params) header_params = {betas: "anthropic-beta", workspace_id: "anthropic-workspace-id"} @client.request( method: :post, path: "v1/files?beta=true", headers: { "content-type" => "multipart/form-data", **parsed.slice(*header_params.keys) }.transform_keys( header_params ), body: parsed.except(*header_params.keys), model: Anthropic::Beta::BetaFileMetadata, options: ) end |