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

-- | Configuration of the script to run during a bootstrap action.
--
-- /See:/ 'newScriptBootstrapActionConfig' smart constructor.
data ScriptBootstrapActionConfig = ScriptBootstrapActionConfig'
  { -- | A list of command line arguments to pass to the bootstrap action script.
    ScriptBootstrapActionConfig -> Maybe [Text]
args :: Prelude.Maybe [Prelude.Text],
    -- | Location in Amazon S3 of the script to run during a bootstrap action.
    ScriptBootstrapActionConfig -> Text
path :: Prelude.Text
  }
  deriving (ScriptBootstrapActionConfig -> ScriptBootstrapActionConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScriptBootstrapActionConfig -> ScriptBootstrapActionConfig -> Bool
$c/= :: ScriptBootstrapActionConfig -> ScriptBootstrapActionConfig -> Bool
== :: ScriptBootstrapActionConfig -> ScriptBootstrapActionConfig -> Bool
$c== :: ScriptBootstrapActionConfig -> ScriptBootstrapActionConfig -> Bool
Prelude.Eq, ReadPrec [ScriptBootstrapActionConfig]
ReadPrec ScriptBootstrapActionConfig
Int -> ReadS ScriptBootstrapActionConfig
ReadS [ScriptBootstrapActionConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScriptBootstrapActionConfig]
$creadListPrec :: ReadPrec [ScriptBootstrapActionConfig]
readPrec :: ReadPrec ScriptBootstrapActionConfig
$creadPrec :: ReadPrec ScriptBootstrapActionConfig
readList :: ReadS [ScriptBootstrapActionConfig]
$creadList :: ReadS [ScriptBootstrapActionConfig]
readsPrec :: Int -> ReadS ScriptBootstrapActionConfig
$creadsPrec :: Int -> ReadS ScriptBootstrapActionConfig
Prelude.Read, Int -> ScriptBootstrapActionConfig -> ShowS
[ScriptBootstrapActionConfig] -> ShowS
ScriptBootstrapActionConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScriptBootstrapActionConfig] -> ShowS
$cshowList :: [ScriptBootstrapActionConfig] -> ShowS
show :: ScriptBootstrapActionConfig -> String
$cshow :: ScriptBootstrapActionConfig -> String
showsPrec :: Int -> ScriptBootstrapActionConfig -> ShowS
$cshowsPrec :: Int -> ScriptBootstrapActionConfig -> ShowS
Prelude.Show, forall x.
Rep ScriptBootstrapActionConfig x -> ScriptBootstrapActionConfig
forall x.
ScriptBootstrapActionConfig -> Rep ScriptBootstrapActionConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ScriptBootstrapActionConfig x -> ScriptBootstrapActionConfig
$cfrom :: forall x.
ScriptBootstrapActionConfig -> Rep ScriptBootstrapActionConfig x
Prelude.Generic)

-- |
-- Create a value of 'ScriptBootstrapActionConfig' 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:
--
-- 'args', 'scriptBootstrapActionConfig_args' - A list of command line arguments to pass to the bootstrap action script.
--
-- 'path', 'scriptBootstrapActionConfig_path' - Location in Amazon S3 of the script to run during a bootstrap action.
newScriptBootstrapActionConfig ::
  -- | 'path'
  Prelude.Text ->
  ScriptBootstrapActionConfig
newScriptBootstrapActionConfig :: Text -> ScriptBootstrapActionConfig
newScriptBootstrapActionConfig Text
pPath_ =
  ScriptBootstrapActionConfig'
    { $sel:args:ScriptBootstrapActionConfig' :: Maybe [Text]
args =
        forall a. Maybe a
Prelude.Nothing,
      $sel:path:ScriptBootstrapActionConfig' :: Text
path = Text
pPath_
    }

-- | A list of command line arguments to pass to the bootstrap action script.
scriptBootstrapActionConfig_args :: Lens.Lens' ScriptBootstrapActionConfig (Prelude.Maybe [Prelude.Text])
scriptBootstrapActionConfig_args :: Lens' ScriptBootstrapActionConfig (Maybe [Text])
scriptBootstrapActionConfig_args = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScriptBootstrapActionConfig' {Maybe [Text]
args :: Maybe [Text]
$sel:args:ScriptBootstrapActionConfig' :: ScriptBootstrapActionConfig -> Maybe [Text]
args} -> Maybe [Text]
args) (\s :: ScriptBootstrapActionConfig
s@ScriptBootstrapActionConfig' {} Maybe [Text]
a -> ScriptBootstrapActionConfig
s {$sel:args:ScriptBootstrapActionConfig' :: Maybe [Text]
args = Maybe [Text]
a} :: ScriptBootstrapActionConfig) 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

-- | Location in Amazon S3 of the script to run during a bootstrap action.
scriptBootstrapActionConfig_path :: Lens.Lens' ScriptBootstrapActionConfig Prelude.Text
scriptBootstrapActionConfig_path :: Lens' ScriptBootstrapActionConfig Text
scriptBootstrapActionConfig_path = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScriptBootstrapActionConfig' {Text
path :: Text
$sel:path:ScriptBootstrapActionConfig' :: ScriptBootstrapActionConfig -> Text
path} -> Text
path) (\s :: ScriptBootstrapActionConfig
s@ScriptBootstrapActionConfig' {} Text
a -> ScriptBootstrapActionConfig
s {$sel:path:ScriptBootstrapActionConfig' :: Text
path = Text
a} :: ScriptBootstrapActionConfig)

instance Prelude.Hashable ScriptBootstrapActionConfig where
  hashWithSalt :: Int -> ScriptBootstrapActionConfig -> Int
hashWithSalt Int
_salt ScriptBootstrapActionConfig' {Maybe [Text]
Text
path :: Text
args :: Maybe [Text]
$sel:path:ScriptBootstrapActionConfig' :: ScriptBootstrapActionConfig -> Text
$sel:args:ScriptBootstrapActionConfig' :: ScriptBootstrapActionConfig -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
args
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
path

instance Prelude.NFData ScriptBootstrapActionConfig where
  rnf :: ScriptBootstrapActionConfig -> ()
rnf ScriptBootstrapActionConfig' {Maybe [Text]
Text
path :: Text
args :: Maybe [Text]
$sel:path:ScriptBootstrapActionConfig' :: ScriptBootstrapActionConfig -> Text
$sel:args:ScriptBootstrapActionConfig' :: ScriptBootstrapActionConfig -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
args seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
path

instance Data.ToJSON ScriptBootstrapActionConfig where
  toJSON :: ScriptBootstrapActionConfig -> Value
toJSON ScriptBootstrapActionConfig' {Maybe [Text]
Text
path :: Text
args :: Maybe [Text]
$sel:path:ScriptBootstrapActionConfig' :: ScriptBootstrapActionConfig -> Text
$sel:args:ScriptBootstrapActionConfig' :: ScriptBootstrapActionConfig -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Args" 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]
args,
            forall a. a -> Maybe a
Prelude.Just (Key
"Path" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
path)
          ]
      )