Class: Api::V2::QcFileResource
- Inherits:
-
BaseResource
- Object
- JSONAPI::Resource
- BaseResource
- Api::V2::QcFileResource
- Defined in:
- app/resources/api/v2/qc_file_resource.rb
Overview
This resource cannot be modified after creation: its endpoint will not accept PATCH
requests.
Access this resource via the /api/v2/qc_files/
endpoint.
Provides a JSON:API representation of QcFile which contains the QC data previously added to a piece of Labware. The file contents are stored in the database using the DbFile model.
For more information about JSON:API see the JSON:API Specifications or look at the JSONAPI::Resources package for Sequencescape’s implementation of the JSON:API standard.
Instance Attribute Summary collapse
-
#content_type ⇒ String
readonly
The content type, or MIME type, of the QC file.
-
#contents ⇒ String
The String contents of the QC file.
-
#created_at ⇒ DateTime
readonly
The date and time the QC file was created.
-
#filename ⇒ String
The filename of the QC file.
-
#labware ⇒ LabwareResource
The Labware which this QcFile belongs to.
-
#size ⇒ Integer
readonly
The size of the QC file in bytes.
-
#uuid ⇒ String
readonly
The UUID of the bulk transfers operation.
Class Method Summary collapse
-
.create_with_tempfile(context, tempfile, filename) ⇒ QcFileResource
The new QcFile resource.
Instance Method Summary collapse
-
#create_with_tempfile ⇒ Object
Create a new QcFile resource with the uploaded data from a temporary file.
-
#filter_uuid ⇒ Object
Filter the QcFile resources by UUID.
Methods inherited from BaseResource
apply_includes, creatable_fields, default_includes, #fetchable_fields, inclusions, resolve_relationship_names_to_relations, updatable_fields
Instance Attribute Details
#content_type ⇒ String (readonly)
Returns The content type, or MIME type, of the QC file.
50 |
# File 'app/resources/api/v2/qc_file_resource.rb', line 50 attribute :content_type, readonly: true |
#contents ⇒ String
Returns The String contents of the QC file. This is usually the CSV data for the QC file. This can only be written once on creation.
56 |
# File 'app/resources/api/v2/qc_file_resource.rb', line 56 attribute :contents, write_once: true |
#created_at ⇒ DateTime (readonly)
Returns The date and time the QC file was created.
70 |
# File 'app/resources/api/v2/qc_file_resource.rb', line 70 attribute :created_at, readonly: true |
#filename ⇒ String
Returns The filename of the QC file. This can only be written once on creation.
75 |
# File 'app/resources/api/v2/qc_file_resource.rb', line 75 attribute :filename, write_once: true |
#labware ⇒ LabwareResource
Returns The Labware which this QcFile belongs to.
96 |
# File 'app/resources/api/v2/qc_file_resource.rb', line 96 has_one :labware, relation_name: :asset, foreign_key: :asset_id, write_once: true |
#size ⇒ Integer (readonly)
Returns The size of the QC file in bytes.
84 |
# File 'app/resources/api/v2/qc_file_resource.rb', line 84 attribute :size, readonly: true |
#uuid ⇒ String (readonly)
Returns The UUID of the bulk transfers operation.
88 |
# File 'app/resources/api/v2/qc_file_resource.rb', line 88 attribute :uuid, readonly: true |
Class Method Details
.create_with_tempfile(context, tempfile, filename) ⇒ QcFileResource
Returns The new QcFile resource.
120 121 122 123 |
# File 'app/resources/api/v2/qc_file_resource.rb', line 120 def self.create_with_tempfile(context, tempfile, filename) opts = { uploaded_data: { tempfile:, filename: } } new(QcFile.new(opts), context) end |
Instance Method Details
#create_with_tempfile ⇒ Object
Create a new QcFile resource with the uploaded data from a temporary file. This is called by the controller when a create request for a QcFile is made. It ensures the contents of the file have been written to a new TempFile instance.
120 121 122 123 |
# File 'app/resources/api/v2/qc_file_resource.rb', line 120 def self.create_with_tempfile(context, tempfile, filename) opts = { uploaded_data: { tempfile:, filename: } } new(QcFile.new(opts), context) end |
#filter_uuid ⇒ Object
Filter the QcFile resources by UUID.
106 |
# File 'app/resources/api/v2/qc_file_resource.rb', line 106 filter :uuid, apply: ->(records, value, ) { records.with_uuid(value) } |