mountetna / magma

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

Create basic /update_model controller #164

Open graft opened 4 years ago

graft commented 4 years ago

A minimal /update_model controller that can perform safe, non-migrating actions might look like this:

  1. Examine each of the actions and validate its required arguments are well-formed
  2. Apply the actions in order to the data graph.

The request contains, at least, { project_name, actions: [ { action, ... }, ... ] } - this allows us to determine the type of each action, which we can use to wrap an action class around the action (like Magma::AddModelAction < Magma::Action for { action: 'add_model' }). This action class can handle most of the argument validation and application logic to actually carry out the appropriate changes. The controller just: (0) wraps the inputs, (1) runs validation on each action and raises if any are invalid, (2) applies each action.

The output of the controller should be the new templates for models that have changed in payload format.

graft commented 4 years ago

Probably the base class is like Magma::Action.new(project_name, action_params)