{-# 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.Secondary
-- 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.Secondary 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

-- | The secondary Region that processes events when failover is triggered or
-- replication is enabled.
--
-- /See:/ 'newSecondary' smart constructor.
data Secondary = Secondary'
  { -- | Defines the secondary Region.
    Secondary -> Text
route :: Prelude.Text
  }
  deriving (Secondary -> Secondary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Secondary -> Secondary -> Bool
$c/= :: Secondary -> Secondary -> Bool
== :: Secondary -> Secondary -> Bool
$c== :: Secondary -> Secondary -> Bool
Prelude.Eq, ReadPrec [Secondary]
ReadPrec Secondary
Int -> ReadS Secondary
ReadS [Secondary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Secondary]
$creadListPrec :: ReadPrec [Secondary]
readPrec :: ReadPrec Secondary
$creadPrec :: ReadPrec Secondary
readList :: ReadS [Secondary]
$creadList :: ReadS [Secondary]
readsPrec :: Int -> ReadS Secondary
$creadsPrec :: Int -> ReadS Secondary
Prelude.Read, Int -> Secondary -> ShowS
[Secondary] -> ShowS
Secondary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Secondary] -> ShowS
$cshowList :: [Secondary] -> ShowS
show :: Secondary -> String
$cshow :: Secondary -> String
showsPrec :: Int -> Secondary -> ShowS
$cshowsPrec :: Int -> Secondary -> ShowS
Prelude.Show, forall x. Rep Secondary x -> Secondary
forall x. Secondary -> Rep Secondary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Secondary x -> Secondary
$cfrom :: forall x. Secondary -> Rep Secondary x
Prelude.Generic)

-- |
-- Create a value of 'Secondary' 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:
--
-- 'route', 'secondary_route' - Defines the secondary Region.
newSecondary ::
  -- | 'route'
  Prelude.Text ->
  Secondary
newSecondary :: Text -> Secondary
newSecondary Text
pRoute_ = Secondary' {$sel:route:Secondary' :: Text
route = Text
pRoute_}

-- | Defines the secondary Region.
secondary_route :: Lens.Lens' Secondary Prelude.Text
secondary_route :: Lens' Secondary Text
secondary_route = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Secondary' {Text
route :: Text
$sel:route:Secondary' :: Secondary -> Text
route} -> Text
route) (\s :: Secondary
s@Secondary' {} Text
a -> Secondary
s {$sel:route:Secondary' :: Text
route = Text
a} :: Secondary)

instance Data.FromJSON Secondary where
  parseJSON :: Value -> Parser Secondary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Secondary"
      (\Object
x -> Text -> Secondary
Secondary' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Route"))

instance Prelude.Hashable Secondary where
  hashWithSalt :: Int -> Secondary -> Int
hashWithSalt Int
_salt Secondary' {Text
route :: Text
$sel:route:Secondary' :: Secondary -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
route

instance Prelude.NFData Secondary where
  rnf :: Secondary -> ()
rnf Secondary' {Text
route :: Text
$sel:route:Secondary' :: Secondary -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
route

instance Data.ToJSON Secondary where
  toJSON :: Secondary -> Value
toJSON Secondary' {Text
route :: Text
$sel:route:Secondary' :: Secondary -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"Route" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
route)]
      )