{-# 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.Route53RecoveryReadiness.Types.R53ResourceRecord
-- 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.Route53RecoveryReadiness.Types.R53ResourceRecord 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

-- | The Route 53 resource that a DNS target resource record points to.
--
-- /See:/ 'newR53ResourceRecord' smart constructor.
data R53ResourceRecord = R53ResourceRecord'
  { -- | The DNS target domain name.
    R53ResourceRecord -> Maybe Text
domainName :: Prelude.Maybe Prelude.Text,
    -- | The Route 53 Resource Record Set ID.
    R53ResourceRecord -> Maybe Text
recordSetId :: Prelude.Maybe Prelude.Text
  }
  deriving (R53ResourceRecord -> R53ResourceRecord -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: R53ResourceRecord -> R53ResourceRecord -> Bool
$c/= :: R53ResourceRecord -> R53ResourceRecord -> Bool
== :: R53ResourceRecord -> R53ResourceRecord -> Bool
$c== :: R53ResourceRecord -> R53ResourceRecord -> Bool
Prelude.Eq, ReadPrec [R53ResourceRecord]
ReadPrec R53ResourceRecord
Int -> ReadS R53ResourceRecord
ReadS [R53ResourceRecord]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [R53ResourceRecord]
$creadListPrec :: ReadPrec [R53ResourceRecord]
readPrec :: ReadPrec R53ResourceRecord
$creadPrec :: ReadPrec R53ResourceRecord
readList :: ReadS [R53ResourceRecord]
$creadList :: ReadS [R53ResourceRecord]
readsPrec :: Int -> ReadS R53ResourceRecord
$creadsPrec :: Int -> ReadS R53ResourceRecord
Prelude.Read, Int -> R53ResourceRecord -> ShowS
[R53ResourceRecord] -> ShowS
R53ResourceRecord -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [R53ResourceRecord] -> ShowS
$cshowList :: [R53ResourceRecord] -> ShowS
show :: R53ResourceRecord -> String
$cshow :: R53ResourceRecord -> String
showsPrec :: Int -> R53ResourceRecord -> ShowS
$cshowsPrec :: Int -> R53ResourceRecord -> ShowS
Prelude.Show, forall x. Rep R53ResourceRecord x -> R53ResourceRecord
forall x. R53ResourceRecord -> Rep R53ResourceRecord x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep R53ResourceRecord x -> R53ResourceRecord
$cfrom :: forall x. R53ResourceRecord -> Rep R53ResourceRecord x
Prelude.Generic)

-- |
-- Create a value of 'R53ResourceRecord' 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:
--
-- 'domainName', 'r53ResourceRecord_domainName' - The DNS target domain name.
--
-- 'recordSetId', 'r53ResourceRecord_recordSetId' - The Route 53 Resource Record Set ID.
newR53ResourceRecord ::
  R53ResourceRecord
newR53ResourceRecord :: R53ResourceRecord
newR53ResourceRecord =
  R53ResourceRecord'
    { $sel:domainName:R53ResourceRecord' :: Maybe Text
domainName = forall a. Maybe a
Prelude.Nothing,
      $sel:recordSetId:R53ResourceRecord' :: Maybe Text
recordSetId = forall a. Maybe a
Prelude.Nothing
    }

-- | The DNS target domain name.
r53ResourceRecord_domainName :: Lens.Lens' R53ResourceRecord (Prelude.Maybe Prelude.Text)
r53ResourceRecord_domainName :: Lens' R53ResourceRecord (Maybe Text)
r53ResourceRecord_domainName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\R53ResourceRecord' {Maybe Text
domainName :: Maybe Text
$sel:domainName:R53ResourceRecord' :: R53ResourceRecord -> Maybe Text
domainName} -> Maybe Text
domainName) (\s :: R53ResourceRecord
s@R53ResourceRecord' {} Maybe Text
a -> R53ResourceRecord
s {$sel:domainName:R53ResourceRecord' :: Maybe Text
domainName = Maybe Text
a} :: R53ResourceRecord)

-- | The Route 53 Resource Record Set ID.
r53ResourceRecord_recordSetId :: Lens.Lens' R53ResourceRecord (Prelude.Maybe Prelude.Text)
r53ResourceRecord_recordSetId :: Lens' R53ResourceRecord (Maybe Text)
r53ResourceRecord_recordSetId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\R53ResourceRecord' {Maybe Text
recordSetId :: Maybe Text
$sel:recordSetId:R53ResourceRecord' :: R53ResourceRecord -> Maybe Text
recordSetId} -> Maybe Text
recordSetId) (\s :: R53ResourceRecord
s@R53ResourceRecord' {} Maybe Text
a -> R53ResourceRecord
s {$sel:recordSetId:R53ResourceRecord' :: Maybe Text
recordSetId = Maybe Text
a} :: R53ResourceRecord)

instance Data.FromJSON R53ResourceRecord where
  parseJSON :: Value -> Parser R53ResourceRecord
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"R53ResourceRecord"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> R53ResourceRecord
R53ResourceRecord'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"domainName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"recordSetId")
      )

instance Prelude.Hashable R53ResourceRecord where
  hashWithSalt :: Int -> R53ResourceRecord -> Int
hashWithSalt Int
_salt R53ResourceRecord' {Maybe Text
recordSetId :: Maybe Text
domainName :: Maybe Text
$sel:recordSetId:R53ResourceRecord' :: R53ResourceRecord -> Maybe Text
$sel:domainName:R53ResourceRecord' :: R53ResourceRecord -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
domainName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
recordSetId

instance Prelude.NFData R53ResourceRecord where
  rnf :: R53ResourceRecord -> ()
rnf R53ResourceRecord' {Maybe Text
recordSetId :: Maybe Text
domainName :: Maybe Text
$sel:recordSetId:R53ResourceRecord' :: R53ResourceRecord -> Maybe Text
$sel:domainName:R53ResourceRecord' :: R53ResourceRecord -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
domainName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
recordSetId

instance Data.ToJSON R53ResourceRecord where
  toJSON :: R53ResourceRecord -> Value
toJSON R53ResourceRecord' {Maybe Text
recordSetId :: Maybe Text
domainName :: Maybe Text
$sel:recordSetId:R53ResourceRecord' :: R53ResourceRecord -> Maybe Text
$sel:domainName:R53ResourceRecord' :: R53ResourceRecord -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"domainName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
domainName,
            (Key
"recordSetId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
recordSetId
          ]
      )