bluecat

package module
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 11 Imported by: 0

README

Bluecat for libdns

Go Reference

This package implements the libdns interfaces for Bluecat Address Manager, allowing you to manage DNS records.

Configuration

To use this provider, you need:

  • Bluecat Address Manager API endpoint (URL)
  • Username
  • Password

Example Usage

package main

import (
	"context"
	"fmt"
	"time"

	"github.com/libdns/bluecat"
	"github.com/libdns/libdns"
)

func main() {
	provider := &bluecat.Provider{
		ServerURL: "https://bluecat.example.com",
		Username:  "api_user",
		Password:  "api_password",
		// Optional: specify configuration and view names
		// ConfigurationName: "config",
		// ViewName: "view",
	}

	zone := "example.com."
	ctx := context.Background()

	// Get existing records
	records, err := provider.GetRecords(ctx, zone)
	if err != nil {
		panic(err)
	}
	fmt.Printf("Found %d records\n", len(records))

	// Append a new A record
	newRecords := []libdns.Record{
		libdns.Address{
			Name: "test",
			TTL:  300 * time.Second,
			IP:   netip.MustParseAddr("192.0.2.1"),
		},
	}
	
	created, err := provider.AppendRecords(ctx, zone, newRecords)
	if err != nil {
		panic(err)
	}
	fmt.Printf("Created %d records\n", len(created))
}

Caveats

  • The provider requires Bluecat Address Manager 9.5.0 or later with the RESTful v2 API enabled
  • Record names should be relative to the zone (e.g., "www" for "www.example.com" in zone "example.com.")
  • Handling of Bluecat's linked records is not properly implemented yet. Networks and existing records to link A records and CNAMEs must already exist.

Features

  • Authentication sessions are automatically managed and tokens are cached for efficiency
  • The provider supports A, AAAA, CNAME, TXT, MX, NS, and SRV record types

Documentation

Overview

Package bluecat implements a DNS record management client compatible with the libdns interfaces for Bluecat Address Manager.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BluecatResourceRecord

type BluecatResourceRecord struct {
	ID               int64  `json:"id,omitempty"`
	Type             string `json:"type"`
	Name             string `json:"name"`
	AbsoluteName     string `json:"absoluteName,omitempty"`
	TTL              int    `json:"ttl,omitempty"`
	RecordType       string `json:"recordType,omitempty"`
	RData            string `json:"rdata,omitempty"`
	Text             string `json:"text,omitempty"`
	LinkedRecordName string `json:"linkedRecordName,omitempty"`
	Priority         int    `json:"priority,omitempty"`
	Weight           int    `json:"weight,omitempty"`
	Port             int    `json:"port,omitempty"`
	Addresses        []struct {
		Address string `json:"address"`
	} `json:"addresses,omitempty"`
}

BluecatResourceRecord represents a resource record in the Bluecat API

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client handles communication with the Bluecat API

func NewClient

func NewClient(baseURL, username, password string) (*Client, error)

NewClient creates a new Bluecat API client

func (*Client) Authenticate

func (c *Client) Authenticate(ctx context.Context) error

Authenticate authenticates with the Bluecat API and stores the token

func (*Client) CreateResourceRecord

func (c *Client) CreateResourceRecord(ctx context.Context, zoneID int64, zone string, record libdns.Record) (libdns.Record, error)

CreateResourceRecord creates a new resource record in the specified zone

func (*Client) DeleteResourceRecord

func (c *Client) DeleteResourceRecord(ctx context.Context, record libdns.Record) error

DeleteResourceRecord deletes a resource record

func (*Client) DeleteResourceRecordByID added in v0.1.4

func (c *Client) DeleteResourceRecordByID(ctx context.Context, recordID int64) error

DeleteResourceRecordByID deletes a resource record by its ID directly

func (*Client) DeployZone added in v0.1.1

func (c *Client) DeployZone(ctx context.Context, zoneID int64) error

DeployZone triggers a quick deployment of changes for a specific zone

func (*Client) GetResourceRecordByAbsoluteName added in v0.1.4

func (c *Client) GetResourceRecordByAbsoluteName(ctx context.Context, absoluteName, recordType string) (*BluecatResourceRecord, error)

GetResourceRecordByAbsoluteName searches for a resource record by its absolute name and type using BlueCat's filter API. This is useful when we need to find a record without knowing which zone it's directly under.

func (*Client) GetResourceRecords

func (c *Client) GetResourceRecords(ctx context.Context, zoneID int64, zone string) ([]libdns.Record, error)

GetResourceRecords retrieves all resource records for a zone. Note: This only fetches the first page of records (up to 1000). For Caddy ACME use case, records are deleted using stored IDs, so full enumeration is not needed.

func (*Client) GetZoneID

func (c *Client) GetZoneID(ctx context.Context, zone, configName, viewName string) (int64, error)

GetZoneID retrieves the zone ID for a given zone name

type Provider

type Provider struct {
	// ServerURL is the base URL of the Bluecat Address Manager server
	// (e.g., "https://bluecat.example.com")
	ServerURL string `json:"server_url,omitempty"`

	// Username for authenticating with the Bluecat API
	Username string `json:"username,omitempty"`

	// Password for authenticating with the Bluecat API
	Password string `json:"password,omitempty"`

	// Configuration name in Bluecat (optional, defaults to first available)
	ConfigurationName string `json:"configuration_name,omitempty"`

	// View name in Bluecat (optional, defaults to first available)
	ViewName string `json:"view_name,omitempty"`
	// contains filtered or unexported fields
}

Provider facilitates DNS record manipulation with Bluecat Address Manager.

func (*Provider) AppendRecords

func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)

AppendRecords adds records to the zone. It returns the records that were added.

func (*Provider) DeleteRecords

func (p *Provider) DeleteRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)

DeleteRecords deletes the specified records from the zone. It returns the records that were deleted. If records have BlueCat IDs in ProviderData, those are used directly. Otherwise, records are looked up by absoluteName to find their IDs.

func (*Provider) GetRecords

func (p *Provider) GetRecords(ctx context.Context, zone string) ([]libdns.Record, error)

GetRecords lists all the records in the zone.

func (*Provider) SetRecords

func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)

SetRecords sets the records in the zone, either by updating existing records or creating new ones. It returns the updated records.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL