Closed reginafcompton closed 5 years ago
This PR adds a new endpoint that enables the deletion of PII on user-specified basis. Handles issue #6.
I added a new UserResource with a single method (POST). The resource calls a new handler function: remove_pii. It expects a JSON payload with "mci_id" as a key, and if the provided mci_id exists in the database, remove_pii removes data from specified fields and adds an entry in the IndividualPIIRemoval table.
remove_pii
Note! I made changes in the mci-database repo to accommodate the functionality of remove_pii: https://github.com/brighthive/mci-database/blob/master/mci_database/db/migrations/versions/2c384e2c23b7_.py
mci-database
https://github.com/brighthive/mci-database/blob/master/mci_database/db/migrations/versions/a50481349c3c_.py
Both the mci and mci-matching-service containers need to be rebuilt to pull in these changes.
remove_pii queries for a user and return that user (if it exists) or return an error (if not). Another function in the user handler does the same thing. So, I moved that logic into a reusable, single-responsibility function: https://github.com/brighthive/master-client-index/pull/7/files#diff-78c473abf1b6298387b01f93e5e68afcR65
I also added a custom error IndividualDoesNotExist, which makes the code DRYer when raising and returning the associated message: https://github.com/brighthive/master-client-index/pull/7/files#diff-fd5384f27f938913b59aceb16633e261R57
IndividualDoesNotExist
I wrote some tests. General excitement about mocking deeply coded dependencies and requests.
@gregmundy - per our conversation this morning I changed the status codes for the error messages. Merging now! Happy deployment!
Overview
This PR adds a new endpoint that enables the deletion of PII on user-specified basis. Handles issue #6.
Main changes
A new resource
I added a new UserResource with a single method (POST). The resource calls a new handler function:
remove_pii
. It expects a JSON payload with "mci_id" as a key, and if the provided mci_id exists in the database,remove_pii
removes data from specified fields and adds an entry in the IndividualPIIRemoval table.Note! I made changes in the
mci-database
repo to accommodate the functionality ofremove_pii
: https://github.com/brighthive/mci-database/blob/master/mci_database/db/migrations/versions/2c384e2c23b7_.pyhttps://github.com/brighthive/mci-database/blob/master/mci_database/db/migrations/versions/a50481349c3c_.py
Both the mci and mci-matching-service containers need to be rebuilt to pull in these changes.
Refactoring
remove_pii
queries for a user and return that user (if it exists) or return an error (if not). Another function in the user handler does the same thing. So, I moved that logic into a reusable, single-responsibility function: https://github.com/brighthive/master-client-index/pull/7/files#diff-78c473abf1b6298387b01f93e5e68afcR65I also added a custom error
IndividualDoesNotExist
, which makes the code DRYer when raising and returning the associated message: https://github.com/brighthive/master-client-index/pull/7/files#diff-fd5384f27f938913b59aceb16633e261R57Tests
I wrote some tests. General excitement about mocking deeply coded dependencies and requests.