Project

General

Profile

API » History » Version 41

Dominic Cleal, 03/19/2013 04:39 AM
API docs now on web site

1 1 Ohad Levy
h1. API
2
3 41 Dominic Cleal
h2. Foreman 1.1 API
4 1 Ohad Levy
5 41 Dominic Cleal
The documentation previously held on this page has been incorporated into the main "theforeman.org":http://theforeman.org/ web site.  You can access it here:
6 1 Ohad Levy
7 41 Dominic Cleal
* "*Foreman API documentation*":http://theforeman.org/api.html
8 1 Ohad Levy
9 41 Dominic Cleal
*NOTE*: Starting with Foreman 1.1 API documentation can be auto generated on your installation using @rake apipie:static@, then access using /apidoc on your foreman instance. Auto generated Ruby binding and CLI are also available.
10
11
h2. Pre-Foreman 1.1 API
12
13
*NOTE*: Version of 0.1-6 or git develop branch are required to use the API
14
15 1 Ohad Levy
Foreman provides a "REST":http://en.wikipedia.org/wiki/Representational_State_Transfer API, communicating via JSON.
16
17 9 Ohad Levy
Please refer to this document for latest information about Foreman API.
18 1 Ohad Levy
19 33 Jan van Eldik
[[Examples]] below are either via curl, perl, ruby rest_client
20 32 Florian Koch
21 1 Ohad Levy
22
most pages can be browsed via adding the format option to the url (at least for get requests), i.e.
23
24
<pre>
25 25 Romain Vrignaud
http://foreman/environments?format=json
26 1 Ohad Levy
</pre>
27
28
Or using HTTP Headers
29
<pre>
30
curl -H "Content-Type:application/json" -H "Accept:application/json"  http://foreman/hosts
31
</pre>
32
33
Output is JSON formatted, in the last example expect a similar output:
34
35
<pre>
36 10 Ohad Levy
[{"host":{"name":"pm1.local.net"}},{"host":{"name":"pm2.local.net"}}....]
37 1 Ohad Levy
</pre>
38
39 3 Ohad Levy
h2. List of API's
40 1 Ohad Levy
41 12 Justin Sherrill
|_.Path|_.REST Type|_.Description|_.Example Input JSON|  
42 14 Justin Sherrill
|_.Architectures |
43 13 Justin Sherrill
|/architectures|POST|Create a new Architecture|{architecture : {"name":string}}|
44 26 Romain Vrignaud
|/architectures/NAME|DELETE|Delete a Architecture||
45 18 Justin Sherrill
|/architectures|GET|Retrieve a list of Architectures||
46 26 Romain Vrignaud
|/architectures/NAME|PUT|Update an existing Architecture|{architecture : {"name":string}}|
47 16 Justin Sherrill
|_.Auth source ldaps |
48 15 Justin Sherrill
|/auth_source_ldaps|POST|Create a new Auth source ldap|{authsourceldap : {"account":string, "account_password":string, "attr_firstname":string, "attr_lastname":string, "attr_login":string, "attr_mail":string, "base_dn":string, "host":string, "name":string, "onthefly_register":string, "port":string, "tls":string, "type":string}}|
49 18 Justin Sherrill
|/auth_source_ldaps/ID|DELETE|Delete a Auth source ldap||
50
|/auth_source_ldaps|GET|Retrieve a list of Auth source ldaps||
51 15 Justin Sherrill
|/auth_source_ldaps/ID|PUT|Update an existing Auth source ldap|{authsourceldap : {"account":string, "account_password":string, "attr_firstname":string, "attr_lastname":string, "attr_login":string, "attr_mail":string, "base_dn":string, "host":string, "name":string, "onthefly_register":string, "port":string, "tls":string, "type":string}}|
52 16 Justin Sherrill
|_.Common parameters |
53 15 Justin Sherrill
|/common_parameters|POST|Create a new Common parameter|{commonparameter : {"name":string, "reference_id":int, "type":string, "value":string}}|
54 18 Justin Sherrill
|/common_parameters/ID|DELETE|Delete a Common parameter||
55
|/common_parameters|GET|Retrieve a list of Common parameters||
56 15 Justin Sherrill
|/common_parameters/ID|PUT|Update an existing Common parameter|{commonparameter : {"name":string, "reference_id":int, "type":string, "value":string}}|
57 16 Justin Sherrill
|_.Config templates |
58 34 Pedro Gomes
|/config_templates|POST|Create a new Config template|{config_template : {"hostgroup_id":int, "name":string, "snippet":boolean, "template":string, "template_kind_id":int}}|
59 18 Justin Sherrill
|/config_templates/ID|DELETE|Delete a Config template||
60
|/config_templates|GET|Retrieve a list of Config templates||
61 34 Pedro Gomes
|/config_templates/ID|PUT|Update an existing Config template|{config_template : {"hostgroup_id":int, "name":string, "snippet":boolean, "template":string, "template_kind_id":int}}|
62 15 Justin Sherrill
|/config_templates/build_pxe_default|GET|Deploy the default pxe template to all smart proxies.||
63 1 Ohad Levy
|_.Domains |
64
|/domains|POST|Create a new Domain|{domain : {"dns_id":int, "fullname":string, "name":string}}|
65 18 Justin Sherrill
|/domains/NAME|DELETE|Delete a Domain||
66
|/domains|GET|Retrieve a list of Domains||
67 15 Justin Sherrill
|/domains/NAME|PUT|Update an existing Domain|{domain : {"dns_id":int, "fullname":string, "name":string}}|
68 1 Ohad Levy
|_.Environments |
69
|/environments|POST|Create a new Environment|{environment : {"name":string}}|
70 18 Justin Sherrill
|/environments/NAME|DELETE|Delete a Environment||
71
|/environments|GET|Retrieve a list of Environments||
72 15 Justin Sherrill
|/environments/NAME|PUT|Update an existing Environment|{environment : {"name":string}}|
73 30 Corey Osman
|_.Fact names |
74 31 Corey Osman
|/facts|GET| Gets list of all fact names|
75 30 Corey Osman
|/facts/<factname>/values| GET | return all hosts with the given factname and its value|
76 16 Justin Sherrill
|_.Fact values |
77 15 Justin Sherrill
|/fact_values|POST|Create a new Fact value|{factvalue : {"fact_name_id":int, "host_id":int, "value":string}}|
78 18 Justin Sherrill
|/fact_values|GET|Retrieve a list of Fact values||
79 14 Justin Sherrill
|_.Hostgroups |
80 1 Ohad Levy
|/hostgroups|POST|Create a new Hostgroup|{hostgroup : {"architecture_id":int, "environment_id":int, "medium_id":int, "name":string, "operatingsystem_id":int, "ptable_id":int, "puppetmaster":string, "root_pass":string}}|
81 27 Romain Vrignaud
|/hostgroups/ID|DELETE|Delete a Hostgroup||
82 18 Justin Sherrill
|/hostgroups|GET|Retrieve a list of Hostgroups||
83 27 Romain Vrignaud
|/hostgroups/ID|PUT|Update an existing Hostgroup|{hostgroup : {"architecture_id":int, "environment_id":int, "medium_id":int, "name":string, "operatingsystem_id":int, "ptable_id":int, "puppetmaster":string, "root_pass":string}}|
84 1 Ohad Levy
|_.Hosts |
85 18 Justin Sherrill
|/hosts|POST|Create a new Host|{host : {"architecture_id":int, "build":string, "comment":string, "disk":string, "domain_id":int, "enabled":string, "environment":string, "environment_id":int, "hostgroup_id":int, "installed_at":string, "ip":string, "last_compile":string, "last_freshcheck":string, "last_report":string, "mac":string, "medium_id":int, "model_id":int, "name":string, "operatingsystem_id":int, "owner_id":int, "owner_type":string, "ptable_id":int, "puppet_status":string, "puppetmaster":string, "root_pass":string, "serial":string, "source_file_id":int, "sp_ip":string, "sp_mac":string, "sp_name":string, "sp_subnet_id":int, "subnet_id":int}}|
86
|/hosts/FQDN|DELETE|Delete a Host||
87 15 Justin Sherrill
|/hosts|GET|Retrieve a list of Hosts||
88
|/hosts/FQDN|PUT|Update an existing Host|{host : {"architecture_id":int, "build":string, "comment":string, "disk":string, "domain_id":int, "enabled":string, "environment":string, "environment_id":int, "hostgroup_id":int, "installed_at":string, "ip":string, "last_compile":string, "last_freshcheck":string, "last_report":string, "mac":string, "medium_id":int, "model_id":int, "name":string, "operatingsystem_id":int, "owner_id":int, "owner_type":string, "ptable_id":int, "puppet_status":string, "puppetmaster":string, "root_pass":string, "serial":string, "source_file_id":int, "sp_ip":string, "sp_mac":string, "sp_name":string, "sp_subnet_id":int, "subnet_id":int}}|
89 1 Ohad Levy
|/hosts/errors|GET|List of hosts in error state(only name)||
90 15 Justin Sherrill
|/hosts/active|GET|List of active hosts (only name)||
91
|/hosts/out_of_sync|GET|List of out of sync hosts(only name)||
92
|/hosts/disabled|GET|List of disabled hosts(only name)||
93 41 Dominic Cleal
|/hosts/FQDN/setBuild|GET|Move host to Build state||
94 15 Justin Sherrill
|/hosts/FQDN/facts|GET|Returns host facts||
95 23 Ohad Levy
|/hosts/FQDN/puppetclasses|GET|Returns host classes (direct and indirect(via a hostgroup)||
96 24 Ohad Levy
|/hosts/FQDN/reports|GET|Reports for host FQDN ||
97
|/hosts/FQDN/reports/last|GET|Last report for host FQDN ||
98 15 Justin Sherrill
|/hosts/FQDN/pxe_config|GET|Returns syslinux configuration file for fqdn||
99 1 Ohad Levy
|_.Hypervisors |
100
|/hypervisors|POST|Create a new Hypervisor|{hypervisor : {"kind":string, "name":string, "uri":string}}|
101 18 Justin Sherrill
|/hypervisors/ID|DELETE|Delete a Hypervisor||
102
|/hypervisors|GET|Retrieve a list of Hypervisors||
103 15 Justin Sherrill
|/hypervisors/ID|PUT|Update an existing Hypervisor|{hypervisor : {"kind":string, "name":string, "uri":string}}|
104 35 Ohad Levy
|_.Smart Variables |
105
|/lookup_keys|POST|Create a new SmartVar key|{lookupkey : {"key":string}}|
106
|/lookup_keys/ID|DELETE|Delete a Smart key||
107
|/lookup_keys|GET|Retrieve a list of Smartvar keys||
108
|/lookup_keys/ID|PUT|Update an existing Smart key|{lookupkey : {"key":string}}|
109 1 Ohad Levy
|_.Smart Variables values |
110 38 Ohad Levy
|/lookup_values|POST|Create a new SmartVar value|{lookupvalue : {"lookup_key_id":integer, "match":string, "value":string}}|
111 35 Ohad Levy
|/lookup_values/ID|DELETE|Delete a Smart value||
112
|/lookup_values|GET|Retrieve a list of Smartvar values||
113
|/lookup_values/ID|PUT|Update an existing Smart value|{lookupvalue : {"value":string}}|
114 16 Justin Sherrill
|_.Medias |
115 1 Ohad Levy
|/media|POST|Create a new Medium|{medium : {"name":string, "path":string}}|
116 18 Justin Sherrill
|/media/ID|DELETE|Delete a Medium||
117
|/media|GET|Retrieve a list of Media||
118 15 Justin Sherrill
|/media/ID|PUT|Update an existing Medium|{medium : {"name":string, "path":string}}|
119 13 Justin Sherrill
|_.Models |
120 12 Justin Sherrill
|/models|POST|Create a new Model|{model : {"info":string, "name":string}}|
121 18 Justin Sherrill
|/models/ID|DELETE|Delete a Model||
122
|/models|GET|Retrieve a list of Models||
123 15 Justin Sherrill
|/models/ID|PUT|Update an existing Model|{model : {"info":string, "name":string}}|
124 13 Justin Sherrill
|_.Operatingsystems |
125
|/operatingsystems|POST|Create a new Operatingsystem|{operatingsystem : {"major":string, "minor":string, "name":string, "nameindicator":string, "release_name":string, "type":string}}|
126 18 Justin Sherrill
|/operatingsystems/ID|DELETE|Delete a Operatingsystem||
127
|/operatingsystems|GET|Retrieve a list of Operatingsystems||
128 1 Ohad Levy
|/operatingsystems/ID|PUT|Update an existing Operatingsystem|{operatingsystem : {"major":string, "minor":string, "name":string, "nameindicator":string, "release_name":string, "type":string}}|
129 20 Ohad Levy
|/operatingsystems/ID/bootfiles?media=<media_name>&architecture=x86_64|GET|tftp boot files and their respective urls (where they can be found)||
130 15 Justin Sherrill
|_.Ptables |
131 13 Justin Sherrill
|/ptables|POST|Create a new Ptable|{ptable : {"layout":string, "name":string, "operatingsystem_id":int}}|
132 18 Justin Sherrill
|/ptables/ID|DELETE|Delete a Ptable||
133
|/ptables|GET|Retrieve a list of Ptables||
134 13 Justin Sherrill
|/ptables/ID|PUT|Update an existing Ptable|{ptable : {"layout":string, "name":string, "operatingsystem_id":int}}|
135 15 Justin Sherrill
|_.Puppetclasses |
136 13 Justin Sherrill
|/puppetclasses|POST|Create a new Puppetclass|{puppetclass : {"name":string, "nameindicator":string, "operatingsystem_id":int}}|
137 18 Justin Sherrill
|/puppetclasses/ID|DELETE|Delete a Puppetclass||
138
|/puppetclasses|GET|Retrieve a list of Puppetclasses||
139 13 Justin Sherrill
|/puppetclasses/ID|PUT|Update an existing Puppetclass|{puppetclass : {"name":string, "nameindicator":string, "operatingsystem_id":int}}|
140 15 Justin Sherrill
|_.Reports |
141 18 Justin Sherrill
|/reports|POST|Create a new Report|{report : {"host_id":int, "metrics":string, "reported_at":string, "status":string}}|
142 1 Ohad Levy
|/reports/ID|DELETE|Delete a Report||
143 24 Ohad Levy
|/reports/last|GET|Retrieve the last report information||
144 28 Corey Osman
|/reports?numreports=xx|GET|Retrieve reports xx items at a single time||
145 13 Justin Sherrill
|_.Roles |
146 1 Ohad Levy
|/roles|POST|Create a new Role|{role : {"builtin":string, "name":string, "permissions":string}}|
147 18 Justin Sherrill
|/roles/ID|DELETE|Delete a Role||
148
|/roles|GET|Retrieve a list of Roles||
149 13 Justin Sherrill
|/roles/ID|PUT|Update an existing Role|{role : {"builtin":string, "name":string, "permissions":string}}|
150 15 Justin Sherrill
|_.Smart proxies |
151 16 Justin Sherrill
|/smart_proxies|POST|Create a new Smart proxy|{smartproxy : {"name":string, "url":string}}|
152 18 Justin Sherrill
|/smart_proxies/ID|DELETE|Delete a Smart proxy||
153
|/smart_proxies|GET|Retrieve a list of Smart proxies||
154 15 Justin Sherrill
|/smart_proxies/ID|PUT|Update an existing Smart proxy|{smartproxy : {"name":string, "url":string}}|
155
|_.Subnets |
156 13 Justin Sherrill
|/subnets|POST|Create a new Subnet|{subnet : {"dhcp_id":int, "domain_id":int, "mask":string, "name":string, "network":string, "priority":string, "ranges":string, "tftp_id":int, "vlanid":int}}|
157 18 Justin Sherrill
|/subnets/ID|DELETE|Delete a Subnet||
158
|/subnets|GET|Retrieve a list of Subnets||
159 13 Justin Sherrill
|/subnets/ID|PUT|Update an existing Subnet|{subnet : {"dhcp_id":int, "domain_id":int, "mask":string, "name":string, "network":string, "priority":string, "ranges":string, "tftp_id":int, "vlanid":int}}|
160 15 Justin Sherrill
|_.Usergroups |
161 13 Justin Sherrill
|/usergroups|POST|Create a new Usergroup|{usergroup : {"name":string}}|
162 18 Justin Sherrill
|/usergroups/ID|DELETE|Delete a Usergroup||
163
|/usergroups|GET|Retrieve a list of Usergroups||
164 4 Ohad Levy
|/usergroups/ID|PUT|Update an existing Usergroup|{usergroup : {"name":string}}|
165 1 Ohad Levy
|_.Users |
166 12 Justin Sherrill
|/users|POST|Create a new User|{user : {"admin":string, "auth_source_id":int, "domains_andor":string, "facts_andor":string, "filter_on_owner":string, "firstname":string, "hostgroups_andor":string, "last_login_on":string, "lastname":string, "login":string, "mail":string, "password_hash":string, "password_salt":string, "role_id":int}}|
167 18 Justin Sherrill
|/users/ID|DELETE|Delete a User||
168
|/users|GET|Retrieve a list of Users||
169 1 Ohad Levy
|/users/ID|PUT|Update an existing User|{user : {"admin":string, "auth_source_id":int, "domains_andor":string, "facts_andor":string, "filter_on_owner":string, "firstname":string, "hostgroups_andor":string, "last_login_on":string, "lastname":string, "login":string, "mail":string, "password_hash":string, "password_salt":string, "role_id":int}}|
170 6 Ohad Levy
|_.Miscellaneous |
171 17 Justin Sherrill
|/dashboard|GET|Summary statistcs (total hosts, active hosts, hosts in error etc)||
172 21 Lukas Zapletal
|/status|GET|System status (result ok/failed, database lag in miliseconds)||
173 18 Justin Sherrill
174 1 Ohad Levy
175
176
177 22 Ohad Levy
see also [[Smart-Proxy:API]]
178 1 Ohad Levy
179
Please raise a new issue if you need additional API's
180 40 Petr Chalupa
181
h2. New version of API
182
183
There is a new version of API being developed. Version 1 will cover current API. 
184
185
* Source code lives in source:app/controllers/api
186
* Documentation can be accessed on http://path.to.foreman/apidoc
187
* [[API OAuth]]