{-# 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.IoTEvents.Types.NotificationTargetActions
-- 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.IoTEvents.Types.NotificationTargetActions where

import qualified Amazonka.Core as Core
import Amazonka.IoTEvents.Types.LambdaAction
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies an AWS Lambda function to manage alarm notifications. You can
-- create one or use the
-- <https://docs.aws.amazon.com/iotevents/latest/developerguide/lambda-support.html AWS Lambda function provided by AWS IoT Events>.
--
-- /See:/ 'newNotificationTargetActions' smart constructor.
data NotificationTargetActions = NotificationTargetActions'
  { NotificationTargetActions -> Maybe LambdaAction
lambdaAction :: Prelude.Maybe LambdaAction
  }
  deriving (NotificationTargetActions -> NotificationTargetActions -> Bool
(NotificationTargetActions -> NotificationTargetActions -> Bool)
-> (NotificationTargetActions -> NotificationTargetActions -> Bool)
-> Eq NotificationTargetActions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NotificationTargetActions -> NotificationTargetActions -> Bool
$c/= :: NotificationTargetActions -> NotificationTargetActions -> Bool
== :: NotificationTargetActions -> NotificationTargetActions -> Bool
$c== :: NotificationTargetActions -> NotificationTargetActions -> Bool
Prelude.Eq, ReadPrec [NotificationTargetActions]
ReadPrec NotificationTargetActions
Int -> ReadS NotificationTargetActions
ReadS [NotificationTargetActions]
(Int -> ReadS NotificationTargetActions)
-> ReadS [NotificationTargetActions]
-> ReadPrec NotificationTargetActions
-> ReadPrec [NotificationTargetActions]
-> Read NotificationTargetActions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NotificationTargetActions]
$creadListPrec :: ReadPrec [NotificationTargetActions]
readPrec :: ReadPrec NotificationTargetActions
$creadPrec :: ReadPrec NotificationTargetActions
readList :: ReadS [NotificationTargetActions]
$creadList :: ReadS [NotificationTargetActions]
readsPrec :: Int -> ReadS NotificationTargetActions
$creadsPrec :: Int -> ReadS NotificationTargetActions
Prelude.Read, Int -> NotificationTargetActions -> ShowS
[NotificationTargetActions] -> ShowS
NotificationTargetActions -> String
(Int -> NotificationTargetActions -> ShowS)
-> (NotificationTargetActions -> String)
-> ([NotificationTargetActions] -> ShowS)
-> Show NotificationTargetActions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NotificationTargetActions] -> ShowS
$cshowList :: [NotificationTargetActions] -> ShowS
show :: NotificationTargetActions -> String
$cshow :: NotificationTargetActions -> String
showsPrec :: Int -> NotificationTargetActions -> ShowS
$cshowsPrec :: Int -> NotificationTargetActions -> ShowS
Prelude.Show, (forall x.
 NotificationTargetActions -> Rep NotificationTargetActions x)
-> (forall x.
    Rep NotificationTargetActions x -> NotificationTargetActions)
-> Generic NotificationTargetActions
forall x.
Rep NotificationTargetActions x -> NotificationTargetActions
forall x.
NotificationTargetActions -> Rep NotificationTargetActions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep NotificationTargetActions x -> NotificationTargetActions
$cfrom :: forall x.
NotificationTargetActions -> Rep NotificationTargetActions x
Prelude.Generic)

-- |
-- Create a value of 'NotificationTargetActions' 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:
--
-- 'lambdaAction', 'notificationTargetActions_lambdaAction' - Undocumented member.
newNotificationTargetActions ::
  NotificationTargetActions
newNotificationTargetActions :: NotificationTargetActions
newNotificationTargetActions =
  NotificationTargetActions' :: Maybe LambdaAction -> NotificationTargetActions
NotificationTargetActions'
    { $sel:lambdaAction:NotificationTargetActions' :: Maybe LambdaAction
lambdaAction =
        Maybe LambdaAction
forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
notificationTargetActions_lambdaAction :: Lens.Lens' NotificationTargetActions (Prelude.Maybe LambdaAction)
notificationTargetActions_lambdaAction :: (Maybe LambdaAction -> f (Maybe LambdaAction))
-> NotificationTargetActions -> f NotificationTargetActions
notificationTargetActions_lambdaAction = (NotificationTargetActions -> Maybe LambdaAction)
-> (NotificationTargetActions
    -> Maybe LambdaAction -> NotificationTargetActions)
-> Lens
     NotificationTargetActions
     NotificationTargetActions
     (Maybe LambdaAction)
     (Maybe LambdaAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotificationTargetActions' {Maybe LambdaAction
lambdaAction :: Maybe LambdaAction
$sel:lambdaAction:NotificationTargetActions' :: NotificationTargetActions -> Maybe LambdaAction
lambdaAction} -> Maybe LambdaAction
lambdaAction) (\s :: NotificationTargetActions
s@NotificationTargetActions' {} Maybe LambdaAction
a -> NotificationTargetActions
s {$sel:lambdaAction:NotificationTargetActions' :: Maybe LambdaAction
lambdaAction = Maybe LambdaAction
a} :: NotificationTargetActions)

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

instance Prelude.Hashable NotificationTargetActions

instance Prelude.NFData NotificationTargetActions

instance Core.ToJSON NotificationTargetActions where
  toJSON :: NotificationTargetActions -> Value
toJSON NotificationTargetActions' {Maybe LambdaAction
lambdaAction :: Maybe LambdaAction
$sel:lambdaAction:NotificationTargetActions' :: NotificationTargetActions -> Maybe LambdaAction
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"lambdaAction" Text -> LambdaAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (LambdaAction -> Pair) -> Maybe LambdaAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LambdaAction
lambdaAction]
      )