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