the cleanliness gained by having two structures with almost
the same fields is probably not enough to justify both of them,
especially because daemon is where we are supposed to build
responses, we might as well deal with the details
Meta was a quick hack, also it hasn't really grown since so we can
try to remove it now
AsyncResponse never takes anything over the result but the change id
* In the daemon, setup a proper ErrorKind for the assertion not being
found and return an errorResult with Kind set appropriately and Value
set to the assertion that wasn't found.
* In the client, add a new method for introspecting an error to see if
it is an ErrorKindAssertionNotFound, which corresponds to ErrNoState.
* In the model command, use the new client method for checking for the
special case of ErrNoState.
* Remove old exported error kind from client in favor of the
introspection method.
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
* Add a new /v2/model GET endpoint which returns the singular, current model
assertion, even if a device has been remodeled and has multiple model
assertions
* Add a new /v2/model/serial GET endpoint which returns the singular, current
serial assertion, even if a device has been remodeled and has multiple serial
assertions
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
The devicestate.Remodel() call returns a []*state.TaskSet right
now. This is the usual pattern we use but for Remodel() its
not the right one because Remodel() cannot be composed with
other changes (doing that would be dangerous because of the
e.g. the task serialization inside remodel). Having a change
also means we can add the new model directly to the change
which will be useful when remodeling to different kernels
or (boot) bases as the validation code will need access to
the new model.
So this PR implements the switch from []*state.TaskSet to
*change. Followups will use it to add the model to the change
and to remodel to a different kernel/base.