google-cloud-node icon indicating copy to clipboard operation
google-cloud-node copied to clipboard

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

Open rqbazan opened this issue 6 months ago • 1 comments

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

rqbazan avatar Jun 19 '25 22:06 rqbazan