{-# 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.CloudWatchEvents.Types.ReplayDestination
-- 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.CloudWatchEvents.Types.ReplayDestination where

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

-- | A @ReplayDestination@ object that contains details about a replay.
--
-- /See:/ 'newReplayDestination' smart constructor.
data ReplayDestination = ReplayDestination'
  { -- | A list of ARNs for rules to replay events to.
    ReplayDestination -> Maybe [Text]
filterArns :: Prelude.Maybe [Prelude.Text],
    -- | The ARN of the event bus to replay event to. You can replay events only
    -- to the event bus specified to create the archive.
    ReplayDestination -> Text
arn :: Prelude.Text
  }
  deriving (ReplayDestination -> ReplayDestination -> Bool
(ReplayDestination -> ReplayDestination -> Bool)
-> (ReplayDestination -> ReplayDestination -> Bool)
-> Eq ReplayDestination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReplayDestination -> ReplayDestination -> Bool
$c/= :: ReplayDestination -> ReplayDestination -> Bool
== :: ReplayDestination -> ReplayDestination -> Bool
$c== :: ReplayDestination -> ReplayDestination -> Bool
Prelude.Eq, ReadPrec [ReplayDestination]
ReadPrec ReplayDestination
Int -> ReadS ReplayDestination
ReadS [ReplayDestination]
(Int -> ReadS ReplayDestination)
-> ReadS [ReplayDestination]
-> ReadPrec ReplayDestination
-> ReadPrec [ReplayDestination]
-> Read ReplayDestination
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReplayDestination]
$creadListPrec :: ReadPrec [ReplayDestination]
readPrec :: ReadPrec ReplayDestination
$creadPrec :: ReadPrec ReplayDestination
readList :: ReadS [ReplayDestination]
$creadList :: ReadS [ReplayDestination]
readsPrec :: Int -> ReadS ReplayDestination
$creadsPrec :: Int -> ReadS ReplayDestination
Prelude.Read, Int -> ReplayDestination -> ShowS
[ReplayDestination] -> ShowS
ReplayDestination -> String
(Int -> ReplayDestination -> ShowS)
-> (ReplayDestination -> String)
-> ([ReplayDestination] -> ShowS)
-> Show ReplayDestination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReplayDestination] -> ShowS
$cshowList :: [ReplayDestination] -> ShowS
show :: ReplayDestination -> String
$cshow :: ReplayDestination -> String
showsPrec :: Int -> ReplayDestination -> ShowS
$cshowsPrec :: Int -> ReplayDestination -> ShowS
Prelude.Show, (forall x. ReplayDestination -> Rep ReplayDestination x)
-> (forall x. Rep ReplayDestination x -> ReplayDestination)
-> Generic ReplayDestination
forall x. Rep ReplayDestination x -> ReplayDestination
forall x. ReplayDestination -> Rep ReplayDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReplayDestination x -> ReplayDestination
$cfrom :: forall x. ReplayDestination -> Rep ReplayDestination x
Prelude.Generic)

-- |
-- Create a value of 'ReplayDestination' 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:
--
-- 'filterArns', 'replayDestination_filterArns' - A list of ARNs for rules to replay events to.
--
-- 'arn', 'replayDestination_arn' - The ARN of the event bus to replay event to. You can replay events only
-- to the event bus specified to create the archive.
newReplayDestination ::
  -- | 'arn'
  Prelude.Text ->
  ReplayDestination
newReplayDestination :: Text -> ReplayDestination
newReplayDestination Text
pArn_ =
  ReplayDestination' :: Maybe [Text] -> Text -> ReplayDestination
ReplayDestination'
    { $sel:filterArns:ReplayDestination' :: Maybe [Text]
filterArns = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:ReplayDestination' :: Text
arn = Text
pArn_
    }

-- | A list of ARNs for rules to replay events to.
replayDestination_filterArns :: Lens.Lens' ReplayDestination (Prelude.Maybe [Prelude.Text])
replayDestination_filterArns :: (Maybe [Text] -> f (Maybe [Text]))
-> ReplayDestination -> f ReplayDestination
replayDestination_filterArns = (ReplayDestination -> Maybe [Text])
-> (ReplayDestination -> Maybe [Text] -> ReplayDestination)
-> Lens
     ReplayDestination ReplayDestination (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplayDestination' {Maybe [Text]
filterArns :: Maybe [Text]
$sel:filterArns:ReplayDestination' :: ReplayDestination -> Maybe [Text]
filterArns} -> Maybe [Text]
filterArns) (\s :: ReplayDestination
s@ReplayDestination' {} Maybe [Text]
a -> ReplayDestination
s {$sel:filterArns:ReplayDestination' :: Maybe [Text]
filterArns = Maybe [Text]
a} :: ReplayDestination) ((Maybe [Text] -> f (Maybe [Text]))
 -> ReplayDestination -> f ReplayDestination)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ReplayDestination
-> f ReplayDestination
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ARN of the event bus to replay event to. You can replay events only
-- to the event bus specified to create the archive.
replayDestination_arn :: Lens.Lens' ReplayDestination Prelude.Text
replayDestination_arn :: (Text -> f Text) -> ReplayDestination -> f ReplayDestination
replayDestination_arn = (ReplayDestination -> Text)
-> (ReplayDestination -> Text -> ReplayDestination)
-> Lens ReplayDestination ReplayDestination Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplayDestination' {Text
arn :: Text
$sel:arn:ReplayDestination' :: ReplayDestination -> Text
arn} -> Text
arn) (\s :: ReplayDestination
s@ReplayDestination' {} Text
a -> ReplayDestination
s {$sel:arn:ReplayDestination' :: Text
arn = Text
a} :: ReplayDestination)

instance Core.FromJSON ReplayDestination where
  parseJSON :: Value -> Parser ReplayDestination
parseJSON =
    String
-> (Object -> Parser ReplayDestination)
-> Value
-> Parser ReplayDestination
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ReplayDestination"
      ( \Object
x ->
          Maybe [Text] -> Text -> ReplayDestination
ReplayDestination'
            (Maybe [Text] -> Text -> ReplayDestination)
-> Parser (Maybe [Text]) -> Parser (Text -> ReplayDestination)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FilterArns" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Text -> ReplayDestination)
-> Parser Text -> Parser ReplayDestination
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Arn")
      )

instance Prelude.Hashable ReplayDestination

instance Prelude.NFData ReplayDestination

instance Core.ToJSON ReplayDestination where
  toJSON :: ReplayDestination -> Value
toJSON ReplayDestination' {Maybe [Text]
Text
arn :: Text
filterArns :: Maybe [Text]
$sel:arn:ReplayDestination' :: ReplayDestination -> Text
$sel:filterArns:ReplayDestination' :: ReplayDestination -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"FilterArns" 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]
filterArns,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Arn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
arn)
          ]
      )