{-# 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 #-}
module Amazonka.EMR.Types.PlacementGroupConfig where
import qualified Amazonka.Core as Core
import Amazonka.EMR.Types.InstanceRoleType
import Amazonka.EMR.Types.PlacementGroupStrategy
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data PlacementGroupConfig = PlacementGroupConfig'
{
PlacementGroupConfig -> Maybe PlacementGroupStrategy
placementStrategy :: Prelude.Maybe PlacementGroupStrategy,
PlacementGroupConfig -> InstanceRoleType
instanceRole :: InstanceRoleType
}
deriving (PlacementGroupConfig -> PlacementGroupConfig -> Bool
(PlacementGroupConfig -> PlacementGroupConfig -> Bool)
-> (PlacementGroupConfig -> PlacementGroupConfig -> Bool)
-> Eq PlacementGroupConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PlacementGroupConfig -> PlacementGroupConfig -> Bool
$c/= :: PlacementGroupConfig -> PlacementGroupConfig -> Bool
== :: PlacementGroupConfig -> PlacementGroupConfig -> Bool
$c== :: PlacementGroupConfig -> PlacementGroupConfig -> Bool
Prelude.Eq, ReadPrec [PlacementGroupConfig]
ReadPrec PlacementGroupConfig
Int -> ReadS PlacementGroupConfig
ReadS [PlacementGroupConfig]
(Int -> ReadS PlacementGroupConfig)
-> ReadS [PlacementGroupConfig]
-> ReadPrec PlacementGroupConfig
-> ReadPrec [PlacementGroupConfig]
-> Read PlacementGroupConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PlacementGroupConfig]
$creadListPrec :: ReadPrec [PlacementGroupConfig]
readPrec :: ReadPrec PlacementGroupConfig
$creadPrec :: ReadPrec PlacementGroupConfig
readList :: ReadS [PlacementGroupConfig]
$creadList :: ReadS [PlacementGroupConfig]
readsPrec :: Int -> ReadS PlacementGroupConfig
$creadsPrec :: Int -> ReadS PlacementGroupConfig
Prelude.Read, Int -> PlacementGroupConfig -> ShowS
[PlacementGroupConfig] -> ShowS
PlacementGroupConfig -> String
(Int -> PlacementGroupConfig -> ShowS)
-> (PlacementGroupConfig -> String)
-> ([PlacementGroupConfig] -> ShowS)
-> Show PlacementGroupConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PlacementGroupConfig] -> ShowS
$cshowList :: [PlacementGroupConfig] -> ShowS
show :: PlacementGroupConfig -> String
$cshow :: PlacementGroupConfig -> String
showsPrec :: Int -> PlacementGroupConfig -> ShowS
$cshowsPrec :: Int -> PlacementGroupConfig -> ShowS
Prelude.Show, (forall x. PlacementGroupConfig -> Rep PlacementGroupConfig x)
-> (forall x. Rep PlacementGroupConfig x -> PlacementGroupConfig)
-> Generic PlacementGroupConfig
forall x. Rep PlacementGroupConfig x -> PlacementGroupConfig
forall x. PlacementGroupConfig -> Rep PlacementGroupConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PlacementGroupConfig x -> PlacementGroupConfig
$cfrom :: forall x. PlacementGroupConfig -> Rep PlacementGroupConfig x
Prelude.Generic)
newPlacementGroupConfig ::
InstanceRoleType ->
PlacementGroupConfig
newPlacementGroupConfig :: InstanceRoleType -> PlacementGroupConfig
newPlacementGroupConfig InstanceRoleType
pInstanceRole_ =
PlacementGroupConfig' :: Maybe PlacementGroupStrategy
-> InstanceRoleType -> PlacementGroupConfig
PlacementGroupConfig'
{ $sel:placementStrategy:PlacementGroupConfig' :: Maybe PlacementGroupStrategy
placementStrategy =
Maybe PlacementGroupStrategy
forall a. Maybe a
Prelude.Nothing,
$sel:instanceRole:PlacementGroupConfig' :: InstanceRoleType
instanceRole = InstanceRoleType
pInstanceRole_
}
placementGroupConfig_placementStrategy :: Lens.Lens' PlacementGroupConfig (Prelude.Maybe PlacementGroupStrategy)
placementGroupConfig_placementStrategy :: (Maybe PlacementGroupStrategy -> f (Maybe PlacementGroupStrategy))
-> PlacementGroupConfig -> f PlacementGroupConfig
placementGroupConfig_placementStrategy = (PlacementGroupConfig -> Maybe PlacementGroupStrategy)
-> (PlacementGroupConfig
-> Maybe PlacementGroupStrategy -> PlacementGroupConfig)
-> Lens
PlacementGroupConfig
PlacementGroupConfig
(Maybe PlacementGroupStrategy)
(Maybe PlacementGroupStrategy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlacementGroupConfig' {Maybe PlacementGroupStrategy
placementStrategy :: Maybe PlacementGroupStrategy
$sel:placementStrategy:PlacementGroupConfig' :: PlacementGroupConfig -> Maybe PlacementGroupStrategy
placementStrategy} -> Maybe PlacementGroupStrategy
placementStrategy) (\s :: PlacementGroupConfig
s@PlacementGroupConfig' {} Maybe PlacementGroupStrategy
a -> PlacementGroupConfig
s {$sel:placementStrategy:PlacementGroupConfig' :: Maybe PlacementGroupStrategy
placementStrategy = Maybe PlacementGroupStrategy
a} :: PlacementGroupConfig)
placementGroupConfig_instanceRole :: Lens.Lens' PlacementGroupConfig InstanceRoleType
placementGroupConfig_instanceRole :: (InstanceRoleType -> f InstanceRoleType)
-> PlacementGroupConfig -> f PlacementGroupConfig
placementGroupConfig_instanceRole = (PlacementGroupConfig -> InstanceRoleType)
-> (PlacementGroupConfig
-> InstanceRoleType -> PlacementGroupConfig)
-> Lens
PlacementGroupConfig
PlacementGroupConfig
InstanceRoleType
InstanceRoleType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlacementGroupConfig' {InstanceRoleType
instanceRole :: InstanceRoleType
$sel:instanceRole:PlacementGroupConfig' :: PlacementGroupConfig -> InstanceRoleType
instanceRole} -> InstanceRoleType
instanceRole) (\s :: PlacementGroupConfig
s@PlacementGroupConfig' {} InstanceRoleType
a -> PlacementGroupConfig
s {$sel:instanceRole:PlacementGroupConfig' :: InstanceRoleType
instanceRole = InstanceRoleType
a} :: PlacementGroupConfig)
instance Core.FromJSON PlacementGroupConfig where
parseJSON :: Value -> Parser PlacementGroupConfig
parseJSON =
String
-> (Object -> Parser PlacementGroupConfig)
-> Value
-> Parser PlacementGroupConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"PlacementGroupConfig"
( \Object
x ->
Maybe PlacementGroupStrategy
-> InstanceRoleType -> PlacementGroupConfig
PlacementGroupConfig'
(Maybe PlacementGroupStrategy
-> InstanceRoleType -> PlacementGroupConfig)
-> Parser (Maybe PlacementGroupStrategy)
-> Parser (InstanceRoleType -> PlacementGroupConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe PlacementGroupStrategy)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PlacementStrategy")
Parser (InstanceRoleType -> PlacementGroupConfig)
-> Parser InstanceRoleType -> Parser PlacementGroupConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser InstanceRoleType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"InstanceRole")
)
instance Prelude.Hashable PlacementGroupConfig
instance Prelude.NFData PlacementGroupConfig
instance Core.ToJSON PlacementGroupConfig where
toJSON :: PlacementGroupConfig -> Value
toJSON PlacementGroupConfig' {Maybe PlacementGroupStrategy
InstanceRoleType
instanceRole :: InstanceRoleType
placementStrategy :: Maybe PlacementGroupStrategy
$sel:instanceRole:PlacementGroupConfig' :: PlacementGroupConfig -> InstanceRoleType
$sel:placementStrategy:PlacementGroupConfig' :: PlacementGroupConfig -> Maybe PlacementGroupStrategy
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"PlacementStrategy" Text -> PlacementGroupStrategy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(PlacementGroupStrategy -> Pair)
-> Maybe PlacementGroupStrategy -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe PlacementGroupStrategy
placementStrategy,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"InstanceRole" Text -> InstanceRoleType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= InstanceRoleType
instanceRole)
]
)