Page MenuHomePhabricator

[User Story] Build the MPIC API endpoints - PATCH /instrument/:slug
Open, Needs TriagePublic5 Estimated Story Points

Description

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.

Artifacts & Resources

Event Timeline

cjming set the point value for this task to 3.Wed, Apr 10, 4:38 PM
cjming changed the point value for this task from 3 to 5.Wed, Apr 10, 8:58 PM

Spun off several tickets from here to fix issues in the current feature branch - https://gitlab.wikimedia.org/repos/data-engineering/mpic/-/merge_requests/9

Moving this ticket to review in spite of issues to get synced on front end in time for next demo.

@Sfaci you can see in the linked tickets above that these are the 5 top issues that need fixing