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

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

-- | Tunnel timeout configuration.
--
-- /See:/ 'newTimeoutConfig' smart constructor.
data TimeoutConfig = TimeoutConfig'
  { -- | The maximum amount of time (in minutes) a tunnel can remain open. If not
    -- specified, maxLifetimeTimeoutMinutes defaults to 720 minutes. Valid
    -- values are from 1 minute to 12 hours (720 minutes)
    TimeoutConfig -> Maybe Natural
maxLifetimeTimeoutMinutes :: Prelude.Maybe Prelude.Natural
  }
  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:
--
-- 'maxLifetimeTimeoutMinutes', 'timeoutConfig_maxLifetimeTimeoutMinutes' - The maximum amount of time (in minutes) a tunnel can remain open. If not
-- specified, maxLifetimeTimeoutMinutes defaults to 720 minutes. Valid
-- values are from 1 minute to 12 hours (720 minutes)
newTimeoutConfig ::
  TimeoutConfig
newTimeoutConfig :: TimeoutConfig
newTimeoutConfig =
  TimeoutConfig' :: Maybe Natural -> TimeoutConfig
TimeoutConfig'
    { $sel:maxLifetimeTimeoutMinutes:TimeoutConfig' :: Maybe Natural
maxLifetimeTimeoutMinutes =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum amount of time (in minutes) a tunnel can remain open. If not
-- specified, maxLifetimeTimeoutMinutes defaults to 720 minutes. Valid
-- values are from 1 minute to 12 hours (720 minutes)
timeoutConfig_maxLifetimeTimeoutMinutes :: Lens.Lens' TimeoutConfig (Prelude.Maybe Prelude.Natural)
timeoutConfig_maxLifetimeTimeoutMinutes :: (Maybe Natural -> f (Maybe Natural))
-> TimeoutConfig -> f TimeoutConfig
timeoutConfig_maxLifetimeTimeoutMinutes = (TimeoutConfig -> Maybe Natural)
-> (TimeoutConfig -> Maybe Natural -> TimeoutConfig)
-> Lens TimeoutConfig TimeoutConfig (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimeoutConfig' {Maybe Natural
maxLifetimeTimeoutMinutes :: Maybe Natural
$sel:maxLifetimeTimeoutMinutes:TimeoutConfig' :: TimeoutConfig -> Maybe Natural
maxLifetimeTimeoutMinutes} -> Maybe Natural
maxLifetimeTimeoutMinutes) (\s :: TimeoutConfig
s@TimeoutConfig' {} Maybe Natural
a -> TimeoutConfig
s {$sel:maxLifetimeTimeoutMinutes:TimeoutConfig' :: Maybe Natural
maxLifetimeTimeoutMinutes = Maybe Natural
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 Natural -> TimeoutConfig
TimeoutConfig'
            (Maybe Natural -> TimeoutConfig)
-> Parser (Maybe Natural) -> Parser TimeoutConfig
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"maxLifetimeTimeoutMinutes")
      )

instance Prelude.Hashable TimeoutConfig

instance Prelude.NFData TimeoutConfig

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