{-# 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.WorkMail.Types.ImpersonationRule where
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
import Amazonka.WorkMail.Types.AccessEffect
data ImpersonationRule = ImpersonationRule'
{
ImpersonationRule -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
ImpersonationRule -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
ImpersonationRule -> Maybe (NonEmpty Text)
notTargetUsers :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
ImpersonationRule -> Maybe (NonEmpty Text)
targetUsers :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
ImpersonationRule -> Text
impersonationRuleId :: Prelude.Text,
ImpersonationRule -> AccessEffect
effect :: AccessEffect
}
deriving (ImpersonationRule -> ImpersonationRule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImpersonationRule -> ImpersonationRule -> Bool
$c/= :: ImpersonationRule -> ImpersonationRule -> Bool
== :: ImpersonationRule -> ImpersonationRule -> Bool
$c== :: ImpersonationRule -> ImpersonationRule -> Bool
Prelude.Eq, ReadPrec [ImpersonationRule]
ReadPrec ImpersonationRule
Int -> ReadS ImpersonationRule
ReadS [ImpersonationRule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImpersonationRule]
$creadListPrec :: ReadPrec [ImpersonationRule]
readPrec :: ReadPrec ImpersonationRule
$creadPrec :: ReadPrec ImpersonationRule
readList :: ReadS [ImpersonationRule]
$creadList :: ReadS [ImpersonationRule]
readsPrec :: Int -> ReadS ImpersonationRule
$creadsPrec :: Int -> ReadS ImpersonationRule
Prelude.Read, Int -> ImpersonationRule -> ShowS
[ImpersonationRule] -> ShowS
ImpersonationRule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImpersonationRule] -> ShowS
$cshowList :: [ImpersonationRule] -> ShowS
show :: ImpersonationRule -> String
$cshow :: ImpersonationRule -> String
showsPrec :: Int -> ImpersonationRule -> ShowS
$cshowsPrec :: Int -> ImpersonationRule -> ShowS
Prelude.Show, forall x. Rep ImpersonationRule x -> ImpersonationRule
forall x. ImpersonationRule -> Rep ImpersonationRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImpersonationRule x -> ImpersonationRule
$cfrom :: forall x. ImpersonationRule -> Rep ImpersonationRule x
Prelude.Generic)
newImpersonationRule ::
Prelude.Text ->
AccessEffect ->
ImpersonationRule
newImpersonationRule :: Text -> AccessEffect -> ImpersonationRule
newImpersonationRule Text
pImpersonationRuleId_ AccessEffect
pEffect_ =
ImpersonationRule'
{ $sel:description:ImpersonationRule' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
$sel:name:ImpersonationRule' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
$sel:notTargetUsers:ImpersonationRule' :: Maybe (NonEmpty Text)
notTargetUsers = forall a. Maybe a
Prelude.Nothing,
$sel:targetUsers:ImpersonationRule' :: Maybe (NonEmpty Text)
targetUsers = forall a. Maybe a
Prelude.Nothing,
$sel:impersonationRuleId:ImpersonationRule' :: Text
impersonationRuleId = Text
pImpersonationRuleId_,
$sel:effect:ImpersonationRule' :: AccessEffect
effect = AccessEffect
pEffect_
}
impersonationRule_description :: Lens.Lens' ImpersonationRule (Prelude.Maybe Prelude.Text)
impersonationRule_description :: Lens' ImpersonationRule (Maybe Text)
impersonationRule_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImpersonationRule' {Maybe Text
description :: Maybe Text
$sel:description:ImpersonationRule' :: ImpersonationRule -> Maybe Text
description} -> Maybe Text
description) (\s :: ImpersonationRule
s@ImpersonationRule' {} Maybe Text
a -> ImpersonationRule
s {$sel:description:ImpersonationRule' :: Maybe Text
description = Maybe Text
a} :: ImpersonationRule)
impersonationRule_name :: Lens.Lens' ImpersonationRule (Prelude.Maybe Prelude.Text)
impersonationRule_name :: Lens' ImpersonationRule (Maybe Text)
impersonationRule_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImpersonationRule' {Maybe Text
name :: Maybe Text
$sel:name:ImpersonationRule' :: ImpersonationRule -> Maybe Text
name} -> Maybe Text
name) (\s :: ImpersonationRule
s@ImpersonationRule' {} Maybe Text
a -> ImpersonationRule
s {$sel:name:ImpersonationRule' :: Maybe Text
name = Maybe Text
a} :: ImpersonationRule)
impersonationRule_notTargetUsers :: Lens.Lens' ImpersonationRule (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
impersonationRule_notTargetUsers :: Lens' ImpersonationRule (Maybe (NonEmpty Text))
impersonationRule_notTargetUsers = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImpersonationRule' {Maybe (NonEmpty Text)
notTargetUsers :: Maybe (NonEmpty Text)
$sel:notTargetUsers:ImpersonationRule' :: ImpersonationRule -> Maybe (NonEmpty Text)
notTargetUsers} -> Maybe (NonEmpty Text)
notTargetUsers) (\s :: ImpersonationRule
s@ImpersonationRule' {} Maybe (NonEmpty Text)
a -> ImpersonationRule
s {$sel:notTargetUsers:ImpersonationRule' :: Maybe (NonEmpty Text)
notTargetUsers = Maybe (NonEmpty Text)
a} :: ImpersonationRule) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
impersonationRule_targetUsers :: Lens.Lens' ImpersonationRule (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
impersonationRule_targetUsers :: Lens' ImpersonationRule (Maybe (NonEmpty Text))
impersonationRule_targetUsers = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImpersonationRule' {Maybe (NonEmpty Text)
targetUsers :: Maybe (NonEmpty Text)
$sel:targetUsers:ImpersonationRule' :: ImpersonationRule -> Maybe (NonEmpty Text)
targetUsers} -> Maybe (NonEmpty Text)
targetUsers) (\s :: ImpersonationRule
s@ImpersonationRule' {} Maybe (NonEmpty Text)
a -> ImpersonationRule
s {$sel:targetUsers:ImpersonationRule' :: Maybe (NonEmpty Text)
targetUsers = Maybe (NonEmpty Text)
a} :: ImpersonationRule) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
impersonationRule_impersonationRuleId :: Lens.Lens' ImpersonationRule Prelude.Text
impersonationRule_impersonationRuleId :: Lens' ImpersonationRule Text
impersonationRule_impersonationRuleId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImpersonationRule' {Text
impersonationRuleId :: Text
$sel:impersonationRuleId:ImpersonationRule' :: ImpersonationRule -> Text
impersonationRuleId} -> Text
impersonationRuleId) (\s :: ImpersonationRule
s@ImpersonationRule' {} Text
a -> ImpersonationRule
s {$sel:impersonationRuleId:ImpersonationRule' :: Text
impersonationRuleId = Text
a} :: ImpersonationRule)
impersonationRule_effect :: Lens.Lens' ImpersonationRule AccessEffect
impersonationRule_effect :: Lens' ImpersonationRule AccessEffect
impersonationRule_effect = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImpersonationRule' {AccessEffect
effect :: AccessEffect
$sel:effect:ImpersonationRule' :: ImpersonationRule -> AccessEffect
effect} -> AccessEffect
effect) (\s :: ImpersonationRule
s@ImpersonationRule' {} AccessEffect
a -> ImpersonationRule
s {$sel:effect:ImpersonationRule' :: AccessEffect
effect = AccessEffect
a} :: ImpersonationRule)
instance Data.FromJSON ImpersonationRule where
parseJSON :: Value -> Parser ImpersonationRule
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"ImpersonationRule"
( \Object
x ->
Maybe Text
-> Maybe Text
-> Maybe (NonEmpty Text)
-> Maybe (NonEmpty Text)
-> Text
-> AccessEffect
-> ImpersonationRule
ImpersonationRule'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Description")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Name")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"NotTargetUsers")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"TargetUsers")
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
"ImpersonationRuleId")
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
"Effect")
)
instance Prelude.Hashable ImpersonationRule where
hashWithSalt :: Int -> ImpersonationRule -> Int
hashWithSalt Int
_salt ImpersonationRule' {Maybe (NonEmpty Text)
Maybe Text
Text
AccessEffect
effect :: AccessEffect
impersonationRuleId :: Text
targetUsers :: Maybe (NonEmpty Text)
notTargetUsers :: Maybe (NonEmpty Text)
name :: Maybe Text
description :: Maybe Text
$sel:effect:ImpersonationRule' :: ImpersonationRule -> AccessEffect
$sel:impersonationRuleId:ImpersonationRule' :: ImpersonationRule -> Text
$sel:targetUsers:ImpersonationRule' :: ImpersonationRule -> Maybe (NonEmpty Text)
$sel:notTargetUsers:ImpersonationRule' :: ImpersonationRule -> Maybe (NonEmpty Text)
$sel:name:ImpersonationRule' :: ImpersonationRule -> Maybe Text
$sel:description:ImpersonationRule' :: ImpersonationRule -> Maybe Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
notTargetUsers
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
targetUsers
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
impersonationRuleId
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` AccessEffect
effect
instance Prelude.NFData ImpersonationRule where
rnf :: ImpersonationRule -> ()
rnf ImpersonationRule' {Maybe (NonEmpty Text)
Maybe Text
Text
AccessEffect
effect :: AccessEffect
impersonationRuleId :: Text
targetUsers :: Maybe (NonEmpty Text)
notTargetUsers :: Maybe (NonEmpty Text)
name :: Maybe Text
description :: Maybe Text
$sel:effect:ImpersonationRule' :: ImpersonationRule -> AccessEffect
$sel:impersonationRuleId:ImpersonationRule' :: ImpersonationRule -> Text
$sel:targetUsers:ImpersonationRule' :: ImpersonationRule -> Maybe (NonEmpty Text)
$sel:notTargetUsers:ImpersonationRule' :: ImpersonationRule -> Maybe (NonEmpty Text)
$sel:name:ImpersonationRule' :: ImpersonationRule -> Maybe Text
$sel:description:ImpersonationRule' :: ImpersonationRule -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
notTargetUsers
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
targetUsers
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
impersonationRuleId
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf AccessEffect
effect
instance Data.ToJSON ImpersonationRule where
toJSON :: ImpersonationRule -> Value
toJSON ImpersonationRule' {Maybe (NonEmpty Text)
Maybe Text
Text
AccessEffect
effect :: AccessEffect
impersonationRuleId :: Text
targetUsers :: Maybe (NonEmpty Text)
notTargetUsers :: Maybe (NonEmpty Text)
name :: Maybe Text
description :: Maybe Text
$sel:effect:ImpersonationRule' :: ImpersonationRule -> AccessEffect
$sel:impersonationRuleId:ImpersonationRule' :: ImpersonationRule -> Text
$sel:targetUsers:ImpersonationRule' :: ImpersonationRule -> Maybe (NonEmpty Text)
$sel:notTargetUsers:ImpersonationRule' :: ImpersonationRule -> Maybe (NonEmpty Text)
$sel:name:ImpersonationRule' :: ImpersonationRule -> Maybe Text
$sel:description:ImpersonationRule' :: ImpersonationRule -> Maybe Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"Description" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
(Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name,
(Key
"NotTargetUsers" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
notTargetUsers,
(Key
"TargetUsers" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
targetUsers,
forall a. a -> Maybe a
Prelude.Just
(Key
"ImpersonationRuleId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
impersonationRuleId),
forall a. a -> Maybe a
Prelude.Just (Key
"Effect" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= AccessEffect
effect)
]
)