{-# 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.Backup.Types.Condition where
import Amazonka.Backup.Types.ConditionType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Condition = Condition'
{
Condition -> ConditionType
conditionType :: ConditionType,
Condition -> Text
conditionKey :: Prelude.Text,
Condition -> Text
conditionValue :: Prelude.Text
}
deriving (Condition -> Condition -> Bool
(Condition -> Condition -> Bool)
-> (Condition -> Condition -> Bool) -> Eq Condition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Condition -> Condition -> Bool
$c/= :: Condition -> Condition -> Bool
== :: Condition -> Condition -> Bool
$c== :: Condition -> Condition -> Bool
Prelude.Eq, ReadPrec [Condition]
ReadPrec Condition
Int -> ReadS Condition
ReadS [Condition]
(Int -> ReadS Condition)
-> ReadS [Condition]
-> ReadPrec Condition
-> ReadPrec [Condition]
-> Read Condition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Condition]
$creadListPrec :: ReadPrec [Condition]
readPrec :: ReadPrec Condition
$creadPrec :: ReadPrec Condition
readList :: ReadS [Condition]
$creadList :: ReadS [Condition]
readsPrec :: Int -> ReadS Condition
$creadsPrec :: Int -> ReadS Condition
Prelude.Read, Int -> Condition -> ShowS
[Condition] -> ShowS
Condition -> String
(Int -> Condition -> ShowS)
-> (Condition -> String)
-> ([Condition] -> ShowS)
-> Show Condition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Condition] -> ShowS
$cshowList :: [Condition] -> ShowS
show :: Condition -> String
$cshow :: Condition -> String
showsPrec :: Int -> Condition -> ShowS
$cshowsPrec :: Int -> Condition -> ShowS
Prelude.Show, (forall x. Condition -> Rep Condition x)
-> (forall x. Rep Condition x -> Condition) -> Generic Condition
forall x. Rep Condition x -> Condition
forall x. Condition -> Rep Condition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Condition x -> Condition
$cfrom :: forall x. Condition -> Rep Condition x
Prelude.Generic)
newCondition ::
ConditionType ->
Prelude.Text ->
Prelude.Text ->
Condition
newCondition :: ConditionType -> Text -> Text -> Condition
newCondition
ConditionType
pConditionType_
Text
pConditionKey_
Text
pConditionValue_ =
Condition' :: ConditionType -> Text -> Text -> Condition
Condition'
{ $sel:conditionType:Condition' :: ConditionType
conditionType = ConditionType
pConditionType_,
$sel:conditionKey:Condition' :: Text
conditionKey = Text
pConditionKey_,
$sel:conditionValue:Condition' :: Text
conditionValue = Text
pConditionValue_
}
condition_conditionType :: Lens.Lens' Condition ConditionType
condition_conditionType :: (ConditionType -> f ConditionType) -> Condition -> f Condition
condition_conditionType = (Condition -> ConditionType)
-> (Condition -> ConditionType -> Condition)
-> Lens Condition Condition ConditionType ConditionType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Condition' {ConditionType
conditionType :: ConditionType
$sel:conditionType:Condition' :: Condition -> ConditionType
conditionType} -> ConditionType
conditionType) (\s :: Condition
s@Condition' {} ConditionType
a -> Condition
s {$sel:conditionType:Condition' :: ConditionType
conditionType = ConditionType
a} :: Condition)
condition_conditionKey :: Lens.Lens' Condition Prelude.Text
condition_conditionKey :: (Text -> f Text) -> Condition -> f Condition
condition_conditionKey = (Condition -> Text)
-> (Condition -> Text -> Condition)
-> Lens Condition Condition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Condition' {Text
conditionKey :: Text
$sel:conditionKey:Condition' :: Condition -> Text
conditionKey} -> Text
conditionKey) (\s :: Condition
s@Condition' {} Text
a -> Condition
s {$sel:conditionKey:Condition' :: Text
conditionKey = Text
a} :: Condition)
condition_conditionValue :: Lens.Lens' Condition Prelude.Text
condition_conditionValue :: (Text -> f Text) -> Condition -> f Condition
condition_conditionValue = (Condition -> Text)
-> (Condition -> Text -> Condition)
-> Lens Condition Condition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Condition' {Text
conditionValue :: Text
$sel:conditionValue:Condition' :: Condition -> Text
conditionValue} -> Text
conditionValue) (\s :: Condition
s@Condition' {} Text
a -> Condition
s {$sel:conditionValue:Condition' :: Text
conditionValue = Text
a} :: Condition)
instance Core.FromJSON Condition where
parseJSON :: Value -> Parser Condition
parseJSON =
String -> (Object -> Parser Condition) -> Value -> Parser Condition
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Condition"
( \Object
x ->
ConditionType -> Text -> Text -> Condition
Condition'
(ConditionType -> Text -> Text -> Condition)
-> Parser ConditionType -> Parser (Text -> Text -> Condition)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser ConditionType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ConditionType")
Parser (Text -> Text -> Condition)
-> Parser Text -> Parser (Text -> Condition)
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
"ConditionKey")
Parser (Text -> Condition) -> Parser Text -> Parser Condition
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
"ConditionValue")
)
instance Prelude.Hashable Condition
instance Prelude.NFData Condition
instance Core.ToJSON Condition where
toJSON :: Condition -> Value
toJSON Condition' {Text
ConditionType
conditionValue :: Text
conditionKey :: Text
conditionType :: ConditionType
$sel:conditionValue:Condition' :: Condition -> Text
$sel:conditionKey:Condition' :: Condition -> Text
$sel:conditionType:Condition' :: Condition -> ConditionType
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"ConditionType" Text -> ConditionType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ConditionType
conditionType),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ConditionKey" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
conditionKey),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"ConditionValue" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
conditionValue)
]
)