{-# 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.EMRServerless.Types.AutoStartConfig
-- 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.EMRServerless.Types.AutoStartConfig 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

-- | The configuration for an application to automatically start on job
-- submission.
--
-- /See:/ 'newAutoStartConfig' smart constructor.
data AutoStartConfig = AutoStartConfig'
  { -- | Enables the application to automatically start on job submission.
    -- Defaults to true.
    AutoStartConfig -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool
  }
  deriving (AutoStartConfig -> AutoStartConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AutoStartConfig -> AutoStartConfig -> Bool
$c/= :: AutoStartConfig -> AutoStartConfig -> Bool
== :: AutoStartConfig -> AutoStartConfig -> Bool
$c== :: AutoStartConfig -> AutoStartConfig -> Bool
Prelude.Eq, ReadPrec [AutoStartConfig]
ReadPrec AutoStartConfig
Int -> ReadS AutoStartConfig
ReadS [AutoStartConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AutoStartConfig]
$creadListPrec :: ReadPrec [AutoStartConfig]
readPrec :: ReadPrec AutoStartConfig
$creadPrec :: ReadPrec AutoStartConfig
readList :: ReadS [AutoStartConfig]
$creadList :: ReadS [AutoStartConfig]
readsPrec :: Int -> ReadS AutoStartConfig
$creadsPrec :: Int -> ReadS AutoStartConfig
Prelude.Read, Int -> AutoStartConfig -> ShowS
[AutoStartConfig] -> ShowS
AutoStartConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AutoStartConfig] -> ShowS
$cshowList :: [AutoStartConfig] -> ShowS
show :: AutoStartConfig -> String
$cshow :: AutoStartConfig -> String
showsPrec :: Int -> AutoStartConfig -> ShowS
$cshowsPrec :: Int -> AutoStartConfig -> ShowS
Prelude.Show, forall x. Rep AutoStartConfig x -> AutoStartConfig
forall x. AutoStartConfig -> Rep AutoStartConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AutoStartConfig x -> AutoStartConfig
$cfrom :: forall x. AutoStartConfig -> Rep AutoStartConfig x
Prelude.Generic)

-- |
-- Create a value of 'AutoStartConfig' 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:
--
-- 'enabled', 'autoStartConfig_enabled' - Enables the application to automatically start on job submission.
-- Defaults to true.
newAutoStartConfig ::
  AutoStartConfig
newAutoStartConfig :: AutoStartConfig
newAutoStartConfig =
  AutoStartConfig' {$sel:enabled:AutoStartConfig' :: Maybe Bool
enabled = forall a. Maybe a
Prelude.Nothing}

-- | Enables the application to automatically start on job submission.
-- Defaults to true.
autoStartConfig_enabled :: Lens.Lens' AutoStartConfig (Prelude.Maybe Prelude.Bool)
autoStartConfig_enabled :: Lens' AutoStartConfig (Maybe Bool)
autoStartConfig_enabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoStartConfig' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:AutoStartConfig' :: AutoStartConfig -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: AutoStartConfig
s@AutoStartConfig' {} Maybe Bool
a -> AutoStartConfig
s {$sel:enabled:AutoStartConfig' :: Maybe Bool
enabled = Maybe Bool
a} :: AutoStartConfig)

instance Data.FromJSON AutoStartConfig where
  parseJSON :: Value -> Parser AutoStartConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AutoStartConfig"
      ( \Object
x ->
          Maybe Bool -> AutoStartConfig
AutoStartConfig' 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
"enabled")
      )

instance Prelude.Hashable AutoStartConfig where
  hashWithSalt :: Int -> AutoStartConfig -> Int
hashWithSalt Int
_salt AutoStartConfig' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:AutoStartConfig' :: AutoStartConfig -> Maybe Bool
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enabled

instance Prelude.NFData AutoStartConfig where
  rnf :: AutoStartConfig -> ()
rnf AutoStartConfig' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:AutoStartConfig' :: AutoStartConfig -> Maybe Bool
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
enabled

instance Data.ToJSON AutoStartConfig where
  toJSON :: AutoStartConfig -> Value
toJSON AutoStartConfig' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:AutoStartConfig' :: AutoStartConfig -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"enabled" 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 Bool
enabled]
      )