{-# 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.CognitoIdentity.Types.MappingRule where
import Amazonka.CognitoIdentity.Types.MappingRuleMatchType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data MappingRule = MappingRule'
{
MappingRule -> Text
claim :: Prelude.Text,
MappingRule -> MappingRuleMatchType
matchType :: MappingRuleMatchType,
MappingRule -> Text
value :: Prelude.Text,
MappingRule -> Text
roleARN :: Prelude.Text
}
deriving (MappingRule -> MappingRule -> Bool
(MappingRule -> MappingRule -> Bool)
-> (MappingRule -> MappingRule -> Bool) -> Eq MappingRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MappingRule -> MappingRule -> Bool
$c/= :: MappingRule -> MappingRule -> Bool
== :: MappingRule -> MappingRule -> Bool
$c== :: MappingRule -> MappingRule -> Bool
Prelude.Eq, ReadPrec [MappingRule]
ReadPrec MappingRule
Int -> ReadS MappingRule
ReadS [MappingRule]
(Int -> ReadS MappingRule)
-> ReadS [MappingRule]
-> ReadPrec MappingRule
-> ReadPrec [MappingRule]
-> Read MappingRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MappingRule]
$creadListPrec :: ReadPrec [MappingRule]
readPrec :: ReadPrec MappingRule
$creadPrec :: ReadPrec MappingRule
readList :: ReadS [MappingRule]
$creadList :: ReadS [MappingRule]
readsPrec :: Int -> ReadS MappingRule
$creadsPrec :: Int -> ReadS MappingRule
Prelude.Read, Int -> MappingRule -> ShowS
[MappingRule] -> ShowS
MappingRule -> String
(Int -> MappingRule -> ShowS)
-> (MappingRule -> String)
-> ([MappingRule] -> ShowS)
-> Show MappingRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MappingRule] -> ShowS
$cshowList :: [MappingRule] -> ShowS
show :: MappingRule -> String
$cshow :: MappingRule -> String
showsPrec :: Int -> MappingRule -> ShowS
$cshowsPrec :: Int -> MappingRule -> ShowS
Prelude.Show, (forall x. MappingRule -> Rep MappingRule x)
-> (forall x. Rep MappingRule x -> MappingRule)
-> Generic MappingRule
forall x. Rep MappingRule x -> MappingRule
forall x. MappingRule -> Rep MappingRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MappingRule x -> MappingRule
$cfrom :: forall x. MappingRule -> Rep MappingRule x
Prelude.Generic)
newMappingRule ::
Prelude.Text ->
MappingRuleMatchType ->
Prelude.Text ->
Prelude.Text ->
MappingRule
newMappingRule :: Text -> MappingRuleMatchType -> Text -> Text -> MappingRule
newMappingRule Text
pClaim_ MappingRuleMatchType
pMatchType_ Text
pValue_ Text
pRoleARN_ =
MappingRule' :: Text -> MappingRuleMatchType -> Text -> Text -> MappingRule
MappingRule'
{ $sel:claim:MappingRule' :: Text
claim = Text
pClaim_,
$sel:matchType:MappingRule' :: MappingRuleMatchType
matchType = MappingRuleMatchType
pMatchType_,
$sel:value:MappingRule' :: Text
value = Text
pValue_,
$sel:roleARN:MappingRule' :: Text
roleARN = Text
pRoleARN_
}
mappingRule_claim :: Lens.Lens' MappingRule Prelude.Text
mappingRule_claim :: (Text -> f Text) -> MappingRule -> f MappingRule
mappingRule_claim = (MappingRule -> Text)
-> (MappingRule -> Text -> MappingRule)
-> Lens MappingRule MappingRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MappingRule' {Text
claim :: Text
$sel:claim:MappingRule' :: MappingRule -> Text
claim} -> Text
claim) (\s :: MappingRule
s@MappingRule' {} Text
a -> MappingRule
s {$sel:claim:MappingRule' :: Text
claim = Text
a} :: MappingRule)
mappingRule_matchType :: Lens.Lens' MappingRule MappingRuleMatchType
mappingRule_matchType :: (MappingRuleMatchType -> f MappingRuleMatchType)
-> MappingRule -> f MappingRule
mappingRule_matchType = (MappingRule -> MappingRuleMatchType)
-> (MappingRule -> MappingRuleMatchType -> MappingRule)
-> Lens
MappingRule MappingRule MappingRuleMatchType MappingRuleMatchType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MappingRule' {MappingRuleMatchType
matchType :: MappingRuleMatchType
$sel:matchType:MappingRule' :: MappingRule -> MappingRuleMatchType
matchType} -> MappingRuleMatchType
matchType) (\s :: MappingRule
s@MappingRule' {} MappingRuleMatchType
a -> MappingRule
s {$sel:matchType:MappingRule' :: MappingRuleMatchType
matchType = MappingRuleMatchType
a} :: MappingRule)
mappingRule_value :: Lens.Lens' MappingRule Prelude.Text
mappingRule_value :: (Text -> f Text) -> MappingRule -> f MappingRule
mappingRule_value = (MappingRule -> Text)
-> (MappingRule -> Text -> MappingRule)
-> Lens MappingRule MappingRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MappingRule' {Text
value :: Text
$sel:value:MappingRule' :: MappingRule -> Text
value} -> Text
value) (\s :: MappingRule
s@MappingRule' {} Text
a -> MappingRule
s {$sel:value:MappingRule' :: Text
value = Text
a} :: MappingRule)
mappingRule_roleARN :: Lens.Lens' MappingRule Prelude.Text
mappingRule_roleARN :: (Text -> f Text) -> MappingRule -> f MappingRule
mappingRule_roleARN = (MappingRule -> Text)
-> (MappingRule -> Text -> MappingRule)
-> Lens MappingRule MappingRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MappingRule' {Text
roleARN :: Text
$sel:roleARN:MappingRule' :: MappingRule -> Text
roleARN} -> Text
roleARN) (\s :: MappingRule
s@MappingRule' {} Text
a -> MappingRule
s {$sel:roleARN:MappingRule' :: Text
roleARN = Text
a} :: MappingRule)
instance Core.FromJSON MappingRule where
parseJSON :: Value -> Parser MappingRule
parseJSON =
String
-> (Object -> Parser MappingRule) -> Value -> Parser MappingRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"MappingRule"
( \Object
x ->
Text -> MappingRuleMatchType -> Text -> Text -> MappingRule
MappingRule'
(Text -> MappingRuleMatchType -> Text -> Text -> MappingRule)
-> Parser Text
-> Parser (MappingRuleMatchType -> Text -> Text -> MappingRule)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Claim")
Parser (MappingRuleMatchType -> Text -> Text -> MappingRule)
-> Parser MappingRuleMatchType
-> Parser (Text -> Text -> MappingRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser MappingRuleMatchType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MatchType")
Parser (Text -> Text -> MappingRule)
-> Parser Text -> Parser (Text -> MappingRule)
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
"Value")
Parser (Text -> MappingRule) -> Parser Text -> Parser MappingRule
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
"RoleARN")
)
instance Prelude.Hashable MappingRule
instance Prelude.NFData MappingRule
instance Core.ToJSON MappingRule where
toJSON :: MappingRule -> Value
toJSON MappingRule' {Text
MappingRuleMatchType
roleARN :: Text
value :: Text
matchType :: MappingRuleMatchType
claim :: Text
$sel:roleARN:MappingRule' :: MappingRule -> Text
$sel:value:MappingRule' :: MappingRule -> Text
$sel:matchType:MappingRule' :: MappingRule -> MappingRuleMatchType
$sel:claim:MappingRule' :: MappingRule -> Text
..} =
[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
"Claim" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
claim),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"MatchType" Text -> MappingRuleMatchType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= MappingRuleMatchType
matchType),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Value" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
value),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RoleARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
roleARN)
]
)