The BlueCat Python API is a set of wrapper classes abstracting the functionality of the BlueCat Address Manager API Client along with certain other BAM and BDDS functions (for example, dynamic updates to host records).
The following example prints the names and addresses of
servers under a given BlueCat Address Manager (BAM)
configuration.
# Print the names and addresses of servers under a given BlueCat Address Manager (BAM) configuration.
from bluecat_libraries.address_manager.api import Client
from bluecat_libraries.address_manager.constants import ObjectType
from bluecat_libraries.http_client.exceptions import ErrorResponse
with Client(<bam_url>) as client:
client.login(<username>, <password>)
try:
config = client.get_entity_by_name(0, <config_name>, ObjectType.CONFIGURATION)
if config is None:
print("No configuration found with the given name.")
else:
servers = client.get_entities(config["id"], ObjectType.SERVER)
for server in servers:
print(server["name"], server["properties"]["servicesIPv4Address"])
except ErrorResponse as e:
# `client.get_entity_by_name()` and `client.get_entities()` call BAM endpoints so either may
# result in an error response.
print(e.message)
client.logout()