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

import qualified Amazonka.Core as Core
import Amazonka.EMRContainers.Types.Configuration
import Amazonka.EMRContainers.Types.MonitoringConfiguration
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A configuration specification to be used to override existing
-- configurations.
--
-- /See:/ 'newConfigurationOverrides' smart constructor.
data ConfigurationOverrides = ConfigurationOverrides'
  { -- | The configurations for monitoring.
    ConfigurationOverrides -> Maybe MonitoringConfiguration
monitoringConfiguration :: Prelude.Maybe MonitoringConfiguration,
    -- | The configurations for the application running by the job run.
    ConfigurationOverrides -> Maybe [Configuration]
applicationConfiguration :: Prelude.Maybe [Configuration]
  }
  deriving (ConfigurationOverrides -> ConfigurationOverrides -> Bool
(ConfigurationOverrides -> ConfigurationOverrides -> Bool)
-> (ConfigurationOverrides -> ConfigurationOverrides -> Bool)
-> Eq ConfigurationOverrides
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
(Int -> ConfigurationOverrides -> ShowS)
-> (ConfigurationOverrides -> String)
-> ([ConfigurationOverrides] -> ShowS)
-> Show ConfigurationOverrides
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. ConfigurationOverrides -> Rep ConfigurationOverrides x)
-> (forall x.
    Rep ConfigurationOverrides x -> ConfigurationOverrides)
-> Generic ConfigurationOverrides
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:
--
-- 'monitoringConfiguration', 'configurationOverrides_monitoringConfiguration' - The configurations for monitoring.
--
-- 'applicationConfiguration', 'configurationOverrides_applicationConfiguration' - The configurations for the application running by the job run.
newConfigurationOverrides ::
  ConfigurationOverrides
newConfigurationOverrides :: ConfigurationOverrides
newConfigurationOverrides =
  ConfigurationOverrides' :: Maybe MonitoringConfiguration
-> Maybe [Configuration] -> ConfigurationOverrides
ConfigurationOverrides'
    { $sel:monitoringConfiguration:ConfigurationOverrides' :: Maybe MonitoringConfiguration
monitoringConfiguration =
        Maybe MonitoringConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:applicationConfiguration:ConfigurationOverrides' :: Maybe [Configuration]
applicationConfiguration = Maybe [Configuration]
forall a. Maybe a
Prelude.Nothing
    }

-- | The configurations for monitoring.
configurationOverrides_monitoringConfiguration :: Lens.Lens' ConfigurationOverrides (Prelude.Maybe MonitoringConfiguration)
configurationOverrides_monitoringConfiguration :: (Maybe MonitoringConfiguration
 -> f (Maybe MonitoringConfiguration))
-> ConfigurationOverrides -> f ConfigurationOverrides
configurationOverrides_monitoringConfiguration = (ConfigurationOverrides -> Maybe MonitoringConfiguration)
-> (ConfigurationOverrides
    -> Maybe MonitoringConfiguration -> ConfigurationOverrides)
-> Lens
     ConfigurationOverrides
     ConfigurationOverrides
     (Maybe MonitoringConfiguration)
     (Maybe 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)

-- | The configurations for the application running by the job run.
configurationOverrides_applicationConfiguration :: Lens.Lens' ConfigurationOverrides (Prelude.Maybe [Configuration])
configurationOverrides_applicationConfiguration :: (Maybe [Configuration] -> f (Maybe [Configuration]))
-> ConfigurationOverrides -> f ConfigurationOverrides
configurationOverrides_applicationConfiguration = (ConfigurationOverrides -> Maybe [Configuration])
-> (ConfigurationOverrides
    -> Maybe [Configuration] -> ConfigurationOverrides)
-> Lens
     ConfigurationOverrides
     ConfigurationOverrides
     (Maybe [Configuration])
     (Maybe [Configuration])
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) ((Maybe [Configuration] -> f (Maybe [Configuration]))
 -> ConfigurationOverrides -> f ConfigurationOverrides)
-> ((Maybe [Configuration] -> f (Maybe [Configuration]))
    -> Maybe [Configuration] -> f (Maybe [Configuration]))
-> (Maybe [Configuration] -> f (Maybe [Configuration]))
-> ConfigurationOverrides
-> f ConfigurationOverrides
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [Configuration] [Configuration] [Configuration] [Configuration]
-> Iso
     (Maybe [Configuration])
     (Maybe [Configuration])
     (Maybe [Configuration])
     (Maybe [Configuration])
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 AnIso
  [Configuration] [Configuration] [Configuration] [Configuration]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ConfigurationOverrides where
  parseJSON :: Value -> Parser ConfigurationOverrides
parseJSON =
    String
-> (Object -> Parser ConfigurationOverrides)
-> Value
-> Parser ConfigurationOverrides
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ConfigurationOverrides"
      ( \Object
x ->
          Maybe MonitoringConfiguration
-> Maybe [Configuration] -> ConfigurationOverrides
ConfigurationOverrides'
            (Maybe MonitoringConfiguration
 -> Maybe [Configuration] -> ConfigurationOverrides)
-> Parser (Maybe MonitoringConfiguration)
-> Parser (Maybe [Configuration] -> ConfigurationOverrides)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe MonitoringConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"monitoringConfiguration")
            Parser (Maybe [Configuration] -> ConfigurationOverrides)
-> Parser (Maybe [Configuration]) -> Parser ConfigurationOverrides
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Configuration]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"applicationConfiguration"
                            Parser (Maybe (Maybe [Configuration]))
-> Maybe [Configuration] -> Parser (Maybe [Configuration])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Configuration]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable ConfigurationOverrides

instance Prelude.NFData ConfigurationOverrides

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