{-# 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.Target
-- 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.SSMContacts.Types.Target 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
import Amazonka.SSMContacts.Types.ChannelTargetInfo
import Amazonka.SSMContacts.Types.ContactTargetInfo

-- | The contact or contact channel that\'s being engaged.
--
-- /See:/ 'newTarget' smart constructor.
data Target = Target'
  { -- | Information about the contact channel Incident Manager is engaging.
    Target -> Maybe ChannelTargetInfo
channelTargetInfo :: Prelude.Maybe ChannelTargetInfo,
    -- | Information about the contact that Incident Manager is engaging.
    Target -> Maybe ContactTargetInfo
contactTargetInfo :: Prelude.Maybe ContactTargetInfo
  }
  deriving (Target -> Target -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Target -> Target -> Bool
$c/= :: Target -> Target -> Bool
== :: Target -> Target -> Bool
$c== :: Target -> Target -> Bool
Prelude.Eq, ReadPrec [Target]
ReadPrec Target
Int -> ReadS Target
ReadS [Target]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Target]
$creadListPrec :: ReadPrec [Target]
readPrec :: ReadPrec Target
$creadPrec :: ReadPrec Target
readList :: ReadS [Target]
$creadList :: ReadS [Target]
readsPrec :: Int -> ReadS Target
$creadsPrec :: Int -> ReadS Target
Prelude.Read, Int -> Target -> ShowS
[Target] -> ShowS
Target -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Target] -> ShowS
$cshowList :: [Target] -> ShowS
show :: Target -> String
$cshow :: Target -> String
showsPrec :: Int -> Target -> ShowS
$cshowsPrec :: Int -> Target -> ShowS
Prelude.Show, forall x. Rep Target x -> Target
forall x. Target -> Rep Target x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Target x -> Target
$cfrom :: forall x. Target -> Rep Target x
Prelude.Generic)

-- |
-- Create a value of 'Target' 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:
--
-- 'channelTargetInfo', 'target_channelTargetInfo' - Information about the contact channel Incident Manager is engaging.
--
-- 'contactTargetInfo', 'target_contactTargetInfo' - Information about the contact that Incident Manager is engaging.
newTarget ::
  Target
newTarget :: Target
newTarget =
  Target'
    { $sel:channelTargetInfo:Target' :: Maybe ChannelTargetInfo
channelTargetInfo = forall a. Maybe a
Prelude.Nothing,
      $sel:contactTargetInfo:Target' :: Maybe ContactTargetInfo
contactTargetInfo = forall a. Maybe a
Prelude.Nothing
    }

-- | Information about the contact channel Incident Manager is engaging.
target_channelTargetInfo :: Lens.Lens' Target (Prelude.Maybe ChannelTargetInfo)
target_channelTargetInfo :: Lens' Target (Maybe ChannelTargetInfo)
target_channelTargetInfo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Target' {Maybe ChannelTargetInfo
channelTargetInfo :: Maybe ChannelTargetInfo
$sel:channelTargetInfo:Target' :: Target -> Maybe ChannelTargetInfo
channelTargetInfo} -> Maybe ChannelTargetInfo
channelTargetInfo) (\s :: Target
s@Target' {} Maybe ChannelTargetInfo
a -> Target
s {$sel:channelTargetInfo:Target' :: Maybe ChannelTargetInfo
channelTargetInfo = Maybe ChannelTargetInfo
a} :: Target)

-- | Information about the contact that Incident Manager is engaging.
target_contactTargetInfo :: Lens.Lens' Target (Prelude.Maybe ContactTargetInfo)
target_contactTargetInfo :: Lens' Target (Maybe ContactTargetInfo)
target_contactTargetInfo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Target' {Maybe ContactTargetInfo
contactTargetInfo :: Maybe ContactTargetInfo
$sel:contactTargetInfo:Target' :: Target -> Maybe ContactTargetInfo
contactTargetInfo} -> Maybe ContactTargetInfo
contactTargetInfo) (\s :: Target
s@Target' {} Maybe ContactTargetInfo
a -> Target
s {$sel:contactTargetInfo:Target' :: Maybe ContactTargetInfo
contactTargetInfo = Maybe ContactTargetInfo
a} :: Target)

instance Data.FromJSON Target where
  parseJSON :: Value -> Parser Target
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Target"
      ( \Object
x ->
          Maybe ChannelTargetInfo -> Maybe ContactTargetInfo -> Target
Target'
            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
"ChannelTargetInfo")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ContactTargetInfo")
      )

instance Prelude.Hashable Target where
  hashWithSalt :: Int -> Target -> Int
hashWithSalt Int
_salt Target' {Maybe ChannelTargetInfo
Maybe ContactTargetInfo
contactTargetInfo :: Maybe ContactTargetInfo
channelTargetInfo :: Maybe ChannelTargetInfo
$sel:contactTargetInfo:Target' :: Target -> Maybe ContactTargetInfo
$sel:channelTargetInfo:Target' :: Target -> Maybe ChannelTargetInfo
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ChannelTargetInfo
channelTargetInfo
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ContactTargetInfo
contactTargetInfo

instance Prelude.NFData Target where
  rnf :: Target -> ()
rnf Target' {Maybe ChannelTargetInfo
Maybe ContactTargetInfo
contactTargetInfo :: Maybe ContactTargetInfo
channelTargetInfo :: Maybe ChannelTargetInfo
$sel:contactTargetInfo:Target' :: Target -> Maybe ContactTargetInfo
$sel:channelTargetInfo:Target' :: Target -> Maybe ChannelTargetInfo
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ChannelTargetInfo
channelTargetInfo
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ContactTargetInfo
contactTargetInfo

instance Data.ToJSON Target where
  toJSON :: Target -> Value
toJSON Target' {Maybe ChannelTargetInfo
Maybe ContactTargetInfo
contactTargetInfo :: Maybe ContactTargetInfo
channelTargetInfo :: Maybe ChannelTargetInfo
$sel:contactTargetInfo:Target' :: Target -> Maybe ContactTargetInfo
$sel:channelTargetInfo:Target' :: Target -> Maybe ChannelTargetInfo
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ChannelTargetInfo" 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 ChannelTargetInfo
channelTargetInfo,
            (Key
"ContactTargetInfo" 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 ContactTargetInfo
contactTargetInfo
          ]
      )