{-# 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.TargetResource
-- 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.TargetResource where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Route53RecoveryReadiness.Types.NLBResource
import Amazonka.Route53RecoveryReadiness.Types.R53ResourceRecord

-- | The target resource the R53 record points to
--
-- /See:/ 'newTargetResource' smart constructor.
data TargetResource = TargetResource'
  { TargetResource -> Maybe R53ResourceRecord
r53Resource :: Prelude.Maybe R53ResourceRecord,
    TargetResource -> Maybe NLBResource
nLBResource :: Prelude.Maybe NLBResource
  }
  deriving (TargetResource -> TargetResource -> Bool
(TargetResource -> TargetResource -> Bool)
-> (TargetResource -> TargetResource -> Bool) -> Eq TargetResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TargetResource -> TargetResource -> Bool
$c/= :: TargetResource -> TargetResource -> Bool
== :: TargetResource -> TargetResource -> Bool
$c== :: TargetResource -> TargetResource -> Bool
Prelude.Eq, ReadPrec [TargetResource]
ReadPrec TargetResource
Int -> ReadS TargetResource
ReadS [TargetResource]
(Int -> ReadS TargetResource)
-> ReadS [TargetResource]
-> ReadPrec TargetResource
-> ReadPrec [TargetResource]
-> Read TargetResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TargetResource]
$creadListPrec :: ReadPrec [TargetResource]
readPrec :: ReadPrec TargetResource
$creadPrec :: ReadPrec TargetResource
readList :: ReadS [TargetResource]
$creadList :: ReadS [TargetResource]
readsPrec :: Int -> ReadS TargetResource
$creadsPrec :: Int -> ReadS TargetResource
Prelude.Read, Int -> TargetResource -> ShowS
[TargetResource] -> ShowS
TargetResource -> String
(Int -> TargetResource -> ShowS)
-> (TargetResource -> String)
-> ([TargetResource] -> ShowS)
-> Show TargetResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TargetResource] -> ShowS
$cshowList :: [TargetResource] -> ShowS
show :: TargetResource -> String
$cshow :: TargetResource -> String
showsPrec :: Int -> TargetResource -> ShowS
$cshowsPrec :: Int -> TargetResource -> ShowS
Prelude.Show, (forall x. TargetResource -> Rep TargetResource x)
-> (forall x. Rep TargetResource x -> TargetResource)
-> Generic TargetResource
forall x. Rep TargetResource x -> TargetResource
forall x. TargetResource -> Rep TargetResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TargetResource x -> TargetResource
$cfrom :: forall x. TargetResource -> Rep TargetResource x
Prelude.Generic)

-- |
-- Create a value of 'TargetResource' 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:
--
-- 'r53Resource', 'targetResource_r53Resource' - Undocumented member.
--
-- 'nLBResource', 'targetResource_nLBResource' - Undocumented member.
newTargetResource ::
  TargetResource
newTargetResource :: TargetResource
newTargetResource =
  TargetResource' :: Maybe R53ResourceRecord -> Maybe NLBResource -> TargetResource
TargetResource'
    { $sel:r53Resource:TargetResource' :: Maybe R53ResourceRecord
r53Resource = Maybe R53ResourceRecord
forall a. Maybe a
Prelude.Nothing,
      $sel:nLBResource:TargetResource' :: Maybe NLBResource
nLBResource = Maybe NLBResource
forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
targetResource_r53Resource :: Lens.Lens' TargetResource (Prelude.Maybe R53ResourceRecord)
targetResource_r53Resource :: (Maybe R53ResourceRecord -> f (Maybe R53ResourceRecord))
-> TargetResource -> f TargetResource
targetResource_r53Resource = (TargetResource -> Maybe R53ResourceRecord)
-> (TargetResource -> Maybe R53ResourceRecord -> TargetResource)
-> Lens
     TargetResource
     TargetResource
     (Maybe R53ResourceRecord)
     (Maybe R53ResourceRecord)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetResource' {Maybe R53ResourceRecord
r53Resource :: Maybe R53ResourceRecord
$sel:r53Resource:TargetResource' :: TargetResource -> Maybe R53ResourceRecord
r53Resource} -> Maybe R53ResourceRecord
r53Resource) (\s :: TargetResource
s@TargetResource' {} Maybe R53ResourceRecord
a -> TargetResource
s {$sel:r53Resource:TargetResource' :: Maybe R53ResourceRecord
r53Resource = Maybe R53ResourceRecord
a} :: TargetResource)

-- | Undocumented member.
targetResource_nLBResource :: Lens.Lens' TargetResource (Prelude.Maybe NLBResource)
targetResource_nLBResource :: (Maybe NLBResource -> f (Maybe NLBResource))
-> TargetResource -> f TargetResource
targetResource_nLBResource = (TargetResource -> Maybe NLBResource)
-> (TargetResource -> Maybe NLBResource -> TargetResource)
-> Lens
     TargetResource
     TargetResource
     (Maybe NLBResource)
     (Maybe NLBResource)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetResource' {Maybe NLBResource
nLBResource :: Maybe NLBResource
$sel:nLBResource:TargetResource' :: TargetResource -> Maybe NLBResource
nLBResource} -> Maybe NLBResource
nLBResource) (\s :: TargetResource
s@TargetResource' {} Maybe NLBResource
a -> TargetResource
s {$sel:nLBResource:TargetResource' :: Maybe NLBResource
nLBResource = Maybe NLBResource
a} :: TargetResource)

instance Core.FromJSON TargetResource where
  parseJSON :: Value -> Parser TargetResource
parseJSON =
    String
-> (Object -> Parser TargetResource)
-> Value
-> Parser TargetResource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TargetResource"
      ( \Object
x ->
          Maybe R53ResourceRecord -> Maybe NLBResource -> TargetResource
TargetResource'
            (Maybe R53ResourceRecord -> Maybe NLBResource -> TargetResource)
-> Parser (Maybe R53ResourceRecord)
-> Parser (Maybe NLBResource -> TargetResource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe R53ResourceRecord)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"r53Resource")
            Parser (Maybe NLBResource -> TargetResource)
-> Parser (Maybe NLBResource) -> Parser TargetResource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe NLBResource)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"nLBResource")
      )

instance Prelude.Hashable TargetResource

instance Prelude.NFData TargetResource

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