ATM installing a snap uses the /details store API, while refreshes use the /metadata API. Since we have grown some more requirements that made us consider reviewing these APIs:
-
we need to send validation context (all currently installed snaps) for all operations, so we avoid an install choosing a revision ignoring validation constraints but the later refresh immediately switching to a different validated revision
-
we are also switching to sticky ignore-validation flags for snap to ask the store not to enforce validation
-
the special case of snap refresh --revision is using the /details API but given epochs we would like to send the current revision (and so implicitly epoch) as well
The proposal for a new API is to have a single bulk endpoint for both install and refreshes. A request in JSON to it would look like this:
{
"context": [ // information about the current installed snaps
{
"snap-id":
"revision": // the current revision
"tracking-channel":
"ignore-validation": // current flag about enforcing validation for the snap
},...],
"actions": [ // call this "intents" instead ?
{
"action": "install"|"refresh|refresh-all" // distinguish auto-refresh vs cmdline "snap refresh" ?
// if action is install
"name":
"channel": // optional, defaults to stable
"tag": // ? tag where from is the install requested
"ignore-validation": true|false // defaults to false
// if action is refresh
"snap-id":
// common
"revision": // explicit requested revision (optional)
// if action refresh-all
}...],
"fields": [...] // which detail fields to send in the response? do we need install-fields vs refresh-fields?
}
The response would look like:
{
"results": [{
"snap-id":
"name":
"result": "install"|"refresh"|"error"
"message": // if result is error
"snap": {
... // requested detail fields
}
}...],
}
These request/response assume we would start switching for new store APIs to use “-” for field names instead of “_”.
Some open questions:
- final naming of request/response fields
- do we need to be able to specify different field sets for the response entries about installs vs refreshes?
- do we want to distinguish a
snap refresh vs auto-refreshes in the actions?
- really switch to use “-” instead of “_”