API

Version 7 (Ohad Levy, 11/07/2010 02:03 pm)

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 5 Ohad Levy
|/dashboard|GET|Summary statistcs (total hosts, active hosts, hosts in error etc)|
32 1
|/domains|GET|List of known domains (name and ID)|
33 1
|/domains/my_domain|GET|Description of "my_domain" (name and ID)|
34 1
|/environments|GET|List of known environments (name and ID)|
35 1
|/environments/production|GET|Description of the "production" (name and ID and associated host list)|
36 1
|/fact_values|GET|List of known Facts (value, name and host)|
37 1
|/hostgroups|GET|List of known hostgroups (name and ID)|
38 1
|/hostgroups/common|GET|Description of "common" (name and ID)|
39 1
|/hosts|GET|List of known hosts (only name)|
40 4 Ohad Levy
|/hosts/errors|GET|List of hosts in error state(only name)|
41 4 Ohad Levy
|/hosts/active|GET|List of active hosts(only name)|
42 4 Ohad Levy
|/hosts/out_of_sync|GET|List of out of sync hosts(only name)|
43 4 Ohad Levy
|/hosts/disabled|GET|List of disabled hosts(only name)|
44 1
|/hosts|POST|creates a new host, 201 return sucesful creation, otherwise the errors will be returned|
45 1
|/hosts/fqdn|GET|Host Attributes (name, usergroup, last_report, os properties...)|
46 1
|/hosts/fqdn|DELETE|Removes the host "fqdn"|
47 1
|/hosts/fqdn/setBuild|GET| Enable Host for (re-)build |
48 1
|/hosts/fqdn/facts|GET| Returns host facts|
49 6 Ohad Levy
|/hosts/fqdn/pxe_config|GET| Returns syslinux configuration file for fqdn|
50 1
|/medias|GET|List of known mediums (name and ID)|
51 1
|/medias/1|GET|Description of media which ID is 1 (name and ID and path/url)|
52 1
|/operatingsystems|GET|List of known operating systems (Release name, ID and allowed mediums, architectures and partition tables)|
53 1
|/operatingsystems/1|GET| Description of operating systems which its ID is 1 (Release name, ID and allowed mediums, architectures and partition tables)|
54 7 Ohad Levy
|/operatingsystems/1/bootfiles?media=<media_name>&architecture=x86_64|GET| tftp boot files and their respective urls (where they can be found)|
55 1
|/ptables|GET|List of known Partition tables (name and ID)|
56 1
|/ptables/1|GET|Description of Partition table which its ID is 1 (name and ID)|
57 1
|/puppetclasses|GET|a hash of known Puppetclasses orginazined by module name (module => {:class1, :class2})|
58 3 Ohad Levy
59 3 Ohad Levy
60 3 Ohad Levy
61 3 Ohad Levy
Please raise a new issue if you need additional API's