Class: Api::V2::StateChangeResource

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

Overview

Note:

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

Note:

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

Provides a JSON:API representation of StateChange

A StateChange records a transition from one state to another for a piece of labware.

}

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 change the state of a target labware

POST /api/v2/state_changes/
{
  "data": {
      "type": "state_changes",
      "attributes": {
          "target_state": "passed",
          "user_uuid": "daa2b6be-3794-11ef-a6f5-26ddcd6c52d7",
          "customer_accepts_responsibility": false
      },
      "relationships": {
          "target": { "data": { "type": "labware", "id": 6 } },
          "user": { "data": { "type": "users", "id": 4 } }
      }
  }

GET request for all StateChange records

GET /api/v2/state_changes/

GET request for a specific StateChange with ID 789

GET /api/v2/state_changes/789/

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

#contentsArray

Note:

This is an optional attribute.

Some targets can have “contents” updated (notably plates). The meaning of this is is dealt with by the target being updated.

Returns:

  • (Array)

    Array of “contents” to fail, deciphered by the target.



48
# File 'app/resources/api/v2/state_change_resource.rb', line 48

attribute :contents

#customer_accepts_responsibility=(value) ⇒ Void (writeonly)

Parameters:

  • value (Boolean)

    Sets whether the customer proceeded against advice and will still be charged in the event of a failure.

Returns:

  • (Void)


54
# File 'app/resources/api/v2/state_change_resource.rb', line 54

attribute :customer_accepts_responsibility, writeonly: true

#previous_stateString (readonly)

The state of the target labware before this state change was applied.

Returns:

  • (String)

    The previous state of the target before this state change.



59
# File 'app/resources/api/v2/state_change_resource.rb', line 59

attribute :previous_state, readonly: true

#reasonString

The reason provided for the state change. This can be used to explain why the transition occurred.

Returns:

  • (String)

    The previous state of the target before this state change.



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

attribute :reason

#targetLabwareResource

Note:

This relationship is required.

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

Returns:



119
# File 'app/resources/api/v2/state_change_resource.rb', line 119

has_one :target, class_name: 'Labware'

#target_stateString

Note:

This attribute is required.

The new state to which the target will be transitioned.

Returns:

  • (String)

    The state of the target after this state change.



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

attribute :target_state

#target_uuid=(value) ⇒ Void (writeonly)

Deprecated.

Use the target relationship instead.

This is provided as a shortcut for setting the target relationship. If both this attribute and the target relationship are provided, the relationship takes precedence.

Parameters:

  • value (String)

    The UUID of the labware affected by this state change.

Returns:

  • (Void)

See Also:



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

attribute :target_uuid, writeonly: true

#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 this state change.



113
# File 'app/resources/api/v2/state_change_resource.rb', line 113

has_one :user

#user_uuid=(value) ⇒ Void (writeonly)

Deprecated.

Use the user relationship instead.

This is provided as a shortcut for setting the user relationship. If both this attribute and the user relationship are provided, the relationship takes precedence.

Parameters:

  • value (String)

    The UUID of the user who performed this state change.

Returns:

  • (Void)

See Also:



93
# File 'app/resources/api/v2/state_change_resource.rb', line 93

attribute :user_uuid, writeonly: true

#uuidString (readonly)

Note:

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

The UUID identifier for this state change.

Returns:

  • (String)

    The UUID of the state change.



103
# File 'app/resources/api/v2/state_change_resource.rb', line 103

attribute :uuid, readonly: true