Skip to main content

Modules for working with BlueCat products.

Project description

Modules for working with products from BlueCat Networks.

The Python clients in this package provide access to the following BlueCat HTTP APIs:

  • Address Manager RESTful v2 API (9.5)

  • Address Manager Legacy REST v1 API (9.3, 9.4, 9.5)

  • Address Manager Failover API

  • DNS Edge API

The examples below illustrate how to use the Address Manager RESTful v2 API and Legacy v1 API to fetch BlueCat Address Manager (BAM) configurations.

Examples using Address Manager RESTful v2 API

from bluecat_libraries.address_manager.apiv2 import Client, MediaType
import csv

# Retrieve the configurations. Request the data as per BAM's default content type.
with Client(<bam_url>) as client:
    client.login(<username>, <password>)
    response = client.http_get("/configurations")
    configurations = response["data"]
    for configuration in configurations:
        print(f'{configuration["id"]}: {configuration["name"]}')
    client.logout()

# Retrieve the configurations. Request that the response is in 'JSON' format.
# The result should contain only fields 'id' and 'name'.
with Client(<bam_url>) as client:
    client.login(<username>, <password>)
    response = client.http_get(
        "/configurations",
        params={"fields": "id,name"},
        headers={"Accept": MediaType.JSON},
    )
    configurations = response["data"]
    for configuration in configurations:
        print(f'{configuration["id"]}: {configuration["name"]}')
    client.logout()

# Retrieve configurations. Request that the response is in 'CSV' format.
# The result should contain only the first 10, ordered alphabetically by name.
with Client(<bam_url>) as client:
    client.login(<username>, <password>)
    configurations_csv = client.http_get(
        "/configurations",
        params={"orderBy": "asc(name)", "limit": "10"},
        headers={"Accept": MediaType.CSV},
    )
    configurations = list(csv.reader(configurations_csv.splitlines()))
    for configuration in configurations:
        # NOTE: The 'id' is the first value in a row, the 'name' is the third one.
        print(f"{configuration[0]}: {configuration[2]}")
    client.logout()

Example using Address Manager Legacy REST v1 API

# Fetch all configurations from a BlueCat Address Manager server.

from bluecat_libraries.address_manager.api import Client
from bluecat_libraries.address_manager.constants import ObjectType

with Client(<bam_url>) as client:
    client.login(<username>, <password>)
    configs = client.get_entities(0, ObjectType.CONFIGURATION)
    client.logout()

for config in configs:
    print(config)

Note

Subpackage bluecat_libraries.address_manager.api.rest.provisional is a deprecated dependency of BlueCat Gateway, and currently exists while we are still in the pre-deprecation-removal grace period. It will be removed in the next release of BlueCat Libraries.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bluecat-libraries-24.2.0.tar.gz (111.1 kB view hashes)

Uploaded Source

Built Distribution

bluecat_libraries-24.2.0-py3-none-any.whl (141.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page