Class: Api::V2::PurposeResource

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

Overview

Note:

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

Note:

the below example is currently broken, as target_type is a required attribute in the model and lifespan is not.

Provides a JSON:API representation of Purpose.

A Purpose defines the intended function of a labware or sample within the system. While it was historically limited to PlatePurpose, it now applies to other labware like Tubes.

}

For more details on JSON:API, see the JSON:API Specifications or check out the JSONAPI::Resources package for Sequencescape's implementation.

Examples:

Fetching all purposes

GET /api/v2/purposes

Fetching a purpose by ID

GET /api/v2/purposes/{id}

Creating a new purpose

POST /api/v2/purposes
{
  "data": {
      "type": "purposes",
      "attributes": {
         "name": "ExamplePurpose",
         "size": 96,
         "lifespan": 1
      }
  }

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

#lifespanInteger

The expected lifespan of the purpose.

Returns:

  • (Integer)


61
# File 'app/resources/api/v2/purpose_resource.rb', line 61

attribute :lifespan, write_once: true

#nameString

The name of the purpose.

Returns:

  • (String)


51
# File 'app/resources/api/v2/purpose_resource.rb', line 51

attribute :name, write_once: true

#sizeInteger

The expected size of the purpose.

Returns:

  • (Integer)


56
# File 'app/resources/api/v2/purpose_resource.rb', line 56

attribute :size, write_once: true

#uuidString (readonly)

Note:

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

Returns The universally unique identifier (UUID) of purpose.

Returns:

  • (String)

    The universally unique identifier (UUID) of purpose.



46
# File 'app/resources/api/v2/purpose_resource.rb', line 46

attribute :uuid, readonly: true

Instance Method Details

#filter_by_nameObject

Allows filtering projects by name.

Examples:

Fetching a purpose by name

GET /api/v2/purposes?filter[name]=ExamplePurpose


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

filter :name