{-# 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-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.Target where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(Target -> Target -> Bool)
-> (Target -> Target -> Bool) -> Eq Target
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]
(Int -> ReadS Target)
-> ReadS [Target]
-> ReadPrec Target
-> ReadPrec [Target]
-> Read 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
(Int -> Target -> ShowS)
-> (Target -> String) -> ([Target] -> ShowS) -> Show Target
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. Target -> Rep Target x)
-> (forall x. Rep Target x -> Target) -> Generic Target
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' :: Maybe ChannelTargetInfo -> Maybe ContactTargetInfo -> Target
Target'
    { $sel:channelTargetInfo:Target' :: Maybe ChannelTargetInfo
channelTargetInfo = Maybe ChannelTargetInfo
forall a. Maybe a
Prelude.Nothing,
      $sel:contactTargetInfo:Target' :: Maybe ContactTargetInfo
contactTargetInfo = Maybe 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 :: (Maybe ChannelTargetInfo -> f (Maybe ChannelTargetInfo))
-> Target -> f Target
target_channelTargetInfo = (Target -> Maybe ChannelTargetInfo)
-> (Target -> Maybe ChannelTargetInfo -> Target)
-> Lens
     Target Target (Maybe ChannelTargetInfo) (Maybe 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 :: (Maybe ContactTargetInfo -> f (Maybe ContactTargetInfo))
-> Target -> f Target
target_contactTargetInfo = (Target -> Maybe ContactTargetInfo)
-> (Target -> Maybe ContactTargetInfo -> Target)
-> Lens
     Target Target (Maybe ContactTargetInfo) (Maybe 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 Core.FromJSON Target where
  parseJSON :: Value -> Parser Target
parseJSON =
    String -> (Object -> Parser Target) -> Value -> Parser Target
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Target"
      ( \Object
x ->
          Maybe ChannelTargetInfo -> Maybe ContactTargetInfo -> Target
Target'
            (Maybe ChannelTargetInfo -> Maybe ContactTargetInfo -> Target)
-> Parser (Maybe ChannelTargetInfo)
-> Parser (Maybe ContactTargetInfo -> Target)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ChannelTargetInfo)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ChannelTargetInfo")
            Parser (Maybe ContactTargetInfo -> Target)
-> Parser (Maybe ContactTargetInfo) -> Parser Target
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ContactTargetInfo)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ContactTargetInfo")
      )

instance Prelude.Hashable Target

instance Prelude.NFData Target

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ChannelTargetInfo" Text -> ChannelTargetInfo -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ChannelTargetInfo -> Pair)
-> Maybe ChannelTargetInfo -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ChannelTargetInfo
channelTargetInfo,
            (Text
"ContactTargetInfo" Text -> ContactTargetInfo -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ContactTargetInfo -> Pair)
-> Maybe ContactTargetInfo -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ContactTargetInfo
contactTargetInfo
          ]
      )