Skip to content

Instantly share code, notes, and snippets.

@antw
Last active May 15, 2020 17:17
Show Gist options
  • Save antw/3eea19501562885b58a989ac09ca3bb7 to your computer and use it in GitHub Desktop.
Save antw/3eea19501562885b58a989ac09ca3bb7 to your computer and use it in GitHub Desktop.
Questions about copying / resetting scenarios

Create a copy of a scenario

When creating the new scenario, send the scenario_id of the scenario to be copied (the "source scenario") as part of the JSON body.

// POST /api/v3/scenarios HTTP/2
// Host: engine.energytransitionmodel.com
// Accept: */*
// Content-Type: application/json

{
  "scenario": {
    "scenario_id": ${SCENARIO_ID}
  }
}

For example:

curl \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{ "scenario": { "scenario_id": 155680 } }' \
  https://engine.energytransitionmodel.com/api/v3/scenarios

Reset an input to its default value

Where you would normally provide the input key and numeric value, instead provide the string "reset" as the value.

// PUT /api/v3/scenarios/${SCENARIO_ID} HTTP/2
// Host: engine.energytransitionmodel.com
// Accept: */*
// Content-Type: application/json

{
  "scenario": {
    "user_values": {
      "${INPUT_KEY}": "reset"
    }
  }
}

For example:

curl \
  -X PUT \
  -H "Content-Type: application/json" \
  -d '{"scenario": { "user_values": { "buildings_insulation_level": "reset" } } }' \
  https://engine.energytransitionmodel.com/api/v3/scenarios/760089

Note that if your scenario is a copy of another (i.e., it was created like "Create a copy of a scenario" describes, above), the input value will not be removed. Rather, it will be reset to the value contained in the source scenario.

@robcalon
Copy link

Thanks for the support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment