Project

General

Profile

API » History » Version 11

Justin Sherrill, 02/21/2011 12:55 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 1 Ohad Levy
Foreman provides a "REST":http://en.wikipedia.org/wiki/Representational_State_Transfer API, communicating via JSON.
6
7 9 Ohad Levy
Please refer to this document for latest information about Foreman API.
8 1 Ohad Levy
9
Examples below are either via curl or ruby rest_client
10
11
most pages can be browsed via adding the format option to the url (at least for get requests), i.e.
12
13
<pre>
14
http://foreman/environemnts?format=json
15
</pre>
16
17
Or using HTTP Headers
18
<pre>
19
curl -H "Content-Type:application/json" -H "Accept:application/json"  http://foreman/hosts
20
</pre>
21
22
Output is JSON formatted, in the last example expect a similar output:
23
24
<pre>
25 10 Ohad Levy
[{"host":{"name":"pm1.local.net"}},{"host":{"name":"pm2.local.net"}}....]
26 1 Ohad Levy
</pre>
27
28 3 Ohad Levy
h2. List of API's
29 1 Ohad Levy
30 11 Justin Sherrill
|_.Path|_.REST Type|_.Example JSON|
31
|/roles/ID|DELETE|{role:{"name":string}}|
32
|/roles|POST|{role:{"builtin":string, "name":string, "permissions":string}}|
33
|/roles|GET|
34
|/roles/ID|PUT|{role:{"builtin":string, "name":string, "permissions":string}}|
35
| |
36
|/factvalues|POST|{factvalue:{"fact_name_id":int, "host_id":int, "value":string}}|
37
|/factvalues|GET|
38
| |
39
|/environments/ID|DELETE|{environment:{"name":string}}|
40
|/environments|POST|{environment:{"name":string}}|
41
|/environments|GET|
42
|/environments/ID|PUT|{environment:{"name":string}}|
43
| |
44
|/operatingsystems/ID|DELETE|{operatingsystem:{"name":string}}|
45
|/operatingsystems|POST|{operatingsystem:{"major":string, "minor":string, "name":string, "nameindicator":string, "release_name":string, "type":string}}|
46
|/operatingsystems|GET|
47
|/operatingsystems/ID|PUT|{operatingsystem:{"major":string, "minor":string, "name":string, "nameindicator":string, "release_name":string, "type":string}}|
48
| |
49
|/hostgroups/ID|DELETE|{hostgroup:{"name":string}}|
50
|/hostgroups|POST|{hostgroup:{"architecture_id":int, "environment_id":int, "medium_id":int, "name":string, "operatingsystem_id":int, "ptable_id":int, "puppetmaster":string, "root_pass":string}}|
51
|/hostgroups|GET|
52
|/hostgroups/ID|PUT|{hostgroup:{"architecture_id":int, "environment_id":int, "medium_id":int, "name":string, "operatingsystem_id":int, "ptable_id":int, "puppetmaster":string, "root_pass":string}}|
53
| |
54
|/ptables/ID|DELETE|{ptable:{"name":string}}|
55
|/ptables|POST|{ptable:{"layout":string, "name":string, "operatingsystem_id":int}}|
56
|/ptables|GET|
57
|/ptables/ID|PUT|{ptable:{"layout":string, "name":string, "operatingsystem_id":int}}|
58
| |
59
|/authsourceldaps/ID|DELETE|{authsourceldap:{"name":string}}|
60
|/authsourceldaps|POST|{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}}|
61
|/authsourceldaps|GET|
62
|/authsourceldaps/ID|PUT|{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}}|
63
| |
64
|/domains/ID|DELETE|{domain:{"name":string}}|
65
|/domains|POST|{domain:{"dns_id":int, "fullname":string, "name":string}}|
66
|/domains|GET|
67
|/domains/ID|PUT|{domain:{"dns_id":int, "fullname":string, "name":string}}|
68
| |
69
|/puppetclasses/ID|DELETE|{puppetclass:{"name":string}}|
70
|/puppetclasses|POST|{puppetclass:{"name":string, "nameindicator":string, "operatingsystem_id":int}}|
71
|/puppetclasses|GET|
72
|/puppetclasses/ID|PUT|{puppetclass:{"name":string, "nameindicator":string, "operatingsystem_id":int}}|
73
| |
74
|/hypervisors/ID|DELETE|{hypervisor:{"name":string}}|
75
|/hypervisors|POST|{hypervisor:{"kind":string, "name":string, "uri":string}}|
76
|/hypervisors|GET|
77
|/hypervisors/ID|PUT|{hypervisor:{"kind":string, "name":string, "uri":string}}|
78
| |
79
|/models/ID|DELETE|{model:{"name":string}}|
80
|/models|POST|{model:{"info":string, "name":string}}|
81
|/models|GET|
82
|/models/ID|PUT|{model:{"info":string, "name":string}}|
83
| |
84
|/usergroups/ID|DELETE|{usergroup:{"name":string}}|
85
|/usergroups|POST|{usergroup:{"name":string}}|
86
|/usergroups|GET|
87
|/usergroups/ID|PUT|{usergroup:{"name":string}}|
88
| |
89
|/reports/ID|DELETE|{report:{}}|
90
|/reports|POST|{report:{"host_id":int, "metrics":string, "reported_at":string, "status":string}}|
91
|/reports|GET|
92
| |
93
|/configtemplates/ID|DELETE|{configtemplate:{"name":string}}|
94
|/configtemplates|POST|{configtemplate:{"hostgroup_id":int, "name":string, "snippet":string, "template":string, "template_kind_id":int}}|
95
|/configtemplates|GET|
96
|/configtemplates/ID|PUT|{configtemplate:{"hostgroup_id":int, "name":string, "snippet":string, "template":string, "template_kind_id":int}}|
97
| |
98
|/commonparameters/ID|DELETE|{commonparameter:{"name":string}}|
99
|/commonparameters|POST|{commonparameter:{"name":string, "reference_id":int, "type":string, "value":string}}|
100
|/commonparameters|GET|
101
|/commonparameters/ID|PUT|{commonparameter:{"name":string, "reference_id":int, "type":string, "value":string}}|
102
| |
103
|/users/ID|DELETE|{user:{}}|
104
|/users|POST|{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}}|
105
|/users|GET|
106
|/users/ID|PUT|{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}}|
107
| |
108
|/architectures/ID|DELETE|{architecture:{"name":string}}|
109
|/architectures|POST|{architecture:{"name":string}}|
110
|/architectures|GET|
111
|/architectures/ID|PUT|{architecture:{"name":string}}|
112
| |
113
|/media/ID|DELETE|{medium:{"name":string}}|
114
|/media|POST|{medium:{"name":string, "path":string}}|
115
|/media|GET|
116
|/media/ID|PUT|{medium:{"name":string, "path":string}}|
117
| |
118
|/hosts/fqdn|DELETE|{host:{"name":string}}|
119
|/hosts|POST|{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}}|
120
|/hosts|GET|
121
|/hosts/fqdn|PUT|{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}}|
122
| |
123
|/subnets/ID|DELETE|{subnet:{"name":string}}|
124
|/subnets|POST|{subnet:{"dhcp_id":int, "domain_id":int, "mask":string, "name":string, "network":string, "priority":string, "ranges":string, "tftp_id":int, "vlanid":int}}|
125
|/subnets|GET|
126
|/subnets/ID|PUT|{subnet:{"dhcp_id":int, "domain_id":int, "mask":string, "name":string, "network":string, "priority":string, "ranges":string, "tftp_id":int, "vlanid":int}}|
127
| |
128
|/smartproxies/ID|DELETE|{smartproxy:{"name":string}}|
129
|/smartproxies|POST|{smartproxy:{"name":string, "url":string}}|
130
|/smartproxies|GET|
131
|/smartproxies/ID|PUT|{smartproxy:{"name":string, "url":string}}|
132
| |
133
|/lookupkeys/ID|DELETE|{lookupkey:{}}|
134
|/lookupkeys|POST|{lookupkey:{"key":string}}|
135
|/lookupkeys|GET|
136
|/lookupkeys/ID|PUT|{lookupkey:{"key":string}}|
137
| |
138
139
140
141
142
143
144
145
146
147 1 Ohad Levy
|/architectures|GET|List of valid OS Architectures(name and ID)|
148
|/architectures/x86_64|GET|Description of the x86_64 Architecture (name and ID)|
149 5 Ohad Levy
|/dashboard|GET|Summary statistcs (total hosts, active hosts, hosts in error etc)|
150 1 Ohad Levy
|/domains|GET|List of known domains (name and ID)|
151
|/domains/my_domain|GET|Description of "my_domain" (name and ID)|
152
|/environments|GET|List of known environments (name and ID)|
153
|/environments/production|GET|Description of the "production" (name and ID and associated host list)|
154
|/fact_values|GET|List of known Facts (value, name and host)|
155
|/hostgroups|GET|List of known hostgroups (name and ID)|
156
|/hostgroups/common|GET|Description of "common" (name and ID)|
157
|/hosts|GET|List of known hosts (only name)|
158 4 Ohad Levy
|/hosts/errors|GET|List of hosts in error state(only name)|
159
|/hosts/active|GET|List of active hosts(only name)|
160
|/hosts/out_of_sync|GET|List of out of sync hosts(only name)|
161
|/hosts/disabled|GET|List of disabled hosts(only name)|
162 1 Ohad Levy
|/hosts|POST|creates a new host, 201 return sucesful creation, otherwise the errors will be returned|
163
|/hosts/fqdn|GET|Host Attributes (name, usergroup, last_report, os properties...)|
164
|/hosts/fqdn|DELETE|Removes the host "fqdn"|
165
|/hosts/fqdn/setBuild|GET| Enable Host for (re-)build |
166
|/hosts/fqdn/facts|GET| Returns host facts|
167 6 Ohad Levy
|/hosts/fqdn/pxe_config|GET| Returns syslinux configuration file for fqdn|
168 1 Ohad Levy
|/medias|GET|List of known mediums (name and ID)|
169
|/medias/1|GET|Description of media which ID is 1 (name and ID and path/url)|
170
|/operatingsystems|GET|List of known operating systems (Release name, ID and allowed mediums, architectures and partition tables)|
171
|/operatingsystems/1|GET| Description of operating systems which its ID is 1 (Release name, ID and allowed mediums, architectures and partition tables)|
172 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)|
173 1 Ohad Levy
|/ptables|GET|List of known Partition tables (name and ID)|
174
|/ptables/1|GET|Description of Partition table which its ID is 1 (name and ID)|
175
|/puppetclasses|GET|a hash of known Puppetclasses orginazined by module name (module => {:class1, :class2})|
176 3 Ohad Levy
177
178
179
Please raise a new issue if you need additional API's