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