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

-- | 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
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]
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
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. 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'
    { $sel:args:HadoopStepConfig' :: Maybe [Text]
args = forall a. Maybe a
Prelude.Nothing,
      $sel:jar:HadoopStepConfig' :: Maybe Text
jar = forall a. Maybe a
Prelude.Nothing,
      $sel:mainClass:HadoopStepConfig' :: Maybe Text
mainClass = forall a. Maybe a
Prelude.Nothing,
      $sel:properties:HadoopStepConfig' :: Maybe (HashMap Text Text)
properties = 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 :: Lens' HadoopStepConfig (Maybe [Text])
hadoopStepConfig_args = 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) 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

-- | The path to the JAR file that runs during the step.
hadoopStepConfig_jar :: Lens.Lens' HadoopStepConfig (Prelude.Maybe Prelude.Text)
hadoopStepConfig_jar :: Lens' HadoopStepConfig (Maybe Text)
hadoopStepConfig_jar = 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 :: Lens' HadoopStepConfig (Maybe Text)
hadoopStepConfig_mainClass = 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 :: Lens' HadoopStepConfig (Maybe (HashMap Text Text))
hadoopStepConfig_properties = 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) 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

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

instance Prelude.Hashable HadoopStepConfig where
  hashWithSalt :: Int -> HadoopStepConfig -> Int
hashWithSalt Int
_salt HadoopStepConfig' {Maybe [Text]
Maybe Text
Maybe (HashMap Text Text)
properties :: Maybe (HashMap Text Text)
mainClass :: Maybe Text
jar :: Maybe Text
args :: Maybe [Text]
$sel:properties:HadoopStepConfig' :: HadoopStepConfig -> Maybe (HashMap Text Text)
$sel:mainClass:HadoopStepConfig' :: HadoopStepConfig -> Maybe Text
$sel:jar:HadoopStepConfig' :: HadoopStepConfig -> Maybe Text
$sel:args:HadoopStepConfig' :: HadoopStepConfig -> 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` Maybe Text
jar
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
mainClass
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
properties

instance Prelude.NFData HadoopStepConfig where
  rnf :: HadoopStepConfig -> ()
rnf HadoopStepConfig' {Maybe [Text]
Maybe Text
Maybe (HashMap Text Text)
properties :: Maybe (HashMap Text Text)
mainClass :: Maybe Text
jar :: Maybe Text
args :: Maybe [Text]
$sel:properties:HadoopStepConfig' :: HadoopStepConfig -> Maybe (HashMap Text Text)
$sel:mainClass:HadoopStepConfig' :: HadoopStepConfig -> Maybe Text
$sel:jar:HadoopStepConfig' :: HadoopStepConfig -> Maybe Text
$sel:args:HadoopStepConfig' :: HadoopStepConfig -> 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 Maybe Text
jar
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
mainClass
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
properties