A minimal /update_model controller that can perform safe, non-migrating actions might look like this:
Examine each of the actions and validate its required arguments are well-formed
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.
A minimal /update_model controller that can perform safe, non-migrating actions might look like this:
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 (likeMagma::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.