Snapd REST API

The list of assertions appears to be missing “preseed”, https://github.com/snapcore/snapd/blob/master/asserts/asserts.go#L140

This is a lot of content for a single page, I would be tempted to give each API endpoint its own page. I would also explain that if one installs the “http” snap, that snap understands the “snapd:” schema so you can run simple commands like:

$ http snapd:///v2/apps

which is really cool. Otherwise, you can use the standard “curl” invocation.

If you peruse the code here, https://github.com/snapcore/snapd/tree/master/daemon, there appear to be a number of API endpoints that are not listed here, including buy, cohorts, debug, download, quotas among others.

Oh, and create-user as well.

And system-recovery-keys.

we do not make compatibility promises about debug, so if documented it should be documented separately

download is still wip

cohorts and system-recovery-keys can/should be documented

everything else you mentioned is obsolete/deprecated, might get removed

I just noticed this commit, https://github.com/snapcore/snapd/commit/f271e0815e5dc9f2cb6f1a19b94cc2cc93c08ea7, which seems to merge a commit entitled “daemon: /v2/system-recovery-keys remove API”. But that commit doesn’t seem to remove the API, just extend it. Can someone clarify this so I can make sure I document this correctly?

I’d read it as “it removes the keys” … not the API…

yes, that’s adding remove support

Ah, thanks. I need to read more carefully. Just trying to update this page.

There still seem to be some endpoints not documented here – at a glance, “accessories” is not mentioned. There are probably others, unless some endpoints are deliberately not included here.

Thanks - I’ve got quotas on my immediate todo, but I’ll look again into what else we should have.

Edit (28th June 2023): quota group documentation has now been added.

“accessories” is not documented because it is limited to snaps with snap-themes-control allowed, which is a bit of a special use case

1 Like

Hello!

In my tests, there is another status: Wait. This appears on classic or hybrid images when you try to refresh a snap that requires a reboot (for instance, the kernel snap, such as pc-kernel). The snap change command will show the status as Wait with a message saying snapd is waiting for the device to be manually rebooted:

$ sudo snap refresh pc-kernel --channel=22/beta
(...)

$ snap change 379
Status  Spawn               Ready               Summary
Done    today at 04:25 UTC  today at 04:25 UTC  Ensure prerequisites for "pc-kernel" are available
Done    today at 04:25 UTC  today at 04:25 UTC  Prepare snap "" (1731)
Done    today at 04:25 UTC  today at 04:25 UTC  Run pre-refresh hook of "pc-kernel" snap if present
Done    today at 04:25 UTC  today at 04:25 UTC  Stop snap "pc-kernel" services
Done    today at 04:25 UTC  today at 04:25 UTC  Remove aliases for snap "pc-kernel"
Done    today at 04:25 UTC  today at 04:25 UTC  Make current revision for snap "pc-kernel" unavailable
Done    today at 04:25 UTC  today at 04:25 UTC  Update assets from kernel "pc-kernel" (1731)
Done    today at 04:25 UTC  today at 04:25 UTC  Copy snap "pc-kernel" data
Done    today at 04:25 UTC  today at 04:25 UTC  Setup snap "pc-kernel" (1731) security profiles
Wait    today at 04:25 UTC  -                   Make snap "pc-kernel" (1731) available to the system
Do      today at 04:25 UTC  -                   Automatically connect eligible plugs and slots of snap "pc-kernel"
Do      today at 04:25 UTC  -                   Set automatic aliases for snap "pc-kernel"
Do      today at 04:25 UTC  -                   Setup snap "pc-kernel" aliases
Do      today at 04:25 UTC  -                   Run post-refresh hook of "pc-kernel" snap if present
Do      today at 04:25 UTC  -                   Start snap "pc-kernel" (1731) services
Do      today at 04:25 UTC  -                   Clean up "pc-kernel" (1731) install
Do      today at 04:25 UTC  -                   Run configure hook of "pc-kernel" snap if present
Do      today at 04:25 UTC  -                   Run health check of "pc-kernel" snap
Wait    today at 04:25 UTC  -                   Monitoring snap "pc-kernel" to determine whether extra refresh steps are required

......................................................................
Update assets from kernel "pc-kernel" (1731)

2024-04-08T04:25:43Z INFO No gadget assets update needed

......................................................................
Make snap "pc-kernel" (1731) available to the system

2024-04-08T04:25:55Z INFO Task set to wait until a system restart allows to continue

......................................................................
Monitoring snap "pc-kernel" to determine whether extra refresh steps are required

2024-04-08T04:25:55Z INFO Task set to wait until a system restart allows to continue

Is this an omission in the documentation?

Thanks for asking this, and for your detailed summary. I’ll ask the team today and get back to you - hopefully updating the doc.

Update (11th April 2024): I spoke to the team about this, and Wait as indeed an omission as some of this work was done later. It basically means the task was successful but dependent on the occurrence of an event outside of its direct control (such as a reboot after a kernel snap update on classic systems). I’ve added this now.

1 Like