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

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

-- | Specifies whether to get notified for alarm state changes.
--
-- /See:/ 'newAcknowledgeFlow' smart constructor.
data AcknowledgeFlow = AcknowledgeFlow'
  { -- | The value must be @TRUE@ or @FALSE@. If @TRUE@, you receive a
    -- notification when the alarm state changes. You must choose to
    -- acknowledge the notification before the alarm state can return to
    -- @NORMAL@. If @FALSE@, you won\'t receive notifications. The alarm
    -- automatically changes to the @NORMAL@ state when the input property
    -- value returns to the specified range.
    AcknowledgeFlow -> Bool
enabled :: Prelude.Bool
  }
  deriving (AcknowledgeFlow -> AcknowledgeFlow -> Bool
(AcknowledgeFlow -> AcknowledgeFlow -> Bool)
-> (AcknowledgeFlow -> AcknowledgeFlow -> Bool)
-> Eq AcknowledgeFlow
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AcknowledgeFlow -> AcknowledgeFlow -> Bool
$c/= :: AcknowledgeFlow -> AcknowledgeFlow -> Bool
== :: AcknowledgeFlow -> AcknowledgeFlow -> Bool
$c== :: AcknowledgeFlow -> AcknowledgeFlow -> Bool
Prelude.Eq, ReadPrec [AcknowledgeFlow]
ReadPrec AcknowledgeFlow
Int -> ReadS AcknowledgeFlow
ReadS [AcknowledgeFlow]
(Int -> ReadS AcknowledgeFlow)
-> ReadS [AcknowledgeFlow]
-> ReadPrec AcknowledgeFlow
-> ReadPrec [AcknowledgeFlow]
-> Read AcknowledgeFlow
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AcknowledgeFlow]
$creadListPrec :: ReadPrec [AcknowledgeFlow]
readPrec :: ReadPrec AcknowledgeFlow
$creadPrec :: ReadPrec AcknowledgeFlow
readList :: ReadS [AcknowledgeFlow]
$creadList :: ReadS [AcknowledgeFlow]
readsPrec :: Int -> ReadS AcknowledgeFlow
$creadsPrec :: Int -> ReadS AcknowledgeFlow
Prelude.Read, Int -> AcknowledgeFlow -> ShowS
[AcknowledgeFlow] -> ShowS
AcknowledgeFlow -> String
(Int -> AcknowledgeFlow -> ShowS)
-> (AcknowledgeFlow -> String)
-> ([AcknowledgeFlow] -> ShowS)
-> Show AcknowledgeFlow
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AcknowledgeFlow] -> ShowS
$cshowList :: [AcknowledgeFlow] -> ShowS
show :: AcknowledgeFlow -> String
$cshow :: AcknowledgeFlow -> String
showsPrec :: Int -> AcknowledgeFlow -> ShowS
$cshowsPrec :: Int -> AcknowledgeFlow -> ShowS
Prelude.Show, (forall x. AcknowledgeFlow -> Rep AcknowledgeFlow x)
-> (forall x. Rep AcknowledgeFlow x -> AcknowledgeFlow)
-> Generic AcknowledgeFlow
forall x. Rep AcknowledgeFlow x -> AcknowledgeFlow
forall x. AcknowledgeFlow -> Rep AcknowledgeFlow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AcknowledgeFlow x -> AcknowledgeFlow
$cfrom :: forall x. AcknowledgeFlow -> Rep AcknowledgeFlow x
Prelude.Generic)

-- |
-- Create a value of 'AcknowledgeFlow' 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:
--
-- 'enabled', 'acknowledgeFlow_enabled' - The value must be @TRUE@ or @FALSE@. If @TRUE@, you receive a
-- notification when the alarm state changes. You must choose to
-- acknowledge the notification before the alarm state can return to
-- @NORMAL@. If @FALSE@, you won\'t receive notifications. The alarm
-- automatically changes to the @NORMAL@ state when the input property
-- value returns to the specified range.
newAcknowledgeFlow ::
  -- | 'enabled'
  Prelude.Bool ->
  AcknowledgeFlow
newAcknowledgeFlow :: Bool -> AcknowledgeFlow
newAcknowledgeFlow Bool
pEnabled_ =
  AcknowledgeFlow' :: Bool -> AcknowledgeFlow
AcknowledgeFlow' {$sel:enabled:AcknowledgeFlow' :: Bool
enabled = Bool
pEnabled_}

-- | The value must be @TRUE@ or @FALSE@. If @TRUE@, you receive a
-- notification when the alarm state changes. You must choose to
-- acknowledge the notification before the alarm state can return to
-- @NORMAL@. If @FALSE@, you won\'t receive notifications. The alarm
-- automatically changes to the @NORMAL@ state when the input property
-- value returns to the specified range.
acknowledgeFlow_enabled :: Lens.Lens' AcknowledgeFlow Prelude.Bool
acknowledgeFlow_enabled :: (Bool -> f Bool) -> AcknowledgeFlow -> f AcknowledgeFlow
acknowledgeFlow_enabled = (AcknowledgeFlow -> Bool)
-> (AcknowledgeFlow -> Bool -> AcknowledgeFlow)
-> Lens AcknowledgeFlow AcknowledgeFlow Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AcknowledgeFlow' {Bool
enabled :: Bool
$sel:enabled:AcknowledgeFlow' :: AcknowledgeFlow -> Bool
enabled} -> Bool
enabled) (\s :: AcknowledgeFlow
s@AcknowledgeFlow' {} Bool
a -> AcknowledgeFlow
s {$sel:enabled:AcknowledgeFlow' :: Bool
enabled = Bool
a} :: AcknowledgeFlow)

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

instance Prelude.Hashable AcknowledgeFlow

instance Prelude.NFData AcknowledgeFlow

instance Core.ToJSON AcknowledgeFlow where
  toJSON :: AcknowledgeFlow -> Value
toJSON AcknowledgeFlow' {Bool
enabled :: Bool
$sel:enabled:AcknowledgeFlow' :: AcknowledgeFlow -> Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"enabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
enabled)]
      )