{-# 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.AdvancedEventSelector where
import Amazonka.CloudTrail.Types.AdvancedFieldSelector
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data AdvancedEventSelector = AdvancedEventSelector'
{
AdvancedEventSelector -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
AdvancedEventSelector -> NonEmpty AdvancedFieldSelector
fieldSelectors :: Prelude.NonEmpty AdvancedFieldSelector
}
deriving (AdvancedEventSelector -> AdvancedEventSelector -> Bool
(AdvancedEventSelector -> AdvancedEventSelector -> Bool)
-> (AdvancedEventSelector -> AdvancedEventSelector -> Bool)
-> Eq AdvancedEventSelector
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AdvancedEventSelector -> AdvancedEventSelector -> Bool
$c/= :: AdvancedEventSelector -> AdvancedEventSelector -> Bool
== :: AdvancedEventSelector -> AdvancedEventSelector -> Bool
$c== :: AdvancedEventSelector -> AdvancedEventSelector -> Bool
Prelude.Eq, ReadPrec [AdvancedEventSelector]
ReadPrec AdvancedEventSelector
Int -> ReadS AdvancedEventSelector
ReadS [AdvancedEventSelector]
(Int -> ReadS AdvancedEventSelector)
-> ReadS [AdvancedEventSelector]
-> ReadPrec AdvancedEventSelector
-> ReadPrec [AdvancedEventSelector]
-> Read AdvancedEventSelector
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AdvancedEventSelector]
$creadListPrec :: ReadPrec [AdvancedEventSelector]
readPrec :: ReadPrec AdvancedEventSelector
$creadPrec :: ReadPrec AdvancedEventSelector
readList :: ReadS [AdvancedEventSelector]
$creadList :: ReadS [AdvancedEventSelector]
readsPrec :: Int -> ReadS AdvancedEventSelector
$creadsPrec :: Int -> ReadS AdvancedEventSelector
Prelude.Read, Int -> AdvancedEventSelector -> ShowS
[AdvancedEventSelector] -> ShowS
AdvancedEventSelector -> String
(Int -> AdvancedEventSelector -> ShowS)
-> (AdvancedEventSelector -> String)
-> ([AdvancedEventSelector] -> ShowS)
-> Show AdvancedEventSelector
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AdvancedEventSelector] -> ShowS
$cshowList :: [AdvancedEventSelector] -> ShowS
show :: AdvancedEventSelector -> String
$cshow :: AdvancedEventSelector -> String
showsPrec :: Int -> AdvancedEventSelector -> ShowS
$cshowsPrec :: Int -> AdvancedEventSelector -> ShowS
Prelude.Show, (forall x. AdvancedEventSelector -> Rep AdvancedEventSelector x)
-> (forall x. Rep AdvancedEventSelector x -> AdvancedEventSelector)
-> Generic AdvancedEventSelector
forall x. Rep AdvancedEventSelector x -> AdvancedEventSelector
forall x. AdvancedEventSelector -> Rep AdvancedEventSelector x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AdvancedEventSelector x -> AdvancedEventSelector
$cfrom :: forall x. AdvancedEventSelector -> Rep AdvancedEventSelector x
Prelude.Generic)
newAdvancedEventSelector ::
Prelude.NonEmpty AdvancedFieldSelector ->
AdvancedEventSelector
newAdvancedEventSelector :: NonEmpty AdvancedFieldSelector -> AdvancedEventSelector
newAdvancedEventSelector NonEmpty AdvancedFieldSelector
pFieldSelectors_ =
AdvancedEventSelector' :: Maybe Text
-> NonEmpty AdvancedFieldSelector -> AdvancedEventSelector
AdvancedEventSelector'
{ $sel:name:AdvancedEventSelector' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:fieldSelectors:AdvancedEventSelector' :: NonEmpty AdvancedFieldSelector
fieldSelectors =
Tagged
(NonEmpty AdvancedFieldSelector)
(Identity (NonEmpty AdvancedFieldSelector))
-> Tagged
(NonEmpty AdvancedFieldSelector)
(Identity (NonEmpty AdvancedFieldSelector))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
(NonEmpty AdvancedFieldSelector)
(Identity (NonEmpty AdvancedFieldSelector))
-> Tagged
(NonEmpty AdvancedFieldSelector)
(Identity (NonEmpty AdvancedFieldSelector)))
-> NonEmpty AdvancedFieldSelector -> NonEmpty AdvancedFieldSelector
forall t b. AReview t b -> b -> t
Lens.# NonEmpty AdvancedFieldSelector
pFieldSelectors_
}
advancedEventSelector_name :: Lens.Lens' AdvancedEventSelector (Prelude.Maybe Prelude.Text)
advancedEventSelector_name :: (Maybe Text -> f (Maybe Text))
-> AdvancedEventSelector -> f AdvancedEventSelector
advancedEventSelector_name = (AdvancedEventSelector -> Maybe Text)
-> (AdvancedEventSelector -> Maybe Text -> AdvancedEventSelector)
-> Lens
AdvancedEventSelector
AdvancedEventSelector
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdvancedEventSelector' {Maybe Text
name :: Maybe Text
$sel:name:AdvancedEventSelector' :: AdvancedEventSelector -> Maybe Text
name} -> Maybe Text
name) (\s :: AdvancedEventSelector
s@AdvancedEventSelector' {} Maybe Text
a -> AdvancedEventSelector
s {$sel:name:AdvancedEventSelector' :: Maybe Text
name = Maybe Text
a} :: AdvancedEventSelector)
advancedEventSelector_fieldSelectors :: Lens.Lens' AdvancedEventSelector (Prelude.NonEmpty AdvancedFieldSelector)
advancedEventSelector_fieldSelectors :: (NonEmpty AdvancedFieldSelector
-> f (NonEmpty AdvancedFieldSelector))
-> AdvancedEventSelector -> f AdvancedEventSelector
advancedEventSelector_fieldSelectors = (AdvancedEventSelector -> NonEmpty AdvancedFieldSelector)
-> (AdvancedEventSelector
-> NonEmpty AdvancedFieldSelector -> AdvancedEventSelector)
-> Lens
AdvancedEventSelector
AdvancedEventSelector
(NonEmpty AdvancedFieldSelector)
(NonEmpty AdvancedFieldSelector)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdvancedEventSelector' {NonEmpty AdvancedFieldSelector
fieldSelectors :: NonEmpty AdvancedFieldSelector
$sel:fieldSelectors:AdvancedEventSelector' :: AdvancedEventSelector -> NonEmpty AdvancedFieldSelector
fieldSelectors} -> NonEmpty AdvancedFieldSelector
fieldSelectors) (\s :: AdvancedEventSelector
s@AdvancedEventSelector' {} NonEmpty AdvancedFieldSelector
a -> AdvancedEventSelector
s {$sel:fieldSelectors:AdvancedEventSelector' :: NonEmpty AdvancedFieldSelector
fieldSelectors = NonEmpty AdvancedFieldSelector
a} :: AdvancedEventSelector) ((NonEmpty AdvancedFieldSelector
-> f (NonEmpty AdvancedFieldSelector))
-> AdvancedEventSelector -> f AdvancedEventSelector)
-> ((NonEmpty AdvancedFieldSelector
-> f (NonEmpty AdvancedFieldSelector))
-> NonEmpty AdvancedFieldSelector
-> f (NonEmpty AdvancedFieldSelector))
-> (NonEmpty AdvancedFieldSelector
-> f (NonEmpty AdvancedFieldSelector))
-> AdvancedEventSelector
-> f AdvancedEventSelector
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty AdvancedFieldSelector
-> f (NonEmpty AdvancedFieldSelector))
-> NonEmpty AdvancedFieldSelector
-> f (NonEmpty AdvancedFieldSelector)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromJSON AdvancedEventSelector where
parseJSON :: Value -> Parser AdvancedEventSelector
parseJSON =
String
-> (Object -> Parser AdvancedEventSelector)
-> Value
-> Parser AdvancedEventSelector
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"AdvancedEventSelector"
( \Object
x ->
Maybe Text
-> NonEmpty AdvancedFieldSelector -> AdvancedEventSelector
AdvancedEventSelector'
(Maybe Text
-> NonEmpty AdvancedFieldSelector -> AdvancedEventSelector)
-> Parser (Maybe Text)
-> Parser (NonEmpty AdvancedFieldSelector -> AdvancedEventSelector)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name")
Parser (NonEmpty AdvancedFieldSelector -> AdvancedEventSelector)
-> Parser (NonEmpty AdvancedFieldSelector)
-> Parser AdvancedEventSelector
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (NonEmpty AdvancedFieldSelector)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"FieldSelectors")
)
instance Prelude.Hashable AdvancedEventSelector
instance Prelude.NFData AdvancedEventSelector
instance Core.ToJSON AdvancedEventSelector where
toJSON :: AdvancedEventSelector -> Value
toJSON AdvancedEventSelector' {Maybe Text
NonEmpty AdvancedFieldSelector
fieldSelectors :: NonEmpty AdvancedFieldSelector
name :: Maybe Text
$sel:fieldSelectors:AdvancedEventSelector' :: AdvancedEventSelector -> NonEmpty AdvancedFieldSelector
$sel:name:AdvancedEventSelector' :: AdvancedEventSelector -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Name" 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
name,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"FieldSelectors" Text -> NonEmpty AdvancedFieldSelector -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty AdvancedFieldSelector
fieldSelectors)
]
)