{-# 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
{ $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 :: Lens' MappingRule Text
mappingRule_claim = 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 :: Lens' MappingRule MappingRuleMatchType
mappingRule_matchType = 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 :: Lens' MappingRule Text
mappingRule_value = 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 :: Lens' MappingRule Text
mappingRule_roleARN = 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 Data.FromJSON MappingRule where
parseJSON :: Value -> Parser MappingRule
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"MappingRule"
( \Object
x ->
Text -> MappingRuleMatchType -> Text -> Text -> MappingRule
MappingRule'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Claim")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"MatchType")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Value")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"RoleARN")
)
instance Prelude.Hashable MappingRule where
hashWithSalt :: Int -> MappingRule -> Int
hashWithSalt Int
_salt 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
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
claim
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` MappingRuleMatchType
matchType
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
roleARN
instance Prelude.NFData MappingRule where
rnf :: MappingRule -> ()
rnf 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
..} =
forall a. NFData a => a -> ()
Prelude.rnf Text
claim
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf MappingRuleMatchType
matchType
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
value
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
roleARN
instance Data.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
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ forall a. a -> Maybe a
Prelude.Just (Key
"Claim" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
claim),
forall a. a -> Maybe a
Prelude.Just (Key
"MatchType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= MappingRuleMatchType
matchType),
forall a. a -> Maybe a
Prelude.Just (Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
value),
forall a. a -> Maybe a
Prelude.Just (Key
"RoleARN" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
roleARN)
]
)