{-# 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.Primary
-- 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.Primary 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 primary Region of the endpoint.
--
-- /See:/ 'newPrimary' smart constructor.
data Primary = Primary'
  { -- | The ARN of the health check used by the endpoint to determine whether
    -- failover is triggered.
    Primary -> Text
healthCheck :: Prelude.Text
  }
  deriving (Primary -> Primary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Primary -> Primary -> Bool
$c/= :: Primary -> Primary -> Bool
== :: Primary -> Primary -> Bool
$c== :: Primary -> Primary -> Bool
Prelude.Eq, ReadPrec [Primary]
ReadPrec Primary
Int -> ReadS Primary
ReadS [Primary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Primary]
$creadListPrec :: ReadPrec [Primary]
readPrec :: ReadPrec Primary
$creadPrec :: ReadPrec Primary
readList :: ReadS [Primary]
$creadList :: ReadS [Primary]
readsPrec :: Int -> ReadS Primary
$creadsPrec :: Int -> ReadS Primary
Prelude.Read, Int -> Primary -> ShowS
[Primary] -> ShowS
Primary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Primary] -> ShowS
$cshowList :: [Primary] -> ShowS
show :: Primary -> String
$cshow :: Primary -> String
showsPrec :: Int -> Primary -> ShowS
$cshowsPrec :: Int -> Primary -> ShowS
Prelude.Show, forall x. Rep Primary x -> Primary
forall x. Primary -> Rep Primary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Primary x -> Primary
$cfrom :: forall x. Primary -> Rep Primary x
Prelude.Generic)

-- |
-- Create a value of 'Primary' 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:
--
-- 'healthCheck', 'primary_healthCheck' - The ARN of the health check used by the endpoint to determine whether
-- failover is triggered.
newPrimary ::
  -- | 'healthCheck'
  Prelude.Text ->
  Primary
newPrimary :: Text -> Primary
newPrimary Text
pHealthCheck_ =
  Primary' {$sel:healthCheck:Primary' :: Text
healthCheck = Text
pHealthCheck_}

-- | The ARN of the health check used by the endpoint to determine whether
-- failover is triggered.
primary_healthCheck :: Lens.Lens' Primary Prelude.Text
primary_healthCheck :: Lens' Primary Text
primary_healthCheck = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Primary' {Text
healthCheck :: Text
$sel:healthCheck:Primary' :: Primary -> Text
healthCheck} -> Text
healthCheck) (\s :: Primary
s@Primary' {} Text
a -> Primary
s {$sel:healthCheck:Primary' :: Text
healthCheck = Text
a} :: Primary)

instance Data.FromJSON Primary where
  parseJSON :: Value -> Parser Primary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Primary"
      ( \Object
x ->
          Text -> Primary
Primary' 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
"HealthCheck")
      )

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

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

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