Class: Api::V2::TubePurposeResource

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

Overview

TODO:

The below POST request does not error if purpose_type is anything other than Tube::Purpose, but the object isn't created. See Y25-236.

Note:

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

Provides a JSON:API representation of Tube::Purpose.

A Tube::Purpose is a base class for the all tube purposes, which describes the role the associated Tube is playing within the lab, and modifies its behaviour.

This resource allows for the management and retrieval of tube purposes.

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:

GET request for all TubePurpose resources

GET /api/v2/tube_purposes/

GET request for a TubePurpose with ID 123

GET /api/v2/tube_purposes/123/

POST request to create a new TubePurpose

POST /api/v2/tube_purposes/
{
  "data": {
    "type": "tube_purposes",
    "attributes": {
      "name": "9DNA Extraction",
      "purpose_type": "Tube::Purpose",
      "target_type": "StockLibraryTube"
    }
  }
}

PATCH request to update a TubePurpose with ID 123

PATCH /api/v2/tube_purposes/123/
{
  "data": {
    "id": 123,
    "type": "tube_purposes",
    "attributes": {
      "name": "DNA Extraction 123",
      "purpose_type": "Tube::Purpose",
      "target_type": "StockLibraryTube"
    }
  }
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseResource

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

Instance Attribute Details

#nameString

Note:

This attribute is required.

Returns The name of the tube purpose, describing the intended use of the tube.

Returns:

  • (String)

    The name of the tube purpose, describing the intended use of the tube.



64
# File 'app/resources/api/v2/tube_purpose_resource.rb', line 64

attribute :name

#purpose_typeString

This is mapped to the type attribute on the model.

Returns:

  • (String)

    The purpose type (e.g., “Tube::Purpose”).



69
# File 'app/resources/api/v2/tube_purpose_resource.rb', line 69

attribute :purpose_type, delegate: :type

#target_typeString

Note:

This attribute is required.

Returns The target type, indicating what type of tube the purpose is associated with (e.g., 'StockLibraryTube').

Returns:

  • (String)

    The target type, indicating what type of tube the purpose is associated with (e.g., 'StockLibraryTube').



75
# File 'app/resources/api/v2/tube_purpose_resource.rb', line 75

attribute :target_type

#uuidString (readonly)

Note:

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

Returns The UUID of the tube purpose.

Returns:

  • (String)

    The UUID of the tube purpose.



80
# File 'app/resources/api/v2/tube_purpose_resource.rb', line 80

attribute :uuid, readonly: true

Instance Method Details

#filter_typeObject

Filter tube purposes by type.

Examples:

GET request with type filter

GET /api/v2/tube_purposes?filter[type]=Extraction


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

filter :type, default: 'Tube::Purpose'