Update a KPI instance
                This endpoint updates a KPI instance.
The update KPI body contains a JSON file, composed of several fields.
The complete list of fields that cannot be edited is as follows:
- editable
 - template
 - id
 - filters
 - improvingDirection
 - unit
 - resultType
 - deleted
 - provider
 - selection modes
 
Nonetheless, if the user tries to do that, the API responds with a meaningful message:
affected entities
Authentication phase
Before using the endpoint, you must run the authentication phase (→ Login).
After the authentication, a session opens and a valid session token persists until:
- The end of the session time-out, that is set through the parameter sessionTimeout (→ OptimaWSI configuration > OptimaAuth section).
 - An explicit Logout call (→ Logout).
 
Request
PUT
                
https://<OPTIMA_HOST_IP_ADDRESS>:<PORT_NUMBER>/optima-kpi/kpi/api/instance
                        Request resource
Not applicable.
Request parameters
Not applicable.
Request content-type
application/JSON
Request body (payload)
A JSON object describing all the necessary information to update an instance.
For a description of the JSON object attributes, please see → JSON structure for a KPI.
Response status
| HTTP status | Description | 
|---|---|
| 
                                         200 OK  | 
                                    
                                         The KPI instance is updated.  | 
                                
| 
                                         400 Bad request  | 
                                    
                                         Several conditions can be classified under this code. Main examples: 
 Generally present when the API has been called with wrong arguments.  | 
                                
| 
                                         403 Forbidden  | 
                                    
                                         Several conditions can be classified under this code. Main examples: 
  | 
                                
| 
                                         404 Not found  | 
                                    
                                         The instance ID does not exists.  | 
                                
Response content-type
application/JSON
Response output
A JSON object with the updated KPI instance.
In case of error 400, the output is formatted as a couple:
<parameter_name>: <error description>
Request
https://<OPTIMA_HOST_IP_ADDRESS>:<PORT_NUMBER>/optima-kpi/kpi/api/instance/
                        Request body (payload)
{
    "id": "<id>",
    "name": "<name>",
    "editable": <true/false>,
    "enabled": <true/false>,
    "description": "<description>",
    "category": "<category>",
    "tags": "<tags>",
    "range": {
        "min": <min>,
        "max": <max>
    },
    "schedule": <schedule>,
    "durablePoints": <true/false>,
    "pointDuration": <point_duration>,
    "templateId": <template_id>,
    "computationTypeCode": "<TRIGGERED/SCHEDULED>",
    "dynamicAttributes": [
        {
            "code": "<dynamic_attribute_code>",
            "value": "<dynamic_attribute_value>"
        },
        {
            "code": "<dynamic_attribute_code>",
            "value": "<dynamic_attribute_value>"
        }
    ],
    "affectedLinks": [
        {
            "tail": <link_tail>,
            "idno": <link_idno>,
            "order": <link_order>
        },
        {
            "tail": <link_tail>,
            "idno": <link_idno>,
            "order": <link_order>
        },
        {...other element in the array...}
    ],
    "affectedStreets": [
        {
            "tail": <strt_tail>,
            "idno": <strt_idno>,
            "order": <strt_order>
        },
        {
            "tail": <strt_tail>,
            "idno": <strt_idno>,
            "order": <strt_order>
        },
        {...other element in the array...}
    ],
    "affectedLines": [
        {
            "idno": <line_idno>
        },
        {
            "idno": <line_idno>
        },
        {...other element in the array...}
    ],
    "affectedStops": [
        {
            "idno": <stop_idno>,
        },
        {
            "idno": <stop_idno>,
        },
        {...other element in the array...}
    ]
}
                    Request
https://<OPTIMA_HOST_IP_ADDRESS>:<PORT_NUMBER>/optima-kpi/kpi/api/instance
                        Request body (payload)
{
    "id": 1
    "templateId": 11,
    "name": "Test KPI instance",
    "description": "Number of Vehicles on the Network",
    "durablePoints": false, 
    "editable": true,
    "enabled": true,
    "category": "Category TEST",
    "tags": "asa",
    "range": {
        "min": 0,
        "max": 60
    },
    "pointDuration": 3000,
    "schedule": 60,
    "computationTypeCode":"TRIGGERED",
    "dynamicAttributes": [
        {
            "code": "fore",
            "value": "1800"
        },
        {
            "code": "onlyQueue",
            "value": "nveh"
        },
        {
            "code": "shortTermForecastKpi",
            "value": "true"
        }
    ],
    "affectedLinks":[
        {
            "tail":3119676,
            "idno":3503373,
            "order":1
        },
        {
            "tail":2788659,
            "idno":3503359,
            "order":2
        },
        {
            "tail":2789655,
            "idno":3503399,
            "order":3
        {
            "tail":2789877,
            "idno":3513001,
            "order":4
         }
    ]
}