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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A cluster step consisting of a JAR file whose main function will be
-- executed. The main function submits a job for Hadoop to execute and
-- waits for the job to finish or fail.
--
-- /See:/ 'newHadoopStepConfig' smart constructor.
data HadoopStepConfig = HadoopStepConfig'
  { -- | The list of command line arguments to pass to the JAR file\'s main
    -- function for execution.
    HadoopStepConfig -> Maybe [Text]
args :: Prelude.Maybe [Prelude.Text],
    -- | The path to the JAR file that runs during the step.
    HadoopStepConfig -> Maybe Text
jar :: Prelude.Maybe Prelude.Text,
    -- | The name of the main class in the specified Java file. If not specified,
    -- the JAR file should specify a main class in its manifest file.
    HadoopStepConfig -> Maybe Text
mainClass :: Prelude.Maybe Prelude.Text,
    -- | The list of Java properties that are set when the step runs. You can use
    -- these properties to pass key-value pairs to your main function.
    HadoopStepConfig -> Maybe (HashMap Text Text)
properties :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (HadoopStepConfig -> HadoopStepConfig -> Bool
(HadoopStepConfig -> HadoopStepConfig -> Bool)
-> (HadoopStepConfig -> HadoopStepConfig -> Bool)
-> Eq HadoopStepConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HadoopStepConfig -> HadoopStepConfig -> Bool
$c/= :: HadoopStepConfig -> HadoopStepConfig -> Bool
== :: HadoopStepConfig -> HadoopStepConfig -> Bool
$c== :: HadoopStepConfig -> HadoopStepConfig -> Bool
Prelude.Eq, ReadPrec [HadoopStepConfig]
ReadPrec HadoopStepConfig
Int -> ReadS HadoopStepConfig
ReadS [HadoopStepConfig]
(Int -> ReadS HadoopStepConfig)
-> ReadS [HadoopStepConfig]
-> ReadPrec HadoopStepConfig
-> ReadPrec [HadoopStepConfig]
-> Read HadoopStepConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HadoopStepConfig]
$creadListPrec :: ReadPrec [HadoopStepConfig]
readPrec :: ReadPrec HadoopStepConfig
$creadPrec :: ReadPrec HadoopStepConfig
readList :: ReadS [HadoopStepConfig]
$creadList :: ReadS [HadoopStepConfig]
readsPrec :: Int -> ReadS HadoopStepConfig
$creadsPrec :: Int -> ReadS HadoopStepConfig
Prelude.Read, Int -> HadoopStepConfig -> ShowS
[HadoopStepConfig] -> ShowS
HadoopStepConfig -> String
(Int -> HadoopStepConfig -> ShowS)
-> (HadoopStepConfig -> String)
-> ([HadoopStepConfig] -> ShowS)
-> Show HadoopStepConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HadoopStepConfig] -> ShowS
$cshowList :: [HadoopStepConfig] -> ShowS
show :: HadoopStepConfig -> String
$cshow :: HadoopStepConfig -> String
showsPrec :: Int -> HadoopStepConfig -> ShowS
$cshowsPrec :: Int -> HadoopStepConfig -> ShowS
Prelude.Show, (forall x. HadoopStepConfig -> Rep HadoopStepConfig x)
-> (forall x. Rep HadoopStepConfig x -> HadoopStepConfig)
-> Generic HadoopStepConfig
forall x. Rep HadoopStepConfig x -> HadoopStepConfig
forall x. HadoopStepConfig -> Rep HadoopStepConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HadoopStepConfig x -> HadoopStepConfig
$cfrom :: forall x. HadoopStepConfig -> Rep HadoopStepConfig x
Prelude.Generic)

-- |
-- Create a value of 'HadoopStepConfig' 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', 'hadoopStepConfig_args' - The list of command line arguments to pass to the JAR file\'s main
-- function for execution.
--
-- 'jar', 'hadoopStepConfig_jar' - The path to the JAR file that runs during the step.
--
-- 'mainClass', 'hadoopStepConfig_mainClass' - The name of the main class in the specified Java file. If not specified,
-- the JAR file should specify a main class in its manifest file.
--
-- 'properties', 'hadoopStepConfig_properties' - The list of Java properties that are set when the step runs. You can use
-- these properties to pass key-value pairs to your main function.
newHadoopStepConfig ::
  HadoopStepConfig
newHadoopStepConfig :: HadoopStepConfig
newHadoopStepConfig =
  HadoopStepConfig' :: Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> HadoopStepConfig
HadoopStepConfig'
    { $sel:args:HadoopStepConfig' :: Maybe [Text]
args = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:jar:HadoopStepConfig' :: Maybe Text
jar = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:mainClass:HadoopStepConfig' :: Maybe Text
mainClass = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:properties:HadoopStepConfig' :: Maybe (HashMap Text Text)
properties = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | The list of command line arguments to pass to the JAR file\'s main
-- function for execution.
hadoopStepConfig_args :: Lens.Lens' HadoopStepConfig (Prelude.Maybe [Prelude.Text])
hadoopStepConfig_args :: (Maybe [Text] -> f (Maybe [Text]))
-> HadoopStepConfig -> f HadoopStepConfig
hadoopStepConfig_args = (HadoopStepConfig -> Maybe [Text])
-> (HadoopStepConfig -> Maybe [Text] -> HadoopStepConfig)
-> Lens
     HadoopStepConfig HadoopStepConfig (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HadoopStepConfig' {Maybe [Text]
args :: Maybe [Text]
$sel:args:HadoopStepConfig' :: HadoopStepConfig -> Maybe [Text]
args} -> Maybe [Text]
args) (\s :: HadoopStepConfig
s@HadoopStepConfig' {} Maybe [Text]
a -> HadoopStepConfig
s {$sel:args:HadoopStepConfig' :: Maybe [Text]
args = Maybe [Text]
a} :: HadoopStepConfig) ((Maybe [Text] -> f (Maybe [Text]))
 -> HadoopStepConfig -> f HadoopStepConfig)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> HadoopStepConfig
-> f HadoopStepConfig
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

-- | The path to the JAR file that runs during the step.
hadoopStepConfig_jar :: Lens.Lens' HadoopStepConfig (Prelude.Maybe Prelude.Text)
hadoopStepConfig_jar :: (Maybe Text -> f (Maybe Text))
-> HadoopStepConfig -> f HadoopStepConfig
hadoopStepConfig_jar = (HadoopStepConfig -> Maybe Text)
-> (HadoopStepConfig -> Maybe Text -> HadoopStepConfig)
-> Lens HadoopStepConfig HadoopStepConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HadoopStepConfig' {Maybe Text
jar :: Maybe Text
$sel:jar:HadoopStepConfig' :: HadoopStepConfig -> Maybe Text
jar} -> Maybe Text
jar) (\s :: HadoopStepConfig
s@HadoopStepConfig' {} Maybe Text
a -> HadoopStepConfig
s {$sel:jar:HadoopStepConfig' :: Maybe Text
jar = Maybe Text
a} :: HadoopStepConfig)

-- | The name of the main class in the specified Java file. If not specified,
-- the JAR file should specify a main class in its manifest file.
hadoopStepConfig_mainClass :: Lens.Lens' HadoopStepConfig (Prelude.Maybe Prelude.Text)
hadoopStepConfig_mainClass :: (Maybe Text -> f (Maybe Text))
-> HadoopStepConfig -> f HadoopStepConfig
hadoopStepConfig_mainClass = (HadoopStepConfig -> Maybe Text)
-> (HadoopStepConfig -> Maybe Text -> HadoopStepConfig)
-> Lens HadoopStepConfig HadoopStepConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HadoopStepConfig' {Maybe Text
mainClass :: Maybe Text
$sel:mainClass:HadoopStepConfig' :: HadoopStepConfig -> Maybe Text
mainClass} -> Maybe Text
mainClass) (\s :: HadoopStepConfig
s@HadoopStepConfig' {} Maybe Text
a -> HadoopStepConfig
s {$sel:mainClass:HadoopStepConfig' :: Maybe Text
mainClass = Maybe Text
a} :: HadoopStepConfig)

-- | The list of Java properties that are set when the step runs. You can use
-- these properties to pass key-value pairs to your main function.
hadoopStepConfig_properties :: Lens.Lens' HadoopStepConfig (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
hadoopStepConfig_properties :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> HadoopStepConfig -> f HadoopStepConfig
hadoopStepConfig_properties = (HadoopStepConfig -> Maybe (HashMap Text Text))
-> (HadoopStepConfig
    -> Maybe (HashMap Text Text) -> HadoopStepConfig)
-> Lens
     HadoopStepConfig
     HadoopStepConfig
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HadoopStepConfig' {Maybe (HashMap Text Text)
properties :: Maybe (HashMap Text Text)
$sel:properties:HadoopStepConfig' :: HadoopStepConfig -> Maybe (HashMap Text Text)
properties} -> Maybe (HashMap Text Text)
properties) (\s :: HadoopStepConfig
s@HadoopStepConfig' {} Maybe (HashMap Text Text)
a -> HadoopStepConfig
s {$sel:properties:HadoopStepConfig' :: Maybe (HashMap Text Text)
properties = Maybe (HashMap Text Text)
a} :: HadoopStepConfig) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> HadoopStepConfig -> f HadoopStepConfig)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> HadoopStepConfig
-> f HadoopStepConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text 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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON HadoopStepConfig where
  parseJSON :: Value -> Parser HadoopStepConfig
parseJSON =
    String
-> (Object -> Parser HadoopStepConfig)
-> Value
-> Parser HadoopStepConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HadoopStepConfig"
      ( \Object
x ->
          Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> HadoopStepConfig
HadoopStepConfig'
            (Maybe [Text]
 -> Maybe Text
 -> Maybe Text
 -> Maybe (HashMap Text Text)
 -> HadoopStepConfig)
-> Parser (Maybe [Text])
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe (HashMap Text Text) -> HadoopStepConfig)
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
"Args" 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 (HashMap Text Text) -> HadoopStepConfig)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe (HashMap Text Text) -> HadoopStepConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Jar")
            Parser
  (Maybe Text -> Maybe (HashMap Text Text) -> HadoopStepConfig)
-> Parser (Maybe Text)
-> Parser (Maybe (HashMap Text Text) -> HadoopStepConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MainClass")
            Parser (Maybe (HashMap Text Text) -> HadoopStepConfig)
-> Parser (Maybe (HashMap Text Text)) -> Parser HadoopStepConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Properties" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable HadoopStepConfig

instance Prelude.NFData HadoopStepConfig