Class: Api::V2::TubePurposeResource

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

Overview

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.



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

attribute :name

#purpose_typeString

This is mapped to the type attribute on the model.

Returns:

  • (String)

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



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

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').



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

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.



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

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


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

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