'Buildbot REST API how to find builds for given revision?

I am using Buildbot 3.5.0 and I am looking for a way to use its REST-API to find all the builds that were started for a given revision.

I know there is the endpoint

http://.../api/v2/builds

and each build has its revision available within the properties element, which is some nested structure. How can I filter that list to get only those builds that mention a given revision inside their properties element?

Or is there some other way to find the relevant builds?

Some example data:

http://.../api/v2/builds

{
  "builds": [
    {
      "builderid": 6,
      "buildid": 358,
      "buildrequestid": 537,
      "complete": true,
      "complete_at": 1652550289,
      "masterid": 16,
      "number": 77,
      "properties": {},
      "results": 0,
      "started_at": 1652550269,
      "state_string": "build successful",
      "workerid": 2
    },
    ... many more builds here ...
  ],
  "meta": {
    "total": 358
  }
}

The properties for the above mentioned build can be found here:

http://.../api/v2/builds/358/properties

{
  "meta": {},
  "properties": [
    {
      "revision": [
        "01234567899a48ecef090efa39647747c0a03ed5",
        "Build"
      ],
      "scheduler": [
        "any_branch_foobar",
        "Scheduler"
      ],
      "workername": [
        "someworker",
        "Worker"
      ],
      ... many more properties here ...
    }
  ]
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source