Project

General

Profile

API » History » Version 7

Ohad Levy, 05/09/2011 02:45 AM

1 1 Ohad Levy
h1. API
2
3
Foreman Smart Proxy provides a "REST":http://en.wikipedia.org/wiki/Representational_State_Transfer API, communicating via JSON.
4
5
Please refer to this document for latest information about Foreman Smart Proxy API.
6
7
h2. List of API's
8
9
|_.Path|_.REST Type|_.Description|_.Example Input JSON|  
10
|_.FEATURES |
11
|/features|GET|List of features supported by the proxy||
12
|_.DHCP |
13
|/dhcp|GET|Retrieve a list of subnets||
14
|/dhcp/10.1.2.0|GET|Retrieve 10.1.2.0 subnets records||
15
|/dhcp/10.1.2.0/10.1.2.5|GET|Retrieve 10.1.2.5 reservation information ||
16
|/dhcp/10.1.2.0/unused_ip|GET|Provides an unused ip address in 10.1.2.0 subnet ||
17 5 Frank Sweetser
|/dhcp/10.1.2.0|POST|creates new reservation in 10.1.2.0 subnet |@{"hostname":string, "name":string, "filename":string, "ip":string, "nextserver":string, "mac":string}@|
18 1 Ohad Levy
|/dhcp/10.1.2.0/10.1.2.5|DELETE|Deletes 10.1.2.5 reservation from 10.1.2.0 subnet||
19
|_.DNS |
20 5 Frank Sweetser
|/dns|POST|Create a new DNS record|@{"fqdn":string(name/ip), "value":string(ip/reverse), "type":string(A/PTR)}@|
21 1 Ohad Levy
|/dns/value|DELETE|remove value(ip or reverse) DNS record||
22
|_.TFTP |
23 5 Frank Sweetser
|/tftp/00:11:22:33:44:55|POST|creates pxelinux configuration file for host with MAC address 00:11:22:33:44:55|@{"syslinux_config":string}@|
24
|/tftp/00:11:22:33:44:55|DELETE|remove pxelinux configuration file for host with MAC address 00:11:22:33:44:55||
25
|/tftp/create_default|POST|creates a default pxelinux configuration file|@{"syslinux_config":string}@|
26
|/tftp/fetch_boot_file|POST|creates a default pxelinux configuration file|@{"prefix":string, "path":string}@|
27 1 Ohad Levy
|_.PUPPET CA |
28
|/puppet/ca|GET| list of all puppet certificates ||
29 7 Ohad Levy
|/puppet/ca/certname|POST| Sign pending certificate request ||
30
|/puppet/ca/certname|DELETE| Remove (clean) and revoke a certificate ||
31 1 Ohad Levy
|/puppet/ca/autosign|GET| list of all puppet autosign entires ||
32
|/puppet/ca/autosign/certname|POST| Add certname to Puppet autosign ||
33
|/puppet/ca/autosign/certname|DELETE| Remove certname from Puppet autosign ||
34
|_.PUPPET |
35 5 Frank Sweetser
|/puppet/run|POST| Trigger puppet run / kick|@["hostA", "hostB"]@|
36 1 Ohad Levy
37
Please raise a new issue if you need additional API's
38 4 Frank Sweetser
39
h2. Manually Calling the API
40
41
The API can be manually tested out using curl.  GET types can be retrieved like any other URL.  This one, for example, will return the HTML formatted page with the list of features enabled on the proxy.
42
43 1 Ohad Levy
<pre>
44
curl http://localhost:8443/features
45
</pre>
46
47
POST URLs, used to create objects or trigger actions, need to have the parameters passed in via the -d argument.  This curl command line will trigger a puppetrun on server.example.com.
48
<pre>
49
curl -d 'nodes=server.example.com' http://localhost:8443/puppet/run
50 5 Frank Sweetser
</pre>
51
52
Multiple post options may be specified by repeating the -d argument.
53
<pre>
54
curl -d 'prefix=boot/CentOS-5-x86_64' -d 'path=http://yourlocalmirrorhere/pub/centos/5/os/x86_64/images/pxeboot/vmlinuz'  http://localhost:8443/tftp/fetch_boot_file
55
</pre>
56
57
When you are creating an object, the identifier for the object is typically passed in as part of the URL, rather than as a POST value.  For example, this will create a PXE boot configuration file for a host with MAC address 00:11:22:33:44:55, and will just put "Hello World" as the contents of the file.  (A real world example would, of course, substitute a valid PXE boot configuration in the string.)
58
59
<pre>
60
curl -d 'syslinux_config=Hello World' http://localhost:8443/tftp/00:11:22:33:44:55
61
</pre>
62
63
In order to delete objects, you use the same URL as in the original creation, but pass it not POST values, and use the DELETE HTTP method instead of POST.  This will delete the PXE boot configuration file created above.
64
65
<pre>
66
curl -X DELETE http://localhost:8443/tftp/00:11:22:33:44:55
67 4 Frank Sweetser
</pre>
68 6 Brian Gupta
69
[[Draft 2.0 version of DNS API]]