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

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

-- | Information required to reset the timer. The timer is reset to the
-- previously evaluated result of the duration. The duration expression
-- isn\'t reevaluated when you reset the timer.
--
-- /See:/ 'newResetTimerAction' smart constructor.
data ResetTimerAction = ResetTimerAction'
  { -- | The name of the timer to reset.
    ResetTimerAction -> Text
timerName :: Prelude.Text
  }
  deriving (ResetTimerAction -> ResetTimerAction -> Bool
(ResetTimerAction -> ResetTimerAction -> Bool)
-> (ResetTimerAction -> ResetTimerAction -> Bool)
-> Eq ResetTimerAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResetTimerAction -> ResetTimerAction -> Bool
$c/= :: ResetTimerAction -> ResetTimerAction -> Bool
== :: ResetTimerAction -> ResetTimerAction -> Bool
$c== :: ResetTimerAction -> ResetTimerAction -> Bool
Prelude.Eq, ReadPrec [ResetTimerAction]
ReadPrec ResetTimerAction
Int -> ReadS ResetTimerAction
ReadS [ResetTimerAction]
(Int -> ReadS ResetTimerAction)
-> ReadS [ResetTimerAction]
-> ReadPrec ResetTimerAction
-> ReadPrec [ResetTimerAction]
-> Read ResetTimerAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResetTimerAction]
$creadListPrec :: ReadPrec [ResetTimerAction]
readPrec :: ReadPrec ResetTimerAction
$creadPrec :: ReadPrec ResetTimerAction
readList :: ReadS [ResetTimerAction]
$creadList :: ReadS [ResetTimerAction]
readsPrec :: Int -> ReadS ResetTimerAction
$creadsPrec :: Int -> ReadS ResetTimerAction
Prelude.Read, Int -> ResetTimerAction -> ShowS
[ResetTimerAction] -> ShowS
ResetTimerAction -> String
(Int -> ResetTimerAction -> ShowS)
-> (ResetTimerAction -> String)
-> ([ResetTimerAction] -> ShowS)
-> Show ResetTimerAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResetTimerAction] -> ShowS
$cshowList :: [ResetTimerAction] -> ShowS
show :: ResetTimerAction -> String
$cshow :: ResetTimerAction -> String
showsPrec :: Int -> ResetTimerAction -> ShowS
$cshowsPrec :: Int -> ResetTimerAction -> ShowS
Prelude.Show, (forall x. ResetTimerAction -> Rep ResetTimerAction x)
-> (forall x. Rep ResetTimerAction x -> ResetTimerAction)
-> Generic ResetTimerAction
forall x. Rep ResetTimerAction x -> ResetTimerAction
forall x. ResetTimerAction -> Rep ResetTimerAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResetTimerAction x -> ResetTimerAction
$cfrom :: forall x. ResetTimerAction -> Rep ResetTimerAction x
Prelude.Generic)

-- |
-- Create a value of 'ResetTimerAction' 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:
--
-- 'timerName', 'resetTimerAction_timerName' - The name of the timer to reset.
newResetTimerAction ::
  -- | 'timerName'
  Prelude.Text ->
  ResetTimerAction
newResetTimerAction :: Text -> ResetTimerAction
newResetTimerAction Text
pTimerName_ =
  ResetTimerAction' :: Text -> ResetTimerAction
ResetTimerAction' {$sel:timerName:ResetTimerAction' :: Text
timerName = Text
pTimerName_}

-- | The name of the timer to reset.
resetTimerAction_timerName :: Lens.Lens' ResetTimerAction Prelude.Text
resetTimerAction_timerName :: (Text -> f Text) -> ResetTimerAction -> f ResetTimerAction
resetTimerAction_timerName = (ResetTimerAction -> Text)
-> (ResetTimerAction -> Text -> ResetTimerAction)
-> Lens ResetTimerAction ResetTimerAction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResetTimerAction' {Text
timerName :: Text
$sel:timerName:ResetTimerAction' :: ResetTimerAction -> Text
timerName} -> Text
timerName) (\s :: ResetTimerAction
s@ResetTimerAction' {} Text
a -> ResetTimerAction
s {$sel:timerName:ResetTimerAction' :: Text
timerName = Text
a} :: ResetTimerAction)

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

instance Prelude.Hashable ResetTimerAction

instance Prelude.NFData ResetTimerAction

instance Core.ToJSON ResetTimerAction where
  toJSON :: ResetTimerAction -> Value
toJSON ResetTimerAction' {Text
timerName :: Text
$sel:timerName:ResetTimerAction' :: ResetTimerAction -> Text
..} =
    [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
"timerName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
timerName)]
      )