Class: Api::V2::RequestResource

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

Overview

TODO:

Figure out how to send a POST for a request with request metadata association. Currently, it is possible to create a request and request metadata seperately, but they are not associated with each other. How do you create the association, either in one request or after the individual requests?

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.



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

attribute :library_type, readonly: true

#optionsObject (readonly)

Note:

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



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

attribute :options, readonly: true

#orderObject (readonly)

The order associated with this request.



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

has_one :order, always_include_linkage_data: true

#poly_metadataArray<PolyMetadatumResource> (readonly)

The metadata associated with the request.

Returns:



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

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:



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

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:



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

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.



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

attribute :priority, write_once: true

#request_metadataRequestMetadataResource (readonly)

The metadata associated with the request.

Returns:



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

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

#request_typeObject (readonly)

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



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

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.



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

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.



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

attribute :state

#submissionObject (readonly)

The submission associated with this request.



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

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.



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

attribute :uuid, readonly: true

Instance Method Details

#pre_capture_pool_idObject

Note:

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



200
201
202
# File 'app/resources/api/v2/request_resource.rb', line 200

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



195
196
197
# File 'app/resources/api/v2/request_resource.rb', line 195

def primer_panel_id
  _model..primer_panel_id
end