Project

General

Profile

Actions

API » History » Revision 6

« Previous | Revision 6/45 (diff) | Next »
Ohad Levy, 11/07/2010 02:00 PM


API

Foreman provides a REST API, communicating via JSON.

Please refer to this document for latest information about API structure.

Examples below are either via curl or ruby rest_client

most pages can be browsed via adding the format option to the url (at least for get requests), i.e.

http://foreman/environemnts?format=json

Or using HTTP Headers

curl -H "Content-Type:application/json" -H "Accept:application/json"  http://foreman/hosts

Output is JSON formatted, in the last example expect a similar output:

[{"host":{"name":"pm.local.net"}},{"host":{"name":"pm.local.net"}}....]

List of API's

Path REST Type Description
/architectures GET List of valid OS Architectures(name and ID)
/architectures/x86_64 GET Description of the x86_64 Architecture (name and ID)
/dashboard GET Summary statistcs (total hosts, active hosts, hosts in error etc)
/domains GET List of known domains (name and ID)
/domains/my_domain GET Description of "my_domain" (name and ID)
/environments GET List of known environments (name and ID)
/environments/production GET Description of the "production" (name and ID and associated host list)
/fact_values GET List of known Facts (value, name and host)
/hostgroups GET List of known hostgroups (name and ID)
/hostgroups/common GET Description of "common" (name and ID)
/hosts GET List of known hosts (only name)
/hosts/errors GET List of hosts in error state(only name)
/hosts/active GET List of active hosts(only name)
/hosts/out_of_sync GET List of out of sync hosts(only name)
/hosts/disabled GET List of disabled hosts(only name)
/hosts POST creates a new host, 201 return sucesful creation, otherwise the errors will be returned
/hosts/fqdn GET Host Attributes (name, usergroup, last_report, os properties...)
/hosts/fqdn DELETE Removes the host "fqdn"
/hosts/fqdn/setBuild GET Enable Host for (re-)build
/hosts/fqdn/facts GET Returns host facts
/hosts/fqdn/pxe_config GET Returns syslinux configuration file for fqdn
/medias GET List of known mediums (name and ID)
/medias/1 GET Description of media which ID is 1 (name and ID and path/url)
/operatingsystems GET List of known operating systems (Release name, ID and allowed mediums, architectures and partition tables)
/operatingsystems/1 GET Description of operating systems which its ID is 1 (Release name, ID and allowed mediums, architectures and partition tables)
/ptables GET List of known Partition tables (name and ID)
/ptables/1 GET Description of Partition table which its ID is 1 (name and ID)
/puppetclasses GET a hash of known Puppetclasses orginazined by module name (module => {:class1, :class2})

Please raise a new issue if you need additional API's

Updated by Ohad Levy about 14 years ago · 45 revisions