ResourceRecord type is now implemented to handle incoming messages.

beta
Philippe Pittoli 2023-07-10 03:15:32 +02:00
parent b3e422c38f
commit f03909f83d
1 changed files with 50 additions and 9 deletions

View File

@ -1,18 +1,59 @@
module App.ResourceRecord where module App.ResourceRecord where
import Prelude import Data.Maybe (Maybe)
import Data.Codec.Argonaut (JsonCodec) import Data.Codec.Argonaut (JsonCodec)
import Data.Codec.Argonaut as CA import Data.Codec.Argonaut as CA
import Data.Newtype (class Newtype) import Data.Codec.Argonaut.Record as CAR
import Data.Profunctor (wrapIso)
newtype ResourceRecord = ResourceRecord String type ResourceRecord
= { rrid :: Int
, name :: String
, ttl :: Int
, target :: String
, readonly :: Boolean
derive instance newtypeResourceRecord :: Newtype ResourceRecord _ -- MX (and SRV) specific entry.
derive instance eqResourceRecord :: Eq ResourceRecord , priority :: Maybe Int
derive instance ordResourceRecord :: Ord ResourceRecord
-- SRV specific entries.
, port :: Maybe Int
, protocol :: Maybe String
, weight :: Maybe Int
-- SOA specific entries.
, mname :: Maybe String
, rname :: Maybe String
, serial :: Maybe Int
, refresh :: Maybe Int
, retry :: Maybe Int
, expire :: Maybe Int
, minttl :: Maybe Int
}
-- | ResourceRecord.codec can be used to parse and encode email addresses.
codec :: JsonCodec ResourceRecord codec :: JsonCodec ResourceRecord
codec = wrapIso ResourceRecord CA.string codec = CA.object "ResourceRecord"
(CAR.record
{ rrid: CA.int
, name: CA.string
, ttl: CA.int
, target: CA.string
, readonly: CA.boolean
-- MX (and SRV) specific entry.
, priority: CAR.optional CA.int
-- SRV specific entries.
, port: CAR.optional CA.int
, protocol: CAR.optional CA.string
, weight: CAR.optional CA.int
-- SOA specific entries.
, mname: CAR.optional CA.string
, rname: CAR.optional CA.string
, serial: CAR.optional CA.int
, refresh: CAR.optional CA.int
, retry: CAR.optional CA.int
, expire: CAR.optional CA.int
, minttl: CAR.optional CA.int
})