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.



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'app/resources/api/v2/pick_list_resource.rb', line 106

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

#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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'app/resources/api/v2/pick_list_resource.rb', line 68

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

#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.



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'app/resources/api/v2/pick_list_resource.rb', line 100

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end
TODO:

this attribute should be read-only. See Y25-236.

A collection of related links for navigation or reference.

Returns:

  • (Hash)

    The related pick list links.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'app/resources/api/v2/pick_list_resource.rb', line 85

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

#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.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'app/resources/api/v2/pick_list_resource.rb', line 91

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

#stateString

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

Returns:

  • (String)

    The pick list state.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'app/resources/api/v2/pick_list_resource.rb', line 78

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

#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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'app/resources/api/v2/pick_list_resource.rb', line 73

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end