Class: Api::V2::Sapio::OperationsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Api::V2::Sapio::OperationsController
- Includes:
- Concerns::ApiKeyAuthenticatable, Concerns::SchemaCheckable
- Defined in:
- app/controllers/api/v2/sapio/operations_controller.rb
Overview
Receives operation requests from Integration Hub, such as a combined reception and work order request, and records each as an ApiOperation whose type is the request's request_type.
The payload is plain JSON rather than JSON:API, so this is a plain controller rather than a JSON:API resource controller.
The endpoint is behind the y26_282_sapio_operations_endpoint
feature flag and accepts requests only with the Integration Hub API
key.
Constant Summary collapse
- PAYLOAD_LOG_FILTER =
Matches every parameter name except the routing ones, so the payload is logged as [FILTERED].
/\A(?!(?:controller|action|format)\z)/- NOT_AN_OBJECT =
The error detail for a body that is not a JSON object
'The request body must be a JSON object.'- NO_EXTERNAL_ID =
The error detail for a missing or empty request ID
'request.external_id must be a non-empty string.'
Constants included from FlashTruncation
FlashTruncation::STRING_OVERHEAD
Instance Method Summary collapse
-
#create ⇒ void
Accepts an operation request.
Methods inherited from ApplicationController
#block_api_access, #evil_parameter_hack!, #extract_header_info, #set_cache_disabled!
Methods included from AuthenticatedSystem
Methods included from FlashTruncation
#max_flash_size, #truncate_flash, #truncate_flash_array
Instance Method Details
#create ⇒ void
This method returns an undefined value.
Accepts an operation request.
A repeat of an earlier request, with the same request ID and the same payload, returns the existing operation instead of creating another one. The same request ID with a different payload is a conflict. Only a new request is checked against the schema, so the answer to a repeat doesn't depend on the schema in use.
Two requests with the same request ID can both find no operation and then both try to save one. The unique index lets only one save, and the other is answered as a repeat.
If the schema can't be loaded, a new request gets a server error and nothing is saved.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/controllers/api/v2/sapio/operations_controller.rb', line 62 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 |