{-# 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.HadoopJarStepConfig
-- 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.HadoopJarStepConfig 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.KeyValue
import qualified Amazonka.Prelude as Prelude

-- | A job flow 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:/ 'newHadoopJarStepConfig' smart constructor.
data HadoopJarStepConfig = HadoopJarStepConfig'
  { -- | A list of command line arguments passed to the JAR file\'s main function
    -- when executed.
    HadoopJarStepConfig -> Maybe [Text]
args :: 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.
    HadoopJarStepConfig -> Maybe Text
mainClass :: Prelude.Maybe Prelude.Text,
    -- | A 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.
    HadoopJarStepConfig -> Maybe [KeyValue]
properties :: Prelude.Maybe [KeyValue],
    -- | A path to a JAR file run during the step.
    HadoopJarStepConfig -> Text
jar :: Prelude.Text
  }
  deriving (HadoopJarStepConfig -> HadoopJarStepConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HadoopJarStepConfig -> HadoopJarStepConfig -> Bool
$c/= :: HadoopJarStepConfig -> HadoopJarStepConfig -> Bool
== :: HadoopJarStepConfig -> HadoopJarStepConfig -> Bool
$c== :: HadoopJarStepConfig -> HadoopJarStepConfig -> Bool
Prelude.Eq, ReadPrec [HadoopJarStepConfig]
ReadPrec HadoopJarStepConfig
Int -> ReadS HadoopJarStepConfig
ReadS [HadoopJarStepConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HadoopJarStepConfig]
$creadListPrec :: ReadPrec [HadoopJarStepConfig]
readPrec :: ReadPrec HadoopJarStepConfig
$creadPrec :: ReadPrec HadoopJarStepConfig
readList :: ReadS [HadoopJarStepConfig]
$creadList :: ReadS [HadoopJarStepConfig]
readsPrec :: Int -> ReadS HadoopJarStepConfig
$creadsPrec :: Int -> ReadS HadoopJarStepConfig
Prelude.Read, Int -> HadoopJarStepConfig -> ShowS
[HadoopJarStepConfig] -> ShowS
HadoopJarStepConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HadoopJarStepConfig] -> ShowS
$cshowList :: [HadoopJarStepConfig] -> ShowS
show :: HadoopJarStepConfig -> String
$cshow :: HadoopJarStepConfig -> String
showsPrec :: Int -> HadoopJarStepConfig -> ShowS
$cshowsPrec :: Int -> HadoopJarStepConfig -> ShowS
Prelude.Show, forall x. Rep HadoopJarStepConfig x -> HadoopJarStepConfig
forall x. HadoopJarStepConfig -> Rep HadoopJarStepConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HadoopJarStepConfig x -> HadoopJarStepConfig
$cfrom :: forall x. HadoopJarStepConfig -> Rep HadoopJarStepConfig x
Prelude.Generic)

-- |
-- Create a value of 'HadoopJarStepConfig' 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', 'hadoopJarStepConfig_args' - A list of command line arguments passed to the JAR file\'s main function
-- when executed.
--
-- 'mainClass', 'hadoopJarStepConfig_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', 'hadoopJarStepConfig_properties' - A 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.
--
-- 'jar', 'hadoopJarStepConfig_jar' - A path to a JAR file run during the step.
newHadoopJarStepConfig ::
  -- | 'jar'
  Prelude.Text ->
  HadoopJarStepConfig
newHadoopJarStepConfig :: Text -> HadoopJarStepConfig
newHadoopJarStepConfig Text
pJar_ =
  HadoopJarStepConfig'
    { $sel:args:HadoopJarStepConfig' :: Maybe [Text]
args = forall a. Maybe a
Prelude.Nothing,
      $sel:mainClass:HadoopJarStepConfig' :: Maybe Text
mainClass = forall a. Maybe a
Prelude.Nothing,
      $sel:properties:HadoopJarStepConfig' :: Maybe [KeyValue]
properties = forall a. Maybe a
Prelude.Nothing,
      $sel:jar:HadoopJarStepConfig' :: Text
jar = Text
pJar_
    }

-- | A list of command line arguments passed to the JAR file\'s main function
-- when executed.
hadoopJarStepConfig_args :: Lens.Lens' HadoopJarStepConfig (Prelude.Maybe [Prelude.Text])
hadoopJarStepConfig_args :: Lens' HadoopJarStepConfig (Maybe [Text])
hadoopJarStepConfig_args = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HadoopJarStepConfig' {Maybe [Text]
args :: Maybe [Text]
$sel:args:HadoopJarStepConfig' :: HadoopJarStepConfig -> Maybe [Text]
args} -> Maybe [Text]
args) (\s :: HadoopJarStepConfig
s@HadoopJarStepConfig' {} Maybe [Text]
a -> HadoopJarStepConfig
s {$sel:args:HadoopJarStepConfig' :: Maybe [Text]
args = Maybe [Text]
a} :: HadoopJarStepConfig) 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 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.
hadoopJarStepConfig_mainClass :: Lens.Lens' HadoopJarStepConfig (Prelude.Maybe Prelude.Text)
hadoopJarStepConfig_mainClass :: Lens' HadoopJarStepConfig (Maybe Text)
hadoopJarStepConfig_mainClass = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HadoopJarStepConfig' {Maybe Text
mainClass :: Maybe Text
$sel:mainClass:HadoopJarStepConfig' :: HadoopJarStepConfig -> Maybe Text
mainClass} -> Maybe Text
mainClass) (\s :: HadoopJarStepConfig
s@HadoopJarStepConfig' {} Maybe Text
a -> HadoopJarStepConfig
s {$sel:mainClass:HadoopJarStepConfig' :: Maybe Text
mainClass = Maybe Text
a} :: HadoopJarStepConfig)

-- | A 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.
hadoopJarStepConfig_properties :: Lens.Lens' HadoopJarStepConfig (Prelude.Maybe [KeyValue])
hadoopJarStepConfig_properties :: Lens' HadoopJarStepConfig (Maybe [KeyValue])
hadoopJarStepConfig_properties = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HadoopJarStepConfig' {Maybe [KeyValue]
properties :: Maybe [KeyValue]
$sel:properties:HadoopJarStepConfig' :: HadoopJarStepConfig -> Maybe [KeyValue]
properties} -> Maybe [KeyValue]
properties) (\s :: HadoopJarStepConfig
s@HadoopJarStepConfig' {} Maybe [KeyValue]
a -> HadoopJarStepConfig
s {$sel:properties:HadoopJarStepConfig' :: Maybe [KeyValue]
properties = Maybe [KeyValue]
a} :: HadoopJarStepConfig) 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

-- | A path to a JAR file run during the step.
hadoopJarStepConfig_jar :: Lens.Lens' HadoopJarStepConfig Prelude.Text
hadoopJarStepConfig_jar :: Lens' HadoopJarStepConfig Text
hadoopJarStepConfig_jar = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HadoopJarStepConfig' {Text
jar :: Text
$sel:jar:HadoopJarStepConfig' :: HadoopJarStepConfig -> Text
jar} -> Text
jar) (\s :: HadoopJarStepConfig
s@HadoopJarStepConfig' {} Text
a -> HadoopJarStepConfig
s {$sel:jar:HadoopJarStepConfig' :: Text
jar = Text
a} :: HadoopJarStepConfig)

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

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

instance Data.ToJSON HadoopJarStepConfig where
  toJSON :: HadoopJarStepConfig -> Value
toJSON HadoopJarStepConfig' {Maybe [Text]
Maybe [KeyValue]
Maybe Text
Text
jar :: Text
properties :: Maybe [KeyValue]
mainClass :: Maybe Text
args :: Maybe [Text]
$sel:jar:HadoopJarStepConfig' :: HadoopJarStepConfig -> Text
$sel:properties:HadoopJarStepConfig' :: HadoopJarStepConfig -> Maybe [KeyValue]
$sel:mainClass:HadoopJarStepConfig' :: HadoopJarStepConfig -> Maybe Text
$sel:args:HadoopJarStepConfig' :: HadoopJarStepConfig -> 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,
            (Key
"MainClass" 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
mainClass,
            (Key
"Properties" 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 [KeyValue]
properties,
            forall a. a -> Maybe a
Prelude.Just (Key
"Jar" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
jar)
          ]
      )