Class: Api::V2::Sapio::StudiesController

Inherits:
JSONAPI::ResourceController
  • Object
show all
Includes:
Concerns::ApiKeyAuthenticatable
Defined in:
app/controllers/api/v2/sapio/studies_controller.rb

Overview

Provides a JSON:API endpoint for Sapio to query Studies by name pattern. This endpoint is feature-flagged and returns a limited result set (max 20 studies).

Constant Summary collapse

RESULTS_RANGE =

The range of valid values for the custom maxResults query parameter to override the default maximum number of search results returned by the index action (Api::V2::BaseResource::MAX_RESULTS).

1..1000

Instance Method Summary collapse

Instance Method Details

#createvoid

Note:

This endpoint is intended exclusively for creating new studies that originate in Sapio. It should NOT be used to transfer an existing Sequencescape study to Sapio — use the update (PATCH) endpoint for that purpose, which sets externally_managed on an existing record.

Note:

Requires an Integration Hub API key. All other callers will receive a 403 Forbidden response.

Note:

Requires the :y26_172_enable_externally_managed_study_restrictions feature flag to be enabled. Returns 404 otherwise.

This method returns an undefined value.

Creates a new Study that is mastered in Sapio (externally_managed: true) from the Integration Hub payload and grants ownership to the requesting user.

Expected Payload

The request body must be a JSON object with a top-level study key:

POST /api/v2/sapio/studies
Content-Type: application/json
X-Sequencescape-Client-Id: <integration_hub_api_key>

{ "study": { "name": "(required) Unique study name, max 200 chars", "uuid": "(required) UUID to assign to the study, must be a valid UUID string" } }

Responses

[201 Created] Study created successfully. Body contains id, uuid, name, and a self link. [403 Forbidden] Missing or non-Integration Hub API key. [404 Not Found] Feature flag disabled. [422 Unprocessable Entity] Validation failed (e.g. missing name). Body contains errors array.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'app/controllers/api/v2/sapio/studies_controller.rb', line 75

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

#indexvoid

This method returns an undefined value.

Enforces a name search constraint on resource index listing.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/api/v2/sapio/studies_controller.rb', line 22

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

#showvoid

This method returns an undefined value.

Displays details for a single study resource.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/api/v2/sapio/studies_controller.rb', line 32

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end