The following example shows how to add a host record to an existing zone. It
demonstrates a complete session using the Address Manager API from Java.
- Connect to the Address Manager API service.
- Log in.
- Get the parent configuration object by name.
- Get the parent view object by name.
- Get the parent zone object by name (you can use the absolute name), and then retrieve its child. In this case, to retrieve example.net, we retrieve the parent com to find its child object, example.com.
- Define a host record object and add it to the parent zone object.
- Log out.
import com.bluecatnetworks.proteus.api.client.java.APILoginUtils;
import com.bluecatnetworks.proteus.api.client.java.constants.ObjectTypes;
import com.bluecatnetworks.proteus.api.client.java.proxy.APIEntity;
import com.bluecatnetworks.proteus.api.client.java.proxy.ProteusAPI;
public class ProteusAddHostRecord
{
public static void main( String[] args ) throws Exception
{
ProteusAPI service = APILoginUtils.connect( "ProteusIPAddress" );
service.login( "api_user", "password" );
APIEntity existingConfiguration = service.getEntityByName( 0, "Existing Config", ObjectTypes.Configuration );
APIEntity existingView = service.getEntityByName( existingConfiguration.getId(), "Existing View", ObjectTypes.View );
long hostRecordId = service.addHostRecord( existingView.getId(), "www.example.com", "10.0.0.6,10.0.0.8", 1, "" );
service.logout();
}
}