{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Route53AutoNaming.Types.SOA where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(SOA -> SOA -> Bool) -> (SOA -> SOA -> Bool) -> Eq SOA
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]
(Int -> ReadS SOA)
-> ReadS [SOA] -> ReadPrec SOA -> ReadPrec [SOA] -> Read 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
(Int -> SOA -> ShowS)
-> (SOA -> String) -> ([SOA] -> ShowS) -> Show SOA
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. SOA -> Rep SOA x)
-> (forall x. Rep SOA x -> SOA) -> Generic SOA
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' :: Natural -> SOA
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 :: (Natural -> f Natural) -> SOA -> f SOA
soa_ttl = (SOA -> Natural)
-> (SOA -> Natural -> SOA) -> Lens SOA SOA Natural Natural
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 Core.FromJSON SOA where
  parseJSON :: Value -> Parser SOA
parseJSON =
    String -> (Object -> Parser SOA) -> Value -> Parser SOA
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SOA"
      (\Object
x -> Natural -> SOA
SOA' (Natural -> SOA) -> Parser Natural -> Parser SOA
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"TTL"))

instance Prelude.Hashable SOA

instance Prelude.NFData SOA

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