{-# 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.LifecycleEventConfiguration
-- 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.LifecycleEventConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.OpsWorks.Types.ShutdownEventConfiguration
import qualified Amazonka.Prelude as Prelude

-- | Specifies the lifecycle event configuration
--
-- /See:/ 'newLifecycleEventConfiguration' smart constructor.
data LifecycleEventConfiguration = LifecycleEventConfiguration'
  { -- | A @ShutdownEventConfiguration@ object that specifies the Shutdown event
    -- configuration.
    LifecycleEventConfiguration -> Maybe ShutdownEventConfiguration
shutdown :: Prelude.Maybe ShutdownEventConfiguration
  }
  deriving (LifecycleEventConfiguration -> LifecycleEventConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LifecycleEventConfiguration -> LifecycleEventConfiguration -> Bool
$c/= :: LifecycleEventConfiguration -> LifecycleEventConfiguration -> Bool
== :: LifecycleEventConfiguration -> LifecycleEventConfiguration -> Bool
$c== :: LifecycleEventConfiguration -> LifecycleEventConfiguration -> Bool
Prelude.Eq, ReadPrec [LifecycleEventConfiguration]
ReadPrec LifecycleEventConfiguration
Int -> ReadS LifecycleEventConfiguration
ReadS [LifecycleEventConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LifecycleEventConfiguration]
$creadListPrec :: ReadPrec [LifecycleEventConfiguration]
readPrec :: ReadPrec LifecycleEventConfiguration
$creadPrec :: ReadPrec LifecycleEventConfiguration
readList :: ReadS [LifecycleEventConfiguration]
$creadList :: ReadS [LifecycleEventConfiguration]
readsPrec :: Int -> ReadS LifecycleEventConfiguration
$creadsPrec :: Int -> ReadS LifecycleEventConfiguration
Prelude.Read, Int -> LifecycleEventConfiguration -> ShowS
[LifecycleEventConfiguration] -> ShowS
LifecycleEventConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LifecycleEventConfiguration] -> ShowS
$cshowList :: [LifecycleEventConfiguration] -> ShowS
show :: LifecycleEventConfiguration -> String
$cshow :: LifecycleEventConfiguration -> String
showsPrec :: Int -> LifecycleEventConfiguration -> ShowS
$cshowsPrec :: Int -> LifecycleEventConfiguration -> ShowS
Prelude.Show, forall x.
Rep LifecycleEventConfiguration x -> LifecycleEventConfiguration
forall x.
LifecycleEventConfiguration -> Rep LifecycleEventConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep LifecycleEventConfiguration x -> LifecycleEventConfiguration
$cfrom :: forall x.
LifecycleEventConfiguration -> Rep LifecycleEventConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'LifecycleEventConfiguration' 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:
--
-- 'shutdown', 'lifecycleEventConfiguration_shutdown' - A @ShutdownEventConfiguration@ object that specifies the Shutdown event
-- configuration.
newLifecycleEventConfiguration ::
  LifecycleEventConfiguration
newLifecycleEventConfiguration :: LifecycleEventConfiguration
newLifecycleEventConfiguration =
  LifecycleEventConfiguration'
    { $sel:shutdown:LifecycleEventConfiguration' :: Maybe ShutdownEventConfiguration
shutdown =
        forall a. Maybe a
Prelude.Nothing
    }

-- | A @ShutdownEventConfiguration@ object that specifies the Shutdown event
-- configuration.
lifecycleEventConfiguration_shutdown :: Lens.Lens' LifecycleEventConfiguration (Prelude.Maybe ShutdownEventConfiguration)
lifecycleEventConfiguration_shutdown :: Lens'
  LifecycleEventConfiguration (Maybe ShutdownEventConfiguration)
lifecycleEventConfiguration_shutdown = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LifecycleEventConfiguration' {Maybe ShutdownEventConfiguration
shutdown :: Maybe ShutdownEventConfiguration
$sel:shutdown:LifecycleEventConfiguration' :: LifecycleEventConfiguration -> Maybe ShutdownEventConfiguration
shutdown} -> Maybe ShutdownEventConfiguration
shutdown) (\s :: LifecycleEventConfiguration
s@LifecycleEventConfiguration' {} Maybe ShutdownEventConfiguration
a -> LifecycleEventConfiguration
s {$sel:shutdown:LifecycleEventConfiguration' :: Maybe ShutdownEventConfiguration
shutdown = Maybe ShutdownEventConfiguration
a} :: LifecycleEventConfiguration)

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

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

instance Prelude.NFData LifecycleEventConfiguration where
  rnf :: LifecycleEventConfiguration -> ()
rnf LifecycleEventConfiguration' {Maybe ShutdownEventConfiguration
shutdown :: Maybe ShutdownEventConfiguration
$sel:shutdown:LifecycleEventConfiguration' :: LifecycleEventConfiguration -> Maybe ShutdownEventConfiguration
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ShutdownEventConfiguration
shutdown

instance Data.ToJSON LifecycleEventConfiguration where
  toJSON :: LifecycleEventConfiguration -> Value
toJSON LifecycleEventConfiguration' {Maybe ShutdownEventConfiguration
shutdown :: Maybe ShutdownEventConfiguration
$sel:shutdown:LifecycleEventConfiguration' :: LifecycleEventConfiguration -> Maybe ShutdownEventConfiguration
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"Shutdown" 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 ShutdownEventConfiguration
shutdown]
      )