Project

General

Profile

API » History » Revision 12

Revision 11 (Justin Sherrill, 02/21/2011 12:55 PM) → Revision 12/45 (Justin Sherrill, 02/21/2011 01:27 PM)

h1. API 

 *NOTE*: Version of 0.1-6 or git develop branch are required to use the API 

 Foreman provides a "REST":http://en.wikipedia.org/wiki/Representational_State_Transfer 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. 

 <pre> 
 http://foreman/environemnts?format=json 
 </pre> 

 Or using HTTP Headers 
 <pre> 
 curl -H "Content-Type:application/json" -H "Accept:application/json"    http://foreman/hosts 
 </pre> 

 Output is JSON formatted, in the last example expect a similar output: 

 <pre> 
 [{"host":{"name":"pm1.local.net"}},{"host":{"name":"pm2.local.net"}}....] 
 </pre> 

 h2. List of API's 

 |_.Path|_.REST Type|_.Description|_.Example Input Type|_.Example JSON|   
 |/roles/false|DELETE|Delete a Role|{role : {"name":string}}| 
 |/roles|POST|Create a new Role|{role : {"builtin":string, |/roles/ID|DELETE|{role:{"name":string}}| 
 |/roles|POST|{role:{"builtin":string, "name":string, "permissions":string}}| 
 |/roles|GET|Retrieve a list of Roles| |/roles|GET| 
 |/roles/false|PUT|Update an existing Role|{role : {"builtin":string, |/roles/ID|PUT|{role:{"builtin":string, "name":string, "permissions":string}}| 
 | | 
 |/factvalues|POST|Create a new Fact value|{factvalue : {"fact_name_id":int, |/factvalues|POST|{factvalue:{"fact_name_id":int, "host_id":int, "value":string}}| 
 |/factvalues|GET|Retrieve a list of Fact values| |/factvalues|GET| 
 | | 
 |/environments/false|DELETE|Delete a Environment|{environment : {"name":string}}| |/environments/ID|DELETE|{environment:{"name":string}}| 
 |/environments|POST|Create a new Environment|{environment : {"name":string}}| |/environments|POST|{environment:{"name":string}}| 
 |/environments|GET|Retrieve a list of Environments| |/environments|GET| 
 |/environments/false|PUT|Update an existing Environment|{environment : {"name":string}}| |/environments/ID|PUT|{environment:{"name":string}}| 
 | | 
 |/operatingsystems/false|DELETE|Delete a Operatingsystem|{operatingsystem : {"name":string}}| |/operatingsystems/ID|DELETE|{operatingsystem:{"name":string}}| 
 |/operatingsystems|POST|Create a new Operatingsystem|{operatingsystem : {"major":string, |/operatingsystems|POST|{operatingsystem:{"major":string, "minor":string, "name":string, "nameindicator":string, "release_name":string, "type":string}}| 
 |/operatingsystems|GET|Retrieve a list of Operatingsystems| |/operatingsystems|GET| 
 |/operatingsystems/false|PUT|Update an existing Operatingsystem|{operatingsystem : {"major":string, |/operatingsystems/ID|PUT|{operatingsystem:{"major":string, "minor":string, "name":string, "nameindicator":string, "release_name":string, "type":string}}| 
 | | 
 |/hostgroups/false|DELETE|Delete a Hostgroup|{hostgroup : {"name":string}}| |/hostgroups/ID|DELETE|{hostgroup:{"name":string}}| 
 |/hostgroups|POST|Create a new Hostgroup|{hostgroup : {"architecture_id":int, |/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}}| 
 |/hostgroups|GET|Retrieve a list of Hostgroups| |/hostgroups|GET| 
 |/hostgroups/false|PUT|Update an existing Hostgroup|{hostgroup : {"architecture_id":int, |/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}}| 
 | | 
 |/ptables/false|DELETE|Delete a Ptable|{ptable : {"name":string}}| |/ptables/ID|DELETE|{ptable:{"name":string}}| 
 |/ptables|POST|Create a new Ptable|{ptable : {"layout":string, |/ptables|POST|{ptable:{"layout":string, "name":string, "operatingsystem_id":int}}| 
 |/ptables|GET|Retrieve a list of Ptables| |/ptables|GET| 
 |/ptables/false|PUT|Update an existing Ptable|{ptable : {"layout":string, |/ptables/ID|PUT|{ptable:{"layout":string, "name":string, "operatingsystem_id":int}}| 
 | | 
 |/authsourceldaps/false|DELETE|Delete a Auth source ldap|{authsourceldap : {"name":string}}| |/authsourceldaps/ID|DELETE|{authsourceldap:{"name":string}}| 
 |/authsourceldaps|POST|Create a new Auth source ldap|{authsourceldap : {"account":string, |/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}}| 
 |/authsourceldaps|GET|Retrieve a list of Auth source ldaps| |/authsourceldaps|GET| 
 |/authsourceldaps/false|PUT|Update an existing Auth source ldap|{authsourceldap : {"account":string, |/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}}| 
 | | 
 |/domains/false|DELETE|Delete a Domain|{domain : {"name":string}}| |/domains/ID|DELETE|{domain:{"name":string}}| 
 |/domains|POST|Create a new Domain|{domain : {"dns_id":int, |/domains|POST|{domain:{"dns_id":int, "fullname":string, "name":string}}| 
 |/domains|GET|Retrieve a list of Domains| |/domains|GET| 
 |/domains/false|PUT|Update an existing Domain|{domain : {"dns_id":int, |/domains/ID|PUT|{domain:{"dns_id":int, "fullname":string, "name":string}}| 
 | | 
 |/puppetclasses/false|DELETE|Delete a Puppetclass|{puppetclass : {"name":string}}| |/puppetclasses/ID|DELETE|{puppetclass:{"name":string}}| 
 |/puppetclasses|POST|Create a new Puppetclass|{puppetclass : {"name":string, |/puppetclasses|POST|{puppetclass:{"name":string, "nameindicator":string, "operatingsystem_id":int}}| 
 |/puppetclasses|GET|Retrieve a list of Puppetclasses| |/puppetclasses|GET| 
 |/puppetclasses/false|PUT|Update an existing Puppetclass|{puppetclass : {"name":string, |/puppetclasses/ID|PUT|{puppetclass:{"name":string, "nameindicator":string, "operatingsystem_id":int}}| 
 | | 
 |/hypervisors/false|DELETE|Delete a Hypervisor|{hypervisor : {"name":string}}| |/hypervisors/ID|DELETE|{hypervisor:{"name":string}}| 
 |/hypervisors|POST|Create a new Hypervisor|{hypervisor : {"kind":string, |/hypervisors|POST|{hypervisor:{"kind":string, "name":string, "uri":string}}| 
 |/hypervisors|GET|Retrieve a list of Hypervisors| |/hypervisors|GET| 
 |/hypervisors/false|PUT|Update an existing Hypervisor|{hypervisor : {"kind":string, |/hypervisors/ID|PUT|{hypervisor:{"kind":string, "name":string, "uri":string}}| 
 | | 
 |/models/false|DELETE|Delete a Model|{model : {"name":string}}| |/models/ID|DELETE|{model:{"name":string}}| 
 |/models|POST|Create a new Model|{model : {"info":string, |/models|POST|{model:{"info":string, "name":string}}| 
 |/models|GET|Retrieve a list of Models| |/models|GET| 
 |/models/false|PUT|Update an existing Model|{model : {"info":string, |/models/ID|PUT|{model:{"info":string, "name":string}}| 
 | | 
 |/usergroups/false|DELETE|Delete a Usergroup|{usergroup : {"name":string}}| |/usergroups/ID|DELETE|{usergroup:{"name":string}}| 
 |/usergroups|POST|Create a new Usergroup|{usergroup : {"name":string}}| |/usergroups|POST|{usergroup:{"name":string}}| 
 |/usergroups|GET|Retrieve a list of Usergroups| |/usergroups|GET| 
 |/usergroups/false|PUT|Update an existing Usergroup|{usergroup : {"name":string}}| |/usergroups/ID|PUT|{usergroup:{"name":string}}| 
 | | 
 |/reports/false|DELETE|Delete a Report|{report : {}}| |/reports/ID|DELETE|{report:{}}| 
 |/reports|POST|Create a new Report|{report : {"host_id":int, |/reports|POST|{report:{"host_id":int, "metrics":string, "reported_at":string, "status":string}}| 
 |/reports|GET|Retrieve a list of Reports| |/reports|GET| 
 | | 
 |/configtemplates/false|DELETE|Delete a Config template|{configtemplate : {"name":string}}| |/configtemplates/ID|DELETE|{configtemplate:{"name":string}}| 
 |/configtemplates|POST|Create a new Config template|{configtemplate : {"hostgroup_id":int, |/configtemplates|POST|{configtemplate:{"hostgroup_id":int, "name":string, "snippet":string, "template":string, "template_kind_id":int}}| 
 |/configtemplates|GET|Retrieve a list of Config templates| |/configtemplates|GET| 
 |/configtemplates/false|PUT|Update an existing Config template|{configtemplate : {"hostgroup_id":int, |/configtemplates/ID|PUT|{configtemplate:{"hostgroup_id":int, "name":string, "snippet":string, "template":string, "template_kind_id":int}}| 
 | | 
 |/commonparameters/false|DELETE|Delete a Common parameter|{commonparameter : {"name":string}}| |/commonparameters/ID|DELETE|{commonparameter:{"name":string}}| 
 |/commonparameters|POST|Create a new Common parameter|{commonparameter : {"name":string, |/commonparameters|POST|{commonparameter:{"name":string, "reference_id":int, "type":string, "value":string}}| 
 |/commonparameters|GET|Retrieve a list of Common parameters| |/commonparameters|GET| 
 |/commonparameters/false|PUT|Update an existing Common parameter|{commonparameter : {"name":string, |/commonparameters/ID|PUT|{commonparameter:{"name":string, "reference_id":int, "type":string, "value":string}}| 
 | | 
 |/users/false|DELETE|Delete a User|{user : {}}| |/users/ID|DELETE|{user:{}}| 
 |/users|POST|Create a new User|{user : {"admin":string, |/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}}| 
 |/users|GET|Retrieve a list of Users| |/users|GET| 
 |/users/false|PUT|Update an existing User|{user : {"admin":string, |/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}}| 
 | | 
 |/architectures/false|DELETE|Delete a Architecture|{architecture : {"name":string}}| |/architectures/ID|DELETE|{architecture:{"name":string}}| 
 |/architectures|POST|Create a new Architecture|{architecture : {"name":string}}| |/architectures|POST|{architecture:{"name":string}}| 
 |/architectures|GET|Retrieve a list of Architectures| |/architectures|GET| 
 |/architectures/false|PUT|Update an existing Architecture|{architecture : {"name":string}}| |/architectures/ID|PUT|{architecture:{"name":string}}| 
 | | 
 |/media/false|DELETE|Delete a Medium|{medium : {"name":string}}| |/media/ID|DELETE|{medium:{"name":string}}| 
 |/media|POST|Create a new Medium|{medium : {"name":string, |/media|POST|{medium:{"name":string, "path":string}}| 
 |/media|GET|Retrieve a list of Media| |/media|GET| 
 |/media/false|PUT|Update an existing Medium|{medium : {"name":string, |/media/ID|PUT|{medium:{"name":string, "path":string}}| 
 | | 
 |/hosts/false|DELETE|Delete a Host|{host : {"name":string}}| |/hosts/fqdn|DELETE|{host:{"name":string}}| 
 |/hosts|POST|Create a new Host|{host : {"architecture_id":int, |/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}}| 
 |/hosts|GET|Retrieve a list of Hosts| |/hosts|GET| 
 |/hosts/false|PUT|Update an existing Host|{host : {"architecture_id":int, |/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}}| 
 | | 
 |/subnets/false|DELETE|Delete a Subnet|{subnet : {"name":string}}| |/subnets/ID|DELETE|{subnet:{"name":string}}| 
 |/subnets|POST|Create a new Subnet|{subnet : {"dhcp_id":int, |/subnets|POST|{subnet:{"dhcp_id":int, "domain_id":int, "mask":string, "name":string, "network":string, "priority":string, "ranges":string, "tftp_id":int, "vlanid":int}}| 
 |/subnets|GET|Retrieve a list of Subnets| |/subnets|GET| 
 |/subnets/false|PUT|Update an existing Subnet|{subnet : {"dhcp_id":int, |/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}}| 
 | | 
 |/smartproxies/false|DELETE|Delete a Smart proxy|{smartproxy : {"name":string}}| |/smartproxies/ID|DELETE|{smartproxy:{"name":string}}| 
 |/smartproxies|POST|Create a new Smart proxy|{smartproxy : {"name":string, |/smartproxies|POST|{smartproxy:{"name":string, "url":string}}| 
 |/smartproxies|GET|Retrieve a list of Smart proxies| |/smartproxies|GET| 
 |/smartproxies/false|PUT|Update an existing Smart proxy|{smartproxy : {"name":string, |/smartproxies/ID|PUT|{smartproxy:{"name":string, "url":string}}| 
 | | 
 |/lookupkeys/false|DELETE|Delete a Lookup key|{lookupkey : {}}| |/lookupkeys/ID|DELETE|{lookupkey:{}}| 
 |/lookupkeys|POST|Create a new Lookup key|{lookupkey : {"key":string}}| |/lookupkeys|POST|{lookupkey:{"key":string}}| 
 |/lookupkeys|GET|Retrieve a list of Lookup keys| |/lookupkeys|GET| 
 |/lookupkeys/false|PUT|Update an existing Lookup key|{lookupkey : {"key":string}}| |/lookupkeys/ID|PUT|{lookupkey:{"key":string}}| 
 | | 











 









 |/architectures|GET|List of valid OS Architectures(name and ID)| 
 |/architectures/x86_64|GET|Description of the x86_64 Architecture (name and ID)| 
 |/dashboard|GET|Summary statistcs (total hosts, active hosts, hosts in error etc)| 
 |/domains|GET|List of known domains (name and ID)| 
 |/domains/my_domain|GET|Description of "my_domain" (name and ID)| 
 |/environments|GET|List of known environments (name and ID)| 
 |/environments/production|GET|Description of the "production" (name and ID and associated host list)| 
 |/fact_values|GET|List of known Facts (value, name and host)| 
 |/hostgroups|GET|List of known hostgroups (name and ID)| 
 |/hostgroups/common|GET|Description of "common" (name and ID)| 
 |/hosts|GET|List of known hosts (only name)| 
 |/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|POST|creates a new host, 201 return sucesful creation, otherwise the errors will be returned| 
 |/hosts/fqdn|GET|Host Attributes (name, usergroup, last_report, os properties...)| 
 |/hosts/fqdn|DELETE|Removes the host "fqdn"| 
 |/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| 
 |/medias|GET|List of known mediums (name and ID)| 
 |/medias/1|GET|Description of media which ID is 1 (name and ID and path/url)| 
 |/operatingsystems|GET|List of known operating systems (Release name, ID and allowed mediums, architectures and partition tables)| 
 |/operatingsystems/1|GET| Description of operating systems which its ID is 1 (Release name, ID and allowed mediums, architectures and partition tables)| 
 |/operatingsystems/1/bootfiles?media=<media_name>&architecture=x86_64|GET| tftp boot files and their respective urls (where they can be found)| 
 |/ptables|GET|List of known Partition tables (name and ID)| 
 |/ptables/1|GET|Description of Partition table which its ID is 1 (name and ID)| 
 |/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