API
Version 4 (Ohad Levy, 11/04/2010 10:41 am)
| 1 | 1 | h1. API |
|
|---|---|---|---|
| 2 | 1 | ||
| 3 | 1 | Foreman provides a "REST":http://en.wikipedia.org/wiki/Representational_State_Transfer API, communicating via JSON. |
|
| 4 | 1 | ||
| 5 | 1 | Please refer to this document for latest information about API structure. |
|
| 6 | 1 | ||
| 7 | 1 | Examples below are either via curl or ruby rest_client |
|
| 8 | 1 | ||
| 9 | 1 | most pages can be browsed via adding the format option to the url (at least for get requests), i.e. |
|
| 10 | 1 | ||
| 11 | 1 | <pre> |
|
| 12 | 1 | http://foreman/environemnts?format=json |
|
| 13 | 1 | </pre> |
|
| 14 | 1 | ||
| 15 | 1 | Or using HTTP Headers |
|
| 16 | 1 | <pre> |
|
| 17 | 1 | curl -H "Content-Type:application/json" -H "Accept:application/json" http://foreman/hosts |
|
| 18 | 1 | </pre> |
|
| 19 | 1 | ||
| 20 | 1 | Output is JSON formatted, in the last example expect a similar output: |
|
| 21 | 1 | ||
| 22 | 1 | <pre> |
|
| 23 | 1 | [{"host":{"name":"pm.local.net"}},{"host":{"name":"pm.local.net"}}....] |
|
| 24 | 1 | </pre> |
|
| 25 | 1 | ||
| 26 | 3 | Ohad Levy | h2. List of API's |
| 27 | 1 | ||
| 28 | 1 | |_.Path|_.REST Type|_.Description| |
|
| 29 | 1 | |/architectures|GET|List of valid OS Architectures(name and ID)| |
|
| 30 | 1 | |/architectures/x86_64|GET|Description of the x86_64 Architecture (name and ID)| |
|
| 31 | 1 | |/domains|GET|List of known domains (name and ID)| |
|
| 32 | 1 | |/domains/my_domain|GET|Description of "my_domain" (name and ID)| |
|
| 33 | 1 | |/environments|GET|List of known environments (name and ID)| |
|
| 34 | 1 | |/environments/production|GET|Description of the "production" (name and ID and associated host list)| |
|
| 35 | 1 | |/fact_values|GET|List of known Facts (value, name and host)| |
|
| 36 | 1 | |/hostgroups|GET|List of known hostgroups (name and ID)| |
|
| 37 | 1 | |/hostgroups/common|GET|Description of "common" (name and ID)| |
|
| 38 | 1 | |/hosts|GET|List of known hosts (only name)| |
|
| 39 | 4 | Ohad Levy | |/hosts/errors|GET|List of hosts in error state(only name)| |
| 40 | 4 | Ohad Levy | |/hosts/active|GET|List of active hosts(only name)| |
| 41 | 4 | Ohad Levy | |/hosts/out_of_sync|GET|List of out of sync hosts(only name)| |
| 42 | 4 | Ohad Levy | |/hosts/disabled|GET|List of disabled hosts(only name)| |
| 43 | 1 | |/hosts|POST|creates a new host, 201 return sucesful creation, otherwise the errors will be returned| |
|
| 44 | 1 | |/hosts/fqdn|GET|Host Attributes (name, usergroup, last_report, os properties...)| |
|
| 45 | 1 | |/hosts/fqdn|DELETE|Removes the host "fqdn"| |
|
| 46 | 1 | |/hosts/fqdn/setBuild|GET| Enable Host for (re-)build | |
|
| 47 | 1 | |/hosts/fqdn/facts|GET| Returns host facts| |
|
| 48 | 1 | |/medias|GET|List of known mediums (name and ID)| |
|
| 49 | 1 | |/medias/1|GET|Description of media which ID is 1 (name and ID and path/url)| |
|
| 50 | 1 | |/operatingsystems|GET|List of known operating systems (Release name, ID and allowed mediums, architectures and partition tables)| |
|
| 51 | 1 | |/operatingsystems/1|GET| Description of operating systems which its ID is 1 (Release name, ID and allowed mediums, architectures and partition tables)| |
|
| 52 | 1 | |/ptables|GET|List of known Partition tables (name and ID)| |
|
| 53 | 1 | |/ptables/1|GET|Description of Partition table which its ID is 1 (name and ID)| |
|
| 54 | 1 | |/puppetclasses|GET|a hash of known Puppetclasses orginazined by module name (module => {:class1, :class2})| |
|
| 55 | 3 | Ohad Levy | |
| 56 | 3 | Ohad Levy | |
| 57 | 3 | Ohad Levy | |
| 58 | 3 | Ohad Levy | Please raise a new issue if you need additional API's |
