{-# 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.Glue.Types.JobCommand
-- 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.Glue.Types.JobCommand 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

-- | Specifies code that runs when a job is run.
--
-- /See:/ 'newJobCommand' smart constructor.
data JobCommand = JobCommand'
  { -- | The name of the job command. For an Apache Spark ETL job, this must be
    -- @glueetl@. For a Python shell job, it must be @pythonshell@. For an
    -- Apache Spark streaming ETL job, this must be @gluestreaming@.
    JobCommand -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The Python version being used to run a Python shell job. Allowed values
    -- are 2 or 3.
    JobCommand -> Maybe Text
pythonVersion :: Prelude.Maybe Prelude.Text,
    -- | Specifies the Amazon Simple Storage Service (Amazon S3) path to a script
    -- that runs a job.
    JobCommand -> Maybe Text
scriptLocation :: Prelude.Maybe Prelude.Text
  }
  deriving (JobCommand -> JobCommand -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JobCommand -> JobCommand -> Bool
$c/= :: JobCommand -> JobCommand -> Bool
== :: JobCommand -> JobCommand -> Bool
$c== :: JobCommand -> JobCommand -> Bool
Prelude.Eq, ReadPrec [JobCommand]
ReadPrec JobCommand
Int -> ReadS JobCommand
ReadS [JobCommand]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JobCommand]
$creadListPrec :: ReadPrec [JobCommand]
readPrec :: ReadPrec JobCommand
$creadPrec :: ReadPrec JobCommand
readList :: ReadS [JobCommand]
$creadList :: ReadS [JobCommand]
readsPrec :: Int -> ReadS JobCommand
$creadsPrec :: Int -> ReadS JobCommand
Prelude.Read, Int -> JobCommand -> ShowS
[JobCommand] -> ShowS
JobCommand -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JobCommand] -> ShowS
$cshowList :: [JobCommand] -> ShowS
show :: JobCommand -> String
$cshow :: JobCommand -> String
showsPrec :: Int -> JobCommand -> ShowS
$cshowsPrec :: Int -> JobCommand -> ShowS
Prelude.Show, forall x. Rep JobCommand x -> JobCommand
forall x. JobCommand -> Rep JobCommand x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JobCommand x -> JobCommand
$cfrom :: forall x. JobCommand -> Rep JobCommand x
Prelude.Generic)

-- |
-- Create a value of 'JobCommand' 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:
--
-- 'name', 'jobCommand_name' - The name of the job command. For an Apache Spark ETL job, this must be
-- @glueetl@. For a Python shell job, it must be @pythonshell@. For an
-- Apache Spark streaming ETL job, this must be @gluestreaming@.
--
-- 'pythonVersion', 'jobCommand_pythonVersion' - The Python version being used to run a Python shell job. Allowed values
-- are 2 or 3.
--
-- 'scriptLocation', 'jobCommand_scriptLocation' - Specifies the Amazon Simple Storage Service (Amazon S3) path to a script
-- that runs a job.
newJobCommand ::
  JobCommand
newJobCommand :: JobCommand
newJobCommand =
  JobCommand'
    { $sel:name:JobCommand' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:pythonVersion:JobCommand' :: Maybe Text
pythonVersion = forall a. Maybe a
Prelude.Nothing,
      $sel:scriptLocation:JobCommand' :: Maybe Text
scriptLocation = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the job command. For an Apache Spark ETL job, this must be
-- @glueetl@. For a Python shell job, it must be @pythonshell@. For an
-- Apache Spark streaming ETL job, this must be @gluestreaming@.
jobCommand_name :: Lens.Lens' JobCommand (Prelude.Maybe Prelude.Text)
jobCommand_name :: Lens' JobCommand (Maybe Text)
jobCommand_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobCommand' {Maybe Text
name :: Maybe Text
$sel:name:JobCommand' :: JobCommand -> Maybe Text
name} -> Maybe Text
name) (\s :: JobCommand
s@JobCommand' {} Maybe Text
a -> JobCommand
s {$sel:name:JobCommand' :: Maybe Text
name = Maybe Text
a} :: JobCommand)

-- | The Python version being used to run a Python shell job. Allowed values
-- are 2 or 3.
jobCommand_pythonVersion :: Lens.Lens' JobCommand (Prelude.Maybe Prelude.Text)
jobCommand_pythonVersion :: Lens' JobCommand (Maybe Text)
jobCommand_pythonVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobCommand' {Maybe Text
pythonVersion :: Maybe Text
$sel:pythonVersion:JobCommand' :: JobCommand -> Maybe Text
pythonVersion} -> Maybe Text
pythonVersion) (\s :: JobCommand
s@JobCommand' {} Maybe Text
a -> JobCommand
s {$sel:pythonVersion:JobCommand' :: Maybe Text
pythonVersion = Maybe Text
a} :: JobCommand)

-- | Specifies the Amazon Simple Storage Service (Amazon S3) path to a script
-- that runs a job.
jobCommand_scriptLocation :: Lens.Lens' JobCommand (Prelude.Maybe Prelude.Text)
jobCommand_scriptLocation :: Lens' JobCommand (Maybe Text)
jobCommand_scriptLocation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobCommand' {Maybe Text
scriptLocation :: Maybe Text
$sel:scriptLocation:JobCommand' :: JobCommand -> Maybe Text
scriptLocation} -> Maybe Text
scriptLocation) (\s :: JobCommand
s@JobCommand' {} Maybe Text
a -> JobCommand
s {$sel:scriptLocation:JobCommand' :: Maybe Text
scriptLocation = Maybe Text
a} :: JobCommand)

instance Data.FromJSON JobCommand where
  parseJSON :: Value -> Parser JobCommand
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"JobCommand"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> JobCommand
JobCommand'
            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
"Name")
            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
"PythonVersion")
            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
"ScriptLocation")
      )

instance Prelude.Hashable JobCommand where
  hashWithSalt :: Int -> JobCommand -> Int
hashWithSalt Int
_salt JobCommand' {Maybe Text
scriptLocation :: Maybe Text
pythonVersion :: Maybe Text
name :: Maybe Text
$sel:scriptLocation:JobCommand' :: JobCommand -> Maybe Text
$sel:pythonVersion:JobCommand' :: JobCommand -> Maybe Text
$sel:name:JobCommand' :: JobCommand -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
pythonVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
scriptLocation

instance Prelude.NFData JobCommand where
  rnf :: JobCommand -> ()
rnf JobCommand' {Maybe Text
scriptLocation :: Maybe Text
pythonVersion :: Maybe Text
name :: Maybe Text
$sel:scriptLocation:JobCommand' :: JobCommand -> Maybe Text
$sel:pythonVersion:JobCommand' :: JobCommand -> Maybe Text
$sel:name:JobCommand' :: JobCommand -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
pythonVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
scriptLocation

instance Data.ToJSON JobCommand where
  toJSON :: JobCommand -> Value
toJSON JobCommand' {Maybe Text
scriptLocation :: Maybe Text
pythonVersion :: Maybe Text
name :: Maybe Text
$sel:scriptLocation:JobCommand' :: JobCommand -> Maybe Text
$sel:pythonVersion:JobCommand' :: JobCommand -> Maybe Text
$sel:name:JobCommand' :: JobCommand -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Name" 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
name,
            (Key
"PythonVersion" 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
pythonVersion,
            (Key
"ScriptLocation" 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
scriptLocation
          ]
      )