mountetna / magma

Data server with friendly data loaders
GNU General Public License v2.0
5 stars 2 forks source link

Add /update_model API endpoint #168

Closed alimi closed 4 years ago

alimi commented 4 years ago

This PR adds a /update_model API endpoint per #131. So far it supports updating an attribute's options.

The endpoint is backed by the newly added UpdateModelController. It will iterate over the array of actions it receives, and defer to action classes to perform those actions. For example, an update_attribute action will be performed by Magma::UpdateAttribute.

In addition to performing actions, each action class is responsible for validating its action params. This division of responsibilities will help keep UpdateModelController pretty stable as we add new actions. It will also make it easier for us to parallelize the work going forward.

We've also restricted the endpoint to superusers based on conversations we've had in the past. We can change the permissions if something else makes sense.

alimi commented 4 years ago

Heh, we did this before stuff was better described in https://github.com/mountetna/magma/issues/164 and https://github.com/mountetna/magma/issues/165 😆. I think we came to same conclusions.

graft commented 4 years ago

Pretty much exactly what I imagined. It seems there is as of yet no base Magma::Action type class (is that the right name?), I guess it will show up later.

As a sanity check I might verify that this thing refuses to change the attribute name and type.

Otherwise... can this just be merged? o_O

alimi commented 4 years ago

If everyone is agreeable, I think we should merge in this PR. It sets up a decent foundation for us to build off of, and we can avoid having a long running PR 😄

graft commented 4 years ago

Sure, let's merge to have a solid footing.