---
# System prepended metadata

title: Risk Model

---

# Risk Model


## Contexto

### Estructura general de la regla
Aqui se define la estructura general de la regla a implementar, es importante tener en cuenta:
* Behaviors:

![](https://zinobe-documentation.s3.us-west-2.amazonaws.com/risk-model/rule.jpg)

### Definicion de fuentes soportadas
Las fuentes no soportadas deberan pasar un proceso de analisis, desarrollo e integracion para porder hacerlos parte de la reglas, en el siguiente esquema se representa el flujo para determinar este caso de uso.
![](https://zinobe-documentation.s3.us-west-2.amazonaws.com/risk-model/plugin.png)


## Create rule

```curl
POST /api/v1/administrator
```

### Request:
```json 

{
    "product_id": uuid,
    "product_name": string,
    "enabled": bolean,
    "draft": bolean,
    "approved": bolean,
    "rule": {
        "sync": int,
        "parallel": int,
        "max_process": int,
        "decision_strategy": string,
        "steps": {
            "any_service": {
                "priority": int,
                "enabled": int,
                "is_service": int,
                "dependencies": [],
                "actions": {
                    "entry": [],
                    "exit": [],
                    "on_failure": []
                },
                "type": string [data|ml|datasource],
                "direct_rejection": 0,
                "binding": {
                    "natural": [],
                    "compose": {}
                },
                "equivalence_matrix": {},
                "rejection_rules": {},
                "decision": []
            },
            "compose": {
                "priority": int,
                "enabled": int,
                "mandatory": int,
                "dependencies": [],
                "type": "compose",
                "binding": {
                    "natural": [],
                    "compose": {},
                    "decision": []
                },
                "equivalence_matrix": {}
            }
        },
        "decision": {
            "decision_strategy": {
                "sub_scores": {},
                "score": {
                    "decision": {
                        "pre-calculate": {},
                        "score": ""
                    }
                }
            }
        }
    }
}


```

### Response
```csvpreview {header="true"}
Code,EndPoint
201,Created
400, Bad Request
401, Unauthorized
500,Internal error
```

```json
{
    "created_at": date,
    "uuid": uuid,
    "rule": {}
}

```
## Update Rule


### Request

```curl
PUT /api/v1/administrator/[UUID]
```
##### Body

```json

{
    "product_id": uuid,
    "product_name": string,
    "enabled": bolean,
    "draft": bolean,
    "approved": bolean,
    "rule": {
        "sync": int,
        "parallel": int,
        "max_process": int,
        "decision_strategy": string,
        "steps": {
            "any_service": {
                "priority": int,
                "enabled": int,
                "is_service": int,
                "dependencies": [],
                "actions": {
                    "entry": [],
                    "exit": [],
                    "on_failure": []
                },
                "type": string [data|ml|datasource],
                "direct_rejection": 0,
                "binding": {
                    "natural": [],
                    "compose": {}
                },
                "equivalence_matrix": {},
                "rejection_rules": {},
                "decision": []
            },
            "compose": {
                "priority": int,
                "enabled": int,
                "mandatory": int,
                "dependencies": [],
                "type": "compose",
                "binding": {
                    "natural": [],
                    "compose": {},
                    "decision": []
                },
                "equivalence_matrix": {}
            }
        },
        "decision": {
            "decision_strategy": {
                "sub_scores": {},
                "score": {
                    "decision": {
                        "pre-calculate": {},
                        "score": ""
                    }
                }
            }
        }
    }
}

```

### Response

```json
{
    "message": "Rule has been update",
    "status_code": "200 OK"
}
```
```csvpreview {header="true"}
Code, EndPoint
200, Update
400, Bad Request
401, Unauthorized
404, Rule not Exist
500, Internal error
```


## Get Rule
```curl
GET /api/v1/administrator?product_name=[NAME]&uuid=[UUID]
```

### Request
```json

```

### Response
```json
{
    "product_id": uuid,
    "product_name": string,
    "enabled": bolean,
    "draft": bolean,
    "approved": bolean,
    "rule": {
        "sync": int,
        "parallel": int,
        "max_process": int,
        "decision_strategy": string,
        "steps": {
            "any_service": {
                "priority": int,
                "enabled": int,
                "is_service": int,
                "dependencies": [],
                "actions": {
                    "entry": [],
                    "exit": [],
                    "on_failure": []
                },
                "type": string [data|ml|datasource],
                "direct_rejection": 0,
                "binding": {
                    "natural": [],
                    "compose": {}
                },
                "equivalence_matrix": {},
                "rejection_rules": {},
                "decision": []
            },
            "compose": {
                "priority": int,
                "enabled": int,
                "mandatory": int,
                "dependencies": [],
                "type": "compose",
                "binding": {
                    "natural": [],
                    "compose": {},
                    "decision": []
                },
                "equivalence_matrix": {}
            }
        },
        "decision": {
            "decision_strategy": {
                "sub_scores": {},
                "score": {
                    "decision": {
                        "pre-calculate": {},
                        "score": ""
                    }
                }
            }
        }
    }
}
```



## Get Score
```curl
POST /api/v1/consumer
```

### Request
```json
{
    "product": uuid,
    "document_user": string
}
```

### Response
```json
{
    "created_at": date,
    "rule": uuid,
    "product_name": string,
    "process": uuid,
    "data": {
        "any_source": {}
    },
    "equivalences": {
        "any_source": {}
    },
    "result": {
        "sub_score": {
            "decision": {
                "calculate": [
                    {
                        "score": int,
                        "item": string,
                        "sentence": string,
                        "render": string
                    }
                ],
                "score": int
            }
        },
        "score": {
            "decision": {
                "calculate": [
                    {
                        "score": int,
                        "item": string,
                        "sentence": string,
                        "render": string
                    }
                ],
                "score": int
            }
        }
    }
}
```

```csvpreview {header="true"}
Code, EndPoint
200, Update
400, Bad Request
401, Unauthorized
404, Rule not Exist
500, Internal error
```