pulp/pulp-cli

Add option to list repositories containing a content

Closed this issue · 1 comments

Summary

It is possible to get this information from the GET http :/pulp/api/v3/repository_versions/?content=<content_href> api endpoint. (see pulp/pulpcore#2865 (comment))

This will only return the hrefs of the repository. It would be helpful if the cli would also return the names of the repositories.

Examples

pulp rpm repository list --content <content_href>

One possibility is to add this functionality to the pulp rpm repository list command where it is possible to specify the href of a content unit. But content is based on the repository version so this is not really correct. Other proposals are always welcome

curl --netrc --silent http://$(hostname)/pulp/api/v3/repository_versions/?content=/pulp/api/v3/content/rpm/packages/47be5d88-5356-47c7-afb6-227db266f39c/ | jq
{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "pulp_href": "/pulp/api/v3/repositories/rpm/rpm/3c400303-baf7-4417-b9b8-2127ba7164a9/versions/1/",
      "pulp_created": "2023-01-25T16:16:51.914377Z",
      "number": 1,
      "repository": "/pulp/api/v3/repositories/rpm/rpm/3c400303-baf7-4417-b9b8-2127ba7164a9/",
      "base_version": "/pulp/api/v3/repositories/rpm/rpm/3c400303-baf7-4417-b9b8-2127ba7164a9/versions/0/",
      "content_summary": {
        "added": {
          "rpm.package": {
            "count": 1,
            "href": "/pulp/api/v3/content/rpm/packages/?repository_version_added=/pulp/api/v3/repositories/rpm/rpm/3c400303-baf7-4417-b9b8-2127ba7164a9/versions/1/"
          }
        },
        "removed": {},
        "present": {
          "rpm.package": {
            "count": 1,
            "href": "/pulp/api/v3/content/rpm/packages/?repository_version=/pulp/api/v3/repositories/rpm/rpm/3c400303-baf7-4417-b9b8-2127ba7164a9/versions/1/"
          }
        }
      }
    }
  ]
}

There is a pulp repository list command for finding repositories regardless of their plugin-type. What if we extend that, adding pulp repository version list, with possible filters supporting all the available filters for the Repository_Versions command (e.g., --content --content-in, --fields, etc)

How does that sound to folk?