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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(LifecycleEventConfiguration
 -> LifecycleEventConfiguration -> Bool)
-> (LifecycleEventConfiguration
    -> LifecycleEventConfiguration -> Bool)
-> Eq LifecycleEventConfiguration
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]
(Int -> ReadS LifecycleEventConfiguration)
-> ReadS [LifecycleEventConfiguration]
-> ReadPrec LifecycleEventConfiguration
-> ReadPrec [LifecycleEventConfiguration]
-> Read 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
(Int -> LifecycleEventConfiguration -> ShowS)
-> (LifecycleEventConfiguration -> String)
-> ([LifecycleEventConfiguration] -> ShowS)
-> Show LifecycleEventConfiguration
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.
 LifecycleEventConfiguration -> Rep LifecycleEventConfiguration x)
-> (forall x.
    Rep LifecycleEventConfiguration x -> LifecycleEventConfiguration)
-> Generic LifecycleEventConfiguration
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' :: Maybe ShutdownEventConfiguration -> LifecycleEventConfiguration
LifecycleEventConfiguration'
    { $sel:shutdown:LifecycleEventConfiguration' :: Maybe ShutdownEventConfiguration
shutdown =
        Maybe ShutdownEventConfiguration
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 :: (Maybe ShutdownEventConfiguration
 -> f (Maybe ShutdownEventConfiguration))
-> LifecycleEventConfiguration -> f LifecycleEventConfiguration
lifecycleEventConfiguration_shutdown = (LifecycleEventConfiguration -> Maybe ShutdownEventConfiguration)
-> (LifecycleEventConfiguration
    -> Maybe ShutdownEventConfiguration -> LifecycleEventConfiguration)
-> Lens
     LifecycleEventConfiguration
     LifecycleEventConfiguration
     (Maybe ShutdownEventConfiguration)
     (Maybe ShutdownEventConfiguration)
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 Core.FromJSON LifecycleEventConfiguration where
  parseJSON :: Value -> Parser LifecycleEventConfiguration
parseJSON =
    String
-> (Object -> Parser LifecycleEventConfiguration)
-> Value
-> Parser LifecycleEventConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LifecycleEventConfiguration"
      ( \Object
x ->
          Maybe ShutdownEventConfiguration -> LifecycleEventConfiguration
LifecycleEventConfiguration'
            (Maybe ShutdownEventConfiguration -> LifecycleEventConfiguration)
-> Parser (Maybe ShutdownEventConfiguration)
-> Parser LifecycleEventConfiguration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ShutdownEventConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Shutdown")
      )

instance Prelude.Hashable LifecycleEventConfiguration

instance Prelude.NFData LifecycleEventConfiguration

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