Class: Api::V2::RequestResource

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

Overview

Note:

This resource supports GET and PATCH requests. It allows fetching requests by their attributes and updating them.

Provides a JSON:API representation of Request.

A Request represents work which needs to be done, either to fulfil a customers needs CustomerRequest or for internal reasons SystemRequest. The progress of a request is tracked through its state machine.

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

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

Examples:

GET request to retrieve all requests

GET /api/v2/requests/

POST request to create a new request

POST /api/v2/requests/
{
  "data": {
    "type": "requests",
    "attributes": {
      "role": "analysis",
      "state": "pending",
      "priority": "high"
    },
    "relationships": {
      "submission": {
        "data": {
          "type": "submissions",
          "id": "123"
        }
      },
      "order": {
        "data": {
          "type": "orders",
          "id": "456"
        }
      },
      "request_type": {
        "data": {
          "type": "request_types",
          "id": "789"
        }
      }
    }
  }
}

PATCH request to update an existing request

PATCH /api/v2/requests/1
{
  "data": {
    "id": "1",
    "type": "requests",
    "attributes": {
      "state": "completed",
      "priority": "medium"
    }
  }
}

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

#library_typeObject (readonly)

Note:

This method retrieves the library type associated with the request.



111
# File 'app/resources/api/v2/request_resource.rb', line 111

attribute :library_type, readonly: true

#optionsObject (readonly)

Note:

This method retrieves the options associated with the request, including metadata from the request_metadata relationship.



105
# File 'app/resources/api/v2/request_resource.rb', line 105

attribute :options, readonly: true

#orderObject (readonly)

The order associated with this request.



125
# File 'app/resources/api/v2/request_resource.rb', line 125

has_one :order, always_include_linkage_data: true

#poly_metadataArray<PolyMetadatumResource> (readonly)

The metadata associated with the request.

Returns:



147
# File 'app/resources/api/v2/request_resource.rb', line 147

has_many :poly_metadata, as: :metadatable, class_name: 'PolyMetadatum'

#pre_capture_poolPreCapturePoolResource (readonly)

Note:

This relationship is read-only.

The pre-capture pool associated with the request.

Returns:



142
# File 'app/resources/api/v2/request_resource.rb', line 142

has_one :pre_capture_pool, readonly: true

#primer_panelPrimerPanelResource (readonly)

Note:

This relationship is read-only.

The primer panel used for the request, if applicable.

Returns:



136
# File 'app/resources/api/v2/request_resource.rb', line 136

has_one :primer_panel, readonly: true

#priorityString

Note:

This attribute can only be set once.

The priority of the request, such as “high,” “medium,” or “low.”

Returns:

  • (String)

    The priority of the request.



99
# File 'app/resources/api/v2/request_resource.rb', line 99

attribute :priority, write_once: true

#request_metadataRequestMetadataResource (readonly)

The metadata associated with the request.

Returns:



152
# File 'app/resources/api/v2/request_resource.rb', line 152

has_one :request_metadata, class_name: 'RequestMetadata', foreign_key_on: :related

#request_typeObject (readonly)

The type of the request, such as “analysis” or “testing.”



130
# File 'app/resources/api/v2/request_resource.rb', line 130

has_one :request_type, always_include_linkage_data: true

#roleString

Note:

This attribute can only be set once.

The role of the request, such as “analysis” or “testing.”

Returns:

  • (String)

    The role of the request.



87
# File 'app/resources/api/v2/request_resource.rb', line 87

attribute :role, write_once: true

#stateString

Note:

This field can be updated during the lifecycle of the request.

The current state of the request, such as “pending,” “completed,” or “in progress.”

Returns:

  • (String)

    The state of the request.



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

attribute :state

#submissionObject (readonly)

The submission associated with this request.



120
# File 'app/resources/api/v2/request_resource.rb', line 120

has_one :submission, always_include_linkage_data: true

#uuidString (readonly)

Note:

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

The UUID of the request.

Returns:

  • (String)

    The unique identifier for the request.



81
# File 'app/resources/api/v2/request_resource.rb', line 81

attribute :uuid, readonly: true

Instance Method Details

#pre_capture_pool_idObject

Note:

This method retrieves the pre-capture pool ID associated with the request.



183
184
185
# File 'app/resources/api/v2/request_resource.rb', line 183

def pre_capture_pool_id
  _model.pooled_request&.pre_capture_pool_id
end

#primer_panel_idObject

Note:

This method retrieves the primer panel ID associated with the request.

JSONAPI::Resource doesn't support has_one through relationships by default



178
179
180
# File 'app/resources/api/v2/request_resource.rb', line 178

def primer_panel_id
  _model..primer_panel_id
end