Commit 526850c
feat: add a new questions API (#2813)
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 <[email protected]>1 parent 29a8685 commit 526850c
File tree
135 files changed
+1936
-3327
lines changed- doc/dbus
- bus
- live/src
- rust
- agama-autoinstall
- src
- agama-cli
- src
- agama-l10n/src
- agama-lib/src
- http
- proxies
- questions
- questions
- answers
- agama-manager/src
- agama-server
- src
- questions
- server
- web
- docs
- tests
- agama-utils/src
- api
- question
- package
- xtask/src
- service
- lib/agama
- autoyast
- commands
- dbus
- clients
- y2dir/software/modules
- http
- clients
- software/callbacks
- storage
- callbacks
- package
- test/agama
- commands
- dbus/clients
- http/clients
- software
- callbacks
- storage
- callbacks
- web
- package
- src
- api
- components/questions
- queries
- types
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
135 files changed
+1936
-3327
lines changedLines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 0 additions & 51 deletions
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | 35 | | |
64 | 36 | | |
65 | | - | |
66 | | - | |
67 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
This file was deleted.
Lines changed: 0 additions & 12 deletions
This file was deleted.
0 commit comments