Adding objects - BlueCat Address Manager - 9.3.0

Address Manager API Guide

prodname
BlueCat Address Manager
version_custom
9.3.0

There are several ways to add objects to Address Manager using the API. This section provides examples of both generic and specific methods.

Generic addEntity

addEntity is a generic adding method that you can use to create any object. This example shows how to add a IP4Block in Address Manager:

// Signature: addEntity( long parentId, APIEntity entity )

// Form the entity object with the data
APIEntity blockEntity = new APIEntity();
// Specify Name
blockEntity.setName( "blockName" ); 
// Specify Type
blockEntity.setType( ObjectTypes.IP4Block ); 
// Specify additional properties required to define object
blockEntity.setProperties( ObjectProperties.CIDR + "=192.168.0.0/16" ); 

// Add this entity under the defined parent
long blockId = service.addEntity( configId, blockEntity );

Specific add methods

There are other add methods that you can use to add specific objects. This example shows how to add an a IP4Block in Address Manager:

// Signature: addIP4BlockByCIDR( long parentId, String CIDR, String properties )

// Add the block specifying the CIDR. Name has to be specified using properties in this case
String properties = ObjectProperties.name + "=blockName2";
long blockId = service.addIP4BlockByCIDR( configId, "20.0.0/16", properties );