{-# 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.OpsWorks.Types.ShutdownEventConfiguration
-- 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.OpsWorks.Types.ShutdownEventConfiguration 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

-- | The Shutdown event configuration.
--
-- /See:/ 'newShutdownEventConfiguration' smart constructor.
data ShutdownEventConfiguration = ShutdownEventConfiguration'
  { -- | Whether to enable Elastic Load Balancing connection draining. For more
    -- information, see
    -- <https://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/TerminologyandKeyConcepts.html#conn-drain Connection Draining>
    ShutdownEventConfiguration -> Maybe Bool
delayUntilElbConnectionsDrained :: Prelude.Maybe Prelude.Bool,
    -- | The time, in seconds, that AWS OpsWorks Stacks will wait after
    -- triggering a Shutdown event before shutting down an instance.
    ShutdownEventConfiguration -> Maybe Int
executionTimeout :: Prelude.Maybe Prelude.Int
  }
  deriving (ShutdownEventConfiguration -> ShutdownEventConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ShutdownEventConfiguration -> ShutdownEventConfiguration -> Bool
$c/= :: ShutdownEventConfiguration -> ShutdownEventConfiguration -> Bool
== :: ShutdownEventConfiguration -> ShutdownEventConfiguration -> Bool
$c== :: ShutdownEventConfiguration -> ShutdownEventConfiguration -> Bool
Prelude.Eq, ReadPrec [ShutdownEventConfiguration]
ReadPrec ShutdownEventConfiguration
Int -> ReadS ShutdownEventConfiguration
ReadS [ShutdownEventConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ShutdownEventConfiguration]
$creadListPrec :: ReadPrec [ShutdownEventConfiguration]
readPrec :: ReadPrec ShutdownEventConfiguration
$creadPrec :: ReadPrec ShutdownEventConfiguration
readList :: ReadS [ShutdownEventConfiguration]
$creadList :: ReadS [ShutdownEventConfiguration]
readsPrec :: Int -> ReadS ShutdownEventConfiguration
$creadsPrec :: Int -> ReadS ShutdownEventConfiguration
Prelude.Read, Int -> ShutdownEventConfiguration -> ShowS
[ShutdownEventConfiguration] -> ShowS
ShutdownEventConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ShutdownEventConfiguration] -> ShowS
$cshowList :: [ShutdownEventConfiguration] -> ShowS
show :: ShutdownEventConfiguration -> String
$cshow :: ShutdownEventConfiguration -> String
showsPrec :: Int -> ShutdownEventConfiguration -> ShowS
$cshowsPrec :: Int -> ShutdownEventConfiguration -> ShowS
Prelude.Show, forall x.
Rep ShutdownEventConfiguration x -> ShutdownEventConfiguration
forall x.
ShutdownEventConfiguration -> Rep ShutdownEventConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ShutdownEventConfiguration x -> ShutdownEventConfiguration
$cfrom :: forall x.
ShutdownEventConfiguration -> Rep ShutdownEventConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ShutdownEventConfiguration' 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:
--
-- 'delayUntilElbConnectionsDrained', 'shutdownEventConfiguration_delayUntilElbConnectionsDrained' - Whether to enable Elastic Load Balancing connection draining. For more
-- information, see
-- <https://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/TerminologyandKeyConcepts.html#conn-drain Connection Draining>
--
-- 'executionTimeout', 'shutdownEventConfiguration_executionTimeout' - The time, in seconds, that AWS OpsWorks Stacks will wait after
-- triggering a Shutdown event before shutting down an instance.
newShutdownEventConfiguration ::
  ShutdownEventConfiguration
newShutdownEventConfiguration :: ShutdownEventConfiguration
newShutdownEventConfiguration =
  ShutdownEventConfiguration'
    { $sel:delayUntilElbConnectionsDrained:ShutdownEventConfiguration' :: Maybe Bool
delayUntilElbConnectionsDrained =
        forall a. Maybe a
Prelude.Nothing,
      $sel:executionTimeout:ShutdownEventConfiguration' :: Maybe Int
executionTimeout = forall a. Maybe a
Prelude.Nothing
    }

-- | Whether to enable Elastic Load Balancing connection draining. For more
-- information, see
-- <https://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/TerminologyandKeyConcepts.html#conn-drain Connection Draining>
shutdownEventConfiguration_delayUntilElbConnectionsDrained :: Lens.Lens' ShutdownEventConfiguration (Prelude.Maybe Prelude.Bool)
shutdownEventConfiguration_delayUntilElbConnectionsDrained :: Lens' ShutdownEventConfiguration (Maybe Bool)
shutdownEventConfiguration_delayUntilElbConnectionsDrained = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ShutdownEventConfiguration' {Maybe Bool
delayUntilElbConnectionsDrained :: Maybe Bool
$sel:delayUntilElbConnectionsDrained:ShutdownEventConfiguration' :: ShutdownEventConfiguration -> Maybe Bool
delayUntilElbConnectionsDrained} -> Maybe Bool
delayUntilElbConnectionsDrained) (\s :: ShutdownEventConfiguration
s@ShutdownEventConfiguration' {} Maybe Bool
a -> ShutdownEventConfiguration
s {$sel:delayUntilElbConnectionsDrained:ShutdownEventConfiguration' :: Maybe Bool
delayUntilElbConnectionsDrained = Maybe Bool
a} :: ShutdownEventConfiguration)

-- | The time, in seconds, that AWS OpsWorks Stacks will wait after
-- triggering a Shutdown event before shutting down an instance.
shutdownEventConfiguration_executionTimeout :: Lens.Lens' ShutdownEventConfiguration (Prelude.Maybe Prelude.Int)
shutdownEventConfiguration_executionTimeout :: Lens' ShutdownEventConfiguration (Maybe Int)
shutdownEventConfiguration_executionTimeout = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ShutdownEventConfiguration' {Maybe Int
executionTimeout :: Maybe Int
$sel:executionTimeout:ShutdownEventConfiguration' :: ShutdownEventConfiguration -> Maybe Int
executionTimeout} -> Maybe Int
executionTimeout) (\s :: ShutdownEventConfiguration
s@ShutdownEventConfiguration' {} Maybe Int
a -> ShutdownEventConfiguration
s {$sel:executionTimeout:ShutdownEventConfiguration' :: Maybe Int
executionTimeout = Maybe Int
a} :: ShutdownEventConfiguration)

instance Data.FromJSON ShutdownEventConfiguration where
  parseJSON :: Value -> Parser ShutdownEventConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ShutdownEventConfiguration"
      ( \Object
x ->
          Maybe Bool -> Maybe Int -> ShutdownEventConfiguration
ShutdownEventConfiguration'
            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
"DelayUntilElbConnectionsDrained")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ExecutionTimeout")
      )

instance Prelude.Hashable ShutdownEventConfiguration where
  hashWithSalt :: Int -> ShutdownEventConfiguration -> Int
hashWithSalt Int
_salt ShutdownEventConfiguration' {Maybe Bool
Maybe Int
executionTimeout :: Maybe Int
delayUntilElbConnectionsDrained :: Maybe Bool
$sel:executionTimeout:ShutdownEventConfiguration' :: ShutdownEventConfiguration -> Maybe Int
$sel:delayUntilElbConnectionsDrained:ShutdownEventConfiguration' :: ShutdownEventConfiguration -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
delayUntilElbConnectionsDrained
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
executionTimeout

instance Prelude.NFData ShutdownEventConfiguration where
  rnf :: ShutdownEventConfiguration -> ()
rnf ShutdownEventConfiguration' {Maybe Bool
Maybe Int
executionTimeout :: Maybe Int
delayUntilElbConnectionsDrained :: Maybe Bool
$sel:executionTimeout:ShutdownEventConfiguration' :: ShutdownEventConfiguration -> Maybe Int
$sel:delayUntilElbConnectionsDrained:ShutdownEventConfiguration' :: ShutdownEventConfiguration -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
delayUntilElbConnectionsDrained
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
executionTimeout

instance Data.ToJSON ShutdownEventConfiguration where
  toJSON :: ShutdownEventConfiguration -> Value
toJSON ShutdownEventConfiguration' {Maybe Bool
Maybe Int
executionTimeout :: Maybe Int
delayUntilElbConnectionsDrained :: Maybe Bool
$sel:executionTimeout:ShutdownEventConfiguration' :: ShutdownEventConfiguration -> Maybe Int
$sel:delayUntilElbConnectionsDrained:ShutdownEventConfiguration' :: ShutdownEventConfiguration -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DelayUntilElbConnectionsDrained" 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 Bool
delayUntilElbConnectionsDrained,
            (Key
"ExecutionTimeout" 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 Int
executionTimeout
          ]
      )