Skip to content

[DNS] Support GetRecordsRequest object for more granular filtering in Zone.replaceRecords() #6434

@rqbazan

Description

@rqbazan

A screenshot that you have tested with "Try this API".

Currently, the replaceRecords method in the DNS Zone class only accepts a recordType parameter (string or string[]) for filtering records to delete before adding new ones. This is overly restrictive as it deletes ALL records of the specified type(s).

Current signature:

replaceRecords(recordType: string | string[], records: Record | Record[]): Promise<Change>

Current behavior:

await zone.replaceRecords("A", recordObject)
// This deletes ALL "A" records in the zone, which is often not desired

What would you like to see in the library?

Allow the first parameter to accept a GetRecordsRequest-like object for more granular filtering, enabling users to specify additional criteria like record name.

replaceRecords(
  filter: string | string[] | GetRecordsRequest, 
  records: Record | Record[]
): Promise<Change>

Desired usage:

await zone.replaceRecords({ type: "A", name: "oldRecordName" }, recordObject)
// This would only delete "A" records with the specific name "oldRecordName"

Describe alternatives you've considered

Currently, users must manually:

  • Query existing records with specific filters
  • Create the DNS change manually

Additional context/notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    size: stype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions