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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EMRServerless.Types.Configuration
import Amazonka.EMRServerless.Types.MonitoringConfiguration
import qualified Amazonka.Prelude as Prelude

-- | A configuration specification to be used to override existing
-- configurations.
--
-- /See:/ 'newConfigurationOverrides' smart constructor.
data ConfigurationOverrides = ConfigurationOverrides'
  { -- | The override configurations for the application.
    ConfigurationOverrides -> Maybe [Configuration]
applicationConfiguration :: Prelude.Maybe [Configuration],
    -- | The override configurations for monitoring.
    ConfigurationOverrides -> Maybe MonitoringConfiguration
monitoringConfiguration :: Prelude.Maybe MonitoringConfiguration
  }
  deriving (ConfigurationOverrides -> ConfigurationOverrides -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfigurationOverrides -> ConfigurationOverrides -> Bool
$c/= :: ConfigurationOverrides -> ConfigurationOverrides -> Bool
== :: ConfigurationOverrides -> ConfigurationOverrides -> Bool
$c== :: ConfigurationOverrides -> ConfigurationOverrides -> Bool
Prelude.Eq, Int -> ConfigurationOverrides -> ShowS
[ConfigurationOverrides] -> ShowS
ConfigurationOverrides -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfigurationOverrides] -> ShowS
$cshowList :: [ConfigurationOverrides] -> ShowS
show :: ConfigurationOverrides -> String
$cshow :: ConfigurationOverrides -> String
showsPrec :: Int -> ConfigurationOverrides -> ShowS
$cshowsPrec :: Int -> ConfigurationOverrides -> ShowS
Prelude.Show, forall x. Rep ConfigurationOverrides x -> ConfigurationOverrides
forall x. ConfigurationOverrides -> Rep ConfigurationOverrides x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConfigurationOverrides x -> ConfigurationOverrides
$cfrom :: forall x. ConfigurationOverrides -> Rep ConfigurationOverrides x
Prelude.Generic)

-- |
-- Create a value of 'ConfigurationOverrides' 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:
--
-- 'applicationConfiguration', 'configurationOverrides_applicationConfiguration' - The override configurations for the application.
--
-- 'monitoringConfiguration', 'configurationOverrides_monitoringConfiguration' - The override configurations for monitoring.
newConfigurationOverrides ::
  ConfigurationOverrides
newConfigurationOverrides :: ConfigurationOverrides
newConfigurationOverrides =
  ConfigurationOverrides'
    { $sel:applicationConfiguration:ConfigurationOverrides' :: Maybe [Configuration]
applicationConfiguration =
        forall a. Maybe a
Prelude.Nothing,
      $sel:monitoringConfiguration:ConfigurationOverrides' :: Maybe MonitoringConfiguration
monitoringConfiguration = forall a. Maybe a
Prelude.Nothing
    }

-- | The override configurations for the application.
configurationOverrides_applicationConfiguration :: Lens.Lens' ConfigurationOverrides (Prelude.Maybe [Configuration])
configurationOverrides_applicationConfiguration :: Lens' ConfigurationOverrides (Maybe [Configuration])
configurationOverrides_applicationConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigurationOverrides' {Maybe [Configuration]
applicationConfiguration :: Maybe [Configuration]
$sel:applicationConfiguration:ConfigurationOverrides' :: ConfigurationOverrides -> Maybe [Configuration]
applicationConfiguration} -> Maybe [Configuration]
applicationConfiguration) (\s :: ConfigurationOverrides
s@ConfigurationOverrides' {} Maybe [Configuration]
a -> ConfigurationOverrides
s {$sel:applicationConfiguration:ConfigurationOverrides' :: Maybe [Configuration]
applicationConfiguration = Maybe [Configuration]
a} :: ConfigurationOverrides) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The override configurations for monitoring.
configurationOverrides_monitoringConfiguration :: Lens.Lens' ConfigurationOverrides (Prelude.Maybe MonitoringConfiguration)
configurationOverrides_monitoringConfiguration :: Lens' ConfigurationOverrides (Maybe MonitoringConfiguration)
configurationOverrides_monitoringConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigurationOverrides' {Maybe MonitoringConfiguration
monitoringConfiguration :: Maybe MonitoringConfiguration
$sel:monitoringConfiguration:ConfigurationOverrides' :: ConfigurationOverrides -> Maybe MonitoringConfiguration
monitoringConfiguration} -> Maybe MonitoringConfiguration
monitoringConfiguration) (\s :: ConfigurationOverrides
s@ConfigurationOverrides' {} Maybe MonitoringConfiguration
a -> ConfigurationOverrides
s {$sel:monitoringConfiguration:ConfigurationOverrides' :: Maybe MonitoringConfiguration
monitoringConfiguration = Maybe MonitoringConfiguration
a} :: ConfigurationOverrides)

instance Data.FromJSON ConfigurationOverrides where
  parseJSON :: Value -> Parser ConfigurationOverrides
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ConfigurationOverrides"
      ( \Object
x ->
          Maybe [Configuration]
-> Maybe MonitoringConfiguration -> ConfigurationOverrides
ConfigurationOverrides'
            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
"applicationConfiguration"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            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
"monitoringConfiguration")
      )

instance Prelude.Hashable ConfigurationOverrides where
  hashWithSalt :: Int -> ConfigurationOverrides -> Int
hashWithSalt Int
_salt ConfigurationOverrides' {Maybe [Configuration]
Maybe MonitoringConfiguration
monitoringConfiguration :: Maybe MonitoringConfiguration
applicationConfiguration :: Maybe [Configuration]
$sel:monitoringConfiguration:ConfigurationOverrides' :: ConfigurationOverrides -> Maybe MonitoringConfiguration
$sel:applicationConfiguration:ConfigurationOverrides' :: ConfigurationOverrides -> Maybe [Configuration]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Configuration]
applicationConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe MonitoringConfiguration
monitoringConfiguration

instance Prelude.NFData ConfigurationOverrides where
  rnf :: ConfigurationOverrides -> ()
rnf ConfigurationOverrides' {Maybe [Configuration]
Maybe MonitoringConfiguration
monitoringConfiguration :: Maybe MonitoringConfiguration
applicationConfiguration :: Maybe [Configuration]
$sel:monitoringConfiguration:ConfigurationOverrides' :: ConfigurationOverrides -> Maybe MonitoringConfiguration
$sel:applicationConfiguration:ConfigurationOverrides' :: ConfigurationOverrides -> Maybe [Configuration]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Configuration]
applicationConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe MonitoringConfiguration
monitoringConfiguration

instance Data.ToJSON ConfigurationOverrides where
  toJSON :: ConfigurationOverrides -> Value
toJSON ConfigurationOverrides' {Maybe [Configuration]
Maybe MonitoringConfiguration
monitoringConfiguration :: Maybe MonitoringConfiguration
applicationConfiguration :: Maybe [Configuration]
$sel:monitoringConfiguration:ConfigurationOverrides' :: ConfigurationOverrides -> Maybe MonitoringConfiguration
$sel:applicationConfiguration:ConfigurationOverrides' :: ConfigurationOverrides -> Maybe [Configuration]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"applicationConfiguration" 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 [Configuration]
applicationConfiguration,
            (Key
"monitoringConfiguration" 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 MonitoringConfiguration
monitoringConfiguration
          ]
      )