{-# 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.EMR.Types.BootstrapActionConfig
-- 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.EMR.Types.BootstrapActionConfig where

import qualified Amazonka.Core as Core
import Amazonka.EMR.Types.ScriptBootstrapActionConfig
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Configuration of a bootstrap action.
--
-- /See:/ 'newBootstrapActionConfig' smart constructor.
data BootstrapActionConfig = BootstrapActionConfig'
  { -- | The name of the bootstrap action.
    BootstrapActionConfig -> Text
name :: Prelude.Text,
    -- | The script run by the bootstrap action.
    BootstrapActionConfig -> ScriptBootstrapActionConfig
scriptBootstrapAction :: ScriptBootstrapActionConfig
  }
  deriving (BootstrapActionConfig -> BootstrapActionConfig -> Bool
(BootstrapActionConfig -> BootstrapActionConfig -> Bool)
-> (BootstrapActionConfig -> BootstrapActionConfig -> Bool)
-> Eq BootstrapActionConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BootstrapActionConfig -> BootstrapActionConfig -> Bool
$c/= :: BootstrapActionConfig -> BootstrapActionConfig -> Bool
== :: BootstrapActionConfig -> BootstrapActionConfig -> Bool
$c== :: BootstrapActionConfig -> BootstrapActionConfig -> Bool
Prelude.Eq, ReadPrec [BootstrapActionConfig]
ReadPrec BootstrapActionConfig
Int -> ReadS BootstrapActionConfig
ReadS [BootstrapActionConfig]
(Int -> ReadS BootstrapActionConfig)
-> ReadS [BootstrapActionConfig]
-> ReadPrec BootstrapActionConfig
-> ReadPrec [BootstrapActionConfig]
-> Read BootstrapActionConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BootstrapActionConfig]
$creadListPrec :: ReadPrec [BootstrapActionConfig]
readPrec :: ReadPrec BootstrapActionConfig
$creadPrec :: ReadPrec BootstrapActionConfig
readList :: ReadS [BootstrapActionConfig]
$creadList :: ReadS [BootstrapActionConfig]
readsPrec :: Int -> ReadS BootstrapActionConfig
$creadsPrec :: Int -> ReadS BootstrapActionConfig
Prelude.Read, Int -> BootstrapActionConfig -> ShowS
[BootstrapActionConfig] -> ShowS
BootstrapActionConfig -> String
(Int -> BootstrapActionConfig -> ShowS)
-> (BootstrapActionConfig -> String)
-> ([BootstrapActionConfig] -> ShowS)
-> Show BootstrapActionConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BootstrapActionConfig] -> ShowS
$cshowList :: [BootstrapActionConfig] -> ShowS
show :: BootstrapActionConfig -> String
$cshow :: BootstrapActionConfig -> String
showsPrec :: Int -> BootstrapActionConfig -> ShowS
$cshowsPrec :: Int -> BootstrapActionConfig -> ShowS
Prelude.Show, (forall x. BootstrapActionConfig -> Rep BootstrapActionConfig x)
-> (forall x. Rep BootstrapActionConfig x -> BootstrapActionConfig)
-> Generic BootstrapActionConfig
forall x. Rep BootstrapActionConfig x -> BootstrapActionConfig
forall x. BootstrapActionConfig -> Rep BootstrapActionConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BootstrapActionConfig x -> BootstrapActionConfig
$cfrom :: forall x. BootstrapActionConfig -> Rep BootstrapActionConfig x
Prelude.Generic)

-- |
-- Create a value of 'BootstrapActionConfig' 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:
--
-- 'name', 'bootstrapActionConfig_name' - The name of the bootstrap action.
--
-- 'scriptBootstrapAction', 'bootstrapActionConfig_scriptBootstrapAction' - The script run by the bootstrap action.
newBootstrapActionConfig ::
  -- | 'name'
  Prelude.Text ->
  -- | 'scriptBootstrapAction'
  ScriptBootstrapActionConfig ->
  BootstrapActionConfig
newBootstrapActionConfig :: Text -> ScriptBootstrapActionConfig -> BootstrapActionConfig
newBootstrapActionConfig
  Text
pName_
  ScriptBootstrapActionConfig
pScriptBootstrapAction_ =
    BootstrapActionConfig' :: Text -> ScriptBootstrapActionConfig -> BootstrapActionConfig
BootstrapActionConfig'
      { $sel:name:BootstrapActionConfig' :: Text
name = Text
pName_,
        $sel:scriptBootstrapAction:BootstrapActionConfig' :: ScriptBootstrapActionConfig
scriptBootstrapAction = ScriptBootstrapActionConfig
pScriptBootstrapAction_
      }

-- | The name of the bootstrap action.
bootstrapActionConfig_name :: Lens.Lens' BootstrapActionConfig Prelude.Text
bootstrapActionConfig_name :: (Text -> f Text)
-> BootstrapActionConfig -> f BootstrapActionConfig
bootstrapActionConfig_name = (BootstrapActionConfig -> Text)
-> (BootstrapActionConfig -> Text -> BootstrapActionConfig)
-> Lens BootstrapActionConfig BootstrapActionConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BootstrapActionConfig' {Text
name :: Text
$sel:name:BootstrapActionConfig' :: BootstrapActionConfig -> Text
name} -> Text
name) (\s :: BootstrapActionConfig
s@BootstrapActionConfig' {} Text
a -> BootstrapActionConfig
s {$sel:name:BootstrapActionConfig' :: Text
name = Text
a} :: BootstrapActionConfig)

-- | The script run by the bootstrap action.
bootstrapActionConfig_scriptBootstrapAction :: Lens.Lens' BootstrapActionConfig ScriptBootstrapActionConfig
bootstrapActionConfig_scriptBootstrapAction :: (ScriptBootstrapActionConfig -> f ScriptBootstrapActionConfig)
-> BootstrapActionConfig -> f BootstrapActionConfig
bootstrapActionConfig_scriptBootstrapAction = (BootstrapActionConfig -> ScriptBootstrapActionConfig)
-> (BootstrapActionConfig
    -> ScriptBootstrapActionConfig -> BootstrapActionConfig)
-> Lens
     BootstrapActionConfig
     BootstrapActionConfig
     ScriptBootstrapActionConfig
     ScriptBootstrapActionConfig
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BootstrapActionConfig' {ScriptBootstrapActionConfig
scriptBootstrapAction :: ScriptBootstrapActionConfig
$sel:scriptBootstrapAction:BootstrapActionConfig' :: BootstrapActionConfig -> ScriptBootstrapActionConfig
scriptBootstrapAction} -> ScriptBootstrapActionConfig
scriptBootstrapAction) (\s :: BootstrapActionConfig
s@BootstrapActionConfig' {} ScriptBootstrapActionConfig
a -> BootstrapActionConfig
s {$sel:scriptBootstrapAction:BootstrapActionConfig' :: ScriptBootstrapActionConfig
scriptBootstrapAction = ScriptBootstrapActionConfig
a} :: BootstrapActionConfig)

instance Prelude.Hashable BootstrapActionConfig

instance Prelude.NFData BootstrapActionConfig

instance Core.ToJSON BootstrapActionConfig where
  toJSON :: BootstrapActionConfig -> Value
toJSON BootstrapActionConfig' {Text
ScriptBootstrapActionConfig
scriptBootstrapAction :: ScriptBootstrapActionConfig
name :: Text
$sel:scriptBootstrapAction:BootstrapActionConfig' :: BootstrapActionConfig -> ScriptBootstrapActionConfig
$sel:name:BootstrapActionConfig' :: BootstrapActionConfig -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"ScriptBootstrapAction"
                  Text -> ScriptBootstrapActionConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ScriptBootstrapActionConfig
scriptBootstrapAction
              )
          ]
      )