{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoT.Types.TimeoutConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:inProgressTimeoutInMinutes:TimeoutConfig' :: Maybe Integer
inProgressTimeoutInMinutes =
        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 :: Lens' TimeoutConfig (Maybe Integer)
timeoutConfig_inProgressTimeoutInMinutes = 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 Data.FromJSON TimeoutConfig where
  parseJSON :: Value -> Parser TimeoutConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TimeoutConfig"
      ( \Object
x ->
          Maybe Integer -> TimeoutConfig
TimeoutConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"inProgressTimeoutInMinutes")
      )

instance Prelude.Hashable TimeoutConfig where
  hashWithSalt :: Int -> TimeoutConfig -> Int
hashWithSalt Int
_salt TimeoutConfig' {Maybe Integer
inProgressTimeoutInMinutes :: Maybe Integer
$sel:inProgressTimeoutInMinutes:TimeoutConfig' :: TimeoutConfig -> Maybe Integer
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
inProgressTimeoutInMinutes

instance Prelude.NFData TimeoutConfig where
  rnf :: TimeoutConfig -> ()
rnf TimeoutConfig' {Maybe Integer
inProgressTimeoutInMinutes :: Maybe Integer
$sel:inProgressTimeoutInMinutes:TimeoutConfig' :: TimeoutConfig -> Maybe Integer
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
inProgressTimeoutInMinutes

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