Description
Use the PATCH HTTP request method to update the Metrics Platform Instrument Configurator application.
- PATCH /instrument/:slug
- Validate the double-submit cookie. If the double-submit cookie is invalid, then clear the session cookie and redirect to GET /. Otherwise, continue processing the request.
- Validate the form. If the form invalid, then show the form with validation errors and stop processing and, since the form is state-changing, send a fresh double-submit cookie with the response. Otherwise, continue processing the request.
- Sanitize $slug
- Fetch the details of the instrument with slug=$slug. If there is no instrument, then return an HTTP 404 Not Found response
- merge the request body with the instrument configuration and Insert the corresponding rows into the instrument and instrument_sample_rate tables above.
- Authentication/authorization is required.
Use Case
The PATCH HTTP request method will be used by the frontend application aka Metrics Platform Instrument Configurator (MPIC) to update data.
User Story/ies
As an engineer, I'd like to send a PATCH request to the MPIC endpoint to change an instrument's configuration.
Outcome
Submitting a PATCH HTTP request to the MPIC post endpoint updated rows in the instrument and instrument_sample_rate tables as noted in the data models of the design document.
Acceptance Criteria
- The PATCH endpoint is able to update instrument configuration.
- Double-submit cookie is validated.
- Form validation of post data.
- Graceful failure of invalid data, non-200 responses.
- Logging success/errors to SAL
Required
- Unit/Integration tests
- Testing Instructions
- Documentation
- Passed QA
Technical Notes
TK
Dependencies
- We can stub responses during development - once the datastore is active, data should be inserted into and updated there instead.