{-# 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.EMRContainers.Types.JobDriver
-- 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.EMRContainers.Types.JobDriver where

import qualified Amazonka.Core as Core
import Amazonka.EMRContainers.Types.SparkSubmitJobDriver
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specify the driver that the job runs on.
--
-- /See:/ 'newJobDriver' smart constructor.
data JobDriver = JobDriver'
  { -- | The job driver parameters specified for spark submit.
    JobDriver -> Maybe SparkSubmitJobDriver
sparkSubmitJobDriver :: Prelude.Maybe SparkSubmitJobDriver
  }
  deriving (JobDriver -> JobDriver -> Bool
(JobDriver -> JobDriver -> Bool)
-> (JobDriver -> JobDriver -> Bool) -> Eq JobDriver
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JobDriver -> JobDriver -> Bool
$c/= :: JobDriver -> JobDriver -> Bool
== :: JobDriver -> JobDriver -> Bool
$c== :: JobDriver -> JobDriver -> Bool
Prelude.Eq, Int -> JobDriver -> ShowS
[JobDriver] -> ShowS
JobDriver -> String
(Int -> JobDriver -> ShowS)
-> (JobDriver -> String)
-> ([JobDriver] -> ShowS)
-> Show JobDriver
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JobDriver] -> ShowS
$cshowList :: [JobDriver] -> ShowS
show :: JobDriver -> String
$cshow :: JobDriver -> String
showsPrec :: Int -> JobDriver -> ShowS
$cshowsPrec :: Int -> JobDriver -> ShowS
Prelude.Show, (forall x. JobDriver -> Rep JobDriver x)
-> (forall x. Rep JobDriver x -> JobDriver) -> Generic JobDriver
forall x. Rep JobDriver x -> JobDriver
forall x. JobDriver -> Rep JobDriver x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JobDriver x -> JobDriver
$cfrom :: forall x. JobDriver -> Rep JobDriver x
Prelude.Generic)

-- |
-- Create a value of 'JobDriver' 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:
--
-- 'sparkSubmitJobDriver', 'jobDriver_sparkSubmitJobDriver' - The job driver parameters specified for spark submit.
newJobDriver ::
  JobDriver
newJobDriver :: JobDriver
newJobDriver =
  JobDriver' :: Maybe SparkSubmitJobDriver -> JobDriver
JobDriver' {$sel:sparkSubmitJobDriver:JobDriver' :: Maybe SparkSubmitJobDriver
sparkSubmitJobDriver = Maybe SparkSubmitJobDriver
forall a. Maybe a
Prelude.Nothing}

-- | The job driver parameters specified for spark submit.
jobDriver_sparkSubmitJobDriver :: Lens.Lens' JobDriver (Prelude.Maybe SparkSubmitJobDriver)
jobDriver_sparkSubmitJobDriver :: (Maybe SparkSubmitJobDriver -> f (Maybe SparkSubmitJobDriver))
-> JobDriver -> f JobDriver
jobDriver_sparkSubmitJobDriver = (JobDriver -> Maybe SparkSubmitJobDriver)
-> (JobDriver -> Maybe SparkSubmitJobDriver -> JobDriver)
-> Lens
     JobDriver
     JobDriver
     (Maybe SparkSubmitJobDriver)
     (Maybe SparkSubmitJobDriver)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobDriver' {Maybe SparkSubmitJobDriver
sparkSubmitJobDriver :: Maybe SparkSubmitJobDriver
$sel:sparkSubmitJobDriver:JobDriver' :: JobDriver -> Maybe SparkSubmitJobDriver
sparkSubmitJobDriver} -> Maybe SparkSubmitJobDriver
sparkSubmitJobDriver) (\s :: JobDriver
s@JobDriver' {} Maybe SparkSubmitJobDriver
a -> JobDriver
s {$sel:sparkSubmitJobDriver:JobDriver' :: Maybe SparkSubmitJobDriver
sparkSubmitJobDriver = Maybe SparkSubmitJobDriver
a} :: JobDriver)

instance Core.FromJSON JobDriver where
  parseJSON :: Value -> Parser JobDriver
parseJSON =
    String -> (Object -> Parser JobDriver) -> Value -> Parser JobDriver
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"JobDriver"
      ( \Object
x ->
          Maybe SparkSubmitJobDriver -> JobDriver
JobDriver'
            (Maybe SparkSubmitJobDriver -> JobDriver)
-> Parser (Maybe SparkSubmitJobDriver) -> Parser JobDriver
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe SparkSubmitJobDriver)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"sparkSubmitJobDriver")
      )

instance Prelude.Hashable JobDriver

instance Prelude.NFData JobDriver

instance Core.ToJSON JobDriver where
  toJSON :: JobDriver -> Value
toJSON JobDriver' {Maybe SparkSubmitJobDriver
sparkSubmitJobDriver :: Maybe SparkSubmitJobDriver
$sel:sparkSubmitJobDriver:JobDriver' :: JobDriver -> Maybe SparkSubmitJobDriver
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"sparkSubmitJobDriver" Text -> SparkSubmitJobDriver -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (SparkSubmitJobDriver -> Pair)
-> Maybe SparkSubmitJobDriver -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SparkSubmitJobDriver
sparkSubmitJobDriver
          ]
      )