Class: Api::V2::TransferRequestCollectionResource

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

Overview

Note:

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

Note:

This resource cannot be modified after creation: its endpoint will not accept PATCH requests.

Provides a JSON:API representation of TransferRequestCollection

A TransferRequestCollection provides a means of bulk creating transfer requests between arbitrary sources and destinations. This resource allows the creation of a collection of transfer requests in a single transaction, avoiding multiple server calls for each transfer request.

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.

Examples:

POST request to create a TransferRequestCollection with multiple transfer requests

POST /api/v2/transfer_request_collections/
{
  "data": {
    "type": "transfer_request_collections",
    "attributes": {
      "transfer_requests_attributes": [
        {
          "source_asset": "dc33e42e-f5e1-11ef-98fe-000000000000",
          "target_asset": "de19e8e2-f5e1-11ef-98fe-000000000000",
          "aliquot_attributes": {
            "tag_depth": "2"
          }
        },
        {
          "source_asset": "44444444-5555-6666-7777-888888999999",
          "target_asset": "55555555-6666-7777-8888-999999000000",
          "aliquot_attributes": {
            "tag_depth": "3"
          }
        }
      ]
    },
    "relationships": {
      "user": {
        "data": {
          "type": "users",
          "id": 4
        }
      }
    }
  }
}

GET request for all TransferRequestCollection resources

GET /api/v2/transfer_request_collections/

GET request for a TransferRequestCollection with ID 123

GET /api/v2/transfer_request_collections/123/

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

#target_tubesArray<TubeResource> (readonly)

in this collection.

Returns:

  • (Array<TubeResource>)

    An array of tubes that are the targets for the transfer requests



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'app/resources/api/v2/transfer_request_collection_resource.rb', line 116

 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

#transfer_requestsArray<TransferRequestResource> (readonly)

Returns An array of transfer requests within this collection.

Returns:



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'app/resources/api/v2/transfer_request_collection_resource.rb', line 120

 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

#transfer_requests_attributes=(value) ⇒ Void (writeonly)

Deprecated.

Use the transfer_requests relationship instead.

To enable the creation of TransferRequest records server side in a single transaction, the attributes for transfer requests to be included in the collection can be passed as an array of hashes. These will be created at the same time as the TransferRequestCollection to avoid making multiple server calls.

Examples:

Hashes should contain the following data about each transfer request

{
  'source_asset': 'The UUID of the source asset as a string.',
  'target_asset': 'The UUID of the destination asset as a string.',
  'aliquot_attributes': {
    'tag_depth': 'The tag depth of the source as a string.'
  }
}

Parameters:

  • value (Array<Hash>)

    An array of hashes, where each hash contains the attributes for a transfer request.

Returns:

  • (Void)

See Also:



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'app/resources/api/v2/transfer_request_collection_resource.rb', line 81

 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

#userUserResource

Note:

This relationship is required.

Setting this relationship alongside the user_uuid attribute will override the attribute value.

Returns:

  • (UserResource)

    The user who initiated the creation of this transfer request collection.



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'app/resources/api/v2/transfer_request_collection_resource.rb', line 126

 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

#user_uuid=(value) ⇒ Void (writeonly)

Deprecated.

Use the user relationship instead. See Y25-236.

Declared for convenience when the user is not available to set as a relationship. Setting this attribute alongside the user relationship will prefer the relationship value.

Parameters:

  • value (String)

    The UUID of the user who initiated the creation of this transfer request collection.

Returns:

  • (Void)

See Also:



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

 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

#uuidString (readonly)

Note:

This identifier is automatically assigned upon creation and cannot be modified.

Returns The UUID of the transfer request collection.

Returns:

  • (String)

    The UUID of the transfer request collection.



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

 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