Class: V1::Ont::RequestResource

Inherits:
JSONAPI::Resource
  • Object
show all
Includes:
Shared::SourceIdentifierFilterable
Defined in:
app/resources/v1/ont/request_resource.rb

Overview

Note:

Access this resource via the /v1/ont/requests/ endpoint.

Provides a JSON:API representation of Ont::Request.

For more information about JSON:API see the JSON:API Specifications or look at the JSONAPI::Resources package for the service implementation of the JSON:API standard. This resource represents an ONT Request and can return all requests, a single request or multiple requests along with their relationships.

Filters:

  • sample_name

  • source_identifier

Examples:


# Get a single request
curl -X GET http://localhost:3000/v1/ont/requests/1

# Get all requests
curl -X GET http://localhost:3000/v1/ont/requests/

# Filter requests by sample name or source identifier
curl -X GET "http://localhost:3000/v1/ont/requests?filter[sample_name]=sample_name"
curl -X GET "http://localhost:3000/v1/ont/requests?filter[source_identifier]=mock-plate-2:B12"
curl -X GET "http://localhost:3000/v1/ont/requests?filter[source_identifier]=mock-plate-2:B12,mock-plate-3:A1"

# Create a new ONT request
curl -X POST http://localhost:3000/v1/ont/requests \
  -H "Content-Type: application/vnd.api+json" \
  -d '{
        "data": {
          "type": "requests",
          "attributes": {
            "library_type": "ONT",
            "data_type": "Basecalling",
            "cost_code": "S12345",
            "external_study_id": "EXT-001",
            "number_of_flowcells": 2,
            "sample_name": "Sample 1"
          }
        }
      }'

# Update an existing ONT request
curl -X PATCH http://localhost:3000/v1/ont/requests/1 \
  -H "Content-Type: application/vnd.api+json" \
  -d '{
        "data": {
          "id": "1",
          "type": "requests",
          "attributes": {
            "cost_code": "S54321"
          }
        }

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#cost_codeString

Returns the cost code associated with the request.

Returns:

  • (String)

    the cost code associated with the request



77
# File 'app/resources/v1/ont/request_resource.rb', line 77

attributes(*::Ont.request_attributes)

#created_atString (readonly)

Returns the creation timestamp of the request.

Returns:

  • (String)

    the creation timestamp of the request



87
88
# File 'app/resources/v1/ont/request_resource.rb', line 87

attributes :sample_name, :sample_retention_instruction, :source_identifier, :created_at,
readonly: true

#data_typeString

Returns the type of the data.

Returns:

  • (String)

    the type of the data



77
# File 'app/resources/v1/ont/request_resource.rb', line 77

attributes(*::Ont.request_attributes)

#external_study_idString

Returns the external study identifier.

Returns:

  • (String)

    the external study identifier



77
# File 'app/resources/v1/ont/request_resource.rb', line 77

attributes(*::Ont.request_attributes)

#library_typeString

Returns the type of the library.

Returns:

  • (String)

    the type of the library



77
# File 'app/resources/v1/ont/request_resource.rb', line 77

attributes(*::Ont.request_attributes)

#number_of_flowcellsInteger

Returns the number of flowcells requested.

Returns:

  • (Integer)

    the number of flowcells requested



77
# File 'app/resources/v1/ont/request_resource.rb', line 77

attributes(*::Ont.request_attributes)

#sample_nameString (readonly)

Returns the name of the sample.

Returns:

  • (String)

    the name of the sample



87
88
# File 'app/resources/v1/ont/request_resource.rb', line 87

attributes :sample_name, :sample_retention_instruction, :source_identifier, :created_at,
readonly: true

#sample_retention_instructionString (readonly)

Returns the retention instruction for the sample.

Returns:

  • (String)

    the retention instruction for the sample



87
88
# File 'app/resources/v1/ont/request_resource.rb', line 87

attributes :sample_name, :sample_retention_instruction, :source_identifier, :created_at,
readonly: true

#source_identifierString (readonly)

Returns the source identifier of the request.

Returns:

  • (String)

    the source identifier of the request



87
88
# File 'app/resources/v1/ont/request_resource.rb', line 87

attributes :sample_name, :sample_retention_instruction, :source_identifier, :created_at,
readonly: true

Class Method Details

.default_sortObject



100
101
102
# File 'app/resources/v1/ont/request_resource.rb', line 100

def self.default_sort
  [{ field: 'created_at', direction: :desc }]
end

.records_for_populate(*_args) ⇒ Object



124
125
126
# File 'app/resources/v1/ont/request_resource.rb', line 124

def self.records_for_populate(*_args)
  super.preload(:library_type, :data_type)
end