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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 @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],
    -- | 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]
  }
  deriving (Recipes -> Recipes -> Bool
(Recipes -> Recipes -> Bool)
-> (Recipes -> Recipes -> Bool) -> Eq Recipes
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]
(Int -> ReadS Recipes)
-> ReadS [Recipes]
-> ReadPrec Recipes
-> ReadPrec [Recipes]
-> Read 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
(Int -> Recipes -> ShowS)
-> (Recipes -> String) -> ([Recipes] -> ShowS) -> Show Recipes
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. Recipes -> Rep Recipes x)
-> (forall x. Rep Recipes x -> Recipes) -> Generic Recipes
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:
--
-- '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.
--
-- '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.
newRecipes ::
  Recipes
newRecipes :: Recipes
newRecipes =
  Recipes' :: Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Recipes
Recipes'
    { $sel:setup:Recipes' :: Maybe [Text]
setup = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:shutdown:Recipes' :: Maybe [Text]
shutdown = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:undeploy:Recipes' :: Maybe [Text]
undeploy = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:configure:Recipes' :: Maybe [Text]
configure = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:deploy:Recipes' :: Maybe [Text]
deploy = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | An array of custom recipe names to be run following a @setup@ event.
recipes_setup :: Lens.Lens' Recipes (Prelude.Maybe [Prelude.Text])
recipes_setup :: (Maybe [Text] -> f (Maybe [Text])) -> Recipes -> f Recipes
recipes_setup = (Recipes -> Maybe [Text])
-> (Recipes -> Maybe [Text] -> Recipes)
-> Lens Recipes Recipes (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text])) -> Recipes -> f Recipes)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Recipes
-> f Recipes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
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 :: (Maybe [Text] -> f (Maybe [Text])) -> Recipes -> f Recipes
recipes_shutdown = (Recipes -> Maybe [Text])
-> (Recipes -> Maybe [Text] -> Recipes)
-> Lens Recipes Recipes (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text])) -> Recipes -> f Recipes)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Recipes
-> f Recipes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
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 :: (Maybe [Text] -> f (Maybe [Text])) -> Recipes -> f Recipes
recipes_undeploy = (Recipes -> Maybe [Text])
-> (Recipes -> Maybe [Text] -> Recipes)
-> Lens Recipes Recipes (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text])) -> Recipes -> f Recipes)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Recipes
-> f Recipes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
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 @configure@ event.
recipes_configure :: Lens.Lens' Recipes (Prelude.Maybe [Prelude.Text])
recipes_configure :: (Maybe [Text] -> f (Maybe [Text])) -> Recipes -> f Recipes
recipes_configure = (Recipes -> Maybe [Text])
-> (Recipes -> Maybe [Text] -> Recipes)
-> Lens Recipes Recipes (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text])) -> Recipes -> f Recipes)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Recipes
-> f Recipes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
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 :: (Maybe [Text] -> f (Maybe [Text])) -> Recipes -> f Recipes
recipes_deploy = (Recipes -> Maybe [Text])
-> (Recipes -> Maybe [Text] -> Recipes)
-> Lens Recipes Recipes (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text])) -> Recipes -> f Recipes)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Recipes
-> f Recipes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON Recipes where
  parseJSON :: Value -> Parser Recipes
parseJSON =
    String -> (Object -> Parser Recipes) -> Value -> Parser Recipes
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Recipes"
      ( \Object
x ->
          Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Recipes
Recipes'
            (Maybe [Text]
 -> Maybe [Text]
 -> Maybe [Text]
 -> Maybe [Text]
 -> Maybe [Text]
 -> Recipes)
-> Parser (Maybe [Text])
-> Parser
     (Maybe [Text]
      -> Maybe [Text] -> Maybe [Text] -> Maybe [Text] -> Recipes)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Setup" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe [Text]
   -> Maybe [Text] -> Maybe [Text] -> Maybe [Text] -> Recipes)
-> Parser (Maybe [Text])
-> Parser (Maybe [Text] -> Maybe [Text] -> Maybe [Text] -> Recipes)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Shutdown" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe [Text] -> Maybe [Text] -> Maybe [Text] -> Recipes)
-> Parser (Maybe [Text])
-> Parser (Maybe [Text] -> Maybe [Text] -> Recipes)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Undeploy" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe [Text] -> Maybe [Text] -> Recipes)
-> Parser (Maybe [Text]) -> Parser (Maybe [Text] -> Recipes)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Configure" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe [Text] -> Recipes)
-> Parser (Maybe [Text]) -> Parser Recipes
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Deploy" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable Recipes

instance Prelude.NFData Recipes

instance Core.ToJSON Recipes where
  toJSON :: Recipes -> Value
toJSON Recipes' {Maybe [Text]
deploy :: Maybe [Text]
configure :: Maybe [Text]
undeploy :: Maybe [Text]
shutdown :: Maybe [Text]
setup :: Maybe [Text]
$sel:deploy:Recipes' :: Recipes -> Maybe [Text]
$sel:configure:Recipes' :: Recipes -> Maybe [Text]
$sel:undeploy:Recipes' :: Recipes -> Maybe [Text]
$sel:shutdown:Recipes' :: Recipes -> Maybe [Text]
$sel:setup:Recipes' :: Recipes -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Setup" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
setup,
            (Text
"Shutdown" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
shutdown,
            (Text
"Undeploy" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
undeploy,
            (Text
"Configure" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
configure,
            (Text
"Deploy" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
deploy
          ]
      )