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

import qualified Amazonka.Core as Core
import Amazonka.EMR.Types.KeyValue
import qualified Amazonka.Lens as Lens
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
(HadoopJarStepConfig -> HadoopJarStepConfig -> Bool)
-> (HadoopJarStepConfig -> HadoopJarStepConfig -> Bool)
-> Eq HadoopJarStepConfig
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]
(Int -> ReadS HadoopJarStepConfig)
-> ReadS [HadoopJarStepConfig]
-> ReadPrec HadoopJarStepConfig
-> ReadPrec [HadoopJarStepConfig]
-> Read 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
(Int -> HadoopJarStepConfig -> ShowS)
-> (HadoopJarStepConfig -> String)
-> ([HadoopJarStepConfig] -> ShowS)
-> Show HadoopJarStepConfig
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. HadoopJarStepConfig -> Rep HadoopJarStepConfig x)
-> (forall x. Rep HadoopJarStepConfig x -> HadoopJarStepConfig)
-> Generic HadoopJarStepConfig
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' :: Maybe [Text]
-> Maybe Text -> Maybe [KeyValue] -> Text -> HadoopJarStepConfig
HadoopJarStepConfig'
    { $sel:args:HadoopJarStepConfig' :: Maybe [Text]
args = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:mainClass:HadoopJarStepConfig' :: Maybe Text
mainClass = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:properties:HadoopJarStepConfig' :: Maybe [KeyValue]
properties = Maybe [KeyValue]
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 :: (Maybe [Text] -> f (Maybe [Text]))
-> HadoopJarStepConfig -> f HadoopJarStepConfig
hadoopJarStepConfig_args = (HadoopJarStepConfig -> Maybe [Text])
-> (HadoopJarStepConfig -> Maybe [Text] -> HadoopJarStepConfig)
-> Lens
     HadoopJarStepConfig
     HadoopJarStepConfig
     (Maybe [Text])
     (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> HadoopJarStepConfig -> f HadoopJarStepConfig)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> HadoopJarStepConfig
-> f HadoopJarStepConfig
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 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 :: (Maybe Text -> f (Maybe Text))
-> HadoopJarStepConfig -> f HadoopJarStepConfig
hadoopJarStepConfig_mainClass = (HadoopJarStepConfig -> Maybe Text)
-> (HadoopJarStepConfig -> Maybe Text -> HadoopJarStepConfig)
-> Lens
     HadoopJarStepConfig HadoopJarStepConfig (Maybe Text) (Maybe Text)
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 :: (Maybe [KeyValue] -> f (Maybe [KeyValue]))
-> HadoopJarStepConfig -> f HadoopJarStepConfig
hadoopJarStepConfig_properties = (HadoopJarStepConfig -> Maybe [KeyValue])
-> (HadoopJarStepConfig -> Maybe [KeyValue] -> HadoopJarStepConfig)
-> Lens
     HadoopJarStepConfig
     HadoopJarStepConfig
     (Maybe [KeyValue])
     (Maybe [KeyValue])
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) ((Maybe [KeyValue] -> f (Maybe [KeyValue]))
 -> HadoopJarStepConfig -> f HadoopJarStepConfig)
-> ((Maybe [KeyValue] -> f (Maybe [KeyValue]))
    -> Maybe [KeyValue] -> f (Maybe [KeyValue]))
-> (Maybe [KeyValue] -> f (Maybe [KeyValue]))
-> HadoopJarStepConfig
-> f HadoopJarStepConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [KeyValue] [KeyValue] [KeyValue] [KeyValue]
-> Iso
     (Maybe [KeyValue])
     (Maybe [KeyValue])
     (Maybe [KeyValue])
     (Maybe [KeyValue])
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 [KeyValue] [KeyValue] [KeyValue] [KeyValue]
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 :: (Text -> f Text) -> HadoopJarStepConfig -> f HadoopJarStepConfig
hadoopJarStepConfig_jar = (HadoopJarStepConfig -> Text)
-> (HadoopJarStepConfig -> Text -> HadoopJarStepConfig)
-> Lens HadoopJarStepConfig HadoopJarStepConfig Text Text
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

instance Prelude.NFData HadoopJarStepConfig

instance Core.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
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,
            (Text
"MainClass" 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
mainClass,
            (Text
"Properties" Text -> [KeyValue] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([KeyValue] -> Pair) -> Maybe [KeyValue] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [KeyValue]
properties,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Jar" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
jar)
          ]
      )