{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.EMR.Types.BootstrapActionConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EMR.Types.ScriptBootstrapActionConfig
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
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]
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
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. 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'
      { $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 :: Lens' BootstrapActionConfig Text
bootstrapActionConfig_name = 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 :: Lens' BootstrapActionConfig ScriptBootstrapActionConfig
bootstrapActionConfig_scriptBootstrapAction = 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 where
  hashWithSalt :: Int -> BootstrapActionConfig -> Int
hashWithSalt Int
_salt BootstrapActionConfig' {Text
ScriptBootstrapActionConfig
scriptBootstrapAction :: ScriptBootstrapActionConfig
name :: Text
$sel:scriptBootstrapAction:BootstrapActionConfig' :: BootstrapActionConfig -> ScriptBootstrapActionConfig
$sel:name:BootstrapActionConfig' :: BootstrapActionConfig -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ScriptBootstrapActionConfig
scriptBootstrapAction

instance Prelude.NFData BootstrapActionConfig where
  rnf :: BootstrapActionConfig -> ()
rnf BootstrapActionConfig' {Text
ScriptBootstrapActionConfig
scriptBootstrapAction :: ScriptBootstrapActionConfig
name :: Text
$sel:scriptBootstrapAction:BootstrapActionConfig' :: BootstrapActionConfig -> ScriptBootstrapActionConfig
$sel:name:BootstrapActionConfig' :: BootstrapActionConfig -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ScriptBootstrapActionConfig
scriptBootstrapAction

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"ScriptBootstrapAction"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ScriptBootstrapActionConfig
scriptBootstrapAction
              )
          ]
      )