Project

General

Profile

API » History » Version 39

Ohad Levy, 09/11/2012 03:34 PM

1 1 Ohad Levy
h1. API
2
3 8 Ohad Levy
*NOTE*: Version of 0.1-6 or git develop branch are required to use the API
4
5 39 Ohad Levy
*NOTE*: Starting with Foreman 1.1 API documentation is auto generated, access using /apidoc on your foreman instance.
6
Auto generated Ruby binding and CLI are also available.
7
8
9 1 Ohad Levy
Foreman provides a "REST":http://en.wikipedia.org/wiki/Representational_State_Transfer API, communicating via JSON.
10
11 9 Ohad Levy
Please refer to this document for latest information about Foreman API.
12 1 Ohad Levy
13 33 Jan van Eldik
[[Examples]] below are either via curl, perl, ruby rest_client
14 32 Florian Koch
15 1 Ohad Levy
16
most pages can be browsed via adding the format option to the url (at least for get requests), i.e.
17
18
<pre>
19 25 Romain Vrignaud
http://foreman/environments?format=json
20 1 Ohad Levy
</pre>
21
22
Or using HTTP Headers
23
<pre>
24
curl -H "Content-Type:application/json" -H "Accept:application/json"  http://foreman/hosts
25
</pre>
26
27
Output is JSON formatted, in the last example expect a similar output:
28
29
<pre>
30 10 Ohad Levy
[{"host":{"name":"pm1.local.net"}},{"host":{"name":"pm2.local.net"}}....]
31 1 Ohad Levy
</pre>
32
33 3 Ohad Levy
h2. List of API's
34 1 Ohad Levy
35 12 Justin Sherrill
|_.Path|_.REST Type|_.Description|_.Example Input JSON|  
36 14 Justin Sherrill
|_.Architectures |
37 13 Justin Sherrill
|/architectures|POST|Create a new Architecture|{architecture : {"name":string}}|
38 26 Romain Vrignaud
|/architectures/NAME|DELETE|Delete a Architecture||
39 18 Justin Sherrill
|/architectures|GET|Retrieve a list of Architectures||
40 26 Romain Vrignaud
|/architectures/NAME|PUT|Update an existing Architecture|{architecture : {"name":string}}|
41 16 Justin Sherrill
|_.Auth source ldaps |
42 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}}|
43 18 Justin Sherrill
|/auth_source_ldaps/ID|DELETE|Delete a Auth source ldap||
44
|/auth_source_ldaps|GET|Retrieve a list of Auth source ldaps||
45 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}}|
46 16 Justin Sherrill
|_.Common parameters |
47 15 Justin Sherrill
|/common_parameters|POST|Create a new Common parameter|{commonparameter : {"name":string, "reference_id":int, "type":string, "value":string}}|
48 18 Justin Sherrill
|/common_parameters/ID|DELETE|Delete a Common parameter||
49
|/common_parameters|GET|Retrieve a list of Common parameters||
50 15 Justin Sherrill
|/common_parameters/ID|PUT|Update an existing Common parameter|{commonparameter : {"name":string, "reference_id":int, "type":string, "value":string}}|
51 16 Justin Sherrill
|_.Config templates |
52 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}}|
53 18 Justin Sherrill
|/config_templates/ID|DELETE|Delete a Config template||
54
|/config_templates|GET|Retrieve a list of Config templates||
55 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}}|
56 15 Justin Sherrill
|/config_templates/build_pxe_default|GET|Deploy the default pxe template to all smart proxies.||
57 1 Ohad Levy
|_.Domains |
58
|/domains|POST|Create a new Domain|{domain : {"dns_id":int, "fullname":string, "name":string}}|
59 18 Justin Sherrill
|/domains/NAME|DELETE|Delete a Domain||
60
|/domains|GET|Retrieve a list of Domains||
61 15 Justin Sherrill
|/domains/NAME|PUT|Update an existing Domain|{domain : {"dns_id":int, "fullname":string, "name":string}}|
62 1 Ohad Levy
|_.Environments |
63
|/environments|POST|Create a new Environment|{environment : {"name":string}}|
64 18 Justin Sherrill
|/environments/NAME|DELETE|Delete a Environment||
65
|/environments|GET|Retrieve a list of Environments||
66 15 Justin Sherrill
|/environments/NAME|PUT|Update an existing Environment|{environment : {"name":string}}|
67 30 Corey Osman
|_.Fact names |
68 31 Corey Osman
|/facts|GET| Gets list of all fact names|
69 30 Corey Osman
|/facts/<factname>/values| GET | return all hosts with the given factname and its value|
70 16 Justin Sherrill
|_.Fact values |
71 15 Justin Sherrill
|/fact_values|POST|Create a new Fact value|{factvalue : {"fact_name_id":int, "host_id":int, "value":string}}|
72 18 Justin Sherrill
|/fact_values|GET|Retrieve a list of Fact values||
73 14 Justin Sherrill
|_.Hostgroups |
74 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}}|
75 27 Romain Vrignaud
|/hostgroups/ID|DELETE|Delete a Hostgroup||
76 18 Justin Sherrill
|/hostgroups|GET|Retrieve a list of Hostgroups||
77 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}}|
78 1 Ohad Levy
|_.Hosts |
79
|/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}}|
80 18 Justin Sherrill
|/hosts/FQDN|DELETE|Delete a Host||
81
|/hosts|GET|Retrieve a list of Hosts||
82 15 Justin Sherrill
|/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}}|
83
|/hosts/errors|GET|List of hosts in error state(only name)||
84
|/hosts/active|GET|List of active hosts (only name)||
85
|/hosts/out_of_sync|GET|List of out of sync hosts(only name)||
86
|/hosts/disabled|GET|List of disabled hosts(only name)||
87
|/hosts/FQDN/setBuild|GET|List of disabled hosts(only name)||
88
|/hosts/FQDN/facts|GET|Returns host facts||
89 23 Ohad Levy
|/hosts/FQDN/puppetclasses|GET|Returns host classes (direct and indirect(via a hostgroup)||
90 24 Ohad Levy
|/hosts/FQDN/reports|GET|Reports for host FQDN ||
91
|/hosts/FQDN/reports/last|GET|Last report for host FQDN ||
92 15 Justin Sherrill
|/hosts/FQDN/pxe_config|GET|Returns syslinux configuration file for fqdn||
93 1 Ohad Levy
|_.Hypervisors |
94
|/hypervisors|POST|Create a new Hypervisor|{hypervisor : {"kind":string, "name":string, "uri":string}}|
95 18 Justin Sherrill
|/hypervisors/ID|DELETE|Delete a Hypervisor||
96
|/hypervisors|GET|Retrieve a list of Hypervisors||
97 15 Justin Sherrill
|/hypervisors/ID|PUT|Update an existing Hypervisor|{hypervisor : {"kind":string, "name":string, "uri":string}}|
98 35 Ohad Levy
|_.Smart Variables |
99
|/lookup_keys|POST|Create a new SmartVar key|{lookupkey : {"key":string}}|
100
|/lookup_keys/ID|DELETE|Delete a Smart key||
101
|/lookup_keys|GET|Retrieve a list of Smartvar keys||
102
|/lookup_keys/ID|PUT|Update an existing Smart key|{lookupkey : {"key":string}}|
103 1 Ohad Levy
|_.Smart Variables values |
104 38 Ohad Levy
|/lookup_values|POST|Create a new SmartVar value|{lookupvalue : {"lookup_key_id":integer, "match":string, "value":string}}|
105 35 Ohad Levy
|/lookup_values/ID|DELETE|Delete a Smart value||
106
|/lookup_values|GET|Retrieve a list of Smartvar values||
107
|/lookup_values/ID|PUT|Update an existing Smart value|{lookupvalue : {"value":string}}|
108 16 Justin Sherrill
|_.Medias |
109 1 Ohad Levy
|/media|POST|Create a new Medium|{medium : {"name":string, "path":string}}|
110 18 Justin Sherrill
|/media/ID|DELETE|Delete a Medium||
111
|/media|GET|Retrieve a list of Media||
112 15 Justin Sherrill
|/media/ID|PUT|Update an existing Medium|{medium : {"name":string, "path":string}}|
113 13 Justin Sherrill
|_.Models |
114 12 Justin Sherrill
|/models|POST|Create a new Model|{model : {"info":string, "name":string}}|
115 18 Justin Sherrill
|/models/ID|DELETE|Delete a Model||
116
|/models|GET|Retrieve a list of Models||
117 15 Justin Sherrill
|/models/ID|PUT|Update an existing Model|{model : {"info":string, "name":string}}|
118 13 Justin Sherrill
|_.Operatingsystems |
119
|/operatingsystems|POST|Create a new Operatingsystem|{operatingsystem : {"major":string, "minor":string, "name":string, "nameindicator":string, "release_name":string, "type":string}}|
120 18 Justin Sherrill
|/operatingsystems/ID|DELETE|Delete a Operatingsystem||
121
|/operatingsystems|GET|Retrieve a list of Operatingsystems||
122 1 Ohad Levy
|/operatingsystems/ID|PUT|Update an existing Operatingsystem|{operatingsystem : {"major":string, "minor":string, "name":string, "nameindicator":string, "release_name":string, "type":string}}|
123 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)||
124 15 Justin Sherrill
|_.Ptables |
125 13 Justin Sherrill
|/ptables|POST|Create a new Ptable|{ptable : {"layout":string, "name":string, "operatingsystem_id":int}}|
126 18 Justin Sherrill
|/ptables/ID|DELETE|Delete a Ptable||
127
|/ptables|GET|Retrieve a list of Ptables||
128 13 Justin Sherrill
|/ptables/ID|PUT|Update an existing Ptable|{ptable : {"layout":string, "name":string, "operatingsystem_id":int}}|
129 15 Justin Sherrill
|_.Puppetclasses |
130 13 Justin Sherrill
|/puppetclasses|POST|Create a new Puppetclass|{puppetclass : {"name":string, "nameindicator":string, "operatingsystem_id":int}}|
131 18 Justin Sherrill
|/puppetclasses/ID|DELETE|Delete a Puppetclass||
132
|/puppetclasses|GET|Retrieve a list of Puppetclasses||
133 13 Justin Sherrill
|/puppetclasses/ID|PUT|Update an existing Puppetclass|{puppetclass : {"name":string, "nameindicator":string, "operatingsystem_id":int}}|
134 15 Justin Sherrill
|_.Reports |
135 18 Justin Sherrill
|/reports|POST|Create a new Report|{report : {"host_id":int, "metrics":string, "reported_at":string, "status":string}}|
136 1 Ohad Levy
|/reports/ID|DELETE|Delete a Report||
137 24 Ohad Levy
|/reports/last|GET|Retrieve the last report information||
138 28 Corey Osman
|/reports?numreports=xx|GET|Retrieve reports xx items at a single time||
139 13 Justin Sherrill
|_.Roles |
140 1 Ohad Levy
|/roles|POST|Create a new Role|{role : {"builtin":string, "name":string, "permissions":string}}|
141 18 Justin Sherrill
|/roles/ID|DELETE|Delete a Role||
142
|/roles|GET|Retrieve a list of Roles||
143 13 Justin Sherrill
|/roles/ID|PUT|Update an existing Role|{role : {"builtin":string, "name":string, "permissions":string}}|
144 15 Justin Sherrill
|_.Smart proxies |
145 16 Justin Sherrill
|/smart_proxies|POST|Create a new Smart proxy|{smartproxy : {"name":string, "url":string}}|
146 18 Justin Sherrill
|/smart_proxies/ID|DELETE|Delete a Smart proxy||
147
|/smart_proxies|GET|Retrieve a list of Smart proxies||
148 15 Justin Sherrill
|/smart_proxies/ID|PUT|Update an existing Smart proxy|{smartproxy : {"name":string, "url":string}}|
149
|_.Subnets |
150 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}}|
151 18 Justin Sherrill
|/subnets/ID|DELETE|Delete a Subnet||
152
|/subnets|GET|Retrieve a list of Subnets||
153 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}}|
154 15 Justin Sherrill
|_.Usergroups |
155 13 Justin Sherrill
|/usergroups|POST|Create a new Usergroup|{usergroup : {"name":string}}|
156 18 Justin Sherrill
|/usergroups/ID|DELETE|Delete a Usergroup||
157
|/usergroups|GET|Retrieve a list of Usergroups||
158 4 Ohad Levy
|/usergroups/ID|PUT|Update an existing Usergroup|{usergroup : {"name":string}}|
159 1 Ohad Levy
|_.Users |
160 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}}|
161 18 Justin Sherrill
|/users/ID|DELETE|Delete a User||
162
|/users|GET|Retrieve a list of Users||
163 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}}|
164 6 Ohad Levy
|_.Miscellaneous |
165 17 Justin Sherrill
|/dashboard|GET|Summary statistcs (total hosts, active hosts, hosts in error etc)||
166 21 Lukas Zapletal
|/status|GET|System status (result ok/failed, database lag in miliseconds)||
167 18 Justin Sherrill
168 1 Ohad Levy
169
170
171 22 Ohad Levy
see also [[Smart-Proxy:API]]
172 1 Ohad Levy
173
Please raise a new issue if you need additional API's