Bind

  • By Canonical IS DevOps
Channel Revision Published Runs on
latest/edge 12 02 May 2024
Ubuntu 22.04
juju deploy bind --channel edge
Show information

Platform:

Ubuntu
22.04

charms.bind.v0.dns_record

Library to manage the integration with the Bind charm.

This library contains the Requires and Provides classes for handling the integration between an application and a charm providing the dns_record integration.

Requirer Charm

from charms.bind.v0.dns_record import DNSRecordRequires

class DNSRecordRequirerCharm(ops.CharmBase):
    def __init__(self, *args):
        super().__init__(*args)
        self.dns_record = DNSRecordRequires(self)
        self.framework.observe(self.dns_record.on.dns_record_data_available, self._handler)
        ...

    def _handler(self, events: DNSRecordDataAvailableEvent) -> None:
        ...

As shown above, the library provides a custom event to handle the scenario in which new DNS data has been added or updated.

The DNSRecordRequires provides an update_relation_data method to update the relation data by passing a DNSRecordRequirerData data object, requesting new DNS records.

Provider Charm

Following the previous example, this is an example of the provider charm.

from charms.bind.v0.dns_record import DNSRecordProvides

class DNSRecordProviderCharm(ops.CharmBase):
    def __init__(self, *args):
        super().__init__(*args)
        self.dns_record = DNSRecordProvides(self)
        ...

The DNSRecordProvides object wraps the list of relations into a relations property and provides an update_relation_data method to update the relation data by passing a DNSRecordRelationData data object.

class DNSRecordProviderCharm(ops.CharmBase):
    ...

    def _on_config_changed(self, _) -> None:
        for relation in self.model.relations[self.dns_record.relation_name]:
            self.dns_record.update_relation_data(relation, self._get_dns_record_data())


class Status

Represent the status values.

Attributes

APPROVED
approved
INVALID_CREDENTIALS
invalid_credentials
PERMISSION_DENIED
permission_denied
CONFLICT
conflict
INVALID_DATA
invalid_data
FAILURE
failure
UNKNOWN
unknown
PENDING
pending

Methods

Status. _missing_( cls , _: object )

Handle the enum when the value is missing.

Returns

value

Status.UNKNOWN.

class RecordType

Represent the DNS record types.

Attributes

A
A
AAAA
AAAA
CNAME
CNAME
MX
MX
DKIM
DKIM
SPF
SPF
DMARC
DMARC
TXT
TXT
CAA
CAA
SRV
SRV
SVCB
SVCB
HTTPS
HTTPS
PTR
PTR
SOA
SOA
NS
NS
DS
DS
DNSKEY
DNSKEY

class RecordClass

Represent the DNS record classes.

Attributes

IN
IN

class DNSProviderData

Represent the DNS provider data.

Attributes

uuid
UUID for the domain request.
status
status for the domain request.
description
status description for the domain request.

class DNSRecordProviderData

List of domains for the provider to manage.

Attributes

dns_domains
list of domains to manage.
dns_entries
list of entries to manage.

Methods

DNSRecordProviderData. to_relation_data( self )

Convert an instance of DNSRecordProviderData to the relation representation.

Returns

Dict containing the representation.

DNSRecordProviderData. from_relation_data( cls , relation_data )

Initialize a new instance of the DNSRecordProviderData class from the relation data.

Description

Args: relation_data: the relation data.

Returns: A DNSRecordProviderData instance.

Raises: ValidationError if the value is not parseable.

class RequirerDomain

DNS requirer domains requested.

Attributes

domain
the domain name.
username
username for authentication.
password_id
secret password for authentication.
uuid
UUID for this entry.

class RequirerEntry

DNS requirer entries requested.

Attributes

domain
the domain name.
host_label
host label.
ttl
TTL.
record_class
DNS record class.
record_type
DNS record type.
record_data
the record value.
uuid
UUID for this entry.

class DNSRecordRequirerData

List of domains for the provider to manage.

Attributes

dns_domains
list of domains to manage.
dns_entries
list of entries to manage.

Methods

DNSRecordRequirerData. to_relation_data( self )

Convert an instance of DNSRecordRequirerData to the relation representation.

Returns

Dict containing the representation.

DNSRecordRequirerData. from_relation_data( cls , relation_data )

Initialize a new instance of the DNSRecordRequirerData class from the relation data.

Description

Args: relation_data: the relation data.

Returns: A DNSRecordRequirerData instance.

Raises: ValidationError if the value is not parseable.

class DNSRecordRequestProcessed

DNS event emitted when a new request is processed.

Attributes

dns_record_provider_relation_data
the DNS provider relation data.
dns_domains
list of processed domains.
dns_entries
list of processed entries.

Methods

DNSRecordRequestProcessed. dns_record_provider_relation_data( self )

Description

Get a DNSRecordProviderData for the relation data. None

DNSRecordRequestProcessed. dns_domains( self )

Description

Fetch the DNS domains from the relation. None

DNSRecordRequestProcessed. dns_entries( self )

Description

Fetch the DNS entries from the relation. None

class DNSRecordRequestReceived

DNS event emitted when a new request is made.

Attributes

dns_record_requirer_relation_data
the DNS requirer relation data.
dns_domains
list of requested domains.
dns_entries
list of requested entries.

Methods

DNSRecordRequestReceived. dns_record_requirer_relation_data( self )

Description

Get a DNSRecordRequirerData for the relation data. None

DNSRecordRequestReceived. dns_domains( self )

Description

Fetch the DNS domains from the relation. None

DNSRecordRequestReceived. dns_entries( self )

Description

Fetch the DNS entries from the relation. None

class DNSRecordRequiresEvents

DNS record requirer events.

Attributes

dns_record_request_processed
the DNSRecordRequestProcessed.

Description

This class defines the events that a DNS record requirer can emit.

class DNSRecordRequires

Requirer side of the DNS requires relation.

Attributes

on
events the provider can emit.

Methods

DNSRecordRequires. __init__( self , charm , relation_name: str )

Construct.

Arguments

charm

the provider charm.

relation_name

the relation name.

DNSRecordRequires. get_remote_relation_data( self )

Retrieve the remote relation data.

Returns

DNSRecordProviderData

the relation data.

DNSRecordRequires. update_relation_data( self , relation , dns_record_requirer_data: DNSRecordRequirerData )

Update the relation data.

Arguments

relation

the relation for which to update the data.

dns_record_requirer_data

a DNSRecordRequirerData instance wrapping the data to be updated.

class DNSRecordProvidesEvents

DNS record provider events.

Attributes

dns_record_request_received
the DNSRecordRequestReceived.

Description

This class defines the events that a DNS record provider can emit.

class DNSRecordProvides

Provider side of the DNS record relation.

Attributes

on
events the provider can emit.

Methods

DNSRecordProvides. __init__( self , charm , relation_name: str )

Construct.

Arguments

charm

the provider charm.

relation_name

the relation name.

DNSRecordProvides. get_remote_relation_data( self )

Retrieve the remote relation data.

Returns

DNSRecordRequirerData

the relation data.

DNSRecordProvides. update_relation_data( self , relation , dns_record_provider_data: DNSRecordProviderData )

Update the relation data.

Arguments

relation

the relation for which to update the data.

dns_record_provider_data

a DNSRecordProviderData instance wrapping the data to be updated.