{-# 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.SSMContacts.Types.ContactTargetInfo
-- 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.SSMContacts.Types.ContactTargetInfo where

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

-- | The contact that Incident Manager is engaging during an incident.
--
-- /See:/ 'newContactTargetInfo' smart constructor.
data ContactTargetInfo = ContactTargetInfo'
  { -- | The Amazon Resource Name (ARN) of the contact.
    ContactTargetInfo -> Maybe Text
contactId :: Prelude.Maybe Prelude.Text,
    -- | A Boolean value determining if the contact\'s acknowledgement stops the
    -- progress of stages in the plan.
    ContactTargetInfo -> Bool
isEssential :: Prelude.Bool
  }
  deriving (ContactTargetInfo -> ContactTargetInfo -> Bool
(ContactTargetInfo -> ContactTargetInfo -> Bool)
-> (ContactTargetInfo -> ContactTargetInfo -> Bool)
-> Eq ContactTargetInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContactTargetInfo -> ContactTargetInfo -> Bool
$c/= :: ContactTargetInfo -> ContactTargetInfo -> Bool
== :: ContactTargetInfo -> ContactTargetInfo -> Bool
$c== :: ContactTargetInfo -> ContactTargetInfo -> Bool
Prelude.Eq, ReadPrec [ContactTargetInfo]
ReadPrec ContactTargetInfo
Int -> ReadS ContactTargetInfo
ReadS [ContactTargetInfo]
(Int -> ReadS ContactTargetInfo)
-> ReadS [ContactTargetInfo]
-> ReadPrec ContactTargetInfo
-> ReadPrec [ContactTargetInfo]
-> Read ContactTargetInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContactTargetInfo]
$creadListPrec :: ReadPrec [ContactTargetInfo]
readPrec :: ReadPrec ContactTargetInfo
$creadPrec :: ReadPrec ContactTargetInfo
readList :: ReadS [ContactTargetInfo]
$creadList :: ReadS [ContactTargetInfo]
readsPrec :: Int -> ReadS ContactTargetInfo
$creadsPrec :: Int -> ReadS ContactTargetInfo
Prelude.Read, Int -> ContactTargetInfo -> ShowS
[ContactTargetInfo] -> ShowS
ContactTargetInfo -> String
(Int -> ContactTargetInfo -> ShowS)
-> (ContactTargetInfo -> String)
-> ([ContactTargetInfo] -> ShowS)
-> Show ContactTargetInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContactTargetInfo] -> ShowS
$cshowList :: [ContactTargetInfo] -> ShowS
show :: ContactTargetInfo -> String
$cshow :: ContactTargetInfo -> String
showsPrec :: Int -> ContactTargetInfo -> ShowS
$cshowsPrec :: Int -> ContactTargetInfo -> ShowS
Prelude.Show, (forall x. ContactTargetInfo -> Rep ContactTargetInfo x)
-> (forall x. Rep ContactTargetInfo x -> ContactTargetInfo)
-> Generic ContactTargetInfo
forall x. Rep ContactTargetInfo x -> ContactTargetInfo
forall x. ContactTargetInfo -> Rep ContactTargetInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ContactTargetInfo x -> ContactTargetInfo
$cfrom :: forall x. ContactTargetInfo -> Rep ContactTargetInfo x
Prelude.Generic)

-- |
-- Create a value of 'ContactTargetInfo' 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:
--
-- 'contactId', 'contactTargetInfo_contactId' - The Amazon Resource Name (ARN) of the contact.
--
-- 'isEssential', 'contactTargetInfo_isEssential' - A Boolean value determining if the contact\'s acknowledgement stops the
-- progress of stages in the plan.
newContactTargetInfo ::
  -- | 'isEssential'
  Prelude.Bool ->
  ContactTargetInfo
newContactTargetInfo :: Bool -> ContactTargetInfo
newContactTargetInfo Bool
pIsEssential_ =
  ContactTargetInfo' :: Maybe Text -> Bool -> ContactTargetInfo
ContactTargetInfo'
    { $sel:contactId:ContactTargetInfo' :: Maybe Text
contactId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:isEssential:ContactTargetInfo' :: Bool
isEssential = Bool
pIsEssential_
    }

-- | The Amazon Resource Name (ARN) of the contact.
contactTargetInfo_contactId :: Lens.Lens' ContactTargetInfo (Prelude.Maybe Prelude.Text)
contactTargetInfo_contactId :: (Maybe Text -> f (Maybe Text))
-> ContactTargetInfo -> f ContactTargetInfo
contactTargetInfo_contactId = (ContactTargetInfo -> Maybe Text)
-> (ContactTargetInfo -> Maybe Text -> ContactTargetInfo)
-> Lens
     ContactTargetInfo ContactTargetInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContactTargetInfo' {Maybe Text
contactId :: Maybe Text
$sel:contactId:ContactTargetInfo' :: ContactTargetInfo -> Maybe Text
contactId} -> Maybe Text
contactId) (\s :: ContactTargetInfo
s@ContactTargetInfo' {} Maybe Text
a -> ContactTargetInfo
s {$sel:contactId:ContactTargetInfo' :: Maybe Text
contactId = Maybe Text
a} :: ContactTargetInfo)

-- | A Boolean value determining if the contact\'s acknowledgement stops the
-- progress of stages in the plan.
contactTargetInfo_isEssential :: Lens.Lens' ContactTargetInfo Prelude.Bool
contactTargetInfo_isEssential :: (Bool -> f Bool) -> ContactTargetInfo -> f ContactTargetInfo
contactTargetInfo_isEssential = (ContactTargetInfo -> Bool)
-> (ContactTargetInfo -> Bool -> ContactTargetInfo)
-> Lens ContactTargetInfo ContactTargetInfo Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContactTargetInfo' {Bool
isEssential :: Bool
$sel:isEssential:ContactTargetInfo' :: ContactTargetInfo -> Bool
isEssential} -> Bool
isEssential) (\s :: ContactTargetInfo
s@ContactTargetInfo' {} Bool
a -> ContactTargetInfo
s {$sel:isEssential:ContactTargetInfo' :: Bool
isEssential = Bool
a} :: ContactTargetInfo)

instance Core.FromJSON ContactTargetInfo where
  parseJSON :: Value -> Parser ContactTargetInfo
parseJSON =
    String
-> (Object -> Parser ContactTargetInfo)
-> Value
-> Parser ContactTargetInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ContactTargetInfo"
      ( \Object
x ->
          Maybe Text -> Bool -> ContactTargetInfo
ContactTargetInfo'
            (Maybe Text -> Bool -> ContactTargetInfo)
-> Parser (Maybe Text) -> Parser (Bool -> ContactTargetInfo)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ContactId")
            Parser (Bool -> ContactTargetInfo)
-> Parser Bool -> Parser ContactTargetInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"IsEssential")
      )

instance Prelude.Hashable ContactTargetInfo

instance Prelude.NFData ContactTargetInfo

instance Core.ToJSON ContactTargetInfo where
  toJSON :: ContactTargetInfo -> Value
toJSON ContactTargetInfo' {Bool
Maybe Text
isEssential :: Bool
contactId :: Maybe Text
$sel:isEssential:ContactTargetInfo' :: ContactTargetInfo -> Bool
$sel:contactId:ContactTargetInfo' :: ContactTargetInfo -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ContactId" 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
contactId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"IsEssential" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
isEssential)
          ]
      )