Skip to content
Greg Neagle edited this page Mar 7, 2016 · 11 revisions

MWA2 supports a basic API for reading from and writing to the Munki repo.

manifests and pkgsinfo endpoints are supported. GET, POST, PUT, PATCH and DELETE are supported.

pkgs and icons endpoints are also supported: for these only GET, POST and DELETE are supported.

Authentication is shared with the rest of MWA2. Currently only HTTP BASIC auth is supported. You should use this only over https. Consider creating special API users with only those rights that are needed (if you only need to read from the repo, use a user with read-only rights, etc)

Some examples of interacting with the API (where the server is running at http://localhost:8080):

GET:

curl -H "Authorization: Basic XXXXXXXX" http://localhost:8080/api/manifests
curl -H "Authorization: Basic XXXXXXXX" \
     "http://localhost:8080/api/manifests?api_fields=filename"
curl -H "Authorization: Basic XXXXXXXX" \
     "http://localhost:8080/api/manifests?catalogs=testing"
curl -H "Authorization: Basic XXXXXXXX" \
     "http://localhost:8080/api/manifests?catalogs=testing&api_fields=filename,catalogs"
curl -H "Authorization: Basic XXXXXXXX" \
     "http://localhost:8080/api/manifests/site_default"

curl -H "Authorization: Basic XXXXXXXX" \
     "http://localhost:8080/api/pkgsinfo?receipts=com.microsoft&api_fields=filename"
curl -H "Authorization: Basic XXXXXXXX" \
     "http://localhost:8080/api/pkgsinfo/?installer_item_location=.mobileconfig&api_fields=filename,installer_item_location"

POST:

curl -H "Authorization: Basic XXXXXXXX" \
     -H "Content-Type: application/json" \
     -X POST \
     --data '{ "filename": "fakepkg-1.0.plist", "name": "fakepkg", "catalogs": ["testing"],"display_name": "Example pkg"}' \
     http://localhost:8080/api/pkgsinfo

PUT:

curl -H "Authorization: Basic XXXXXXXX" \
     -H "Content-Type: application/json" \
     -X PUT \
     --data '{ "filename": "fakepkg-1.0.plist", "name": "fakepkg", "catalogs": ["production"], "display_name": "Example pkg"}' \
     http://localhost:8080/api/pkgsinfo/fakepkg-1.0.plist

PATCH:

curl -H "Authorization: Basic XXXXXXXX" \
     -H "Content-Type: application/json" \
     -X PATCH \
     --data '{ "version": "1.0" }' \
     http://localhost:8080/api/pkgsinfo/fakepkg-1.0.plist

DELETE:

curl -H "Authorization: Basic XXXXXXXX" \
     -X DELETE \
     http://localhost:8080/api/pkgsinfo/fakepkg-1.0.plist
Clone this wiki locally