How to determine which snap is active as returned from /v2/snaps?select=all

If you get all the installed revisions of a snap, i.e.:

$ curl --unix-socket /run/snapd.socket 'http://localhost/v2/snaps?select=all&snaps=core' | jq .

you get something like:

{
  "type": "sync",
  "status-code": 200,
  "status": "OK",
  "result": [
    {
      "id": "99T7MUlRhtI3U0QFgl5mXXESAiSwt776",
      "title": "core",
      "summary": "snapd runtime environment",
      "description": "The core runtime environment for snapd",
      "installed-size": 90759168,
      "name": "core",
      "developer": "canonical",
      "status": "installed",
      "type": "os",
      "version": "16-2.32.5",
      "channel": "stable",
      "tracking-channel": "stable",
      "ignore-validation": false,
      "revision": "4486",
      "confinement": "strict",
      "private": false,
      "devmode": false,
      "jailmode": false,
      "contact": "mailto:snappy-canonical-storeaccount@canonical.com",
      "install-date": "2018-04-16T14:33:06+04:00"
    },
    {
      "id": "99T7MUlRhtI3U0QFgl5mXXESAiSwt776",
      "title": "core",
      "summary": "snapd runtime environment",
      "description": "The core runtime environment for snapd",
      "installed-size": 90828800,
      "name": "core",
      "developer": "canonical",
      "status": "installed",
      "type": "os",
      "version": "16-2.32.6",
      "channel": "stable",
      "tracking-channel": "stable",
      "ignore-validation": false,
      "revision": "4571",
      "confinement": "strict",
      "private": false,
      "devmode": false,
      "jailmode": false,
      "contact": "mailto:snappy-canonical-storeaccount@canonical.com",
      "install-date": "2018-04-29T22:29:48+04:00"
    },
    {
      "id": "99T7MUlRhtI3U0QFgl5mXXESAiSwt776",
      "title": "core",
      "summary": "snapd runtime environment",
      "description": "The core runtime environment for snapd",
      "installed-size": 90812416,
      "name": "core",
      "developer": "canonical",
      "status": "active",
      "type": "os",
      "version": "16-2.32.8",
      "channel": "stable",
      "tracking-channel": "stable",
      "ignore-validation": false,
      "revision": "4650",
      "confinement": "strict",
      "private": false,
      "devmode": false,
      "jailmode": false,
      "contact": "mailto:snappy-canonical-storeaccount@canonical.com",
      "install-date": "2018-05-11T18:51:12+04:00"
    }
  ],
  "sources": [
    "local"
  ]
}

How does a snapd client determine which one of these is active (as would have been returned without the select=all)?

afaik "status:" "active" vs just "status": "installed"

1 Like

Thanks, I was staring at them and just didn’t notice that difference…