final class ApiRecordRepository implements RecordRepositoryInterface (View source)

Record reads for the API backend mode, served from PowerDNS RRsets.

Methods

__construct(DnsBackendProviderInterface $backendProvider)

No description

int
getZoneIdFromRecordId(int|string $rid)

Get Zone ID from Record ID

int
countZoneRecords(int $zone_id)

Count Zone Records for Zone ID

array
getRecordDetailsFromRecordId(int|string $rid)

Get record details from Record ID

array|null
getRecordFromId(int|string $id)

Get a Record from a Record ID

array
getRecordsFromDomainId(int $id, int $rowstart = 0, int $rowamount = Constants::DEFAULT_MAX_ROWS, string $sortby = 'name', string $sortDirection = 'ASC', bool $fetchComments = false)

Get all records from a domain id.

int
recidToDomid(int|string $id)

Record ID to Domain ID

bool
hasNonDelegationRecords(string $name)

Check if non-delegation records exist for a given name

bool
hasSimilarRecords(int $domain_id, string $name, string $type, int|string $record_id)

Check if record has similar records with same name and type

bool
recordExists(int $domain_id, string $name, string $type, string $content)

Check if a record with the given parameters already exists

bool
hasPtrRecord(int $domain_id, string $name)

Check if any PTR record exists for a given reverse domain name

string
getSerialByZid(int $zid)

Get Serial for Zone ID

array
getSerialsByZoneIds(array $zoneIds)

Get serial numbers for multiple zones in a single query

array
getRecordsByDomainId(int $domainId, string|null $recordType = null, bool $withComments = false)

Get records by domain ID

array
getRecordsPageByDomainId(int $domainId, string|null $recordType, bool $withComments, int $limit, int $offset)

One page of the records getRecordsByDomainId() returns, in the same order, without the empty non-terminals (rows with no type or no name)

int
countRecordsByDomainId(int $domainId, string|null $recordType = null)

Number of rows getRecordsPageByDomainId() pages through

array
getRRSetPageRecords(int $domainId, string|null $recordType, int $limit, int $offset)

The records of one page of RRsets: the RRsets (name and type) are paged in the order they first appear in getRecordsByDomainId(), and every record of each one on the page comes back, in that same order

array
getRecordsByDomainIdContaining(int $domainId, string|null $recordType, bool $withComments, array $contains)

getRecordsByDomainId(), narrowed to rows that may contain the given substrings, case-insensitively. It never drops a row that contains them; it may keep more, so callers still apply their own exact filter.

array
getRRSetRecordsContaining(int $domainId, string|null $recordType, array $contains)

Every record of each RRset (name and type) that has a member which may contain the given substrings, in getRecordsByDomainId() order. Like getRecordsByDomainIdContaining() it may keep more than the exact match.

int
countRRSetsByDomainId(int $domainId, string|null $recordType = null)

Number of RRsets getRRSetPageRecords() pages through

string|null
getCommentForRecord(int|string $recordId, int $domainId, string $name, string $type)

The comment shown for one record: the SQL backend gives the comment linked to the record, else the unlinked comment for its name and type; the API backend gives the RRset comment, shared by every record in the set.

array
getRecordsByName(int $domainId, string $name, string|null $type = null)

Get the records at one name in a zone, optionally filtered by type.

array
getRecordsAtOrUnder(int $domainId, string $name)

Get the enabled records in a zone at a name or anywhere below it, matched case-insensitively. Empty non-terminals are excluded.

array
getFilteredRecords(int $zone_id, int $row_start, int $row_amount, string $sort_by, string $sort_direction, bool $include_comments, string $search_term = '', string $type_filter = '', string $content_filter = '')

Get filtered records from a domain with search capabilities

int
getFilteredRecordCount(int $zone_id, bool $include_comments, string $search_term = '', string $type_filter = '', string $content_filter = '')

Get count of filtered records

int|string|null
getNewRecordId(int $domainId, string $name, string $type, string $content)

Get the ID of a newly created record

array|null
getRecordById(int|string $recordId)

Get a record by ID

array
getRRSetRecords(int $domainId, string $name, string $type)

Get all records in an RRset (matching domain, name, and type)

Details

__construct(DnsBackendProviderInterface $backendProvider)

No description

Parameters

DnsBackendProviderInterface $backendProvider

int getZoneIdFromRecordId(int|string $rid)

Get Zone ID from Record ID

Parameters

int|string $rid

Record ID

Return Value

int

Zone ID

int countZoneRecords(int $zone_id)

Count Zone Records for Zone ID

Parameters

int $zone_id

Zone ID

Return Value

int

Record count

array getRecordDetailsFromRecordId(int|string $rid)

Get record details from Record ID

Parameters

int|string $rid

Record ID (int for SQL mode, encoded string for API mode)

Return Value

array

array of record details [rid,zid,name,type,content,ttl,prio]

array|null getRecordFromId(int|string $id)

Get a Record from a Record ID

Retrieve all fields of the record and send it back to the function caller.

Parameters

int|string $id

Record ID (int for SQL mode, encoded string for API mode)

Return Value

array|null

array of record detail, or null if nothing found

array getRecordsFromDomainId(int $id, int $rowstart = 0, int $rowamount = Constants::DEFAULT_MAX_ROWS, string $sortby = 'name', string $sortDirection = 'ASC', bool $fetchComments = false)

Get all records from a domain id.

Retrieve all fields of the records and send it back to the function caller.

Parameters

int $id

Domain ID

int $rowstart

Starting row [default=0]

int $rowamount

Number of rows to return in this query [default=9999]

string $sortby

Column to sort by [default='name']

string $sortDirection

Sort direction [default='ASC']

bool $fetchComments

Whether to fetch record comments [default=false]

Return Value

array

One read model per record, empty when the zone has none

int recidToDomid(int|string $id)

Record ID to Domain ID

Gets the id of the domain by a given record id

Parameters

int|string $id

Record ID (int for SQL mode, encoded string for API mode)

Return Value

int

Domain ID of record

bool hasNonDelegationRecords(string $name)

Check if non-delegation records exist for a given name

Per RFC 1034: Delegation NS records are NOT authoritative data. Per RFC 4034: DS records are part of the delegation for DNSSEC. This method checks for records other than NS/DS which indicate authoritative data. Only delegation records (NS, DS) at a name should not prevent zone creation.

Parameters

string $name

Record name

Return Value

bool

True if non-delegation records exist, false otherwise

bool hasSimilarRecords(int $domain_id, string $name, string $type, int|string $record_id)

Check if record has similar records with same name and type

Parameters

int $domain_id

Domain ID

string $name

Record name

string $type

Record type

int|string $record_id

Current record ID to exclude from check

Return Value

bool

True if similar records found, false otherwise

bool recordExists(int $domain_id, string $name, string $type, string $content)

Check if a record with the given parameters already exists

Parameters

int $domain_id

Domain ID

string $name

Record name

string $type

Record type

string $content

Record content

Return Value

bool

True if record exists, false otherwise

bool hasPtrRecord(int $domain_id, string $name)

Check if any PTR record exists for a given reverse domain name

Parameters

int $domain_id

Domain ID

string $name

Reverse domain name (e.g., "1.1.168.192.in-addr.arpa")

Return Value

bool

True if any PTR record exists for this name

string getSerialByZid(int $zid)

Get Serial for Zone ID

Parameters

int $zid

Zone ID

Return Value

string

Serial Number or false if not found

array getSerialsByZoneIds(array $zoneIds)

Get serial numbers for multiple zones in a single query

Parameters

array $zoneIds

Array of zone IDs

Return Value

array

Array mapping zone ID to serial number

array getRecordsByDomainId(int $domainId, string|null $recordType = null, bool $withComments = false)

Get records by domain ID

Parameters

int $domainId

Domain ID

string|null $recordType

Optional record type filter

bool $withComments

Add a comment key (string or null) to every row, resolved in one lookup

Return Value

array

Array of records

array getRecordsPageByDomainId(int $domainId, string|null $recordType, bool $withComments, int $limit, int $offset)

One page of the records getRecordsByDomainId() returns, in the same order, without the empty non-terminals (rows with no type or no name)

Parameters

int $domainId

Domain ID

string|null $recordType

Optional record type filter

bool $withComments

Add a comment key (string or null) to every row

int $limit

Rows per page

int $offset

Rows to skip

Return Value

array

Array of records

int countRecordsByDomainId(int $domainId, string|null $recordType = null)

Number of rows getRecordsPageByDomainId() pages through

Parameters

int $domainId

Domain ID

string|null $recordType

Optional record type filter

Return Value

int

Record count

array getRRSetPageRecords(int $domainId, string|null $recordType, int $limit, int $offset)

The records of one page of RRsets: the RRsets (name and type) are paged in the order they first appear in getRecordsByDomainId(), and every record of each one on the page comes back, in that same order

Parameters

int $domainId

Domain ID

string|null $recordType

Optional record type filter

int $limit

RRsets per page

int $offset

RRsets to skip

Return Value

array

Array of records

array getRecordsByDomainIdContaining(int $domainId, string|null $recordType, bool $withComments, array $contains)

getRecordsByDomainId(), narrowed to rows that may contain the given substrings, case-insensitively. It never drops a row that contains them; it may keep more, so callers still apply their own exact filter.

Parameters

int $domainId

Domain ID

string|null $recordType

Optional record type filter

bool $withComments

Add a comment key (string or null) to every row

array $contains

Needles by query parameter: name, content, q (name or content)

Return Value

array

Array of records

array getRRSetRecordsContaining(int $domainId, string|null $recordType, array $contains)

Every record of each RRset (name and type) that has a member which may contain the given substrings, in getRecordsByDomainId() order. Like getRecordsByDomainIdContaining() it may keep more than the exact match.

Parameters

int $domainId

Domain ID

string|null $recordType

Optional record type filter

array $contains

Needles by query parameter: name, content, q

Return Value

array

Array of records

int countRRSetsByDomainId(int $domainId, string|null $recordType = null)

Number of RRsets getRRSetPageRecords() pages through

Parameters

int $domainId

Domain ID

string|null $recordType

Optional record type filter

Return Value

int

RRset count

string|null getCommentForRecord(int|string $recordId, int $domainId, string $name, string $type)

The comment shown for one record: the SQL backend gives the comment linked to the record, else the unlinked comment for its name and type; the API backend gives the RRset comment, shared by every record in the set.

Parameters

int|string $recordId

Record ID (int for SQL mode, encoded string for API mode)

int $domainId

Domain ID

string $name

Fully qualified record name, no trailing dot

string $type

Record type

Return Value

string|null

The comment, null when there is none

array getRecordsByName(int $domainId, string $name, string|null $type = null)

Get the records at one name in a zone, optionally filtered by type.

Prefer this over getRecordsByDomainId() whenever only one name matters: in API backend mode the zone-wide call fetches every record in the zone. Names match case-insensitively, per RFC 4343.

Parameters

int $domainId

Domain ID

string $name

Record name, with or without a trailing dot

string|null $type

Optional record type filter

Return Value

array

Array of records

array getRecordsAtOrUnder(int $domainId, string $name)

Get the enabled records in a zone at a name or anywhere below it, matched case-insensitively. Empty non-terminals are excluded.

Parameters

int $domainId

Domain ID

string $name

Name without a trailing dot

Return Value

array

Records ordered by name and type

array getFilteredRecords(int $zone_id, int $row_start, int $row_amount, string $sort_by, string $sort_direction, bool $include_comments, string $search_term = '', string $type_filter = '', string $content_filter = '')

Get filtered records from a domain with search capabilities

Parameters

int $zone_id

The zone ID

int $row_start

Starting row for pagination

int $row_amount

Number of rows per page

string $sort_by

Column to sort by

string $sort_direction

Sort direction (ASC or DESC)

bool $include_comments

Whether to include comments

string $search_term

Optional search term to filter by name or content

string $type_filter

Optional record type filter

string $content_filter

Optional content filter

Return Value

array

One read model per matching record

int getFilteredRecordCount(int $zone_id, bool $include_comments, string $search_term = '', string $type_filter = '', string $content_filter = '')

Get count of filtered records

Parameters

int $zone_id

The zone ID

bool $include_comments

Whether to include comments in the search

string $search_term

Optional search term to filter by name or content

string $type_filter

Optional record type filter

string $content_filter

Optional content filter

Return Value

int

Number of filtered records

int|string|null getNewRecordId(int $domainId, string $name, string $type, string $content)

Get the ID of a newly created record

Parameters

int $domainId

Domain ID

string $name

Record name

string $type

Record type

string $content

Record content

Return Value

int|string|null

Record ID or null if not found

array|null getRecordById(int|string $recordId)

Get a record by ID

Parameters

int|string $recordId

Record ID (int for SQL mode, encoded string for API mode)

Return Value

array|null

Record data if found, null otherwise

array getRRSetRecords(int $domainId, string $name, string $type)

Get all records in an RRset (matching domain, name, and type)

Parameters

int $domainId

The domain/zone ID

string $name

The record name

string $type

Record type (A, AAAA, CNAME, etc.)

Return Value

array

Array of matching records