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

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

-- | Information about the contact channel that Incident Manager uses to
-- engage the contact.
--
-- /See:/ 'newChannelTargetInfo' smart constructor.
data ChannelTargetInfo = ChannelTargetInfo'
  { -- | The number of minutes to wait to retry sending engagement in the case
    -- the engagement initially fails.
    ChannelTargetInfo -> Maybe Natural
retryIntervalInMinutes :: Prelude.Maybe Prelude.Natural,
    -- | The Amazon Resource Name (ARN) of the contact channel.
    ChannelTargetInfo -> Text
contactChannelId :: Prelude.Text
  }
  deriving (ChannelTargetInfo -> ChannelTargetInfo -> Bool
(ChannelTargetInfo -> ChannelTargetInfo -> Bool)
-> (ChannelTargetInfo -> ChannelTargetInfo -> Bool)
-> Eq ChannelTargetInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChannelTargetInfo -> ChannelTargetInfo -> Bool
$c/= :: ChannelTargetInfo -> ChannelTargetInfo -> Bool
== :: ChannelTargetInfo -> ChannelTargetInfo -> Bool
$c== :: ChannelTargetInfo -> ChannelTargetInfo -> Bool
Prelude.Eq, ReadPrec [ChannelTargetInfo]
ReadPrec ChannelTargetInfo
Int -> ReadS ChannelTargetInfo
ReadS [ChannelTargetInfo]
(Int -> ReadS ChannelTargetInfo)
-> ReadS [ChannelTargetInfo]
-> ReadPrec ChannelTargetInfo
-> ReadPrec [ChannelTargetInfo]
-> Read ChannelTargetInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ChannelTargetInfo]
$creadListPrec :: ReadPrec [ChannelTargetInfo]
readPrec :: ReadPrec ChannelTargetInfo
$creadPrec :: ReadPrec ChannelTargetInfo
readList :: ReadS [ChannelTargetInfo]
$creadList :: ReadS [ChannelTargetInfo]
readsPrec :: Int -> ReadS ChannelTargetInfo
$creadsPrec :: Int -> ReadS ChannelTargetInfo
Prelude.Read, Int -> ChannelTargetInfo -> ShowS
[ChannelTargetInfo] -> ShowS
ChannelTargetInfo -> String
(Int -> ChannelTargetInfo -> ShowS)
-> (ChannelTargetInfo -> String)
-> ([ChannelTargetInfo] -> ShowS)
-> Show ChannelTargetInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChannelTargetInfo] -> ShowS
$cshowList :: [ChannelTargetInfo] -> ShowS
show :: ChannelTargetInfo -> String
$cshow :: ChannelTargetInfo -> String
showsPrec :: Int -> ChannelTargetInfo -> ShowS
$cshowsPrec :: Int -> ChannelTargetInfo -> ShowS
Prelude.Show, (forall x. ChannelTargetInfo -> Rep ChannelTargetInfo x)
-> (forall x. Rep ChannelTargetInfo x -> ChannelTargetInfo)
-> Generic ChannelTargetInfo
forall x. Rep ChannelTargetInfo x -> ChannelTargetInfo
forall x. ChannelTargetInfo -> Rep ChannelTargetInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChannelTargetInfo x -> ChannelTargetInfo
$cfrom :: forall x. ChannelTargetInfo -> Rep ChannelTargetInfo x
Prelude.Generic)

-- |
-- Create a value of 'ChannelTargetInfo' 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:
--
-- 'retryIntervalInMinutes', 'channelTargetInfo_retryIntervalInMinutes' - The number of minutes to wait to retry sending engagement in the case
-- the engagement initially fails.
--
-- 'contactChannelId', 'channelTargetInfo_contactChannelId' - The Amazon Resource Name (ARN) of the contact channel.
newChannelTargetInfo ::
  -- | 'contactChannelId'
  Prelude.Text ->
  ChannelTargetInfo
newChannelTargetInfo :: Text -> ChannelTargetInfo
newChannelTargetInfo Text
pContactChannelId_ =
  ChannelTargetInfo' :: Maybe Natural -> Text -> ChannelTargetInfo
ChannelTargetInfo'
    { $sel:retryIntervalInMinutes:ChannelTargetInfo' :: Maybe Natural
retryIntervalInMinutes =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:contactChannelId:ChannelTargetInfo' :: Text
contactChannelId = Text
pContactChannelId_
    }

-- | The number of minutes to wait to retry sending engagement in the case
-- the engagement initially fails.
channelTargetInfo_retryIntervalInMinutes :: Lens.Lens' ChannelTargetInfo (Prelude.Maybe Prelude.Natural)
channelTargetInfo_retryIntervalInMinutes :: (Maybe Natural -> f (Maybe Natural))
-> ChannelTargetInfo -> f ChannelTargetInfo
channelTargetInfo_retryIntervalInMinutes = (ChannelTargetInfo -> Maybe Natural)
-> (ChannelTargetInfo -> Maybe Natural -> ChannelTargetInfo)
-> Lens
     ChannelTargetInfo ChannelTargetInfo (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelTargetInfo' {Maybe Natural
retryIntervalInMinutes :: Maybe Natural
$sel:retryIntervalInMinutes:ChannelTargetInfo' :: ChannelTargetInfo -> Maybe Natural
retryIntervalInMinutes} -> Maybe Natural
retryIntervalInMinutes) (\s :: ChannelTargetInfo
s@ChannelTargetInfo' {} Maybe Natural
a -> ChannelTargetInfo
s {$sel:retryIntervalInMinutes:ChannelTargetInfo' :: Maybe Natural
retryIntervalInMinutes = Maybe Natural
a} :: ChannelTargetInfo)

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

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

instance Prelude.Hashable ChannelTargetInfo

instance Prelude.NFData ChannelTargetInfo

instance Core.ToJSON ChannelTargetInfo where
  toJSON :: ChannelTargetInfo -> Value
toJSON ChannelTargetInfo' {Maybe Natural
Text
contactChannelId :: Text
retryIntervalInMinutes :: Maybe Natural
$sel:contactChannelId:ChannelTargetInfo' :: ChannelTargetInfo -> Text
$sel:retryIntervalInMinutes:ChannelTargetInfo' :: ChannelTargetInfo -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RetryIntervalInMinutes" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
retryIntervalInMinutes,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ContactChannelId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
contactChannelId)
          ]
      )