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

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

-- | Specifies code that runs when a job is run.
--
-- /See:/ 'newJobCommand' smart constructor.
data JobCommand = JobCommand'
  { -- | Specifies the Amazon Simple Storage Service (Amazon S3) path to a script
    -- that runs a job.
    JobCommand -> Maybe Text
scriptLocation :: 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,
    -- | 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
  }
  deriving (JobCommand -> JobCommand -> Bool
(JobCommand -> JobCommand -> Bool)
-> (JobCommand -> JobCommand -> Bool) -> Eq JobCommand
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]
(Int -> ReadS JobCommand)
-> ReadS [JobCommand]
-> ReadPrec JobCommand
-> ReadPrec [JobCommand]
-> Read 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
(Int -> JobCommand -> ShowS)
-> (JobCommand -> String)
-> ([JobCommand] -> ShowS)
-> Show JobCommand
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. JobCommand -> Rep JobCommand x)
-> (forall x. Rep JobCommand x -> JobCommand) -> Generic JobCommand
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:
--
-- 'scriptLocation', 'jobCommand_scriptLocation' - Specifies the Amazon Simple Storage Service (Amazon S3) path to a script
-- that runs a job.
--
-- 'pythonVersion', 'jobCommand_pythonVersion' - The Python version being used to run a Python shell job. Allowed values
-- are 2 or 3.
--
-- '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@.
newJobCommand ::
  JobCommand
newJobCommand :: JobCommand
newJobCommand =
  JobCommand' :: Maybe Text -> Maybe Text -> Maybe Text -> JobCommand
JobCommand'
    { $sel:scriptLocation:JobCommand' :: Maybe Text
scriptLocation = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:pythonVersion:JobCommand' :: Maybe Text
pythonVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:JobCommand' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> JobCommand -> f JobCommand
jobCommand_scriptLocation = (JobCommand -> Maybe Text)
-> (JobCommand -> Maybe Text -> JobCommand)
-> Lens JobCommand JobCommand (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> JobCommand -> f JobCommand
jobCommand_pythonVersion = (JobCommand -> Maybe Text)
-> (JobCommand -> Maybe Text -> JobCommand)
-> Lens JobCommand JobCommand (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> JobCommand -> f JobCommand
jobCommand_name = (JobCommand -> Maybe Text)
-> (JobCommand -> Maybe Text -> JobCommand)
-> Lens JobCommand JobCommand (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable JobCommand

instance Prelude.NFData JobCommand

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