{-# 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.CloudTrail.Types.EventSelector where
import Amazonka.CloudTrail.Types.DataResource
import Amazonka.CloudTrail.Types.ReadWriteType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data EventSelector = EventSelector'
{
EventSelector -> Maybe [DataResource]
dataResources :: Prelude.Maybe [DataResource],
EventSelector -> Maybe ReadWriteType
readWriteType :: Prelude.Maybe ReadWriteType,
EventSelector -> Maybe [Text]
excludeManagementEventSources :: Prelude.Maybe [Prelude.Text],
EventSelector -> Maybe Bool
includeManagementEvents :: Prelude.Maybe Prelude.Bool
}
deriving (EventSelector -> EventSelector -> Bool
(EventSelector -> EventSelector -> Bool)
-> (EventSelector -> EventSelector -> Bool) -> Eq EventSelector
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventSelector -> EventSelector -> Bool
$c/= :: EventSelector -> EventSelector -> Bool
== :: EventSelector -> EventSelector -> Bool
$c== :: EventSelector -> EventSelector -> Bool
Prelude.Eq, ReadPrec [EventSelector]
ReadPrec EventSelector
Int -> ReadS EventSelector
ReadS [EventSelector]
(Int -> ReadS EventSelector)
-> ReadS [EventSelector]
-> ReadPrec EventSelector
-> ReadPrec [EventSelector]
-> Read EventSelector
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventSelector]
$creadListPrec :: ReadPrec [EventSelector]
readPrec :: ReadPrec EventSelector
$creadPrec :: ReadPrec EventSelector
readList :: ReadS [EventSelector]
$creadList :: ReadS [EventSelector]
readsPrec :: Int -> ReadS EventSelector
$creadsPrec :: Int -> ReadS EventSelector
Prelude.Read, Int -> EventSelector -> ShowS
[EventSelector] -> ShowS
EventSelector -> String
(Int -> EventSelector -> ShowS)
-> (EventSelector -> String)
-> ([EventSelector] -> ShowS)
-> Show EventSelector
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventSelector] -> ShowS
$cshowList :: [EventSelector] -> ShowS
show :: EventSelector -> String
$cshow :: EventSelector -> String
showsPrec :: Int -> EventSelector -> ShowS
$cshowsPrec :: Int -> EventSelector -> ShowS
Prelude.Show, (forall x. EventSelector -> Rep EventSelector x)
-> (forall x. Rep EventSelector x -> EventSelector)
-> Generic EventSelector
forall x. Rep EventSelector x -> EventSelector
forall x. EventSelector -> Rep EventSelector x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventSelector x -> EventSelector
$cfrom :: forall x. EventSelector -> Rep EventSelector x
Prelude.Generic)
newEventSelector ::
EventSelector
newEventSelector :: EventSelector
newEventSelector =
EventSelector' :: Maybe [DataResource]
-> Maybe ReadWriteType
-> Maybe [Text]
-> Maybe Bool
-> EventSelector
EventSelector'
{ $sel:dataResources:EventSelector' :: Maybe [DataResource]
dataResources = Maybe [DataResource]
forall a. Maybe a
Prelude.Nothing,
$sel:readWriteType:EventSelector' :: Maybe ReadWriteType
readWriteType = Maybe ReadWriteType
forall a. Maybe a
Prelude.Nothing,
$sel:excludeManagementEventSources:EventSelector' :: Maybe [Text]
excludeManagementEventSources = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
$sel:includeManagementEvents:EventSelector' :: Maybe Bool
includeManagementEvents = Maybe Bool
forall a. Maybe a
Prelude.Nothing
}
eventSelector_dataResources :: Lens.Lens' EventSelector (Prelude.Maybe [DataResource])
eventSelector_dataResources :: (Maybe [DataResource] -> f (Maybe [DataResource]))
-> EventSelector -> f EventSelector
eventSelector_dataResources = (EventSelector -> Maybe [DataResource])
-> (EventSelector -> Maybe [DataResource] -> EventSelector)
-> Lens
EventSelector
EventSelector
(Maybe [DataResource])
(Maybe [DataResource])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventSelector' {Maybe [DataResource]
dataResources :: Maybe [DataResource]
$sel:dataResources:EventSelector' :: EventSelector -> Maybe [DataResource]
dataResources} -> Maybe [DataResource]
dataResources) (\s :: EventSelector
s@EventSelector' {} Maybe [DataResource]
a -> EventSelector
s {$sel:dataResources:EventSelector' :: Maybe [DataResource]
dataResources = Maybe [DataResource]
a} :: EventSelector) ((Maybe [DataResource] -> f (Maybe [DataResource]))
-> EventSelector -> f EventSelector)
-> ((Maybe [DataResource] -> f (Maybe [DataResource]))
-> Maybe [DataResource] -> f (Maybe [DataResource]))
-> (Maybe [DataResource] -> f (Maybe [DataResource]))
-> EventSelector
-> f EventSelector
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [DataResource] [DataResource] [DataResource] [DataResource]
-> Iso
(Maybe [DataResource])
(Maybe [DataResource])
(Maybe [DataResource])
(Maybe [DataResource])
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 AnIso [DataResource] [DataResource] [DataResource] [DataResource]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
eventSelector_readWriteType :: Lens.Lens' EventSelector (Prelude.Maybe ReadWriteType)
eventSelector_readWriteType :: (Maybe ReadWriteType -> f (Maybe ReadWriteType))
-> EventSelector -> f EventSelector
eventSelector_readWriteType = (EventSelector -> Maybe ReadWriteType)
-> (EventSelector -> Maybe ReadWriteType -> EventSelector)
-> Lens
EventSelector
EventSelector
(Maybe ReadWriteType)
(Maybe ReadWriteType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventSelector' {Maybe ReadWriteType
readWriteType :: Maybe ReadWriteType
$sel:readWriteType:EventSelector' :: EventSelector -> Maybe ReadWriteType
readWriteType} -> Maybe ReadWriteType
readWriteType) (\s :: EventSelector
s@EventSelector' {} Maybe ReadWriteType
a -> EventSelector
s {$sel:readWriteType:EventSelector' :: Maybe ReadWriteType
readWriteType = Maybe ReadWriteType
a} :: EventSelector)
eventSelector_excludeManagementEventSources :: Lens.Lens' EventSelector (Prelude.Maybe [Prelude.Text])
eventSelector_excludeManagementEventSources :: (Maybe [Text] -> f (Maybe [Text]))
-> EventSelector -> f EventSelector
eventSelector_excludeManagementEventSources = (EventSelector -> Maybe [Text])
-> (EventSelector -> Maybe [Text] -> EventSelector)
-> Lens EventSelector EventSelector (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventSelector' {Maybe [Text]
excludeManagementEventSources :: Maybe [Text]
$sel:excludeManagementEventSources:EventSelector' :: EventSelector -> Maybe [Text]
excludeManagementEventSources} -> Maybe [Text]
excludeManagementEventSources) (\s :: EventSelector
s@EventSelector' {} Maybe [Text]
a -> EventSelector
s {$sel:excludeManagementEventSources:EventSelector' :: Maybe [Text]
excludeManagementEventSources = Maybe [Text]
a} :: EventSelector) ((Maybe [Text] -> f (Maybe [Text]))
-> EventSelector -> f EventSelector)
-> ((Maybe [Text] -> f (Maybe [Text]))
-> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> EventSelector
-> f EventSelector
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
eventSelector_includeManagementEvents :: Lens.Lens' EventSelector (Prelude.Maybe Prelude.Bool)
eventSelector_includeManagementEvents :: (Maybe Bool -> f (Maybe Bool)) -> EventSelector -> f EventSelector
eventSelector_includeManagementEvents = (EventSelector -> Maybe Bool)
-> (EventSelector -> Maybe Bool -> EventSelector)
-> Lens EventSelector EventSelector (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventSelector' {Maybe Bool
includeManagementEvents :: Maybe Bool
$sel:includeManagementEvents:EventSelector' :: EventSelector -> Maybe Bool
includeManagementEvents} -> Maybe Bool
includeManagementEvents) (\s :: EventSelector
s@EventSelector' {} Maybe Bool
a -> EventSelector
s {$sel:includeManagementEvents:EventSelector' :: Maybe Bool
includeManagementEvents = Maybe Bool
a} :: EventSelector)
instance Core.FromJSON EventSelector where
parseJSON :: Value -> Parser EventSelector
parseJSON =
String
-> (Object -> Parser EventSelector)
-> Value
-> Parser EventSelector
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"EventSelector"
( \Object
x ->
Maybe [DataResource]
-> Maybe ReadWriteType
-> Maybe [Text]
-> Maybe Bool
-> EventSelector
EventSelector'
(Maybe [DataResource]
-> Maybe ReadWriteType
-> Maybe [Text]
-> Maybe Bool
-> EventSelector)
-> Parser (Maybe [DataResource])
-> Parser
(Maybe ReadWriteType
-> Maybe [Text] -> Maybe Bool -> EventSelector)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [DataResource]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DataResources" Parser (Maybe (Maybe [DataResource]))
-> Maybe [DataResource] -> Parser (Maybe [DataResource])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [DataResource]
forall a. Monoid a => a
Prelude.mempty)
Parser
(Maybe ReadWriteType
-> Maybe [Text] -> Maybe Bool -> EventSelector)
-> Parser (Maybe ReadWriteType)
-> Parser (Maybe [Text] -> Maybe Bool -> EventSelector)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ReadWriteType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ReadWriteType")
Parser (Maybe [Text] -> Maybe Bool -> EventSelector)
-> Parser (Maybe [Text]) -> Parser (Maybe Bool -> EventSelector)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ExcludeManagementEventSources"
Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
)
Parser (Maybe Bool -> EventSelector)
-> Parser (Maybe Bool) -> Parser EventSelector
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IncludeManagementEvents")
)
instance Prelude.Hashable EventSelector
instance Prelude.NFData EventSelector
instance Core.ToJSON EventSelector where
toJSON :: EventSelector -> Value
toJSON EventSelector' {Maybe Bool
Maybe [Text]
Maybe [DataResource]
Maybe ReadWriteType
includeManagementEvents :: Maybe Bool
excludeManagementEventSources :: Maybe [Text]
readWriteType :: Maybe ReadWriteType
dataResources :: Maybe [DataResource]
$sel:includeManagementEvents:EventSelector' :: EventSelector -> Maybe Bool
$sel:excludeManagementEventSources:EventSelector' :: EventSelector -> Maybe [Text]
$sel:readWriteType:EventSelector' :: EventSelector -> Maybe ReadWriteType
$sel:dataResources:EventSelector' :: EventSelector -> Maybe [DataResource]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"DataResources" Text -> [DataResource] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([DataResource] -> Pair) -> Maybe [DataResource] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [DataResource]
dataResources,
(Text
"ReadWriteType" Text -> ReadWriteType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ReadWriteType -> Pair) -> Maybe ReadWriteType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ReadWriteType
readWriteType,
(Text
"ExcludeManagementEventSources" 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]
excludeManagementEventSources,
(Text
"IncludeManagementEvents" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
includeManagementEvents
]
)