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.
228 229 230 |
# File 'lib/anthropic/resources/beta/files.rb', line 228 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.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/anthropic/resources/beta/files.rb', line 81 def delete(file_id, params = {}) parsed, = Anthropic::Beta::FileDeleteParams.dump_request(params) @client.request( qualifiers: {beta: "true"}, span_name: Anthropic::Internal::Tracing::SpanName::FILES_DELETE, span_attributes: {"anthropic.file.id" => file_id}, span_route: "/v1/files/{file_id}", method: :delete, path: ["v1/files/%1$s", 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.
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/anthropic/resources/beta/files.rb', line 121 def download(file_id, params = {}) parsed, = Anthropic::Beta::FileDownloadParams.dump_request(params) @client.request( qualifiers: {beta: "true"}, span_name: Anthropic::Internal::Tracing::SpanName::FILES_DOWNLOAD, span_attributes: {"anthropic.file.id" => file_id}, span_route: "/v1/files/{file_id}/content", method: :get, path: ["v1/files/%1$s/content", 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.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/anthropic/resources/beta/files.rb', line 36 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( qualifiers: {beta: "true"}, span_name: Anthropic::Internal::Tracing::SpanName::FILES_LIST, span_route: "/v1/files", span_query: %w[ids limit page scope_id], method: :get, path: "v1/files", 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.
162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/anthropic/resources/beta/files.rb', line 162 def (file_id, params = {}) parsed, = Anthropic::Beta::FileRetrieveMetadataParams.dump_request(params) @client.request( qualifiers: {beta: "true"}, span_name: Anthropic::Internal::Tracing::SpanName::FILES_RETRIEVE_METADATA, span_attributes: {"anthropic.file.id" => file_id}, span_route: "/v1/files/{file_id}", method: :get, path: ["v1/files/%1$s", 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.
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/anthropic/resources/beta/files.rb', line 203 def upload(params) parsed, = Anthropic::Beta::FileUploadParams.dump_request(params) header_params = {betas: "anthropic-beta", workspace_id: "anthropic-workspace-id"} @client.request( qualifiers: {beta: "true"}, span_name: Anthropic::Internal::Tracing::SpanName::FILES_UPLOAD, span_created_id: "anthropic.file.id", span_route: "/v1/files", 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::Beta::BetaFileMetadata, options: ) end |