{-# 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.Recipes
-- 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.Recipes 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

-- | AWS OpsWorks Stacks supports five lifecycle events: __setup__,
-- __configuration__, __deploy__, __undeploy__, and __shutdown__. For each
-- layer, AWS OpsWorks Stacks runs a set of standard recipes for each
-- event. In addition, you can provide custom recipes for any or all layers
-- and events. AWS OpsWorks Stacks runs custom event recipes after the
-- standard recipes. @LayerCustomRecipes@ specifies the custom recipes for
-- a particular layer to be run in response to each of the five events.
--
-- To specify a recipe, use the cookbook\'s directory name in the
-- repository followed by two colons and the recipe name, which is the
-- recipe\'s file name without the .rb extension. For example:
-- phpapp2::dbsetup specifies the dbsetup.rb recipe in the repository\'s
-- phpapp2 folder.
--
-- /See:/ 'newRecipes' smart constructor.
data Recipes = Recipes'
  { -- | An array of custom recipe names to be run following a @configure@ event.
    Recipes -> Maybe [Text]
configure :: Prelude.Maybe [Prelude.Text],
    -- | An array of custom recipe names to be run following a @deploy@ event.
    Recipes -> Maybe [Text]
deploy :: Prelude.Maybe [Prelude.Text],
    -- | An array of custom recipe names to be run following a @setup@ event.
    Recipes -> Maybe [Text]
setup :: Prelude.Maybe [Prelude.Text],
    -- | An array of custom recipe names to be run following a @shutdown@ event.
    Recipes -> Maybe [Text]
shutdown :: Prelude.Maybe [Prelude.Text],
    -- | An array of custom recipe names to be run following a @undeploy@ event.
    Recipes -> Maybe [Text]
undeploy :: Prelude.Maybe [Prelude.Text]
  }
  deriving (Recipes -> Recipes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Recipes -> Recipes -> Bool
$c/= :: Recipes -> Recipes -> Bool
== :: Recipes -> Recipes -> Bool
$c== :: Recipes -> Recipes -> Bool
Prelude.Eq, ReadPrec [Recipes]
ReadPrec Recipes
Int -> ReadS Recipes
ReadS [Recipes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Recipes]
$creadListPrec :: ReadPrec [Recipes]
readPrec :: ReadPrec Recipes
$creadPrec :: ReadPrec Recipes
readList :: ReadS [Recipes]
$creadList :: ReadS [Recipes]
readsPrec :: Int -> ReadS Recipes
$creadsPrec :: Int -> ReadS Recipes
Prelude.Read, Int -> Recipes -> ShowS
[Recipes] -> ShowS
Recipes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Recipes] -> ShowS
$cshowList :: [Recipes] -> ShowS
show :: Recipes -> String
$cshow :: Recipes -> String
showsPrec :: Int -> Recipes -> ShowS
$cshowsPrec :: Int -> Recipes -> ShowS
Prelude.Show, forall x. Rep Recipes x -> Recipes
forall x. Recipes -> Rep Recipes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Recipes x -> Recipes
$cfrom :: forall x. Recipes -> Rep Recipes x
Prelude.Generic)

-- |
-- Create a value of 'Recipes' 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:
--
-- 'configure', 'recipes_configure' - An array of custom recipe names to be run following a @configure@ event.
--
-- 'deploy', 'recipes_deploy' - An array of custom recipe names to be run following a @deploy@ event.
--
-- 'setup', 'recipes_setup' - An array of custom recipe names to be run following a @setup@ event.
--
-- 'shutdown', 'recipes_shutdown' - An array of custom recipe names to be run following a @shutdown@ event.
--
-- 'undeploy', 'recipes_undeploy' - An array of custom recipe names to be run following a @undeploy@ event.
newRecipes ::
  Recipes
newRecipes :: Recipes
newRecipes =
  Recipes'
    { $sel:configure:Recipes' :: Maybe [Text]
configure = forall a. Maybe a
Prelude.Nothing,
      $sel:deploy:Recipes' :: Maybe [Text]
deploy = forall a. Maybe a
Prelude.Nothing,
      $sel:setup:Recipes' :: Maybe [Text]
setup = forall a. Maybe a
Prelude.Nothing,
      $sel:shutdown:Recipes' :: Maybe [Text]
shutdown = forall a. Maybe a
Prelude.Nothing,
      $sel:undeploy:Recipes' :: Maybe [Text]
undeploy = forall a. Maybe a
Prelude.Nothing
    }

-- | An array of custom recipe names to be run following a @configure@ event.
recipes_configure :: Lens.Lens' Recipes (Prelude.Maybe [Prelude.Text])
recipes_configure :: Lens' Recipes (Maybe [Text])
recipes_configure = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Recipes' {Maybe [Text]
configure :: Maybe [Text]
$sel:configure:Recipes' :: Recipes -> Maybe [Text]
configure} -> Maybe [Text]
configure) (\s :: Recipes
s@Recipes' {} Maybe [Text]
a -> Recipes
s {$sel:configure:Recipes' :: Maybe [Text]
configure = Maybe [Text]
a} :: Recipes) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An array of custom recipe names to be run following a @deploy@ event.
recipes_deploy :: Lens.Lens' Recipes (Prelude.Maybe [Prelude.Text])
recipes_deploy :: Lens' Recipes (Maybe [Text])
recipes_deploy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Recipes' {Maybe [Text]
deploy :: Maybe [Text]
$sel:deploy:Recipes' :: Recipes -> Maybe [Text]
deploy} -> Maybe [Text]
deploy) (\s :: Recipes
s@Recipes' {} Maybe [Text]
a -> Recipes
s {$sel:deploy:Recipes' :: Maybe [Text]
deploy = Maybe [Text]
a} :: Recipes) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An array of custom recipe names to be run following a @setup@ event.
recipes_setup :: Lens.Lens' Recipes (Prelude.Maybe [Prelude.Text])
recipes_setup :: Lens' Recipes (Maybe [Text])
recipes_setup = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Recipes' {Maybe [Text]
setup :: Maybe [Text]
$sel:setup:Recipes' :: Recipes -> Maybe [Text]
setup} -> Maybe [Text]
setup) (\s :: Recipes
s@Recipes' {} Maybe [Text]
a -> Recipes
s {$sel:setup:Recipes' :: Maybe [Text]
setup = Maybe [Text]
a} :: Recipes) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An array of custom recipe names to be run following a @shutdown@ event.
recipes_shutdown :: Lens.Lens' Recipes (Prelude.Maybe [Prelude.Text])
recipes_shutdown :: Lens' Recipes (Maybe [Text])
recipes_shutdown = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Recipes' {Maybe [Text]
shutdown :: Maybe [Text]
$sel:shutdown:Recipes' :: Recipes -> Maybe [Text]
shutdown} -> Maybe [Text]
shutdown) (\s :: Recipes
s@Recipes' {} Maybe [Text]
a -> Recipes
s {$sel:shutdown:Recipes' :: Maybe [Text]
shutdown = Maybe [Text]
a} :: Recipes) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An array of custom recipe names to be run following a @undeploy@ event.
recipes_undeploy :: Lens.Lens' Recipes (Prelude.Maybe [Prelude.Text])
recipes_undeploy :: Lens' Recipes (Maybe [Text])
recipes_undeploy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Recipes' {Maybe [Text]
undeploy :: Maybe [Text]
$sel:undeploy:Recipes' :: Recipes -> Maybe [Text]
undeploy} -> Maybe [Text]
undeploy) (\s :: Recipes
s@Recipes' {} Maybe [Text]
a -> Recipes
s {$sel:undeploy:Recipes' :: Maybe [Text]
undeploy = Maybe [Text]
a} :: Recipes) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON Recipes where
  parseJSON :: Value -> Parser Recipes
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Recipes"
      ( \Object
x ->
          Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Recipes
Recipes'
            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
"Configure" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"Deploy" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"Setup" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"Shutdown" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"Undeploy" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable Recipes where
  hashWithSalt :: Int -> Recipes -> Int
hashWithSalt Int
_salt Recipes' {Maybe [Text]
undeploy :: Maybe [Text]
shutdown :: Maybe [Text]
setup :: Maybe [Text]
deploy :: Maybe [Text]
configure :: Maybe [Text]
$sel:undeploy:Recipes' :: Recipes -> Maybe [Text]
$sel:shutdown:Recipes' :: Recipes -> Maybe [Text]
$sel:setup:Recipes' :: Recipes -> Maybe [Text]
$sel:deploy:Recipes' :: Recipes -> Maybe [Text]
$sel:configure:Recipes' :: Recipes -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
configure
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
deploy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
setup
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
shutdown
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
undeploy

instance Prelude.NFData Recipes where
  rnf :: Recipes -> ()
rnf Recipes' {Maybe [Text]
undeploy :: Maybe [Text]
shutdown :: Maybe [Text]
setup :: Maybe [Text]
deploy :: Maybe [Text]
configure :: Maybe [Text]
$sel:undeploy:Recipes' :: Recipes -> Maybe [Text]
$sel:shutdown:Recipes' :: Recipes -> Maybe [Text]
$sel:setup:Recipes' :: Recipes -> Maybe [Text]
$sel:deploy:Recipes' :: Recipes -> Maybe [Text]
$sel:configure:Recipes' :: Recipes -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
configure
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
deploy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
setup
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
shutdown
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
undeploy

instance Data.ToJSON Recipes where
  toJSON :: Recipes -> Value
toJSON Recipes' {Maybe [Text]
undeploy :: Maybe [Text]
shutdown :: Maybe [Text]
setup :: Maybe [Text]
deploy :: Maybe [Text]
configure :: Maybe [Text]
$sel:undeploy:Recipes' :: Recipes -> Maybe [Text]
$sel:shutdown:Recipes' :: Recipes -> Maybe [Text]
$sel:setup:Recipes' :: Recipes -> Maybe [Text]
$sel:deploy:Recipes' :: Recipes -> Maybe [Text]
$sel:configure:Recipes' :: Recipes -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Configure" 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 [Text]
configure,
            (Key
"Deploy" 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 [Text]
deploy,
            (Key
"Setup" 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 [Text]
setup,
            (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 [Text]
shutdown,
            (Key
"Undeploy" 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 [Text]
undeploy
          ]
      )