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