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

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

-- | The Route 53 resource a DNS Target Resource record points to
--
-- /See:/ 'newR53ResourceRecord' smart constructor.
data R53ResourceRecord = R53ResourceRecord'
  { -- | The DNS target name
    R53ResourceRecord -> Maybe Text
domainName :: Prelude.Maybe Prelude.Text,
    -- | The Resource Record set id
    R53ResourceRecord -> Maybe Text
recordSetId :: Prelude.Maybe Prelude.Text
  }
  deriving (R53ResourceRecord -> R53ResourceRecord -> Bool
(R53ResourceRecord -> R53ResourceRecord -> Bool)
-> (R53ResourceRecord -> R53ResourceRecord -> Bool)
-> Eq R53ResourceRecord
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]
(Int -> ReadS R53ResourceRecord)
-> ReadS [R53ResourceRecord]
-> ReadPrec R53ResourceRecord
-> ReadPrec [R53ResourceRecord]
-> Read 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
(Int -> R53ResourceRecord -> ShowS)
-> (R53ResourceRecord -> String)
-> ([R53ResourceRecord] -> ShowS)
-> Show R53ResourceRecord
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. R53ResourceRecord -> Rep R53ResourceRecord x)
-> (forall x. Rep R53ResourceRecord x -> R53ResourceRecord)
-> Generic R53ResourceRecord
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 name
--
-- 'recordSetId', 'r53ResourceRecord_recordSetId' - The Resource Record set id
newR53ResourceRecord ::
  R53ResourceRecord
newR53ResourceRecord :: R53ResourceRecord
newR53ResourceRecord =
  R53ResourceRecord' :: Maybe Text -> Maybe Text -> R53ResourceRecord
R53ResourceRecord'
    { $sel:domainName:R53ResourceRecord' :: Maybe Text
domainName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:recordSetId:R53ResourceRecord' :: Maybe Text
recordSetId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The DNS target name
r53ResourceRecord_domainName :: Lens.Lens' R53ResourceRecord (Prelude.Maybe Prelude.Text)
r53ResourceRecord_domainName :: (Maybe Text -> f (Maybe Text))
-> R53ResourceRecord -> f R53ResourceRecord
r53ResourceRecord_domainName = (R53ResourceRecord -> Maybe Text)
-> (R53ResourceRecord -> Maybe Text -> R53ResourceRecord)
-> Lens
     R53ResourceRecord R53ResourceRecord (Maybe Text) (Maybe Text)
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 Resource Record set id
r53ResourceRecord_recordSetId :: Lens.Lens' R53ResourceRecord (Prelude.Maybe Prelude.Text)
r53ResourceRecord_recordSetId :: (Maybe Text -> f (Maybe Text))
-> R53ResourceRecord -> f R53ResourceRecord
r53ResourceRecord_recordSetId = (R53ResourceRecord -> Maybe Text)
-> (R53ResourceRecord -> Maybe Text -> R53ResourceRecord)
-> Lens
     R53ResourceRecord R53ResourceRecord (Maybe Text) (Maybe Text)
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 Core.FromJSON R53ResourceRecord where
  parseJSON :: Value -> Parser R53ResourceRecord
parseJSON =
    String
-> (Object -> Parser R53ResourceRecord)
-> Value
-> Parser R53ResourceRecord
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"R53ResourceRecord"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> R53ResourceRecord
R53ResourceRecord'
            (Maybe Text -> Maybe Text -> R53ResourceRecord)
-> Parser (Maybe Text) -> Parser (Maybe Text -> R53ResourceRecord)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"domainName")
            Parser (Maybe Text -> R53ResourceRecord)
-> Parser (Maybe Text) -> Parser R53ResourceRecord
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"recordSetId")
      )

instance Prelude.Hashable R53ResourceRecord

instance Prelude.NFData R53ResourceRecord

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"domainName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
domainName,
            (Text
"recordSetId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
recordSetId
          ]
      )