From 2ff9eebc078bfe54f84a6e91424516da03b82416 Mon Sep 17 00:00:00 2001 From: Christoph Herzog Date: Thu, 21 Mar 2024 17:26:39 +0100 Subject: [PATCH] feat(backend-api): Add some more DnsRecord helper methods --- lib/backend-api/src/types.rs | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/lib/backend-api/src/types.rs b/lib/backend-api/src/types.rs index fb4f9c67ae8..bd481e85272 100644 --- a/lib/backend-api/src/types.rs +++ b/lib/backend-api/src/types.rs @@ -1162,6 +1162,60 @@ mod queries { DnsRecord::Unknown => None, } } + + pub fn created_at(&self) -> Option<&DateTime> { + match self { + DnsRecord::A(record) => Some(&record.created_at), + DnsRecord::AAAA(record) => Some(&record.created_at), + DnsRecord::CName(record) => Some(&record.created_at), + DnsRecord::Txt(record) => Some(&record.created_at), + DnsRecord::Mx(record) => Some(&record.created_at), + DnsRecord::Ns(record) => Some(&record.created_at), + DnsRecord::CAA(record) => Some(&record.created_at), + DnsRecord::DName(record) => Some(&record.created_at), + DnsRecord::Ptr(record) => Some(&record.created_at), + DnsRecord::Soa(record) => Some(&record.created_at), + DnsRecord::Srv(record) => Some(&record.created_at), + DnsRecord::Sshfp(record) => Some(&record.created_at), + DnsRecord::Unknown => None, + } + } + + pub fn updated_at(&self) -> Option<&DateTime> { + match self { + Self::A(record) => Some(&record.updated_at), + Self::AAAA(record) => Some(&record.updated_at), + Self::CName(record) => Some(&record.updated_at), + Self::Txt(record) => Some(&record.updated_at), + Self::Mx(record) => Some(&record.updated_at), + Self::Ns(record) => Some(&record.updated_at), + Self::CAA(record) => Some(&record.updated_at), + Self::DName(record) => Some(&record.updated_at), + Self::Ptr(record) => Some(&record.updated_at), + Self::Soa(record) => Some(&record.updated_at), + Self::Srv(record) => Some(&record.updated_at), + Self::Sshfp(record) => Some(&record.updated_at), + Self::Unknown => None, + } + } + + pub fn deleted_at(&self) -> Option<&DateTime> { + match self { + Self::A(record) => record.deleted_at.as_ref(), + Self::AAAA(record) => record.deleted_at.as_ref(), + Self::CName(record) => record.deleted_at.as_ref(), + Self::Txt(record) => record.deleted_at.as_ref(), + Self::Mx(record) => record.deleted_at.as_ref(), + Self::Ns(record) => record.deleted_at.as_ref(), + Self::CAA(record) => record.deleted_at.as_ref(), + Self::DName(record) => record.deleted_at.as_ref(), + Self::Ptr(record) => record.deleted_at.as_ref(), + Self::Soa(record) => record.deleted_at.as_ref(), + Self::Srv(record) => record.deleted_at.as_ref(), + Self::Sshfp(record) => record.deleted_at.as_ref(), + Self::Unknown => None, + } + } } #[derive(cynic::Enum, Clone, Copy, Debug)]