==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 [[ https://docs.google.com/document/d/1ShOnODmq_RnRWE2h4oHIxyrCUDSjdL2zqDfT3aHp_lo/edit#heading=h.ye4o5addy3wp | 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 [[ https://wikitech.wikimedia.org/wiki/Server_Admin_Log | 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.
==Artifacts & Resources
- [[ https://miro.com/app/board/uXjVMtGrgVc=/?moveToWidget=3458764579792923671&cot=14 | Architecture Diagram ]]
- [[ https://docs.google.com/document/d/1ShOnODmq_RnRWE2h4oHIxyrCUDSjdL2zqDfT3aHp_lo/edit#heading=h.dkwj61y6h2kw | Instrument Configurator Implementation Design Doc ]]
- [[ https://www.figma.com/file/DeYZ9XwYNqbT0NW2aL8GdM/T352903---Metrics-Platform---Control-Plane?type=design&node-id=432-14297&mode=design&t=J0YulBdr19TkbeLR-0 | Wireframes ]]