---
# System prepended metadata

title: Public api

---

# Public api

Popisuje api medzi Acl Service a klientami, ktorý s ním komunikujú.

# Formát a štruktúra správ

Komunikácia prebieha prostredníctvom NATS správ. Je rozdelená na eventy a requesty. Eventy nečakajú na odpoveď, reqeusty áno.

Formát správ je JSON.

Štruktúra je unifikvoaná pre všetky eventy a requesty:

**Štruktúra požiadavky:**

```json
{
    "body": <request-data|null>
}
```

**Štruktúra odpovede:**

```json
{
    "error": <error string|null>,
    "data": <response-data|null>
}
```

`<request-data>` a `<response-data>` závisia od konkrétneho volania api (NATS topic)

# Dátové štruktúry

## Základné
#### AclObject
```json
"id": int|null // pri komunikacii smerom client -> acl service as nevyplna/neberie do uvahy
"idReference": int
"typeReference": int
```

#### Hierarchy
```json
"child": AclObject
"parent": AclObject
```
#### Permission
```json
"id": int|null // pri komunikacii smerom client -> acl service as nevyplna/neberie do uvahy
"aro": AclObject
"aco": AclObject
"operation": AclObject
"granted": bool
```

## Right štruktúry

`GUID` je uninkatny identifikator acl objektu v kontexte klienta. Ide o kombinaciu jeho referencneho idecka a typu v tvare: `<idReference>:<typeReference>`

#### RightResponse
```json
{
    "granted": bool
    "inherit": Permission|null // null ak je vysledne permission explicitne. V opacnom pripade je tu uvedene permission, z ktoreho sa vysledne pravo zdedilo
}
```

#### RightFilter
```json
{
    "aroTypeReference": int|null
    "acoTypeReference": int|null
    "operationTypeReference": int|null
}
```

#### AroRightsReq 
```json
"aro": AclObject
"aco": []AclObject
"operation": []AclObject
"filter": RightFilter|null
```
#### AroPermissionsRes
```json
{
    "<aco1 GUID>": {
        "<operation1 GUID>": PermissionResponse|null, // nul je v pripade ak pre dane aco a operation neexistuje ziadne permission
        "<operation2 GUID>": PermissionResponse|null,
        ...
    },
    "<aco2 GUID>": 
    ...
}
```

#### AcoPermissionsReq
```json
"aro": []AclObject
"aco": AclObject
"operation": []AclObject
```
#### AcoPermissionsRes
```json
{
    "<aro1 GUID>": {
        "<operation1 GUID>": PermissionResponse|null, // nul je v pripade ak pre dane aco a operation neexistuje ziadne permission
        "<operation2 GUID>": PermissionResponse|null,
        ...
    },
    "<aro2 GUID>": 
    ...
}
```

#### OperationPermissionsReq
```json
"aro": []AclObject
"aco": []AclObject
"operation": AclObject
```

#### OperationPermissionsRes
```json
{
    "<aro1 GUID>": {
        "<aco1 GUID>": PermissionResponse|null, // nul je v pripade ak pre dane aco a operation neexistuje ziadne permission
        "<aco2 GUID>": PermissionResponse|null,
        ...
    },
    "<aro2 GUID>": 
    ...
}
```

# Api volania (NATS topics)

Eventy, ktoré emituje Acl Service a Requesty na ktoré počúva


| Api (NATS topic) | Štruktúra požiadavky | Štruktúra odpovede |
| ------------------------------------- | -----------------------   |  -----------------------  |
| **Poziadavky na zmenu struktury acl objektov ich hierachie a permission**||
| request.acl.post.aro                  | [AclObject](#aclobject)*  | [AclObject](#aclobject)   |
| request.acl.delete.aro                | [AclObject](#aclobject)*  | null\|error               |
| request.acl.post.aro-hierarchy        | [Hierarchy](#hierarchy)*  | null\|error               |
| request.acl.delete.aro-hierarchy      | [Hierarchy](#hierarchy)*  | null\|error               |
| request.acl.post.aco                  | [AclObject](#aclobject)*  | [AclObject](#aclobject)   |
| request.acl.delete.aco                | [AclObject](#aclobject)*  | null\|error               |
| request.acl.post.aco-hierarchy        | [Hierarchy](#hierarchy)*  | null\|error               |
| request.acl.delete.aco-hierarchy      | [Hierarchy](#hierarchy)*  | null\|error               |
| request.acl.post.operation            | [AclObject](#aclobject)*  | [AclObject](#aclobject)   |
| request.acl.delete.operation          | [AclObject](#aclobject)*  | null\|error               |
| request.acl.post.operation-hierarchy  | [Hierarchy](#hierarchy)*  | null\|error               |
| request.acl.delete.operation-hierarchy| [Hierarchy](#hierarchy)*  | null\|error               |
| request.acl.post.permission           | [Permission](#permission)*| [Permission](#permission) |
| request.acl.delete.permission         | [Permission](#permission)*| null\|error               |
| **Eventy o zmene struktury acl objektov ich hierachie a permission**||
| event.acl.aro.inserted                | [AclObject](#aclobject)   | - |
| event.acl.aro.deleted                 | [AclObject](#aclobject)   | - |
| event.acl.aro-hierarchy.inserted      | [Hierarchy](#hierachy)    | - |
| event.acl.aro-hierarchy.deleted       | [Hierarchy](#hierachy)    | - |
| event.acl.aco.inserted                | [AclObject](#aclobject)   | - |
| event.acl.aco.deleted                 | [AclObject](#aclobject)   | - |
| event.acl.aco-hierarchy.inserted      | [Hierarchy](#hierachy)    | - |
| event.acl.aco-hierarchy.deleted       | [Hierarchy](#hierachy)    | - |
| event.acl.operation.inserted          | [AclObject](#aclobject)   | - |
| event.acl.operation.deleted           | [AclObject](#aclobject)   | - |
| event.acl.operation-hierarchy.inserted| [Hierarchy](#hierachy)    | - |
| event.acl.operation-hierarchy.deleted | [Hierarchy](#hierachy)    | - |
| event.acl.permission.set              | [Permission](#permission) | - |
| event.acl.permission.deleted          | [Permission](#permission) | - |
| **Poziadavky na zoznamy acl objektov ich hierachiu a permission**||
| request.acl.get.aros                  | null | [][AclObject](#aclobject)      |
| request.acl.get.aro-hierarchies       | null | [][Hierarchy](#hierarchy)      |
| request.acl.get.acos                  | null | [][AclObject](#aclobject)      |
| request.acl.get.aco-hierarchies       | null | [][Hierarchy](#hierarchy)      |
| request.acl.get.operations            | null | [][AclObject](#aclobject)      |
| request.acl.get.operation-hierarchies | null | [][Hierarchy](#hierarchy)      |
| request.acl.get.permissions           | null | [][Permission](#permission)    |
| **Poziadavky na vypocet opravneni**||
| request.acl.aro-permissions           | [AroPermissionsReq](#aropermissionsreq)*   | [AroPermissionsRes](#aropermissionsres)|
| request.acl.aco-permissions           | [AcoPermissionsReq](#acopermissionsreq)*   | [AcoPermissionsRes](#acopermissionsres)|
| request.acl.operation-permissions           | [OperationPermissionsReq](#operationpermissionsreq)*   | [OperationPermissionsRes](#operationpermissionsres)|

\* parameter/parametre "id" je null (neberie sa pri spracovani do uvahy). Entity sa identifikuju na zaklade idReferece a typeReference