Skip to content

API Reference

cohoe edited this page May 20, 2011 · 7 revisions

Table of Contents

Implementation Guide

Function Calls

To call an API function, you simply have to issue a SQL SELECT query on that function. Example:

SELECT api.get_current_user();

The query result will be the return value (if any) of that function. If an error occurs, the API throws an exception and aborts the query returning the error. It is up to the client to display that error.

Null Values

Some functions allow NULL to be passed in. This usually will set the value to the site default value. An example of this is the function api.create_dns_address() The TTL input can take an integer or NULL, which will default to the site default value (300). You can specify this by executing the query:

SELECT api.create_dns_address('192.168.0.1','localhost','localdomain',NULL,'username');

Note that the word NULL is not surrounded with double or single quotes. Passing in something like '' technically passes an empty string, which is not the same as not null. Note that you cant do this with an integer anyway, but this also applies to comments (which can be NULL).

Create Resources

Create new system

A system object corresponds to a physical computer.

api.create_system([system_name],[owner_username OR NULL],[system_type],[os_name],[comment OR NULL])

Create new subnet

A site is comprised of one or many subnets. These are the IP addresses that you have control over.

api.create_subnet([subnet],[name],[autogenerate],[comment OR NULL])

Create new IP range

Ranges of addresses can be configured for logical management of address resources.

api.create_ip_range([first_ip],[last_ip],[subnet],[use],[comment OR NULL])

Create new DHCP Class

DHCP classes can have special options sent to the client (pxeboot, etc)

api.create_dhcp_class([class],[comment OR NULL])

Create DHCP class option

Specify an option for a DHCP class

api.create_dhcp_class_option([class],[option],[value])

Create DHCP subnet option

Subnets can have different options (usually for routers, dns servers, etc)

api.create_dhcp_subnet_option([subnet],[option],[value])

Create DNS Key

To execute an update on a zone, a key is used to authenticate with the server

api.create_dns_key([keyname],[key],[comment OR NULL],[last_modifier])

Create DNS zone

DNS zones (domains) are the names under your control.

api.create_dns_zone([zone],[keyname],[forward],[comment OR NULL],[last_modifier])

Create New Interface

Interfaces correspond to a NIC in the computer system. They are identified with the MAC address.

api.create_interface([system_name],[interface_name],[mac_address],[comment OR NULL])

Create Interface Address (manually)

Specify the address that you want for an interface

api.create_interface_address_manual([interface_mac_address],[ip_address],[configuration],[class],[comment OR NULL])

Create Interface Address (automatically)

Only specify the range that you fall under, rather than the exact address

api.create_interface_address_manual([interface_mac_address],[range_name],[configuration],[class],[comment OR NULL])

Create DNS Address Record

An address can have zero or one address record. This is also used for reverse dns on that address. It is highly recommended to always do this. The client is responsible for yelling at the user to make one.

api.create_dns_address([ip_address],[hostname],[domain (zone)],[TTL OR NULL],[owner OR NULL])

Delete Resources

Delete system

api.delete_system([system_name])

Delete subnet

api.delete_subnet([subnet])

Delete IP range

api.delete_ip_range([first_ip],[last_ip])

Delete DHCP class

api.delete_dhcp_class([class])

Delete DHCP class option

api.delete_dhcp_class_option([class],[option],[value])

Delete DHCP subnet option

api.delete_dhcp_subnet_option([subnet],[option],[value])

Delete DNS Key

api.delete_dns_key([keyname])

Delete DNS zone

api.delete_dns_zone([zone])

Delete Interface

api.delete_interface([mac_address])

Delete Interface Address

api.delete_interface_address([ip_address])

Delete DNS Address Record

api.delete_dns_address([ip_address])

General Functions

Create Log Entry

If you need to place a message in the log, this is how you do it

api.create_log_entry([source], [INFO|DEBUG|ERROR], [message])

Get Current User

The database creates a temporary table when you call the api.initialize() function. This is it's way of seeing who it thinks you are.

api.get_current_user()

Validate Domain

Check if a given hostname, domain, or FQDN is RFC compliant, and thus valid for use. The database will handle this, but the client can have an option to verify a name if the user is not sure.

api.validate_domain([hostname OR NULL],[domain OR NULL])

Renew System

Systems expire after a year, and will automatically delete themselves if the user does not renew them. This will help keep everything cleaned up.

api.renew_system([system_name])

Get Address from Range

Given the name of a range, get the first available IP address to assign to a potential interface.

api.get_address_from_range([range_name])

Clone this wiki locally