{-# 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.GreengrassV2.Types.IoTJobTimeoutConfig
-- 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.GreengrassV2.Types.IoTJobTimeoutConfig where

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

-- | Contains information about the timeout configuration for a job.
--
-- /See:/ 'newIoTJobTimeoutConfig' smart constructor.
data IoTJobTimeoutConfig = IoTJobTimeoutConfig'
  { -- | The amount of time, in minutes, that devices have to complete the job.
    -- The timer starts when the job status is set to @IN_PROGRESS@. If the job
    -- status doesn\'t change to a terminal state before the time expires, then
    -- the job status is set to @TIMED_OUT@.
    --
    -- The timeout interval must be between 1 minute and 7 days (10080
    -- minutes).
    IoTJobTimeoutConfig -> Maybe Integer
inProgressTimeoutInMinutes :: Prelude.Maybe Prelude.Integer
  }
  deriving (IoTJobTimeoutConfig -> IoTJobTimeoutConfig -> Bool
(IoTJobTimeoutConfig -> IoTJobTimeoutConfig -> Bool)
-> (IoTJobTimeoutConfig -> IoTJobTimeoutConfig -> Bool)
-> Eq IoTJobTimeoutConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IoTJobTimeoutConfig -> IoTJobTimeoutConfig -> Bool
$c/= :: IoTJobTimeoutConfig -> IoTJobTimeoutConfig -> Bool
== :: IoTJobTimeoutConfig -> IoTJobTimeoutConfig -> Bool
$c== :: IoTJobTimeoutConfig -> IoTJobTimeoutConfig -> Bool
Prelude.Eq, ReadPrec [IoTJobTimeoutConfig]
ReadPrec IoTJobTimeoutConfig
Int -> ReadS IoTJobTimeoutConfig
ReadS [IoTJobTimeoutConfig]
(Int -> ReadS IoTJobTimeoutConfig)
-> ReadS [IoTJobTimeoutConfig]
-> ReadPrec IoTJobTimeoutConfig
-> ReadPrec [IoTJobTimeoutConfig]
-> Read IoTJobTimeoutConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IoTJobTimeoutConfig]
$creadListPrec :: ReadPrec [IoTJobTimeoutConfig]
readPrec :: ReadPrec IoTJobTimeoutConfig
$creadPrec :: ReadPrec IoTJobTimeoutConfig
readList :: ReadS [IoTJobTimeoutConfig]
$creadList :: ReadS [IoTJobTimeoutConfig]
readsPrec :: Int -> ReadS IoTJobTimeoutConfig
$creadsPrec :: Int -> ReadS IoTJobTimeoutConfig
Prelude.Read, Int -> IoTJobTimeoutConfig -> ShowS
[IoTJobTimeoutConfig] -> ShowS
IoTJobTimeoutConfig -> String
(Int -> IoTJobTimeoutConfig -> ShowS)
-> (IoTJobTimeoutConfig -> String)
-> ([IoTJobTimeoutConfig] -> ShowS)
-> Show IoTJobTimeoutConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IoTJobTimeoutConfig] -> ShowS
$cshowList :: [IoTJobTimeoutConfig] -> ShowS
show :: IoTJobTimeoutConfig -> String
$cshow :: IoTJobTimeoutConfig -> String
showsPrec :: Int -> IoTJobTimeoutConfig -> ShowS
$cshowsPrec :: Int -> IoTJobTimeoutConfig -> ShowS
Prelude.Show, (forall x. IoTJobTimeoutConfig -> Rep IoTJobTimeoutConfig x)
-> (forall x. Rep IoTJobTimeoutConfig x -> IoTJobTimeoutConfig)
-> Generic IoTJobTimeoutConfig
forall x. Rep IoTJobTimeoutConfig x -> IoTJobTimeoutConfig
forall x. IoTJobTimeoutConfig -> Rep IoTJobTimeoutConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IoTJobTimeoutConfig x -> IoTJobTimeoutConfig
$cfrom :: forall x. IoTJobTimeoutConfig -> Rep IoTJobTimeoutConfig x
Prelude.Generic)

-- |
-- Create a value of 'IoTJobTimeoutConfig' 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', 'ioTJobTimeoutConfig_inProgressTimeoutInMinutes' - The amount of time, in minutes, that devices have to complete the job.
-- The timer starts when the job status is set to @IN_PROGRESS@. If the job
-- status doesn\'t change to a terminal state before the time expires, then
-- the job status is set to @TIMED_OUT@.
--
-- The timeout interval must be between 1 minute and 7 days (10080
-- minutes).
newIoTJobTimeoutConfig ::
  IoTJobTimeoutConfig
newIoTJobTimeoutConfig :: IoTJobTimeoutConfig
newIoTJobTimeoutConfig =
  IoTJobTimeoutConfig' :: Maybe Integer -> IoTJobTimeoutConfig
IoTJobTimeoutConfig'
    { $sel:inProgressTimeoutInMinutes:IoTJobTimeoutConfig' :: Maybe Integer
inProgressTimeoutInMinutes =
        Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | The amount of time, in minutes, that devices have to complete the job.
-- The timer starts when the job status is set to @IN_PROGRESS@. If the job
-- status doesn\'t change to a terminal state before the time expires, then
-- the job status is set to @TIMED_OUT@.
--
-- The timeout interval must be between 1 minute and 7 days (10080
-- minutes).
ioTJobTimeoutConfig_inProgressTimeoutInMinutes :: Lens.Lens' IoTJobTimeoutConfig (Prelude.Maybe Prelude.Integer)
ioTJobTimeoutConfig_inProgressTimeoutInMinutes :: (Maybe Integer -> f (Maybe Integer))
-> IoTJobTimeoutConfig -> f IoTJobTimeoutConfig
ioTJobTimeoutConfig_inProgressTimeoutInMinutes = (IoTJobTimeoutConfig -> Maybe Integer)
-> (IoTJobTimeoutConfig -> Maybe Integer -> IoTJobTimeoutConfig)
-> Lens
     IoTJobTimeoutConfig
     IoTJobTimeoutConfig
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IoTJobTimeoutConfig' {Maybe Integer
inProgressTimeoutInMinutes :: Maybe Integer
$sel:inProgressTimeoutInMinutes:IoTJobTimeoutConfig' :: IoTJobTimeoutConfig -> Maybe Integer
inProgressTimeoutInMinutes} -> Maybe Integer
inProgressTimeoutInMinutes) (\s :: IoTJobTimeoutConfig
s@IoTJobTimeoutConfig' {} Maybe Integer
a -> IoTJobTimeoutConfig
s {$sel:inProgressTimeoutInMinutes:IoTJobTimeoutConfig' :: Maybe Integer
inProgressTimeoutInMinutes = Maybe Integer
a} :: IoTJobTimeoutConfig)

instance Core.FromJSON IoTJobTimeoutConfig where
  parseJSON :: Value -> Parser IoTJobTimeoutConfig
parseJSON =
    String
-> (Object -> Parser IoTJobTimeoutConfig)
-> Value
-> Parser IoTJobTimeoutConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"IoTJobTimeoutConfig"
      ( \Object
x ->
          Maybe Integer -> IoTJobTimeoutConfig
IoTJobTimeoutConfig'
            (Maybe Integer -> IoTJobTimeoutConfig)
-> Parser (Maybe Integer) -> Parser IoTJobTimeoutConfig
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 IoTJobTimeoutConfig

instance Prelude.NFData IoTJobTimeoutConfig

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