{-# 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.IoTEventsData.Types.TimerDefinition
-- 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.IoTEventsData.Types.TimerDefinition where

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

-- | The new setting of a timer.
--
-- /See:/ 'newTimerDefinition' smart constructor.
data TimerDefinition = TimerDefinition'
  { -- | The name of the timer.
    TimerDefinition -> Text
name :: Prelude.Text,
    -- | The new setting of the timer (the number of seconds before the timer
    -- elapses).
    TimerDefinition -> Int
seconds :: Prelude.Int
  }
  deriving (TimerDefinition -> TimerDefinition -> Bool
(TimerDefinition -> TimerDefinition -> Bool)
-> (TimerDefinition -> TimerDefinition -> Bool)
-> Eq TimerDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimerDefinition -> TimerDefinition -> Bool
$c/= :: TimerDefinition -> TimerDefinition -> Bool
== :: TimerDefinition -> TimerDefinition -> Bool
$c== :: TimerDefinition -> TimerDefinition -> Bool
Prelude.Eq, ReadPrec [TimerDefinition]
ReadPrec TimerDefinition
Int -> ReadS TimerDefinition
ReadS [TimerDefinition]
(Int -> ReadS TimerDefinition)
-> ReadS [TimerDefinition]
-> ReadPrec TimerDefinition
-> ReadPrec [TimerDefinition]
-> Read TimerDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TimerDefinition]
$creadListPrec :: ReadPrec [TimerDefinition]
readPrec :: ReadPrec TimerDefinition
$creadPrec :: ReadPrec TimerDefinition
readList :: ReadS [TimerDefinition]
$creadList :: ReadS [TimerDefinition]
readsPrec :: Int -> ReadS TimerDefinition
$creadsPrec :: Int -> ReadS TimerDefinition
Prelude.Read, Int -> TimerDefinition -> ShowS
[TimerDefinition] -> ShowS
TimerDefinition -> String
(Int -> TimerDefinition -> ShowS)
-> (TimerDefinition -> String)
-> ([TimerDefinition] -> ShowS)
-> Show TimerDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimerDefinition] -> ShowS
$cshowList :: [TimerDefinition] -> ShowS
show :: TimerDefinition -> String
$cshow :: TimerDefinition -> String
showsPrec :: Int -> TimerDefinition -> ShowS
$cshowsPrec :: Int -> TimerDefinition -> ShowS
Prelude.Show, (forall x. TimerDefinition -> Rep TimerDefinition x)
-> (forall x. Rep TimerDefinition x -> TimerDefinition)
-> Generic TimerDefinition
forall x. Rep TimerDefinition x -> TimerDefinition
forall x. TimerDefinition -> Rep TimerDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TimerDefinition x -> TimerDefinition
$cfrom :: forall x. TimerDefinition -> Rep TimerDefinition x
Prelude.Generic)

-- |
-- Create a value of 'TimerDefinition' 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:
--
-- 'name', 'timerDefinition_name' - The name of the timer.
--
-- 'seconds', 'timerDefinition_seconds' - The new setting of the timer (the number of seconds before the timer
-- elapses).
newTimerDefinition ::
  -- | 'name'
  Prelude.Text ->
  -- | 'seconds'
  Prelude.Int ->
  TimerDefinition
newTimerDefinition :: Text -> Int -> TimerDefinition
newTimerDefinition Text
pName_ Int
pSeconds_ =
  TimerDefinition' :: Text -> Int -> TimerDefinition
TimerDefinition'
    { $sel:name:TimerDefinition' :: Text
name = Text
pName_,
      $sel:seconds:TimerDefinition' :: Int
seconds = Int
pSeconds_
    }

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

-- | The new setting of the timer (the number of seconds before the timer
-- elapses).
timerDefinition_seconds :: Lens.Lens' TimerDefinition Prelude.Int
timerDefinition_seconds :: (Int -> f Int) -> TimerDefinition -> f TimerDefinition
timerDefinition_seconds = (TimerDefinition -> Int)
-> (TimerDefinition -> Int -> TimerDefinition)
-> Lens TimerDefinition TimerDefinition Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimerDefinition' {Int
seconds :: Int
$sel:seconds:TimerDefinition' :: TimerDefinition -> Int
seconds} -> Int
seconds) (\s :: TimerDefinition
s@TimerDefinition' {} Int
a -> TimerDefinition
s {$sel:seconds:TimerDefinition' :: Int
seconds = Int
a} :: TimerDefinition)

instance Prelude.Hashable TimerDefinition

instance Prelude.NFData TimerDefinition

instance Core.ToJSON TimerDefinition where
  toJSON :: TimerDefinition -> Value
toJSON TimerDefinition' {Int
Text
seconds :: Int
name :: Text
$sel:seconds:TimerDefinition' :: TimerDefinition -> Int
$sel:name:TimerDefinition' :: TimerDefinition -> 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
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"seconds" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Int
seconds)
          ]
      )