{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Route53AutoNaming.Types.SOA
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Route53AutoNaming.Types.SOA where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Start of Authority (SOA) properties for a public or private DNS
-- namespace.
--
-- /See:/ 'newSOA' smart constructor.
data SOA = SOA'
  { -- | The time to live (TTL) for purposes of negative caching.
    SOA -> Natural
ttl :: Prelude.Natural
  }
  deriving (SOA -> SOA -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SOA -> SOA -> Bool
$c/= :: SOA -> SOA -> Bool
== :: SOA -> SOA -> Bool
$c== :: SOA -> SOA -> Bool
Prelude.Eq, ReadPrec [SOA]
ReadPrec SOA
Int -> ReadS SOA
ReadS [SOA]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SOA]
$creadListPrec :: ReadPrec [SOA]
readPrec :: ReadPrec SOA
$creadPrec :: ReadPrec SOA
readList :: ReadS [SOA]
$creadList :: ReadS [SOA]
readsPrec :: Int -> ReadS SOA
$creadsPrec :: Int -> ReadS SOA
Prelude.Read, Int -> SOA -> ShowS
[SOA] -> ShowS
SOA -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SOA] -> ShowS
$cshowList :: [SOA] -> ShowS
show :: SOA -> String
$cshow :: SOA -> String
showsPrec :: Int -> SOA -> ShowS
$cshowsPrec :: Int -> SOA -> ShowS
Prelude.Show, forall x. Rep SOA x -> SOA
forall x. SOA -> Rep SOA x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SOA x -> SOA
$cfrom :: forall x. SOA -> Rep SOA x
Prelude.Generic)

-- |
-- Create a value of 'SOA' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'ttl', 'soa_ttl' - The time to live (TTL) for purposes of negative caching.
newSOA ::
  -- | 'ttl'
  Prelude.Natural ->
  SOA
newSOA :: Natural -> SOA
newSOA Natural
pTTL_ = SOA' {$sel:ttl:SOA' :: Natural
ttl = Natural
pTTL_}

-- | The time to live (TTL) for purposes of negative caching.
soa_ttl :: Lens.Lens' SOA Prelude.Natural
soa_ttl :: Lens' SOA Natural
soa_ttl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SOA' {Natural
ttl :: Natural
$sel:ttl:SOA' :: SOA -> Natural
ttl} -> Natural
ttl) (\s :: SOA
s@SOA' {} Natural
a -> SOA
s {$sel:ttl:SOA' :: Natural
ttl = Natural
a} :: SOA)

instance Data.FromJSON SOA where
  parseJSON :: Value -> Parser SOA
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SOA"
      (\Object
x -> Natural -> SOA
SOA' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"TTL"))

instance Prelude.Hashable SOA where
  hashWithSalt :: Int -> SOA -> Int
hashWithSalt Int
_salt SOA' {Natural
ttl :: Natural
$sel:ttl:SOA' :: SOA -> Natural
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
ttl

instance Prelude.NFData SOA where
  rnf :: SOA -> ()
rnf SOA' {Natural
ttl :: Natural
$sel:ttl:SOA' :: SOA -> Natural
..} = forall a. NFData a => a -> ()
Prelude.rnf Natural
ttl

instance Data.ToJSON SOA where
  toJSON :: SOA -> Value
toJSON SOA' {Natural
ttl :: Natural
$sel:ttl:SOA' :: SOA -> Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"TTL" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
ttl)]
      )