Class: Api::V2::PickListResource

Inherits:
BaseResource
  • Object
show all
Defined in:
app/resources/api/v2/pick_list_resource.rb

Overview

Note:

Access this resource via the /api/v2/pick_lists/ endpoint.

Provides a JSON:API representation of PickList.

A PickList is a lightweight wrapper to provide a simplified interface for automatically generating batches for the CherrypickPipeline. It is intended to isolate external applications from the implementation and to provide an interface for eventually building a simplified means for generating cherrypicks

For more information about JSON:API, see the JSON:API Specifications or the JSONAPI::Resources package for Sequencescape's implementation of the JSON:API standard.

Examples:

GET request to retrieve all pick lists

GET /api/v2/pick_lists/

GET request to retrieve a specific pick list by ID

GET /api/v2/pick_lists/123/

POST request to create a new pick list (receptacle-based picks)

POST /api/v2/pick_lists/
{
  "data": {
    "type": "pick_lists",
    "attributes": {
      "asynchronous": true,
      "pick_attributes": [{ "source_receptacle_id": 96, "study_id": 1, "project_id": 1 }]
    }
  }
}

POST request to create a new pick list (labware-based picks)

POST /api/v2/pick_lists/
{
  "data": {
    "type": "pick_lists",
    "attributes": {
      "asynchronous": true,
      "labware_pick_attributes": [
        { "source_labware_id": 1, "source_labware_barcode": "SQPD-9001", "study_id": 1, "project_id": 1 }
      ]
    }
  }
}

Constant Summary collapse

PERMITTED_PICK_ATTRIBUTES =

List of permitted attributes for pick creation based on receptacles.

%i[source_receptacle_id study_id project_id].freeze
PERMITTED_LABWARE_PICK_ATTRIBUTES =

List of permitted attributes for pick creation based on labware.

%i[source_labware_id source_labware_barcode study_id project_id].freeze

Instance Attribute Summary collapse

Method Summary

Methods inherited from BaseResource

apply_includes, creatable_fields, default_includes, #fetchable_fields, inclusions, resolve_relationship_names_to_relations, updatable_fields

Instance Attribute Details

#asynchronousBoolean

Note:

this attribute defaults to true if not provided.

Indicates whether the pick list should be processed asynchronously.

Returns:

  • (Boolean)

    Whether the operation should be handled asynchronously.



105
# File 'app/resources/api/v2/pick_list_resource.rb', line 105

attribute :asynchronous

#created_atString (readonly)

Note:

This timestamp is automatically assigned upon creation.

Returns The timestamp indicating when the pick list was created.

Returns:

  • (String)

    The timestamp indicating when the pick list was created.



68
# File 'app/resources/api/v2/pick_list_resource.rb', line 68

attribute :created_at, readonly: true

#labware_pick_attributes=(labware_picks) ⇒ Object (writeonly)

This provides an alternative API for passing in a list of labware, either by ids or barcodes. This avoids the need to make additional requests for the receptacle ids. We keep this as a separate accessor to avoid the confusion of passing in a list of 12 picks, and receiving more back.

Parameters:

  • labware_picks (Array<Hash>)

    A list of pick attributes containing source_labware_barcode, study_id, and project_id.

Raises:

  • (JSONAPI::Exceptions::BadRequest)

    If a provided attribute does not match an actual record.



99
# File 'app/resources/api/v2/pick_list_resource.rb', line 99

attribute :labware_pick_attributes, writeonly: true
TODO:

this attribute should be read-only.

A collection of related links for navigation or reference.

Returns:

  • (Hash)

    The related pick list links.



84
# File 'app/resources/api/v2/pick_list_resource.rb', line 84

attribute :links, write_once: true

#pick_attributesArray<Hash>

Retrieves the formatted pick attributes for API response.

Returns:

  • (Array<Hash>)

    A list of pick attributes containing source_receptacle_id, study_id, and project_id.



90
# File 'app/resources/api/v2/pick_list_resource.rb', line 90

attribute :pick_attributes

#stateString

The current state of the pick list, indicating its processing status.

Returns:

  • (String)

    The pick list state.



78
# File 'app/resources/api/v2/pick_list_resource.rb', line 78

attribute :state, write_once: true

#updated_atString (readonly)

Note:

This timestamp is automatically updated upon modification.

Returns The timestamp indicating when the pick list was last updated.

Returns:

  • (String)

    The timestamp indicating when the pick list was last updated.



73
# File 'app/resources/api/v2/pick_list_resource.rb', line 73

attribute :updated_at, readonly: true