{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CloudWatchEvents.Types.ReplayDestination 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

-- | 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
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]
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
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. 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'
    { $sel:filterArns:ReplayDestination' :: Maybe [Text]
filterArns = 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 :: Lens' ReplayDestination (Maybe [Text])
replayDestination_filterArns = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' ReplayDestination Text
replayDestination_arn = 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 Data.FromJSON ReplayDestination where
  parseJSON :: Value -> Parser ReplayDestination
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ReplayDestination"
      ( \Object
x ->
          Maybe [Text] -> Text -> ReplayDestination
ReplayDestination'
            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
"FilterArns" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Arn")
      )

instance Prelude.Hashable ReplayDestination where
  hashWithSalt :: Int -> ReplayDestination -> Int
hashWithSalt Int
_salt ReplayDestination' {Maybe [Text]
Text
arn :: Text
filterArns :: Maybe [Text]
$sel:arn:ReplayDestination' :: ReplayDestination -> Text
$sel:filterArns:ReplayDestination' :: ReplayDestination -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
filterArns
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn

instance Prelude.NFData ReplayDestination where
  rnf :: ReplayDestination -> ()
rnf ReplayDestination' {Maybe [Text]
Text
arn :: Text
filterArns :: Maybe [Text]
$sel:arn:ReplayDestination' :: ReplayDestination -> Text
$sel:filterArns:ReplayDestination' :: ReplayDestination -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
filterArns
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
arn

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"FilterArns" 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]
filterArns,
            forall a. a -> Maybe a
Prelude.Just (Key
"Arn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
arn)
          ]
      )