{-# 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.EMR.Types.Configuration
-- 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.EMR.Types.Configuration 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

-- | Amazon EMR releases 4.x or later.
--
-- An optional configuration specification to be used when provisioning
-- cluster instances, which can include configurations for applications and
-- software bundled with Amazon EMR. A configuration consists of a
-- classification, properties, and optional nested configurations. A
-- classification refers to an application-specific configuration file.
-- Properties are the settings you want to change in that file. For more
-- information, see
-- <https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-configure-apps.html Configuring Applications>.
--
-- /See:/ 'newConfiguration' smart constructor.
data Configuration = Configuration'
  { -- | The classification within a configuration.
    Configuration -> Maybe Text
classification :: Prelude.Maybe Prelude.Text,
    -- | A list of additional configurations to apply within a configuration
    -- object.
    Configuration -> Maybe [Configuration]
configurations :: Prelude.Maybe [Configuration],
    -- | A set of properties specified within a configuration classification.
    Configuration -> Maybe (HashMap Text Text)
properties :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (Configuration -> Configuration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Configuration -> Configuration -> Bool
$c/= :: Configuration -> Configuration -> Bool
== :: Configuration -> Configuration -> Bool
$c== :: Configuration -> Configuration -> Bool
Prelude.Eq, ReadPrec [Configuration]
ReadPrec Configuration
Int -> ReadS Configuration
ReadS [Configuration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Configuration]
$creadListPrec :: ReadPrec [Configuration]
readPrec :: ReadPrec Configuration
$creadPrec :: ReadPrec Configuration
readList :: ReadS [Configuration]
$creadList :: ReadS [Configuration]
readsPrec :: Int -> ReadS Configuration
$creadsPrec :: Int -> ReadS Configuration
Prelude.Read, Int -> Configuration -> ShowS
[Configuration] -> ShowS
Configuration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Configuration] -> ShowS
$cshowList :: [Configuration] -> ShowS
show :: Configuration -> String
$cshow :: Configuration -> String
showsPrec :: Int -> Configuration -> ShowS
$cshowsPrec :: Int -> Configuration -> ShowS
Prelude.Show, forall x. Rep Configuration x -> Configuration
forall x. Configuration -> Rep Configuration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Configuration x -> Configuration
$cfrom :: forall x. Configuration -> Rep Configuration x
Prelude.Generic)

-- |
-- Create a value of 'Configuration' 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:
--
-- 'classification', 'configuration_classification' - The classification within a configuration.
--
-- 'configurations', 'configuration_configurations' - A list of additional configurations to apply within a configuration
-- object.
--
-- 'properties', 'configuration_properties' - A set of properties specified within a configuration classification.
newConfiguration ::
  Configuration
newConfiguration :: Configuration
newConfiguration =
  Configuration'
    { $sel:classification:Configuration' :: Maybe Text
classification = forall a. Maybe a
Prelude.Nothing,
      $sel:configurations:Configuration' :: Maybe [Configuration]
configurations = forall a. Maybe a
Prelude.Nothing,
      $sel:properties:Configuration' :: Maybe (HashMap Text Text)
properties = forall a. Maybe a
Prelude.Nothing
    }

-- | The classification within a configuration.
configuration_classification :: Lens.Lens' Configuration (Prelude.Maybe Prelude.Text)
configuration_classification :: Lens' Configuration (Maybe Text)
configuration_classification = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Configuration' {Maybe Text
classification :: Maybe Text
$sel:classification:Configuration' :: Configuration -> Maybe Text
classification} -> Maybe Text
classification) (\s :: Configuration
s@Configuration' {} Maybe Text
a -> Configuration
s {$sel:classification:Configuration' :: Maybe Text
classification = Maybe Text
a} :: Configuration)

-- | A list of additional configurations to apply within a configuration
-- object.
configuration_configurations :: Lens.Lens' Configuration (Prelude.Maybe [Configuration])
configuration_configurations :: Lens' Configuration (Maybe [Configuration])
configuration_configurations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Configuration' {Maybe [Configuration]
configurations :: Maybe [Configuration]
$sel:configurations:Configuration' :: Configuration -> Maybe [Configuration]
configurations} -> Maybe [Configuration]
configurations) (\s :: Configuration
s@Configuration' {} Maybe [Configuration]
a -> Configuration
s {$sel:configurations:Configuration' :: Maybe [Configuration]
configurations = Maybe [Configuration]
a} :: Configuration) 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

-- | A set of properties specified within a configuration classification.
configuration_properties :: Lens.Lens' Configuration (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
configuration_properties :: Lens' Configuration (Maybe (HashMap Text Text))
configuration_properties = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Configuration' {Maybe (HashMap Text Text)
properties :: Maybe (HashMap Text Text)
$sel:properties:Configuration' :: Configuration -> Maybe (HashMap Text Text)
properties} -> Maybe (HashMap Text Text)
properties) (\s :: Configuration
s@Configuration' {} Maybe (HashMap Text Text)
a -> Configuration
s {$sel:properties:Configuration' :: Maybe (HashMap Text Text)
properties = Maybe (HashMap Text Text)
a} :: Configuration) 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

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

instance Prelude.Hashable Configuration where
  hashWithSalt :: Int -> Configuration -> Int
hashWithSalt Int
_salt Configuration' {Maybe [Configuration]
Maybe Text
Maybe (HashMap Text Text)
properties :: Maybe (HashMap Text Text)
configurations :: Maybe [Configuration]
classification :: Maybe Text
$sel:properties:Configuration' :: Configuration -> Maybe (HashMap Text Text)
$sel:configurations:Configuration' :: Configuration -> Maybe [Configuration]
$sel:classification:Configuration' :: Configuration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
classification
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Configuration]
configurations
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
properties

instance Prelude.NFData Configuration where
  rnf :: Configuration -> ()
rnf Configuration' {Maybe [Configuration]
Maybe Text
Maybe (HashMap Text Text)
properties :: Maybe (HashMap Text Text)
configurations :: Maybe [Configuration]
classification :: Maybe Text
$sel:properties:Configuration' :: Configuration -> Maybe (HashMap Text Text)
$sel:configurations:Configuration' :: Configuration -> Maybe [Configuration]
$sel:classification:Configuration' :: Configuration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
classification
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Configuration]
configurations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
properties

instance Data.ToJSON Configuration where
  toJSON :: Configuration -> Value
toJSON Configuration' {Maybe [Configuration]
Maybe Text
Maybe (HashMap Text Text)
properties :: Maybe (HashMap Text Text)
configurations :: Maybe [Configuration]
classification :: Maybe Text
$sel:properties:Configuration' :: Configuration -> Maybe (HashMap Text Text)
$sel:configurations:Configuration' :: Configuration -> Maybe [Configuration]
$sel:classification:Configuration' :: Configuration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Classification" 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 Text
classification,
            (Key
"Configurations" 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]
configurations,
            (Key
"Properties" 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 (HashMap Text Text)
properties
          ]
      )