{-# 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.IoT.Types.TimeoutConfig
-- 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.IoT.Types.TimeoutConfig where

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

-- | Specifies the amount of time each device has to finish its execution of
-- the job. A timer is started when the job execution status is set to
-- @IN_PROGRESS@. If the job execution status is not set to another
-- terminal state before the timer expires, it will be automatically set to
-- @TIMED_OUT@.
--
-- /See:/ 'newTimeoutConfig' smart constructor.
data TimeoutConfig = TimeoutConfig'
  { -- | Specifies the amount of time, in minutes, this device has to finish
    -- execution of this job. The timeout interval can be anywhere between 1
    -- minute and 7 days (1 to 10080 minutes). The in progress timer can\'t be
    -- updated and will apply to all job executions for the job. Whenever a job
    -- execution remains in the IN_PROGRESS status for longer than this
    -- interval, the job execution will fail and switch to the terminal
    -- @TIMED_OUT@ status.
    TimeoutConfig -> Maybe Integer
inProgressTimeoutInMinutes :: Prelude.Maybe Prelude.Integer
  }
  deriving (TimeoutConfig -> TimeoutConfig -> Bool
(TimeoutConfig -> TimeoutConfig -> Bool)
-> (TimeoutConfig -> TimeoutConfig -> Bool) -> Eq TimeoutConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimeoutConfig -> TimeoutConfig -> Bool
$c/= :: TimeoutConfig -> TimeoutConfig -> Bool
== :: TimeoutConfig -> TimeoutConfig -> Bool
$c== :: TimeoutConfig -> TimeoutConfig -> Bool
Prelude.Eq, ReadPrec [TimeoutConfig]
ReadPrec TimeoutConfig
Int -> ReadS TimeoutConfig
ReadS [TimeoutConfig]
(Int -> ReadS TimeoutConfig)
-> ReadS [TimeoutConfig]
-> ReadPrec TimeoutConfig
-> ReadPrec [TimeoutConfig]
-> Read TimeoutConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TimeoutConfig]
$creadListPrec :: ReadPrec [TimeoutConfig]
readPrec :: ReadPrec TimeoutConfig
$creadPrec :: ReadPrec TimeoutConfig
readList :: ReadS [TimeoutConfig]
$creadList :: ReadS [TimeoutConfig]
readsPrec :: Int -> ReadS TimeoutConfig
$creadsPrec :: Int -> ReadS TimeoutConfig
Prelude.Read, Int -> TimeoutConfig -> ShowS
[TimeoutConfig] -> ShowS
TimeoutConfig -> String
(Int -> TimeoutConfig -> ShowS)
-> (TimeoutConfig -> String)
-> ([TimeoutConfig] -> ShowS)
-> Show TimeoutConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimeoutConfig] -> ShowS
$cshowList :: [TimeoutConfig] -> ShowS
show :: TimeoutConfig -> String
$cshow :: TimeoutConfig -> String
showsPrec :: Int -> TimeoutConfig -> ShowS
$cshowsPrec :: Int -> TimeoutConfig -> ShowS
Prelude.Show, (forall x. TimeoutConfig -> Rep TimeoutConfig x)
-> (forall x. Rep TimeoutConfig x -> TimeoutConfig)
-> Generic TimeoutConfig
forall x. Rep TimeoutConfig x -> TimeoutConfig
forall x. TimeoutConfig -> Rep TimeoutConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TimeoutConfig x -> TimeoutConfig
$cfrom :: forall x. TimeoutConfig -> Rep TimeoutConfig x
Prelude.Generic)

-- |
-- Create a value of 'TimeoutConfig' 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:
--
-- 'inProgressTimeoutInMinutes', 'timeoutConfig_inProgressTimeoutInMinutes' - Specifies the amount of time, in minutes, this device has to finish
-- execution of this job. The timeout interval can be anywhere between 1
-- minute and 7 days (1 to 10080 minutes). The in progress timer can\'t be
-- updated and will apply to all job executions for the job. Whenever a job
-- execution remains in the IN_PROGRESS status for longer than this
-- interval, the job execution will fail and switch to the terminal
-- @TIMED_OUT@ status.
newTimeoutConfig ::
  TimeoutConfig
newTimeoutConfig :: TimeoutConfig
newTimeoutConfig =
  TimeoutConfig' :: Maybe Integer -> TimeoutConfig
TimeoutConfig'
    { $sel:inProgressTimeoutInMinutes:TimeoutConfig' :: Maybe Integer
inProgressTimeoutInMinutes =
        Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the amount of time, in minutes, this device has to finish
-- execution of this job. The timeout interval can be anywhere between 1
-- minute and 7 days (1 to 10080 minutes). The in progress timer can\'t be
-- updated and will apply to all job executions for the job. Whenever a job
-- execution remains in the IN_PROGRESS status for longer than this
-- interval, the job execution will fail and switch to the terminal
-- @TIMED_OUT@ status.
timeoutConfig_inProgressTimeoutInMinutes :: Lens.Lens' TimeoutConfig (Prelude.Maybe Prelude.Integer)
timeoutConfig_inProgressTimeoutInMinutes :: (Maybe Integer -> f (Maybe Integer))
-> TimeoutConfig -> f TimeoutConfig
timeoutConfig_inProgressTimeoutInMinutes = (TimeoutConfig -> Maybe Integer)
-> (TimeoutConfig -> Maybe Integer -> TimeoutConfig)
-> Lens TimeoutConfig TimeoutConfig (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimeoutConfig' {Maybe Integer
inProgressTimeoutInMinutes :: Maybe Integer
$sel:inProgressTimeoutInMinutes:TimeoutConfig' :: TimeoutConfig -> Maybe Integer
inProgressTimeoutInMinutes} -> Maybe Integer
inProgressTimeoutInMinutes) (\s :: TimeoutConfig
s@TimeoutConfig' {} Maybe Integer
a -> TimeoutConfig
s {$sel:inProgressTimeoutInMinutes:TimeoutConfig' :: Maybe Integer
inProgressTimeoutInMinutes = Maybe Integer
a} :: TimeoutConfig)

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

instance Prelude.Hashable TimeoutConfig

instance Prelude.NFData TimeoutConfig

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