API » History » Version 12
Justin Sherrill, 02/21/2011 01:27 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 | 12 | Justin Sherrill | |_.Path|_.REST Type|_.Description|_.Example Input JSON| |
31 | |/roles/false|DELETE|Delete a Role|{role : {"name":string}}| |
||
32 | |/roles|POST|Create a new Role|{role : {"builtin":string, "name":string, "permissions":string}}| |
||
33 | |/roles|GET|Retrieve a list of Roles| |
||
34 | |/roles/false|PUT|Update an existing Role|{role : {"builtin":string, "name":string, "permissions":string}}| |
||
35 | 11 | Justin Sherrill | | | |
36 | 12 | Justin Sherrill | |/factvalues|POST|Create a new Fact value|{factvalue : {"fact_name_id":int, "host_id":int, "value":string}}| |
37 | |/factvalues|GET|Retrieve a list of Fact values| |
||
38 | 11 | Justin Sherrill | | | |
39 | 12 | Justin Sherrill | |/environments/false|DELETE|Delete a Environment|{environment : {"name":string}}| |
40 | |/environments|POST|Create a new Environment|{environment : {"name":string}}| |
||
41 | |/environments|GET|Retrieve a list of Environments| |
||
42 | |/environments/false|PUT|Update an existing Environment|{environment : {"name":string}}| |
||
43 | 11 | Justin Sherrill | | | |
44 | 12 | Justin Sherrill | |/operatingsystems/false|DELETE|Delete a Operatingsystem|{operatingsystem : {"name":string}}| |
45 | |/operatingsystems|POST|Create a new Operatingsystem|{operatingsystem : {"major":string, "minor":string, "name":string, "nameindicator":string, "release_name":string, "type":string}}| |
||
46 | |/operatingsystems|GET|Retrieve a list of Operatingsystems| |
||
47 | |/operatingsystems/false|PUT|Update an existing Operatingsystem|{operatingsystem : {"major":string, "minor":string, "name":string, "nameindicator":string, "release_name":string, "type":string}}| |
||
48 | 11 | Justin Sherrill | | | |
49 | 12 | Justin Sherrill | |/hostgroups/false|DELETE|Delete a Hostgroup|{hostgroup : {"name":string}}| |
50 | |/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}}| |
||
51 | |/hostgroups|GET|Retrieve a list of Hostgroups| |
||
52 | |/hostgroups/false|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}}| |
||
53 | 11 | Justin Sherrill | | | |
54 | 12 | Justin Sherrill | |/ptables/false|DELETE|Delete a Ptable|{ptable : {"name":string}}| |
55 | |/ptables|POST|Create a new Ptable|{ptable : {"layout":string, "name":string, "operatingsystem_id":int}}| |
||
56 | |/ptables|GET|Retrieve a list of Ptables| |
||
57 | |/ptables/false|PUT|Update an existing Ptable|{ptable : {"layout":string, "name":string, "operatingsystem_id":int}}| |
||
58 | 11 | Justin Sherrill | | | |
59 | 12 | Justin Sherrill | |/authsourceldaps/false|DELETE|Delete a Auth source ldap|{authsourceldap : {"name":string}}| |
60 | |/authsourceldaps|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}}| |
||
61 | |/authsourceldaps|GET|Retrieve a list of Auth source ldaps| |
||
62 | |/authsourceldaps/false|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}}| |
||
63 | 11 | Justin Sherrill | | | |
64 | 12 | Justin Sherrill | |/domains/false|DELETE|Delete a Domain|{domain : {"name":string}}| |
65 | |/domains|POST|Create a new Domain|{domain : {"dns_id":int, "fullname":string, "name":string}}| |
||
66 | |/domains|GET|Retrieve a list of Domains| |
||
67 | |/domains/false|PUT|Update an existing Domain|{domain : {"dns_id":int, "fullname":string, "name":string}}| |
||
68 | 11 | Justin Sherrill | | | |
69 | 12 | Justin Sherrill | |/puppetclasses/false|DELETE|Delete a Puppetclass|{puppetclass : {"name":string}}| |
70 | |/puppetclasses|POST|Create a new Puppetclass|{puppetclass : {"name":string, "nameindicator":string, "operatingsystem_id":int}}| |
||
71 | |/puppetclasses|GET|Retrieve a list of Puppetclasses| |
||
72 | |/puppetclasses/false|PUT|Update an existing Puppetclass|{puppetclass : {"name":string, "nameindicator":string, "operatingsystem_id":int}}| |
||
73 | 11 | Justin Sherrill | | | |
74 | 12 | Justin Sherrill | |/hypervisors/false|DELETE|Delete a Hypervisor|{hypervisor : {"name":string}}| |
75 | |/hypervisors|POST|Create a new Hypervisor|{hypervisor : {"kind":string, "name":string, "uri":string}}| |
||
76 | |/hypervisors|GET|Retrieve a list of Hypervisors| |
||
77 | |/hypervisors/false|PUT|Update an existing Hypervisor|{hypervisor : {"kind":string, "name":string, "uri":string}}| |
||
78 | 11 | Justin Sherrill | | | |
79 | 12 | Justin Sherrill | |/models/false|DELETE|Delete a Model|{model : {"name":string}}| |
80 | |/models|POST|Create a new Model|{model : {"info":string, "name":string}}| |
||
81 | |/models|GET|Retrieve a list of Models| |
||
82 | |/models/false|PUT|Update an existing Model|{model : {"info":string, "name":string}}| |
||
83 | 11 | Justin Sherrill | | | |
84 | 12 | Justin Sherrill | |/usergroups/false|DELETE|Delete a Usergroup|{usergroup : {"name":string}}| |
85 | |/usergroups|POST|Create a new Usergroup|{usergroup : {"name":string}}| |
||
86 | |/usergroups|GET|Retrieve a list of Usergroups| |
||
87 | |/usergroups/false|PUT|Update an existing Usergroup|{usergroup : {"name":string}}| |
||
88 | 11 | Justin Sherrill | | | |
89 | 12 | Justin Sherrill | |/reports/false|DELETE|Delete a Report|{report : {}}| |
90 | |/reports|POST|Create a new Report|{report : {"host_id":int, "metrics":string, "reported_at":string, "status":string}}| |
||
91 | |/reports|GET|Retrieve a list of Reports| |
||
92 | 11 | Justin Sherrill | | | |
93 | 12 | Justin Sherrill | |/configtemplates/false|DELETE|Delete a Config template|{configtemplate : {"name":string}}| |
94 | |/configtemplates|POST|Create a new Config template|{configtemplate : {"hostgroup_id":int, "name":string, "snippet":string, "template":string, "template_kind_id":int}}| |
||
95 | |/configtemplates|GET|Retrieve a list of Config templates| |
||
96 | |/configtemplates/false|PUT|Update an existing Config template|{configtemplate : {"hostgroup_id":int, "name":string, "snippet":string, "template":string, "template_kind_id":int}}| |
||
97 | 11 | Justin Sherrill | | | |
98 | 12 | Justin Sherrill | |/commonparameters/false|DELETE|Delete a Common parameter|{commonparameter : {"name":string}}| |
99 | |/commonparameters|POST|Create a new Common parameter|{commonparameter : {"name":string, "reference_id":int, "type":string, "value":string}}| |
||
100 | |/commonparameters|GET|Retrieve a list of Common parameters| |
||
101 | |/commonparameters/false|PUT|Update an existing Common parameter|{commonparameter : {"name":string, "reference_id":int, "type":string, "value":string}}| |
||
102 | 11 | Justin Sherrill | | | |
103 | 12 | Justin Sherrill | |/users/false|DELETE|Delete a User|{user : {}}| |
104 | |/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}}| |
||
105 | |/users|GET|Retrieve a list of Users| |
||
106 | |/users/false|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}}| |
||
107 | 11 | Justin Sherrill | | | |
108 | 12 | Justin Sherrill | |/architectures/false|DELETE|Delete a Architecture|{architecture : {"name":string}}| |
109 | |/architectures|POST|Create a new Architecture|{architecture : {"name":string}}| |
||
110 | |/architectures|GET|Retrieve a list of Architectures| |
||
111 | |/architectures/false|PUT|Update an existing Architecture|{architecture : {"name":string}}| |
||
112 | 11 | Justin Sherrill | | | |
113 | 12 | Justin Sherrill | |/media/false|DELETE|Delete a Medium|{medium : {"name":string}}| |
114 | |/media|POST|Create a new Medium|{medium : {"name":string, "path":string}}| |
||
115 | |/media|GET|Retrieve a list of Media| |
||
116 | |/media/false|PUT|Update an existing Medium|{medium : {"name":string, "path":string}}| |
||
117 | 11 | Justin Sherrill | | | |
118 | 12 | Justin Sherrill | |/hosts/false|DELETE|Delete a Host|{host : {"name":string}}| |
119 | |/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}}| |
||
120 | |/hosts|GET|Retrieve a list of Hosts| |
||
121 | |/hosts/false|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}}| |
||
122 | 11 | Justin Sherrill | | | |
123 | 12 | Justin Sherrill | |/subnets/false|DELETE|Delete a Subnet|{subnet : {"name":string}}| |
124 | |/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}}| |
||
125 | |/subnets|GET|Retrieve a list of Subnets| |
||
126 | |/subnets/false|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}}| |
||
127 | 11 | Justin Sherrill | | | |
128 | 12 | Justin Sherrill | |/smartproxies/false|DELETE|Delete a Smart proxy|{smartproxy : {"name":string}}| |
129 | |/smartproxies|POST|Create a new Smart proxy|{smartproxy : {"name":string, "url":string}}| |
||
130 | |/smartproxies|GET|Retrieve a list of Smart proxies| |
||
131 | |/smartproxies/false|PUT|Update an existing Smart proxy|{smartproxy : {"name":string, "url":string}}| |
||
132 | 1 | Ohad Levy | | | |
133 | 12 | Justin Sherrill | |/lookupkeys/false|DELETE|Delete a Lookup key|{lookupkey : {}}| |
134 | |/lookupkeys|POST|Create a new Lookup key|{lookupkey : {"key":string}}| |
||
135 | |/lookupkeys|GET|Retrieve a list of Lookup keys| |
||
136 | |/lookupkeys/false|PUT|Update an existing Lookup key|{lookupkey : {"key":string}}| |
||
137 | 1 | Ohad Levy | | | |
138 | |||
139 | |||
140 | |||
141 | |||
142 | 4 | Ohad Levy | |
143 | |||
144 | |||
145 | |||
146 | 1 | Ohad Levy | |
147 | 12 | Justin Sherrill | |
148 | |||
149 | 1 | Ohad Levy | |/dashboard|GET|Summary statistcs (total hosts, active hosts, hosts in error etc)| |
150 | |/fact_values|GET|List of known Facts (value, name and host)| |
||
151 | 6 | Ohad Levy | |/hosts/errors|GET|List of hosts in error state(only name)| |
152 | 1 | Ohad Levy | |/hosts/active|GET|List of active hosts(only name)| |
153 | |/hosts/out_of_sync|GET|List of out of sync hosts(only name)| |
||
154 | |/hosts/disabled|GET|List of disabled hosts(only name)| |
||
155 | |/hosts/fqdn/setBuild|GET| Enable Host for (re-)build | |
||
156 | 7 | Ohad Levy | |/hosts/fqdn/facts|GET| Returns host facts| |
157 | 1 | Ohad Levy | |/hosts/fqdn/pxe_config|GET| Returns syslinux configuration file for fqdn| |
158 | |/operatingsystems/1/bootfiles?media=<media_name>&architecture=x86_64|GET| tftp boot files and their respective urls (where they can be found)| |
||
159 | |/puppetclasses|GET|a hash of known Puppetclasses orginazined by module name (module => {:class1, :class2})| |
||
160 | 3 | Ohad Levy | |
161 | |||
162 | |||
163 | Please raise a new issue if you need additional API's |