Update examples - BlueCat Address Manager - 9.0.0

Address Manager API Guide

Locale
English (United States)
Product name
BlueCat Address Manager
Version
9.0.0

Provides an example how the update method can be used in Java and Perl.

In this example, an existing shared network is passed to a configuration object as a parameter. After the values in the object or properties string have been set, the update() method modifies the value in the Address Manager database. Property values can be a string, long, or integer value. Address Manager uses the appropriate method to process the data for that property.

Java example

This example uses Java to return a managed server as an APIEntity, get the properties for the server, add a connected property with the value true, set the properties for the server, and then update the server.
// Get the object, here Server
		APIEntity server = service.getEntityByName(config.getId(), serverName, ObjectTypes.Server);
		
		// Get the current properties & add a new property
		EntityProperties props = new EntityProperties(server.getProperties());
		props.addProperty(ObjectProperties.connected, "true");
		
		// Set the changed properties on the object & send it to server to update
		server.setProperties(props.getPropertiesString());
		service.update(server);

Perl example

This example uses Perl to update an external host record.
my $externalHostRecord = $service->getEntityById( SOAP::Data->type( 'long' )-> 
name( 'id' )->
value( $externalHostRecordId )->
attr({xmlns => ''}) ) ->result;
$externalHostRecord = BAMConnection->blessAPIEntity( "object" => $externalHostRecord );
$externalHostRecord->set_name( "external2.host2.com" );
$service->update( SOAP::Data->type( 'APIEntity' )-> 
name( 'entity' )->
value( $externalHostRecord )-> attr({xmlns => ''}) );