Snapd rest api update-available missing?

Hi,

The docs [1] show the GET v2/snaps endpoint returning an update-available field.

"update-available": 247,

I don’t see this output though, even when the installed snap is a rev behind the current snap published on the followed channel: so there is an available update.

Is this unimplemented? (grepping source, I don’t find it, but I do find other fields that are returned.)

If so, is there another way to determine from the rest api that an update is or is not available for a given snap?

(Asking for a customer.)

[1] Snapd REST API

This does appear to be a mistake in the REST API, as that is not currently implemented on master (I don’t know if it ever was planned to or not, or why that was put into the docs).

However, if what you are trying to do is tell if there is a refresh available for the snap, you can do what the snap refresh --list command does via the API, which is to call the /v2/find endpoint with the select key set to refresh as in:

$ curl --unix-socket /run/snapd.socket http://localhost/v2/find?select=refresh | jq

which gives you a document something like this:

{
  "type": "sync",
  "status-code": 200,
  "status": "OK",
  "result": [
    {
      "id": "PMrrV4ml8uWuEUDBT8dSGnKUYbevVhc4",
      "title": "snapd",
      "summary": "Background service that manages and maintains installed snaps",
      "description": "**Note: you do not need to install _snapd_ manually if you already have _snap_ installed.**\n\nSnaps are app packages for desktop, cloud and IoT that update automatically, are easy to install, secure, cross-platform and dependency-free. They're being used on millions of Linux systems every day.\n\nAlongside its various service and management functions, snapd:\n- provides the _snap_ command that's used to install and remove snaps and interact with the wider snap ecosystem\n- implements the confinement policies that isolate snaps from the base system and from each other\n- governs the interfaces that allow snaps to access specific system resources outside of their confinement\n\nFor general details, including _installation_ and _Getting started_  guides, head over to our _Snap documentation_: https://snapcraft.io/docs\n\nIf you want to build your own snaps, start with our _Creating a snap_ documentation: https://snapcraft.io/docs/creating-a-snap\n\n**Get involved**\n\nThis is an _open source_ project and we warmly welcome community contributions, suggestions, and constructive feedback. If you're interested in contributing, please take a look at our _Code of Conduct_ first.\n\n- to report an issue, please file _a bug report_ (https://bugs.launchpad.net/snappy/+filebug) on our _Launchpad issue tracker_ (https://bugs.launchpad.net/snappy/)\n- for suggestions and constructive feedback, create a post on the _Snapcraft forum_ (https://forum.snapcraft.io/c/snapd)\n- to build snapd manually, or to get started with snapd development, see  _HACKING.md (https://raw.githubusercontent.com/snapcore/snapd/master/HACKING.md)\n\n**Get in touch**\n\nWe're friendly! We have a community forum at https://forum.snapcraft.io where we discuss feature plans, development news, issues, updates and troubleshooting. You can chat in realtime with the snapd team and our wider community on the _#snappy_ (https://webchat.freenode.net/?channels=snappy) IRC channel on _freenode_ (https://freenode.net/).\n\nFor news and updates, follow us on _Twitter_ (https://twitter.com/snapcraftio) and on _Facebook_ (https://www.facebook.com/snapcraftio).\n\nThe snapd source code can be found on GitHub: https://github.com/snapcore/snapd",
      "download-size": 31629312,
      "icon": "https://dashboard.snapcraft.io/site_media/appmedia/2019/09/snapd.png",
      "name": "snapd",
      "publisher": {
        "id": "canonical",
        "username": "canonical",
        "display-name": "Canonical",
        "validation": "verified"
      },
      "developer": "canonical",
      "status": "available",
      "type": "snapd",
      "version": "2.45.2+git2145.gc3e89a0",
      "channel": "latest/edge",
      "ignore-validation": false,
      "revision": "8676",
      "confinement": "strict",
      "private": false,
      "devmode": false,
      "jailmode": false,
      "contact": "",
      "license": "GPL-3.0+",
      "website": "https://snapcraft.io",
      "media": [
        {
          "type": "icon",
          "url": "https://dashboard.snapcraft.io/site_media/appmedia/2019/09/snapd.png",
          "width": 460,
          "height": 460
        },
        {
          "type": "screenshot",
          "url": "https://dashboard.snapcraft.io/site_media/appmedia/2019/09/Screenshot_20190924_115756_hLcyetO.png",
          "width": 956,
          "height": 648
        },
        {
          "type": "screenshot",
          "url": "https://dashboard.snapcraft.io/site_media/appmedia/2019/09/Screenshot_20190924_115824_2v3y6l8.png",
          "width": 956,
          "height": 648
        },
        {
          "type": "screenshot",
          "url": "https://dashboard.snapcraft.io/site_media/appmedia/2019/09/Screenshot_20190924_115055_Uuq7KIb.png",
          "width": 1023,
          "height": 834
        },
        {
          "type": "screenshot",
          "url": "https://dashboard.snapcraft.io/site_media/appmedia/2019/09/Screenshot_20190924_125944.png",
          "width": 956,
          "height": 648
        }
      ]
    }
  ]
}

Yes, that shows the snap in need of a refresh. Thanks!

1 Like

My test-snapdapi golang client now has updates-available command which lists snaps with updates available: https://github.com/knitzsche/test-snapdapi/commit/2e0d98f7ae0c8bad13e6102c59a6ac1bb50b50b6