Class: AtlasRb::FileSet
Overview
Constant Summary collapse
- ROUTE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Atlas REST endpoint prefix for this resource.
"/file_sets/"
Class Method Summary collapse
-
.create(id, classification, idempotency_key: nil, nuid: nil, on_behalf_of: nil) ⇒ Hash
Create a new FileSet under a Work.
-
.destroy(id, nuid: nil, on_behalf_of: nil) ⇒ Faraday::Response
Delete a FileSet.
-
.find(id, nuid: nil, on_behalf_of: nil) ⇒ Hash
Fetch a single FileSet by ID.
-
.update(id, blob_path, nuid: nil, on_behalf_of: nil) ⇒ Hash
Attach (or replace) the binary content backing this FileSet.
Methods inherited from Resource
Methods included from FaradayHelper
#connection, #multipart, #system_connection
Class Method Details
.create(id, classification, idempotency_key: nil, nuid: nil, on_behalf_of: nil) ⇒ Hash
Create a new FileSet under a Work.
61 62 63 64 65 66 |
# File 'lib/atlas_rb/file_set.rb', line 61 def self.create(id, classification, idempotency_key: nil, nuid: nil, on_behalf_of: nil) AtlasRb::Mash.new(JSON.parse( connection({ work_id: id, classification: classification }, nuid, on_behalf_of: on_behalf_of, idempotency_key: idempotency_key).post(ROUTE)&.body ))["file_set"] end |
.destroy(id, nuid: nil, on_behalf_of: nil) ⇒ Faraday::Response
Delete a FileSet.
81 82 83 |
# File 'lib/atlas_rb/file_set.rb', line 81 def self.destroy(id, nuid: nil, on_behalf_of: nil) connection({}, nuid, on_behalf_of: on_behalf_of).delete(ROUTE + id) end |
.find(id, nuid: nil, on_behalf_of: nil) ⇒ Hash
Fetch a single FileSet by ID.
30 31 32 33 34 |
# File 'lib/atlas_rb/file_set.rb', line 30 def self.find(id, nuid: nil, on_behalf_of: nil) AtlasRb::Mash.new(JSON.parse( connection({}, nuid, on_behalf_of: on_behalf_of).get(ROUTE + id)&.body ))["file_set"] end |
.update(id, blob_path, nuid: nil, on_behalf_of: nil) ⇒ Hash
Attach (or replace) the binary content backing this FileSet.
The body is uploaded as application/octet-stream regardless of the
file's true type — Atlas inspects the content server-side. To upload
a binary blob plus an original filename, use Blob.create directly
against the underlying /files/ endpoint.
104 105 106 107 108 109 110 111 112 |
# File 'lib/atlas_rb/file_set.rb', line 104 def self.update(id, blob_path, nuid: nil, on_behalf_of: nil) # Need to figure out blob vs XML payload = { binary: Faraday::Multipart::FilePart.new(File.open(blob_path), "application/octet-stream", File.basename(blob_path)) } AtlasRb::Mash.new(JSON.parse( multipart(nuid, on_behalf_of: on_behalf_of).patch(ROUTE + id, payload)&.body )) end |