Bind

  • Canonical IS DevOps
Channel Revision Published Runs on
latest/edge 36 08 Oct 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_request_processed, self._handler)
        ...

    def _handler(self, events: DNSRecordRequestProcessed) -> 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 entries for the provider to manage.

Attributes

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( cls , relation )

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

Arguments

relation

the relation.

Returns

A DNSRecordProviderData instance.

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.

Methods

RequirerEntry. validate_dns_entry( self , _: ValidationInfo )

Validate DNS entries.

Returns

the DNS entry if valid.

class DNSRecordRequirerData

List of domains for the provider to manage.

Attributes

service_account
service account.
service_account_secret_id
the secret ID containing the service account.
dns_entries
list of entries to manage.

Methods

DNSRecordRequirerData. check_service_account_or_service_account_secret_id( cls , values: Dict )

Check if service_account or service_account_secret_id is defined.

Arguments

values

The values to validate

Returns

values

The validated values

DNSRecordRequirerData. set_service_account_secret_id( self , model , relation )

Store the service account as a Juju secret.

Arguments

model

the Juju model

relation

relation to grant access to the secrets to.

DNSRecordRequirerData. get_service_account( cls , model , service_account_secret_id )

Retrieve the password corresponding to the password_id.

Arguments

model

the Juju model.

service_account_secret_id

the secret ID for the service account.

Returns

the plain password or None if not found.

DNSRecordRequirerData. to_relation_data( self , model , relation )

Convert an instance of DNSRecordRequirerData to the relation representation.

Arguments

model

the Juju model.

relation

relation to grant access to the secrets to.

Returns

Dict containing the representation.

DNSRecordRequirerData. from_relation( cls , model , relation )

Get a Tuple of DNSRecordRequirerData and DNSRecordProviderData from the relation data.

Arguments

model

the Juju model.

relation

the relation.

Returns

the relation data and the processed entries for it.

class DNSRecordRequestProcessed

DNS event emitted when a new request is processed.

Attributes

dns_entries
list of processed entries.

Methods

DNSRecordRequestProcessed. get_dns_record_provider_relation_data( self )

Get a DNSRecordProviderData for the relation data.

Returns

the DNSRecordProviderData for the relation data.

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.
service_account
service account.
dns_entries
list of requested entries.
processed_entries
list of processed entries from the original request.

Methods

DNSRecordRequestReceived. dns_record_requirer_relation_data( self )

Description

Get the requirer data and corresponding provider data the relation data. None

DNSRecordRequestReceived. service_account( self )

Description

Fetch the service account from the relation. None

DNSRecordRequestReceived. dns_entries( self )

Description

Fetch the DNS entries from the relation. None

DNSRecordRequestReceived. processed_entries( self )

Description

Fetch the processed DNS entries. 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

DNSRecordRequirerData 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 all the remote relations data.

Returns

the relation data and the processed entries for it.

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.