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

import qualified Amazonka.Core as Core
import Amazonka.EMR.Types.ExecutionEngineType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies the execution engine (cluster) to run the notebook and perform
-- the notebook execution, for example, an EMR cluster.
--
-- /See:/ 'newExecutionEngineConfig' smart constructor.
data ExecutionEngineConfig = ExecutionEngineConfig'
  { -- | An optional unique ID of an EC2 security group to associate with the
    -- master instance of the EMR cluster for this notebook execution. For more
    -- information see
    -- <https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-managed-notebooks-security-groups.html Specifying EC2 Security Groups for EMR Notebooks>
    -- in the /EMR Management Guide/.
    ExecutionEngineConfig -> Maybe Text
masterInstanceSecurityGroupId :: Prelude.Maybe Prelude.Text,
    -- | The type of execution engine. A value of @EMR@ specifies an EMR cluster.
    ExecutionEngineConfig -> Maybe ExecutionEngineType
type' :: Prelude.Maybe ExecutionEngineType,
    -- | The unique identifier of the execution engine. For an EMR cluster, this
    -- is the cluster ID.
    ExecutionEngineConfig -> Text
id :: Prelude.Text
  }
  deriving (ExecutionEngineConfig -> ExecutionEngineConfig -> Bool
(ExecutionEngineConfig -> ExecutionEngineConfig -> Bool)
-> (ExecutionEngineConfig -> ExecutionEngineConfig -> Bool)
-> Eq ExecutionEngineConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecutionEngineConfig -> ExecutionEngineConfig -> Bool
$c/= :: ExecutionEngineConfig -> ExecutionEngineConfig -> Bool
== :: ExecutionEngineConfig -> ExecutionEngineConfig -> Bool
$c== :: ExecutionEngineConfig -> ExecutionEngineConfig -> Bool
Prelude.Eq, ReadPrec [ExecutionEngineConfig]
ReadPrec ExecutionEngineConfig
Int -> ReadS ExecutionEngineConfig
ReadS [ExecutionEngineConfig]
(Int -> ReadS ExecutionEngineConfig)
-> ReadS [ExecutionEngineConfig]
-> ReadPrec ExecutionEngineConfig
-> ReadPrec [ExecutionEngineConfig]
-> Read ExecutionEngineConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExecutionEngineConfig]
$creadListPrec :: ReadPrec [ExecutionEngineConfig]
readPrec :: ReadPrec ExecutionEngineConfig
$creadPrec :: ReadPrec ExecutionEngineConfig
readList :: ReadS [ExecutionEngineConfig]
$creadList :: ReadS [ExecutionEngineConfig]
readsPrec :: Int -> ReadS ExecutionEngineConfig
$creadsPrec :: Int -> ReadS ExecutionEngineConfig
Prelude.Read, Int -> ExecutionEngineConfig -> ShowS
[ExecutionEngineConfig] -> ShowS
ExecutionEngineConfig -> String
(Int -> ExecutionEngineConfig -> ShowS)
-> (ExecutionEngineConfig -> String)
-> ([ExecutionEngineConfig] -> ShowS)
-> Show ExecutionEngineConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExecutionEngineConfig] -> ShowS
$cshowList :: [ExecutionEngineConfig] -> ShowS
show :: ExecutionEngineConfig -> String
$cshow :: ExecutionEngineConfig -> String
showsPrec :: Int -> ExecutionEngineConfig -> ShowS
$cshowsPrec :: Int -> ExecutionEngineConfig -> ShowS
Prelude.Show, (forall x. ExecutionEngineConfig -> Rep ExecutionEngineConfig x)
-> (forall x. Rep ExecutionEngineConfig x -> ExecutionEngineConfig)
-> Generic ExecutionEngineConfig
forall x. Rep ExecutionEngineConfig x -> ExecutionEngineConfig
forall x. ExecutionEngineConfig -> Rep ExecutionEngineConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExecutionEngineConfig x -> ExecutionEngineConfig
$cfrom :: forall x. ExecutionEngineConfig -> Rep ExecutionEngineConfig x
Prelude.Generic)

-- |
-- Create a value of 'ExecutionEngineConfig' 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:
--
-- 'masterInstanceSecurityGroupId', 'executionEngineConfig_masterInstanceSecurityGroupId' - An optional unique ID of an EC2 security group to associate with the
-- master instance of the EMR cluster for this notebook execution. For more
-- information see
-- <https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-managed-notebooks-security-groups.html Specifying EC2 Security Groups for EMR Notebooks>
-- in the /EMR Management Guide/.
--
-- 'type'', 'executionEngineConfig_type' - The type of execution engine. A value of @EMR@ specifies an EMR cluster.
--
-- 'id', 'executionEngineConfig_id' - The unique identifier of the execution engine. For an EMR cluster, this
-- is the cluster ID.
newExecutionEngineConfig ::
  -- | 'id'
  Prelude.Text ->
  ExecutionEngineConfig
newExecutionEngineConfig :: Text -> ExecutionEngineConfig
newExecutionEngineConfig Text
pId_ =
  ExecutionEngineConfig' :: Maybe Text
-> Maybe ExecutionEngineType -> Text -> ExecutionEngineConfig
ExecutionEngineConfig'
    { $sel:masterInstanceSecurityGroupId:ExecutionEngineConfig' :: Maybe Text
masterInstanceSecurityGroupId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':ExecutionEngineConfig' :: Maybe ExecutionEngineType
type' = Maybe ExecutionEngineType
forall a. Maybe a
Prelude.Nothing,
      $sel:id:ExecutionEngineConfig' :: Text
id = Text
pId_
    }

-- | An optional unique ID of an EC2 security group to associate with the
-- master instance of the EMR cluster for this notebook execution. For more
-- information see
-- <https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-managed-notebooks-security-groups.html Specifying EC2 Security Groups for EMR Notebooks>
-- in the /EMR Management Guide/.
executionEngineConfig_masterInstanceSecurityGroupId :: Lens.Lens' ExecutionEngineConfig (Prelude.Maybe Prelude.Text)
executionEngineConfig_masterInstanceSecurityGroupId :: (Maybe Text -> f (Maybe Text))
-> ExecutionEngineConfig -> f ExecutionEngineConfig
executionEngineConfig_masterInstanceSecurityGroupId = (ExecutionEngineConfig -> Maybe Text)
-> (ExecutionEngineConfig -> Maybe Text -> ExecutionEngineConfig)
-> Lens
     ExecutionEngineConfig
     ExecutionEngineConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionEngineConfig' {Maybe Text
masterInstanceSecurityGroupId :: Maybe Text
$sel:masterInstanceSecurityGroupId:ExecutionEngineConfig' :: ExecutionEngineConfig -> Maybe Text
masterInstanceSecurityGroupId} -> Maybe Text
masterInstanceSecurityGroupId) (\s :: ExecutionEngineConfig
s@ExecutionEngineConfig' {} Maybe Text
a -> ExecutionEngineConfig
s {$sel:masterInstanceSecurityGroupId:ExecutionEngineConfig' :: Maybe Text
masterInstanceSecurityGroupId = Maybe Text
a} :: ExecutionEngineConfig)

-- | The type of execution engine. A value of @EMR@ specifies an EMR cluster.
executionEngineConfig_type :: Lens.Lens' ExecutionEngineConfig (Prelude.Maybe ExecutionEngineType)
executionEngineConfig_type :: (Maybe ExecutionEngineType -> f (Maybe ExecutionEngineType))
-> ExecutionEngineConfig -> f ExecutionEngineConfig
executionEngineConfig_type = (ExecutionEngineConfig -> Maybe ExecutionEngineType)
-> (ExecutionEngineConfig
    -> Maybe ExecutionEngineType -> ExecutionEngineConfig)
-> Lens
     ExecutionEngineConfig
     ExecutionEngineConfig
     (Maybe ExecutionEngineType)
     (Maybe ExecutionEngineType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionEngineConfig' {Maybe ExecutionEngineType
type' :: Maybe ExecutionEngineType
$sel:type':ExecutionEngineConfig' :: ExecutionEngineConfig -> Maybe ExecutionEngineType
type'} -> Maybe ExecutionEngineType
type') (\s :: ExecutionEngineConfig
s@ExecutionEngineConfig' {} Maybe ExecutionEngineType
a -> ExecutionEngineConfig
s {$sel:type':ExecutionEngineConfig' :: Maybe ExecutionEngineType
type' = Maybe ExecutionEngineType
a} :: ExecutionEngineConfig)

-- | The unique identifier of the execution engine. For an EMR cluster, this
-- is the cluster ID.
executionEngineConfig_id :: Lens.Lens' ExecutionEngineConfig Prelude.Text
executionEngineConfig_id :: (Text -> f Text)
-> ExecutionEngineConfig -> f ExecutionEngineConfig
executionEngineConfig_id = (ExecutionEngineConfig -> Text)
-> (ExecutionEngineConfig -> Text -> ExecutionEngineConfig)
-> Lens ExecutionEngineConfig ExecutionEngineConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionEngineConfig' {Text
id :: Text
$sel:id:ExecutionEngineConfig' :: ExecutionEngineConfig -> Text
id} -> Text
id) (\s :: ExecutionEngineConfig
s@ExecutionEngineConfig' {} Text
a -> ExecutionEngineConfig
s {$sel:id:ExecutionEngineConfig' :: Text
id = Text
a} :: ExecutionEngineConfig)

instance Core.FromJSON ExecutionEngineConfig where
  parseJSON :: Value -> Parser ExecutionEngineConfig
parseJSON =
    String
-> (Object -> Parser ExecutionEngineConfig)
-> Value
-> Parser ExecutionEngineConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ExecutionEngineConfig"
      ( \Object
x ->
          Maybe Text
-> Maybe ExecutionEngineType -> Text -> ExecutionEngineConfig
ExecutionEngineConfig'
            (Maybe Text
 -> Maybe ExecutionEngineType -> Text -> ExecutionEngineConfig)
-> Parser (Maybe Text)
-> Parser
     (Maybe ExecutionEngineType -> Text -> ExecutionEngineConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MasterInstanceSecurityGroupId")
            Parser (Maybe ExecutionEngineType -> Text -> ExecutionEngineConfig)
-> Parser (Maybe ExecutionEngineType)
-> Parser (Text -> ExecutionEngineConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ExecutionEngineType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
            Parser (Text -> ExecutionEngineConfig)
-> Parser Text -> Parser ExecutionEngineConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Id")
      )

instance Prelude.Hashable ExecutionEngineConfig

instance Prelude.NFData ExecutionEngineConfig

instance Core.ToJSON ExecutionEngineConfig where
  toJSON :: ExecutionEngineConfig -> Value
toJSON ExecutionEngineConfig' {Maybe Text
Maybe ExecutionEngineType
Text
id :: Text
type' :: Maybe ExecutionEngineType
masterInstanceSecurityGroupId :: Maybe Text
$sel:id:ExecutionEngineConfig' :: ExecutionEngineConfig -> Text
$sel:type':ExecutionEngineConfig' :: ExecutionEngineConfig -> Maybe ExecutionEngineType
$sel:masterInstanceSecurityGroupId:ExecutionEngineConfig' :: ExecutionEngineConfig -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"MasterInstanceSecurityGroupId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
masterInstanceSecurityGroupId,
            (Text
"Type" Text -> ExecutionEngineType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ExecutionEngineType -> Pair)
-> Maybe ExecutionEngineType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ExecutionEngineType
type',
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id)
          ]
      )