OasisLMF / OasisPlatform

Loss modelling platform.
BSD 3-Clause "New" or "Revised" License
42 stars 16 forks source link

Accept settings JSON on analysis or model creation #1067

Closed sambles closed 1 week ago

sambles commented 2 weeks ago

Accept settings JSON on analysis or model creation

Models and Analyses V2 endpoints now accept settings json on POST and PATCH calls via an optional 'settings: { .. json ..}' field. These are validated before the new object is created, if valid the settings are loaded into the newly created (or updated) instance.

Example Analysis (POST / PATCH)

{
  "name": "string",
  "portfolio": 1,
  "model": 1,
  "settings": {
    "model_name_id": "PiWind",
    "model_supplier_id": "OasisLMF",
    "gul_threshold": 0,
    "gul_output": true,
    "model_settings": {
        "event_set": "p",
        "event_occurrence_id": "lt"
    },
    "gul_summaries": [
        {"id": 1, "eltcalc": true}
    ],
    "il_output": false,
    "il_summaries": [],
    "ri_output": 'foo',
    "ri_summaries": []
  }
}

Example Model (POST / PATCH)

{
  "supplier_id": "OasisLMF",
  "model_id": "PiWind",
  "version_id": "ver",
  "settings": {  
    "model_settings":{
        "event_set":{
            "name": "Event Set",
            "desc": "Piwind Event Set selection",
            "default": "p",
            "options":[
                {"id":"p", "desc": "Probabilistic", "number_of_events": 1447}
            ]
         },
        "event_occurrence_id":{
            "name": "Occurrence Set",
            "desc": "PiWind Occurrence selection",
            "default": "lt",
            "options":[
                {"id":"lt", "desc": "Long Term"}
            ]
        }
     },
    "lookup_settings":{},
    "model_default_samples" :10
  }
}