This PR introduces a new questions API. It is build on a single resource
`/questions` which lists all the registered questions.
```json
[
{
"id": 1,
"text": "LUKS password",
"class": "storage.luks",
"field": {
"type": "string"
},
"actions": [
{
"id": "accept",
"label": "Accept"
},
{
"id": "skip",
"label": "Skip"
}
],
"defaultAction": "skip"
}
]
```
## The new model
According to this new API, each question is composed by:
* `text`: the text for the question.
* `class`: it works as a hint for the UI or to match pre-defined answers
(e.g., "autoyast.unsupported").
* `field`: optionally, a question might define an additional field
(e.g., a password, a selector, etc.).
* `actions`: list of available actions (e.g., "next", "skip", etc.).
* `defaultAction`: default action.
## Registering a question
A new question is registered through a `POST` request to the
`/questions` API. The payload
describes the question.
```json
{
"text": "LUKS password",
"class": "storage.luks",
"field": {
"type": "string"
},
"actions": [
{
"id": "accept",
"label": "Accept"
},
{
"id": "skip",
"label": "Skip"
}
],
"defaultAction": "skip"
}
```
## Answering a question
A question is answered by sending a `PATCH` on the connection with the
following payload.
```json
{
"id": 1,
"action": "accept",
"value": "my-password"
}
```
## Automatic answers
As in the previous API, it is possible to set up the questions service
to automatically response some questions.
```json
{
"update": {
"questions": {
"policy": "auto",
"answers": [
{
"class": "storage.luks",
"action": "ok",
"value": "secret"
}
]
}
}
}
```
## Field types
The field types allow to grow this API to cover more use cases in the
future, like software conflicts.
At this time, it supports:
* `none`: when no additional data is needed (most of the cases).
* `string`: currently unused.
* `password`: for LUKS.
* `selection`: unused but planed for software conflicts (although it
might need some improvements).
---------
Co-authored-by: Ladislav Slezák <lslezak@suse.com>