Actions
API » History » Revision 14
« Previous |
Revision 14/45
(diff)
| Next »
Justin Sherrill, 02/21/2011 01:40 PM
API¶
NOTE: Version of 0.1-6 or git develop branch are required to use the API
Foreman provides a REST API, communicating via JSON.
Please refer to this document for latest information about Foreman API.
Examples below are either via curl or ruby rest_client
most pages can be browsed via adding the format option to the url (at least for get requests), i.e.
http://foreman/environemnts?format=json
Or using HTTP Headers
curl -H "Content-Type:application/json" -H "Accept:application/json" http://foreman/hosts
Output is JSON formatted, in the last example expect a similar output:
[{"host":{"name":"pm1.local.net"}},{"host":{"name":"pm2.local.net"}}....]
List of API's¶
Path | REST Type | Description | Example Input JSON |
---|---|---|---|
Architectures | |||
/architectures | POST | Create a new Architecture | {architecture : {"name":string}} |
/architectures/false | DELETE | Delete a Architecture | {architecture : {"name":string}} |
/architectures | GET | Retrieve a list of Architectures | |
/architectures/false | PUT | Update an existing Architecture | {architecture : {"name":string}} |
Authsourceldaps | |||
/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}} |
/authsourceldaps/false | DELETE | Delete a Auth source ldap | {authsourceldap : {"name":string}} |
/authsourceldaps | GET | Retrieve a list of Auth source ldaps | |
/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}} |
Commonparameters | |||
/commonparameters | POST | Create a new Common parameter | {commonparameter : {"name":string, "reference_id":int, "type":string, "value":string}} |
/commonparameters/false | DELETE | Delete a Common parameter | {commonparameter : {"name":string}} |
/commonparameters | GET | Retrieve a list of Common parameters | |
/commonparameters/false | PUT | Update an existing Common parameter | {commonparameter : {"name":string, "reference_id":int, "type":string, "value":string}} |
Configtemplates | |||
/configtemplates | POST | Create a new Config template | {configtemplate : {"hostgroup_id":int, "name":string, "snippet":string, "template":string, "template_kind_id":int}} |
/configtemplates/false | DELETE | Delete a Config template | {configtemplate : {"name":string}} |
/configtemplates | GET | Retrieve a list of Config templates | |
/configtemplates/false | PUT | Update an existing Config template | {configtemplate : {"hostgroup_id":int, "name":string, "snippet":string, "template":string, "template_kind_id":int}} |
Domains | |||
/domains | POST | Create a new Domain | {domain : {"dns_id":int, "fullname":string, "name":string}} |
/domains/false | DELETE | Delete a Domain | {domain : {"name":string}} |
/domains | GET | Retrieve a list of Domains | |
/domains/false | PUT | Update an existing Domain | {domain : {"dns_id":int, "fullname":string, "name":string}} |
Environments | |||
/environments | POST | Create a new Environment | {environment : {"name":string}} |
/environments/false | DELETE | Delete a Environment | {environment : {"name":string}} |
/environments | GET | Retrieve a list of Environments | |
/environments/false | PUT | Update an existing Environment | {environment : {"name":string}} |
Factvalues | |||
/factvalues | POST | Create a new Fact value | {factvalue : {"fact_name_id":int, "host_id":int, "value":string}} |
/factvalues | GET | Retrieve a list of Fact values | |
Hostgroups | |||
/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}} |
/hostgroups/false | DELETE | Delete a Hostgroup | {hostgroup : {"name":string}} |
/hostgroups | GET | Retrieve a list of Hostgroups | |
/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}} |
Hosts | |||
/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}} |
/hosts/false | DELETE | Delete a Host | {host : {"name":string}} |
/hosts | GET | Retrieve a list of Hosts | |
/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}} |
Hypervisors | |||
/hypervisors | POST | Create a new Hypervisor | {hypervisor : {"kind":string, "name":string, "uri":string}} |
/hypervisors/false | DELETE | Delete a Hypervisor | {hypervisor : {"name":string}} |
/hypervisors | GET | Retrieve a list of Hypervisors | |
/hypervisors/false | PUT | Update an existing Hypervisor | {hypervisor : {"kind":string, "name":string, "uri":string}} |
Lookupkeys | |||
/lookupkeys | POST | Create a new Lookup key | {lookupkey : {"key":string}} |
/lookupkeys/false | DELETE | Delete a Lookup key | {lookupkey : {}} |
/lookupkeys | GET | Retrieve a list of Lookup keys | |
/lookupkeys/false | PUT | Update an existing Lookup key | {lookupkey : {"key":string}} |
Media | |||
/media | POST | Create a new Medium | {medium : {"name":string, "path":string}} |
/media/false | DELETE | Delete a Medium | {medium : {"name":string}} |
/media | GET | Retrieve a list of Media | |
/media/false | PUT | Update an existing Medium | {medium : {"name":string, "path":string}} |
Models | |||
/models | POST | Create a new Model | {model : {"info":string, "name":string}} |
/models/false | DELETE | Delete a Model | {model : {"name":string}} |
/models | GET | Retrieve a list of Models | |
/models/false | PUT | Update an existing Model | {model : {"info":string, "name":string}} |
Operatingsystems | |||
/operatingsystems | POST | Create a new Operatingsystem | {operatingsystem : {"major":string, "minor":string, "name":string, "nameindicator":string, "release_name":string, "type":string}} |
/operatingsystems/false | DELETE | Delete a Operatingsystem | {operatingsystem : {"name":string}} |
/operatingsystems | GET | Retrieve a list of Operatingsystems | |
/operatingsystems/false | PUT | Update an existing Operatingsystem | {operatingsystem : {"major":string, "minor":string, "name":string, "nameindicator":string, "release_name":string, "type":string}} |
Ptables | |||
/ptables | POST | Create a new Ptable | {ptable : {"layout":string, "name":string, "operatingsystem_id":int}} |
/ptables/false | DELETE | Delete a Ptable | {ptable : {"name":string}} |
/ptables | GET | Retrieve a list of Ptables | |
/ptables/false | PUT | Update an existing Ptable | {ptable : {"layout":string, "name":string, "operatingsystem_id":int}} |
Puppetclasses | |||
/puppetclasses | POST | Create a new Puppetclass | {puppetclass : {"name":string, "nameindicator":string, "operatingsystem_id":int}} |
/puppetclasses/false | DELETE | Delete a Puppetclass | {puppetclass : {"name":string}} |
/puppetclasses | GET | Retrieve a list of Puppetclasses | |
/puppetclasses/false | PUT | Update an existing Puppetclass | {puppetclass : {"name":string, "nameindicator":string, "operatingsystem_id":int}} |
Reports | |||
/reports | POST | Create a new Report | {report : {"host_id":int, "metrics":string, "reported_at":string, "status":string}} |
/reports/false | DELETE | Delete a Report | {report : {}} |
/reports | GET | Retrieve a list of Reports | |
Roles | |||
/roles | POST | Create a new Role | {role : {"builtin":string, "name":string, "permissions":string}} |
/roles/false | DELETE | Delete a Role | {role : {"name":string}} |
/roles | GET | Retrieve a list of Roles | |
/roles/false | PUT | Update an existing Role | {role : {"builtin":string, "name":string, "permissions":string}} |
Smartproxies | |||
/smartproxies | POST | Create a new Smart proxy | {smartproxy : {"name":string, "url":string}} |
/smartproxies/false | DELETE | Delete a Smart proxy | {smartproxy : {"name":string}} |
/smartproxies | GET | Retrieve a list of Smart proxies | |
/smartproxies/false | PUT | Update an existing Smart proxy | {smartproxy : {"name":string, "url":string}} |
Subnets | |||
/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}} |
/subnets/false | DELETE | Delete a Subnet | {subnet : {"name":string}} |
/subnets | GET | Retrieve a list of Subnets | |
/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}} |
Usergroups | |||
/usergroups | POST | Create a new Usergroup | {usergroup : {"name":string}} |
/usergroups/false | DELETE | Delete a Usergroup | {usergroup : {"name":string}} |
/usergroups | GET | Retrieve a list of Usergroups | |
/usergroups/false | PUT | Update an existing Usergroup | {usergroup : {"name":string}} |
Users | |||
/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}} |
/users/false | DELETE | Delete a User | {user : {}} |
/users | GET | Retrieve a list of Users | |
/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}} |
/dashboard | GET | Summary statistcs (total hosts, active hosts, hosts in error etc) |
/fact_values | GET | List of known Facts (value, name and host) |
/hosts/errors | GET | List of hosts in error state(only name) |
/hosts/active | GET | List of active hosts(only name) |
/hosts/out_of_sync | GET | List of out of sync hosts(only name) |
/hosts/disabled | GET | List of disabled hosts(only name) |
/hosts/fqdn/setBuild | GET | Enable Host for (re-)build |
/hosts/fqdn/facts | GET | Returns host facts |
/hosts/fqdn/pxe_config | GET | Returns syslinux configuration file for fqdn |
/operatingsystems/1/bootfiles?media=<media_name>&architecture=x86_64 | GET | tftp boot files and their respective urls (where they can be found) |
/puppetclasses | GET | a hash of known Puppetclasses orginazined by module name (module => {:class1, :class2}) |
Please raise a new issue if you need additional API's
Updated by Justin Sherrill almost 14 years ago · 45 revisions