Because I cannot overwrite packages in the internal feed, I need to be able to check whether the package already exists before I attempt to push it. The API, however, does not seem to list the packages in the internal feed.
Using Octopus.Client from the 3.0 installation, the OctopusRepository class doesn’t seem to have anything related to packages. Using the OctopusClient class, I can make a request to http://x.x.x.x/api/feeds/feeds-builtin/packages, and an empty array is returned.
How can I get a list of packages (or, ideally, search for the specific one I’m interested in)?
I’ve made progress. The 3.0 API seems to have changed the URIs. I can get the specific package I want at http://x.x.x.x/api/packages?nuGetPackageId=foo.package and I get a list of versions.
As the list of versions is going to get large over time, however, it would be nice if I could filter to a specific version. It looks like the id is built up as packages-[nuget package id]-[package version], so I can use that, but I doubt it’s a contract, and guaranteed not to change.
I’ve had a look at the api code and you’re right, you can’t filter by package version. Using ‘?filter’ will only filter by name. I think the most robust solution would be to get a list of packages matching the package id by using ‘?nuGetPackageId’, extract the version of each package from the Version field and then check that against the version you would like to push.