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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ScriptBootstrapActionConfig
 -> ScriptBootstrapActionConfig -> Bool)
-> (ScriptBootstrapActionConfig
    -> ScriptBootstrapActionConfig -> Bool)
-> Eq ScriptBootstrapActionConfig
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]
(Int -> ReadS ScriptBootstrapActionConfig)
-> ReadS [ScriptBootstrapActionConfig]
-> ReadPrec ScriptBootstrapActionConfig
-> ReadPrec [ScriptBootstrapActionConfig]
-> Read 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
(Int -> ScriptBootstrapActionConfig -> ShowS)
-> (ScriptBootstrapActionConfig -> String)
-> ([ScriptBootstrapActionConfig] -> ShowS)
-> Show ScriptBootstrapActionConfig
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.
 ScriptBootstrapActionConfig -> Rep ScriptBootstrapActionConfig x)
-> (forall x.
    Rep ScriptBootstrapActionConfig x -> ScriptBootstrapActionConfig)
-> Generic ScriptBootstrapActionConfig
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' :: Maybe [Text] -> Text -> ScriptBootstrapActionConfig
ScriptBootstrapActionConfig'
    { $sel:args:ScriptBootstrapActionConfig' :: Maybe [Text]
args =
        Maybe [Text]
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 :: (Maybe [Text] -> f (Maybe [Text]))
-> ScriptBootstrapActionConfig -> f ScriptBootstrapActionConfig
scriptBootstrapActionConfig_args = (ScriptBootstrapActionConfig -> Maybe [Text])
-> (ScriptBootstrapActionConfig
    -> Maybe [Text] -> ScriptBootstrapActionConfig)
-> Lens
     ScriptBootstrapActionConfig
     ScriptBootstrapActionConfig
     (Maybe [Text])
     (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> ScriptBootstrapActionConfig -> f ScriptBootstrapActionConfig)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ScriptBootstrapActionConfig
-> f ScriptBootstrapActionConfig
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

-- | Location in Amazon S3 of the script to run during a bootstrap action.
scriptBootstrapActionConfig_path :: Lens.Lens' ScriptBootstrapActionConfig Prelude.Text
scriptBootstrapActionConfig_path :: (Text -> f Text)
-> ScriptBootstrapActionConfig -> f ScriptBootstrapActionConfig
scriptBootstrapActionConfig_path = (ScriptBootstrapActionConfig -> Text)
-> (ScriptBootstrapActionConfig
    -> Text -> ScriptBootstrapActionConfig)
-> Lens
     ScriptBootstrapActionConfig ScriptBootstrapActionConfig Text Text
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

instance Prelude.NFData ScriptBootstrapActionConfig

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Args" 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]
args,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Path" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
path)
          ]
      )