Class: Api::V2::QcFileResource
- Inherits:
-
BaseResource
- Object
- JSONAPI::Resource
- BaseResource
- Api::V2::QcFileResource
- Defined in:
- app/resources/api/v2/qc_file_resource.rb
Overview
Access this resource via the /api/v2/qc_files/
endpoint.
This resource cannot be modified after creation: its endpoint will not accept PATCH
requests.
Known issue
Occasionally, encoding failures may occur resulting in 500 Internal Server errors mentioning from ASCII-8BIT to UTF-8
. If this occurs, try re-requesting the resource without including the contents
attribute, for example: /api/v2/qc_files/1?fields[qc_files]=filename,uuid,created_at
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
Returns the file contents as UTF-8.
-
#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
Instance Method Summary collapse
-
#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.
56 |
# File 'app/resources/api/v2/qc_file_resource.rb', line 56 attribute :content_type, readonly: true |
#contents ⇒ String
Returns the file contents as UTF-8.
Not all uploaded files contain encoding information, causing encoding errors on less-common characters. See background at yehudakatz.com/2010/05/05/ruby-1-9-encodings-a-primer-and-the-solution-for-rails/
96 |
# File 'app/resources/api/v2/qc_file_resource.rb', line 96 attribute :contents, write_once: true |
#created_at ⇒ DateTime (readonly)
Returns The date and time the QC file was created.
60 |
# File 'app/resources/api/v2/qc_file_resource.rb', line 60 attribute :created_at, readonly: true |
#filename ⇒ String
Returns The filename of the QC file. This can only be written once on creation.
114 |
# File 'app/resources/api/v2/qc_file_resource.rb', line 114 attribute :filename, write_once: true |
#labware ⇒ LabwareResource
Returns The Labware which this QcFile belongs to.
76 |
# File 'app/resources/api/v2/qc_file_resource.rb', line 76 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.
64 |
# File 'app/resources/api/v2/qc_file_resource.rb', line 64 attribute :size, readonly: true |
#uuid ⇒ String (readonly)
Returns The UUID of the bulk transfers operation.
68 |
# File 'app/resources/api/v2/qc_file_resource.rb', line 68 attribute :uuid, readonly: true |
Class Method Details
.create(context) ⇒ Object
117 118 119 120 |
# File 'app/resources/api/v2/qc_file_resource.rb', line 117 def self.create(context) opts = { uploaded_data: context.slice(:filename, :tempfile) } new(QcFile.new(opts), context) end |
Instance Method Details
#filter_uuid ⇒ Object
Filter the QcFile resources by UUID.
86 |
# File 'app/resources/api/v2/qc_file_resource.rb', line 86 filter :uuid, apply: ->(records, value, ) { records.with_uuid(value) } |