octodns.record.geo

Classes

GeoCodes()

GeoValidator(id[, sets])

Validates the deprecated geo block of a record: each key is a valid continent/country/subdivision code and each list of values passes the record's value-type validation.

GeoValue(geo, values)

class octodns.record.geo.GeoCodes[source]

Bases: object

log = <Logger GeoCodes (WARNING)>
classmethod validate(code, prefix, validator_id=None)[source]

Validates an octoDNS geo code making sure that it is a valid and corresponding:

  • continent

  • continent & country

  • continent, country, & province

classmethod parse(code)[source]
classmethod country_to_code(country)[source]
classmethod province_to_code(province)[source]
class octodns.record.geo.GeoValue(geo, values)[source]

Bases: EqualityTupleMixin

geo_re = re.compile('^(?P<continent_code>\\w\\w)(-(?P<country_code>\\w\\w)(-(?P<subdivision_code>\\w\\w))?)?$')
classmethod _validate_geo(code, validator_id=None)[source]
__init__(geo, values)[source]
property parents
_equality_tuple()[source]
__repr__()[source]

Return repr(self).

class octodns.record.geo.GeoValidator(id, sets=None)[source]

Bases: RecordValidator

Validates the deprecated geo block of a record: each key is a valid continent/country/subdivision code and each list of values passes the record’s value-type validation.

validate(record_cls, name, fqdn, data, disabled=None)[source]

Validate a record’s non-value attributes.

Parameters:
  • record_cls (type) – The concrete Record subclass being validated. Validators that need access to record class-level attributes (e.g. _type, _value_type) should read them from record_cls. Per-instance configuration should live on self, not on record_cls.

  • name (str) – The record’s name relative to its zone ('' for the zone root). Already idna_encode’d.

  • fqdn (str) – The record’s fully-qualified domain name (name + zone name).

  • data (dict) – The raw record config dict (as loaded from YAML/JSON) including ttl, type, value/values, and any type-specific fields like dynamic, geo, or octodns.

  • disabled (dict or None) – The zone’s per-type map of disabled validator ids (record_cls ._type or '*' -> set of ids), as configured via the zone’s validators.record.disable_validators. Most validators can ignore this; it only matters to validators that themselves dispatch to other validators (e.g. value-type bridges, geo and dynamic validators), which must forward it along so the disabled ids are honored down the chain.

Returns:

A list of ValidationReason objects describing validation failures — construct each with ValidationReason(reason, validator_id=self.id). Must return an empty list when the record is valid. Reasons from multiple validators are concatenated by the caller, so each reason must stand alone without context from the others. Returning bare str reasons is DEPRECATED — the registry wraps them in ValidationReason and emits a deprecation warning; support will be removed in 2.0.

Return type:

list[ValidationReason]

Notes

Implementations must not raise on invalid input — all failures are reported via the returned list. Reason text is surfaced verbatim in ValidationError messages, so phrasing and punctuation should be stable across releases.

Third-party validators that predate the disabled parameter and implement validate(self, record_cls, name, fqdn, data) continue to work: the caller detects the TypeError and falls back to calling without it, emitting a deprecation warning. Support for the parameter-less form will be removed in 2.0.

class octodns.record.geo._GeoMixin(zone, name, data, *args, **kwargs)[source]

Bases: ValuesMixin

Adds GeoDNS support to a record.

Must be included before Record.

VALIDATORS = [<octodns.record.geo.GeoValidator object>]
classmethod _schema(value_schema)[source]

JSON Schema fragment describing the geo block.

Keys are geo codes (continent, continent-country, or continent-country-subdivision); values are lists of record values.

__init__(zone, name, data, *args, **kwargs)[source]
_data()[source]
changes(other, target)[source]
__repr__()[source]

Return repr(self).