Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Format tweak

 

 

 

Table of Contents
 

DHCPv2 Module

The DHCPv2 system is built upon the Resource API, so actions relating to DHCP tasks are largely expressed in terms of Resource actions.  

...

get all DHCP-enabled resources

DescriptionFinds all resources from section 'dhcp_module,' which indicates that their parents are DHCP-enabled. Adding in other Resource-Get API parameters can filter this list further.
URL/api/v1/api.php?target=resource&action=get&type=dhcp_module
Returns

Examples:

SUCCESSFUL:{"success":1,"message":"Search successful","data":[{"id":"1432", "name":"1392 DHCP Module" ,"slug":"1392-dhcp-module", "type":"dhcp_module", "parent_id":"1392", "category_id":null, "attr":{"_dhcp_attributes":"{\"type\":\"ISC\", \"notes\":\"\", \"username\":\"\", \"port\":\"\", \"config_test\":\"\/etc\/init.d\/dhcpd configtest\", \"server_stop\":\"\/etc\/init.d\/dhcpd stop\", \"server_start\":\"\/etc\/init.d\/dhcpd start\", \"config_path\":\"\", \"option_routers\":\"\", \"option_domain_name_servers\":\"\", \"option_domain_name\":\"\", \"authoritative\":\"1\", \"default_lease_time\":\"600\", \"max_lease_time\":\"7200\", \"local_port\":\"67\", \"log_facility\":\"local7\", \"password\":\"\", \"server_ip\":\"10.0.0.0\", \"freeLines\":0}", "_dhcp_config_id":"33"}}], "result_count":1, "found_count":1}
ERROR:{"success":0, "message":"error message"}

Return Detail:

NameTypeDescription
idINTEGERID of the dhcp_module resource
nameSTRINGThe name of the dhcp_module
slugSTRINGThe unique reference string for this resource
typeSTRINGAlways 'dhcp_module
parent_idINTEGERThe resource to which the dhcp_module is attached
category_idINTEGERThe category to which this dhcp_module is associated
result_countINTEGERHow many dhcp_modules are returned in this search.
found_countINTEGERHow many dhcp_modules were found in this query, without pagination.

Attributes:

KeyTypeDescription
_dhcp_attributesJSONA JSON-encoded string containing all the specific configuration parameters which govern this DHCP server. An expansion of the JSON object is given below in the Data Attributes section.
_dhcp_config_idINTEGERA reference to the DHCP Config file written within the system. This field is maintained by the DHCPv2 system itself and should not be set externally.

 

 

create a new DHCP-enabled resource

DescriptionA resource becomes a DHCP-enabled by adding a special "dhcp_module" resource as a child. This action is identical to a normal Resource Create command.
URL/api/v1/api.php?target=resource&action=add&meta[type]=dhcp_module&meta[name]=2163 DHCP Module&meta[parent_id]=2163
Returns

Examples:

SUCCESSFUL:{"success":1,"message":"Resource added","data":{"id": 2165,"name" :"2163 DHCP Module","slug": "2163-dhcp-module-2","type" :"dhcp_module","parent_id": 2163,"category_id": null,"attr":[]}}
ERROR:{"success":0, "message":"error message"}

Return Detail:

NameTypeDescription
idINTEGERID of the newly created dhcp_module
nameSTRINGThe name of the dhcp_module
slugSTRINGThe unique reference string for this resource
typeSTRINGAlways 'dhcp_module'
parent_idINTEGERThe resource to which the dhcp_module is attached
category_idINTEGERThe category to which this dhcp_module is associated

 

 

update a DHCP-enabled resource with new configuration info

DescriptionModifying an existing dhcp_module uses the identical commands as all other Resource-Update actions. An example of configuring a DHCP server is given below.
URL/api/v1/api.php?target=resource&action=update&meta[id]=2178 &meta[type]=dhcp_module&fields[_dhcp_attributes][]={"type":"ISC","notes":"notes go here","username":"username","port":"port","config_test":"/etc/init.d/dhcpd configtest","server_stop":"/etc/init.d/dhcpd stop","server_start":"/etc/init.d/dhcpd start","config_path":"/tmp/dhcpd.conf","option_routers":"192.168.0.0","option_domain_name_servers":"ns1.6connect.com","option_domain_name":"6connect.com","authoritative":"1","default_lease_time":"600","max_lease_time":"7200","local_port":"67","log_facility":"local7","password":"password","server_ip":"192.168.0.1","freeLines":3,"freeLine1":"free line 1","freeLine2":"free line 2","freeLine3":"free line 3"}
Returns

Examples:

SUCCESSFUL:{"success": 1,"message": "Resource Updated","data": {"id":"2166" ,"name":"2163 DHCP Module", "slug":"2163-dhcp-module-3" ,"type":"dhcp_module", "parent_id":"2163", "category_id":null ,"attr":{"_dhcp_attributes": "{\"type\":\"ISC\", \"notes\":\"notes go here\", \"username\":\"username\", \"port\":\"port\", \"config_test\":\"\\\/etc\\\/init.d\\\/dhcpd configtest\" ,\"server_stop\":\"\\\/etc\\\/init.d\\\/dhcpd stop\" ,\"server_start\":\"\\\/etc\\\/init.d\\\/dhcpd start\",\"config_path\":\"\\\/tmp\\\/dhcpd.conf\", \"option_routers\":\"192.168.0.0\", \"option_domain_name_servers\":\"ns1.6connect.com\", \"option_domain_name\":\"6connect.com\", \"authoritative\":\"1\", \"default_lease_time\":\"600\", \"max_lease_time\":\"7200\", \"local_port\":\"67\", \"log_facility\":\"local7\" ,\"password\":\"**********\", \"server_ip\":\"192.168.0.1\", \"freeLines\":3, \"freeLine1\":\"free line 1\", \"freeLine2\":\"free line 2\", \"freeLine3\":\"free line 3\"}"}}}
ERROR:{"success":0, "message":"error message"}

Return Detail:

NameTypeDescription
idINTEGERID of the newly created dhcp_module
nameSTRINGThe name of the dhcp_module
slugSTRINGThe unique reference string for this resource
typeSTRINGAlways 'dhcp_module'
parent_idINTEGERThe resource to which the dhcp_module is attached
category_idINTEGERThe category to which this dhcp_module is associated

Attributes:

KeyTypeDescription
_dhcp_attributesJSONA JSON-encoded string containing all the specific configuration parameters which govern this DHCP server. An expansion of the JSON object is given below in the Data Attributes section.

 

 

remove DHCP functionality from a resource

DescriptionTo remove DHCP functionality, delete the dhcp_module child resource. This operation uses general Resource->Delete functionality.
URL/api/v1/api.php?target=resource&action=delete&id=2166
Returns

Examples:

SUCCESSFUL:{"success":1,"message":"Deleted 2163-dhcp-module-3 (#2166)"}
ERROR:{"success":0, "message":"error message"}

 

 

get all DHCP Pools

DescriptionAs with the dhcp_module commands, the API endpoints governing DHCP IP Pools use the general Resource system. All the modifiers that can be applied to a Resource-Get can be used to filter this query.
URL/api/v1/api.php?target=resource&action=get&type=dhcp_pool
Returns

Examples:

SUCCESSFUL:{"success":1,"message":"Search successful","data":[{"id":"1482","name":"Blah","slug":"blah","type":"dhcp_pool","parent_id":"1","category_id":null,"attr":{"_dhcp_type":"subnet","_dhcp_pool_attributes":"{\"mac\":\"\",\"rangeStart\":\"13.0.0.0\",\"rangeEnd\":\"13.0.0.255\",\"freeLines\":0}","_dhcp_ip_id":"80902"}}],"result_count":1,"found_count":1}
ERROR:{"success":0, "message":"error message"}

Return Detail:

NameTypeDescription
idINTEGERID of the dhcp_pool resource
nameSTRINGThe name of the dhcp_pool
slugSTRINGThe unique reference string for this resource
typeSTRINGAlways 'dhcp_pool'
parent_idINTEGERThe resource to which the dhcp_pool is attached
category_idINTEGERThe category to which this dhcp_pool is associated
result_countINTEGERHow many dhcp_pools are returned in this search.
found_countINTEGERHow many dhcp_pools were found in this query, without pagination.

Attributes:

KeyTypeDescription
_dhcp_typeSTRINGEither 'subnet' or 'host'. Determines whether this DHCP Pool is describing a Subnet or a Host.
_dhcp_pool_attributesJSONA JSON-encoded string containing all the specific configuration parameters which govern this DHCP Pool. An expansion of the JSON object is given below in the Data Attributes section.
_dhcp_ip_idINTEGERThe id of the IPAM subnet or host which is assigned to this DHCP Pool

 

 

create a new DHCP Pool resource

DescriptionUses the general Resource-Add endpoint to create a DHCP Pool resource.
URL/api/v1/api.php?target=resource& action=add& meta[type]=dhcp_pool& meta[name]=New Subnet& fields[_dhcp_type][]=host& fields[_dhcp_pool_attributes][]={"mac":"aa:bb:cc:dd:ee:ff", "rangeStart":"", "rangeEnd":"", "freeLines":3, "freeLine1":"Free Line 1", "freeLine2":"Free Line 2", "freeLine3":"Free Line 3"}
Returns

Examples:

SUCCESSFUL:{"success":1,"message":"Resource added","data":{"id":2167,"name":"New Subnet","slug":"new-subnet","type":"dhcp_pool ","parent_id":1,"category_id":null,"attr":[]}}
ERROR:{"success":0, "message":"error message"}

Return Detail:

NameTypeDescription
idINTEGERID of the newly created dhcp_pool
nameSTRINGThe name of the dhcp_pool
slugSTRINGThe unique reference string for this resource
typeSTRINGAlways 'dhcp_pool'
parent_idINTEGERThe parent resource; by default the TLR.
category_idINTEGERThe category to which this dhcp_pool is associated

 

 

update a DHCP Pool

DescriptionModifying an existing dhcp_pool uses the identical commands as all other Resource-Update actions.
URL/api/v1/api.php?target=resource& action=update& meta[type]=dhcp_pool& meta[name]=Another Test& fields[_dhcp_type][]=subnet& fields[_dhcp_pool_attributes][]={"mac":"", "rangeStart":"10.10.10.4", "rangeEnd":"10.10.10.5", "freeLines":3, "freeLine1":"example1", "freeLine2":"example2", "freeLine3":"example3"}&fields[_dhcp_ip_id][]=92430&meta[id]=2165
Returns

Examples:

SUCCESSFUL:{"success":1, "message":"Resource Updated", "data":{"id":"2165", "name":"Another Test", "slug":"2163-dhcp-module-2", "type":"dhcp_module", "parent_id":"2163", "category_id":null,"attr":{"_dhcp_type":"subnet" ,"_dhcp_pool_attributes":"{\"mac\":\"\", \"rangeStart\":\"10.10.10.4\", \"rangeEnd\":\"10.10.10.5\", \"freeLines\":3, \"freeLine1\":\"example1\", \"freeLine2\":\"example2\", \"freeLine3\":\"example3\"}", "_dhcp_ip_id":"92430"}}}
ERROR:{"success":0, "message":"error message"}

Return Detail:

NameTypeDescription
idINTEGERID of the newly created dhcp_module
nameSTRINGThe name of the dhcp_module
slugSTRINGThe unique reference string for this resource
typeSTRINGAlways 'dhcp_module'
parent_idINTEGERThe resource to which the dhcp_module is attached
category_idINTEGERThe category to which this dhcp_module is associated

Attributes:

KeyTypeDescription
_dhcp_typeSTRINGEither 'subnet' or 'host'. Determines whether this DHCP Pool is describing a Subnet or a Host.
_dhcp_pool_attributesJSONA JSON-encoded string containing all the specific configuration parameters which govern this DHCP Pool. An expansion of the JSON object is given below in the Data Attributes section.
_dhcp_ip_idINTEGERThe id of the IPAM subnet or host which is assigned to this DHCP Pool

 

 

delete a DHCP Pool

DescriptionTo delete a DHCP Pool, use the standard Resource-Delete functionality
URL/api/v1/api.php?target=resource&action=delete&id=2165
Returns

Examples:

SUCCESSFUL:{"success":1,"message":"Deleted 2165-another-subnet-3 (#2165)"}
ERROR:{"success":0, "message":"error message"}

 

 

assigning an IP address or blocks to a DHCP Pool

DescriptionAssigning IP addresses or blocks to a DHCP Pool resource removes them from the available pool so they cannot be assigned out again. This procedure uses all the standard IPAM assignment functions, so long as the resource assigned from is the DHCP Available resource.
URL/api/v1/api.php?target=ipam&action=smartAssign&resourceId=2162&type=ipv4&mask=31&rir=1918&assignedResourceId=1282
Returns

Examples:

SUCCESSFUL:{"success":1,"message":"Assigned 10.8.1.4\/31 to 208.39.104.106 (2162) via Smart Assign","id":94468,"data":{"id":94468,"type":"ipv4","top_aggregate":44616,"cidr":"10.8.1.4\/31","formatted_ip":"10.8.1.4\/31","address":"168296708","end_address":"168296709","mask":31,"netmask":"255.255.255.254","child1":null,"child2":null,"is_assigned":1,"is_swipped":0,"is_aggregate":1,"custid":2162,"resource_id":2162,"resource_name":null,"last_updated_time":"2015-03-15 20:17:32","description":null,"parent":80882,"rir":"1918","lir_id":null,"notes":null,"generic_code":null,"code":null,"region":"Quito","region_name":"Quito","vlan":null,"arin_net_id":null,"arin_cust_id":null,"org_id":null,"arin_swip_time":null,"assigned_time":"2015-03-15 20:17:32","asn":null,"allowSubAssignments":false,"permissions":[],"range":"10.8.1.4 - 10.8.1.5","tags":["DHCP"]}}
ERROR:{"success":0, "message":"error message"}

Return Detail:

For a detailed breakdown of this endpoint's return data, please see the IPAM documentation.

 

 

get all DHCP Pool linkages

DescriptionThe association between DHCP Pools and DHCP Modules belongs to the Resource Linkage family of endpoints. The 'relation' field should be set to the 'dhcpPoolLink' type to pull only DHCP Pool linkage information.
URL/api/v1/api.php?target=resource&action=getLink&relation=dhcpPoolLink
Returns

Examples:

SUCCESSFUL:{"success":1 ,"message":"Search successful", "data":{"meta":{"totalRecords":"3", "retrieved":3}, "0":{"id":"22", "resource_id1":"1292", "resource_id2":"1302", "relation":"dhcpPoolLink"}, "1":{"id":"2", "resource_id1":"1292", "resource_id2":"1452", "relation":"dhcpPoolLink"}, "2":{"id":"12", "resource_id1":"1422", "resource_id2":"1482", "relation":"dhcpPoolLink"}}}
ERROR:{"success":0, "message":"error message"}

Return Detail:

NameTypeDescription
idINTEGERId of the pool-module linkage
resource_id1INTEGERThe id of the dhcp_module resource
resource_id2INTEGERThe id of the dhcp_pool resource
relationSTRINGThe relation type. Always 'dhcpPoolLink'

Meta Attributes:

NameTypeDescription
totalRecordsINTEGERHow many records were found by this query, without pagination.
retrievedINTEGERHow many records were returned by this query, with pagination.

 

 

add a new DHCP Pool linkage

DescriptionAdds a new link between a DHCP Pool and a dhcp_module resource. A single pool can be linked to many dhcp_modules, and a single dhcp_module can have any number of linked pools.
URL/api/v1/api.php?target=resource&action=addLink&resource_id1=1292&resource_id2=2162&relation=dhcpPoolLink
Returns

Examples:

SUCCESSFUL:{"success":1,"message":"Resource link added"}
ERROR:{"success":0, "message":"error message"}

Data Detail:

NameTypeDescription
resource_id1INTEGERThe id of the dhcp_module resource
resource_id2INTEGERThe id of the dhcp_pool resource
relationSTRINGThe relation type being added. Always 'dhcpPoolLink'

 

 

delete DHCP Pool linkages

DescriptionDeletes a link between a dhcp_module and a dhcp_pool. Uses the standard Resource Linkage endpoints.
URL/api/v1/api.php?target=resource&action=deleteLink&id=22
Returns

Examples:

SUCCESSFUL:{"success":1,"message":"Resource link(s) deleted."}
ERROR:{"success":0, "message":"error message"}

 

 

push a DHCP config

DescriptionBuilds a DHCP configuration from the attributes assigned to a dhcp_module and all of the linked dhcp_pools. Pushes that config to the configured DHCP server, tests it against the config parsing function, then restarts the server with the new configuration.
URL/api/v1/api.php?target=dhcp&action=push&id=1292
Returns

Examples:

SUCCESSFUL:{"success":1,"message":"Pushes Attempted.","data":[[1,"1292","381 DHCP Module","Configuration successfully pushed."]]}
ERROR:{"success":0, "message":"error message"}

Data Detail

NameTypeDescription
idINTEGERThe id of the dhcp_module resource whose configuration is to be pushed.

...