{-# 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.AwsJobTimeoutConfig
-- 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.AwsJobTimeoutConfig 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:/ 'newAwsJobTimeoutConfig' smart constructor.
data AwsJobTimeoutConfig = AwsJobTimeoutConfig'
  { -- | 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.
    AwsJobTimeoutConfig -> Maybe Integer
inProgressTimeoutInMinutes :: Prelude.Maybe Prelude.Integer
  }
  deriving (AwsJobTimeoutConfig -> AwsJobTimeoutConfig -> Bool
(AwsJobTimeoutConfig -> AwsJobTimeoutConfig -> Bool)
-> (AwsJobTimeoutConfig -> AwsJobTimeoutConfig -> Bool)
-> Eq AwsJobTimeoutConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsJobTimeoutConfig -> AwsJobTimeoutConfig -> Bool
$c/= :: AwsJobTimeoutConfig -> AwsJobTimeoutConfig -> Bool
== :: AwsJobTimeoutConfig -> AwsJobTimeoutConfig -> Bool
$c== :: AwsJobTimeoutConfig -> AwsJobTimeoutConfig -> Bool
Prelude.Eq, ReadPrec [AwsJobTimeoutConfig]
ReadPrec AwsJobTimeoutConfig
Int -> ReadS AwsJobTimeoutConfig
ReadS [AwsJobTimeoutConfig]
(Int -> ReadS AwsJobTimeoutConfig)
-> ReadS [AwsJobTimeoutConfig]
-> ReadPrec AwsJobTimeoutConfig
-> ReadPrec [AwsJobTimeoutConfig]
-> Read AwsJobTimeoutConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsJobTimeoutConfig]
$creadListPrec :: ReadPrec [AwsJobTimeoutConfig]
readPrec :: ReadPrec AwsJobTimeoutConfig
$creadPrec :: ReadPrec AwsJobTimeoutConfig
readList :: ReadS [AwsJobTimeoutConfig]
$creadList :: ReadS [AwsJobTimeoutConfig]
readsPrec :: Int -> ReadS AwsJobTimeoutConfig
$creadsPrec :: Int -> ReadS AwsJobTimeoutConfig
Prelude.Read, Int -> AwsJobTimeoutConfig -> ShowS
[AwsJobTimeoutConfig] -> ShowS
AwsJobTimeoutConfig -> String
(Int -> AwsJobTimeoutConfig -> ShowS)
-> (AwsJobTimeoutConfig -> String)
-> ([AwsJobTimeoutConfig] -> ShowS)
-> Show AwsJobTimeoutConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsJobTimeoutConfig] -> ShowS
$cshowList :: [AwsJobTimeoutConfig] -> ShowS
show :: AwsJobTimeoutConfig -> String
$cshow :: AwsJobTimeoutConfig -> String
showsPrec :: Int -> AwsJobTimeoutConfig -> ShowS
$cshowsPrec :: Int -> AwsJobTimeoutConfig -> ShowS
Prelude.Show, (forall x. AwsJobTimeoutConfig -> Rep AwsJobTimeoutConfig x)
-> (forall x. Rep AwsJobTimeoutConfig x -> AwsJobTimeoutConfig)
-> Generic AwsJobTimeoutConfig
forall x. Rep AwsJobTimeoutConfig x -> AwsJobTimeoutConfig
forall x. AwsJobTimeoutConfig -> Rep AwsJobTimeoutConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AwsJobTimeoutConfig x -> AwsJobTimeoutConfig
$cfrom :: forall x. AwsJobTimeoutConfig -> Rep AwsJobTimeoutConfig x
Prelude.Generic)

-- |
-- Create a value of 'AwsJobTimeoutConfig' 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', 'awsJobTimeoutConfig_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.
newAwsJobTimeoutConfig ::
  AwsJobTimeoutConfig
newAwsJobTimeoutConfig :: AwsJobTimeoutConfig
newAwsJobTimeoutConfig =
  AwsJobTimeoutConfig' :: Maybe Integer -> AwsJobTimeoutConfig
AwsJobTimeoutConfig'
    { $sel:inProgressTimeoutInMinutes:AwsJobTimeoutConfig' :: 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.
awsJobTimeoutConfig_inProgressTimeoutInMinutes :: Lens.Lens' AwsJobTimeoutConfig (Prelude.Maybe Prelude.Integer)
awsJobTimeoutConfig_inProgressTimeoutInMinutes :: (Maybe Integer -> f (Maybe Integer))
-> AwsJobTimeoutConfig -> f AwsJobTimeoutConfig
awsJobTimeoutConfig_inProgressTimeoutInMinutes = (AwsJobTimeoutConfig -> Maybe Integer)
-> (AwsJobTimeoutConfig -> Maybe Integer -> AwsJobTimeoutConfig)
-> Lens
     AwsJobTimeoutConfig
     AwsJobTimeoutConfig
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsJobTimeoutConfig' {Maybe Integer
inProgressTimeoutInMinutes :: Maybe Integer
$sel:inProgressTimeoutInMinutes:AwsJobTimeoutConfig' :: AwsJobTimeoutConfig -> Maybe Integer
inProgressTimeoutInMinutes} -> Maybe Integer
inProgressTimeoutInMinutes) (\s :: AwsJobTimeoutConfig
s@AwsJobTimeoutConfig' {} Maybe Integer
a -> AwsJobTimeoutConfig
s {$sel:inProgressTimeoutInMinutes:AwsJobTimeoutConfig' :: Maybe Integer
inProgressTimeoutInMinutes = Maybe Integer
a} :: AwsJobTimeoutConfig)

instance Prelude.Hashable AwsJobTimeoutConfig

instance Prelude.NFData AwsJobTimeoutConfig

instance Core.ToJSON AwsJobTimeoutConfig where
  toJSON :: AwsJobTimeoutConfig -> Value
toJSON AwsJobTimeoutConfig' {Maybe Integer
inProgressTimeoutInMinutes :: Maybe Integer
$sel:inProgressTimeoutInMinutes:AwsJobTimeoutConfig' :: AwsJobTimeoutConfig -> 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
          ]
      )