Skip to content

API Model Helpers

Chris Martin requested to merge cmart/exosphere:issue-427-attempt-3 into master

For many resources in the model (e.g. servers), we track the loading status. When we make an API request for one of these resources, we must update the model to reflect that we are loading it. Previously, we would do these as two separate, de-coupled actions.

I think these actions should generally be coupled -- we should reach for one function which both fires the Cmd to request the resource, and sets it as loading in the model. I think this will produce cleaner high-level code and less opportunity for mistakes. This MR attempts to do that with Rest.ApiModelHelpers. The requestServers function both makes the request and updates the model to show it is loading.

I am also trying out a pipelineCmd function, which makes it easy to pipeline functions which expect a Model and return a (Model, Cmd Msg). For example, the following pipeline makes three API requests and sets the resource status to loading for each!

( model, cmd )
    |> Helpers.pipelineCmd (ApiModelHelpers.requestNetworks project.auth.project.uuid)
    |> Helpers.pipelineCmd (ApiModelHelpers.requestComputeQuota project.auth.project.uuid)
    |> Helpers.pipelineCmd (ApiModelHelpers.requestVolumeQuota project.auth.project.uuid)

This is sort of related to #427 (closed).

To do

  • What to do about Orchestration module, which generally deals in Projects rather than the entire Model? See #431.

How to Test

(Please describe how to exercise these changes in the application)

Screenshots

(If visual changes are introduced, show what they look like)

Edited by Chris Martin

Merge request reports