Class: Api::V2::StudyResource

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

Overview

Note:

This resource is immutable: its endpoint will not accept POST, PATCH, or DELETE requests.

Note:

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

A Study is a collection of various samples and the work done on them.

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 studies

GET /api/v2/studies/

GET request for a study with ID 123

GET /api/v2/studies/123/

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 (readonly)

Returns The name of the study.

Returns:

  • (String)

    The name of the study.



32
# File 'app/resources/api/v2/study_resource.rb', line 32

attribute :name

#poly_metadataArray<PolyMetadatumResource> (readonly)

This metadata allows for the flexible extension of study attributes.

Returns:



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

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

#uuidString (readonly)

Note:

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

Returns The UUID of the study.

Returns:

  • (String)

    The UUID of the study.



37
# File 'app/resources/api/v2/study_resource.rb', line 37

attribute :uuid

Instance Method Details

#filter_by_name(name) ⇒ Object

Allows filtering studies by their name.

Examples:

GET /api/v2/studies?filter=Genomics Study

Parameters:

  • name (String)

    The name of the study to filter by.



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

filter :name

#filter_by_state(state) ⇒ Object

Allows filtering studies by their state (e.g., active, archived).

Examples:

GET /api/v2/studies?filter=active

Parameters:

  • state (String)

    The state of the study to filter by.



62
# File 'app/resources/api/v2/study_resource.rb', line 62

filter :state, apply: lambda { |records, value, _options| records.by_state(value) }

#filter_by_user(user_id) ⇒ Object

Allows filtering studies by the user who owns or manages them.

Examples:

Parameters:

  • user_id (String)

    The ID of the user to filter by.



68
# File 'app/resources/api/v2/study_resource.rb', line 68

filter :user, apply: lambda { |records, value, _options| records.by_user(value) }