{-# 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.ElastiCache.Types.DestinationDetails
-- 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.ElastiCache.Types.DestinationDetails where

import qualified Amazonka.Core as Core
import Amazonka.ElastiCache.Types.CloudWatchLogsDestinationDetails
import Amazonka.ElastiCache.Types.KinesisFirehoseDestinationDetails
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Configuration details of either a CloudWatch Logs destination or Kinesis
-- Data Firehose destination.
--
-- /See:/ 'newDestinationDetails' smart constructor.
data DestinationDetails = DestinationDetails'
  { -- | The configuration details of the CloudWatch Logs destination.
    DestinationDetails -> Maybe CloudWatchLogsDestinationDetails
cloudWatchLogsDetails :: Prelude.Maybe CloudWatchLogsDestinationDetails,
    -- | The configuration details of the Kinesis Data Firehose destination.
    DestinationDetails -> Maybe KinesisFirehoseDestinationDetails
kinesisFirehoseDetails :: Prelude.Maybe KinesisFirehoseDestinationDetails
  }
  deriving (DestinationDetails -> DestinationDetails -> Bool
(DestinationDetails -> DestinationDetails -> Bool)
-> (DestinationDetails -> DestinationDetails -> Bool)
-> Eq DestinationDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DestinationDetails -> DestinationDetails -> Bool
$c/= :: DestinationDetails -> DestinationDetails -> Bool
== :: DestinationDetails -> DestinationDetails -> Bool
$c== :: DestinationDetails -> DestinationDetails -> Bool
Prelude.Eq, ReadPrec [DestinationDetails]
ReadPrec DestinationDetails
Int -> ReadS DestinationDetails
ReadS [DestinationDetails]
(Int -> ReadS DestinationDetails)
-> ReadS [DestinationDetails]
-> ReadPrec DestinationDetails
-> ReadPrec [DestinationDetails]
-> Read DestinationDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DestinationDetails]
$creadListPrec :: ReadPrec [DestinationDetails]
readPrec :: ReadPrec DestinationDetails
$creadPrec :: ReadPrec DestinationDetails
readList :: ReadS [DestinationDetails]
$creadList :: ReadS [DestinationDetails]
readsPrec :: Int -> ReadS DestinationDetails
$creadsPrec :: Int -> ReadS DestinationDetails
Prelude.Read, Int -> DestinationDetails -> ShowS
[DestinationDetails] -> ShowS
DestinationDetails -> String
(Int -> DestinationDetails -> ShowS)
-> (DestinationDetails -> String)
-> ([DestinationDetails] -> ShowS)
-> Show DestinationDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DestinationDetails] -> ShowS
$cshowList :: [DestinationDetails] -> ShowS
show :: DestinationDetails -> String
$cshow :: DestinationDetails -> String
showsPrec :: Int -> DestinationDetails -> ShowS
$cshowsPrec :: Int -> DestinationDetails -> ShowS
Prelude.Show, (forall x. DestinationDetails -> Rep DestinationDetails x)
-> (forall x. Rep DestinationDetails x -> DestinationDetails)
-> Generic DestinationDetails
forall x. Rep DestinationDetails x -> DestinationDetails
forall x. DestinationDetails -> Rep DestinationDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DestinationDetails x -> DestinationDetails
$cfrom :: forall x. DestinationDetails -> Rep DestinationDetails x
Prelude.Generic)

-- |
-- Create a value of 'DestinationDetails' 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:
--
-- 'cloudWatchLogsDetails', 'destinationDetails_cloudWatchLogsDetails' - The configuration details of the CloudWatch Logs destination.
--
-- 'kinesisFirehoseDetails', 'destinationDetails_kinesisFirehoseDetails' - The configuration details of the Kinesis Data Firehose destination.
newDestinationDetails ::
  DestinationDetails
newDestinationDetails :: DestinationDetails
newDestinationDetails =
  DestinationDetails' :: Maybe CloudWatchLogsDestinationDetails
-> Maybe KinesisFirehoseDestinationDetails -> DestinationDetails
DestinationDetails'
    { $sel:cloudWatchLogsDetails:DestinationDetails' :: Maybe CloudWatchLogsDestinationDetails
cloudWatchLogsDetails =
        Maybe CloudWatchLogsDestinationDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:kinesisFirehoseDetails:DestinationDetails' :: Maybe KinesisFirehoseDestinationDetails
kinesisFirehoseDetails = Maybe KinesisFirehoseDestinationDetails
forall a. Maybe a
Prelude.Nothing
    }

-- | The configuration details of the CloudWatch Logs destination.
destinationDetails_cloudWatchLogsDetails :: Lens.Lens' DestinationDetails (Prelude.Maybe CloudWatchLogsDestinationDetails)
destinationDetails_cloudWatchLogsDetails :: (Maybe CloudWatchLogsDestinationDetails
 -> f (Maybe CloudWatchLogsDestinationDetails))
-> DestinationDetails -> f DestinationDetails
destinationDetails_cloudWatchLogsDetails = (DestinationDetails -> Maybe CloudWatchLogsDestinationDetails)
-> (DestinationDetails
    -> Maybe CloudWatchLogsDestinationDetails -> DestinationDetails)
-> Lens
     DestinationDetails
     DestinationDetails
     (Maybe CloudWatchLogsDestinationDetails)
     (Maybe CloudWatchLogsDestinationDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DestinationDetails' {Maybe CloudWatchLogsDestinationDetails
cloudWatchLogsDetails :: Maybe CloudWatchLogsDestinationDetails
$sel:cloudWatchLogsDetails:DestinationDetails' :: DestinationDetails -> Maybe CloudWatchLogsDestinationDetails
cloudWatchLogsDetails} -> Maybe CloudWatchLogsDestinationDetails
cloudWatchLogsDetails) (\s :: DestinationDetails
s@DestinationDetails' {} Maybe CloudWatchLogsDestinationDetails
a -> DestinationDetails
s {$sel:cloudWatchLogsDetails:DestinationDetails' :: Maybe CloudWatchLogsDestinationDetails
cloudWatchLogsDetails = Maybe CloudWatchLogsDestinationDetails
a} :: DestinationDetails)

-- | The configuration details of the Kinesis Data Firehose destination.
destinationDetails_kinesisFirehoseDetails :: Lens.Lens' DestinationDetails (Prelude.Maybe KinesisFirehoseDestinationDetails)
destinationDetails_kinesisFirehoseDetails :: (Maybe KinesisFirehoseDestinationDetails
 -> f (Maybe KinesisFirehoseDestinationDetails))
-> DestinationDetails -> f DestinationDetails
destinationDetails_kinesisFirehoseDetails = (DestinationDetails -> Maybe KinesisFirehoseDestinationDetails)
-> (DestinationDetails
    -> Maybe KinesisFirehoseDestinationDetails -> DestinationDetails)
-> Lens
     DestinationDetails
     DestinationDetails
     (Maybe KinesisFirehoseDestinationDetails)
     (Maybe KinesisFirehoseDestinationDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DestinationDetails' {Maybe KinesisFirehoseDestinationDetails
kinesisFirehoseDetails :: Maybe KinesisFirehoseDestinationDetails
$sel:kinesisFirehoseDetails:DestinationDetails' :: DestinationDetails -> Maybe KinesisFirehoseDestinationDetails
kinesisFirehoseDetails} -> Maybe KinesisFirehoseDestinationDetails
kinesisFirehoseDetails) (\s :: DestinationDetails
s@DestinationDetails' {} Maybe KinesisFirehoseDestinationDetails
a -> DestinationDetails
s {$sel:kinesisFirehoseDetails:DestinationDetails' :: Maybe KinesisFirehoseDestinationDetails
kinesisFirehoseDetails = Maybe KinesisFirehoseDestinationDetails
a} :: DestinationDetails)

instance Core.FromXML DestinationDetails where
  parseXML :: [Node] -> Either String DestinationDetails
parseXML [Node]
x =
    Maybe CloudWatchLogsDestinationDetails
-> Maybe KinesisFirehoseDestinationDetails -> DestinationDetails
DestinationDetails'
      (Maybe CloudWatchLogsDestinationDetails
 -> Maybe KinesisFirehoseDestinationDetails -> DestinationDetails)
-> Either String (Maybe CloudWatchLogsDestinationDetails)
-> Either
     String
     (Maybe KinesisFirehoseDestinationDetails -> DestinationDetails)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node]
-> Text -> Either String (Maybe CloudWatchLogsDestinationDetails)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"CloudWatchLogsDetails")
      Either
  String
  (Maybe KinesisFirehoseDestinationDetails -> DestinationDetails)
-> Either String (Maybe KinesisFirehoseDestinationDetails)
-> Either String DestinationDetails
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node]
-> Text -> Either String (Maybe KinesisFirehoseDestinationDetails)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"KinesisFirehoseDetails")

instance Prelude.Hashable DestinationDetails

instance Prelude.NFData DestinationDetails

instance Core.ToQuery DestinationDetails where
  toQuery :: DestinationDetails -> QueryString
toQuery DestinationDetails' {Maybe CloudWatchLogsDestinationDetails
Maybe KinesisFirehoseDestinationDetails
kinesisFirehoseDetails :: Maybe KinesisFirehoseDestinationDetails
cloudWatchLogsDetails :: Maybe CloudWatchLogsDestinationDetails
$sel:kinesisFirehoseDetails:DestinationDetails' :: DestinationDetails -> Maybe KinesisFirehoseDestinationDetails
$sel:cloudWatchLogsDetails:DestinationDetails' :: DestinationDetails -> Maybe CloudWatchLogsDestinationDetails
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"CloudWatchLogsDetails"
          ByteString -> Maybe CloudWatchLogsDestinationDetails -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe CloudWatchLogsDestinationDetails
cloudWatchLogsDetails,
        ByteString
"KinesisFirehoseDetails"
          ByteString
-> Maybe KinesisFirehoseDestinationDetails -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe KinesisFirehoseDestinationDetails
kinesisFirehoseDetails
      ]