{-# 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.IoTAnalytics.Types.DatasetAction where
import qualified Amazonka.Core as Core
import Amazonka.IoTAnalytics.Types.ContainerDatasetAction
import Amazonka.IoTAnalytics.Types.SqlQueryDatasetAction
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data DatasetAction = DatasetAction'
{
DatasetAction -> Maybe SqlQueryDatasetAction
queryAction :: Prelude.Maybe SqlQueryDatasetAction,
DatasetAction -> Maybe Text
actionName :: Prelude.Maybe Prelude.Text,
DatasetAction -> Maybe ContainerDatasetAction
containerAction :: Prelude.Maybe ContainerDatasetAction
}
deriving (DatasetAction -> DatasetAction -> Bool
(DatasetAction -> DatasetAction -> Bool)
-> (DatasetAction -> DatasetAction -> Bool) -> Eq DatasetAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DatasetAction -> DatasetAction -> Bool
$c/= :: DatasetAction -> DatasetAction -> Bool
== :: DatasetAction -> DatasetAction -> Bool
$c== :: DatasetAction -> DatasetAction -> Bool
Prelude.Eq, ReadPrec [DatasetAction]
ReadPrec DatasetAction
Int -> ReadS DatasetAction
ReadS [DatasetAction]
(Int -> ReadS DatasetAction)
-> ReadS [DatasetAction]
-> ReadPrec DatasetAction
-> ReadPrec [DatasetAction]
-> Read DatasetAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DatasetAction]
$creadListPrec :: ReadPrec [DatasetAction]
readPrec :: ReadPrec DatasetAction
$creadPrec :: ReadPrec DatasetAction
readList :: ReadS [DatasetAction]
$creadList :: ReadS [DatasetAction]
readsPrec :: Int -> ReadS DatasetAction
$creadsPrec :: Int -> ReadS DatasetAction
Prelude.Read, Int -> DatasetAction -> ShowS
[DatasetAction] -> ShowS
DatasetAction -> String
(Int -> DatasetAction -> ShowS)
-> (DatasetAction -> String)
-> ([DatasetAction] -> ShowS)
-> Show DatasetAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DatasetAction] -> ShowS
$cshowList :: [DatasetAction] -> ShowS
show :: DatasetAction -> String
$cshow :: DatasetAction -> String
showsPrec :: Int -> DatasetAction -> ShowS
$cshowsPrec :: Int -> DatasetAction -> ShowS
Prelude.Show, (forall x. DatasetAction -> Rep DatasetAction x)
-> (forall x. Rep DatasetAction x -> DatasetAction)
-> Generic DatasetAction
forall x. Rep DatasetAction x -> DatasetAction
forall x. DatasetAction -> Rep DatasetAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DatasetAction x -> DatasetAction
$cfrom :: forall x. DatasetAction -> Rep DatasetAction x
Prelude.Generic)
newDatasetAction ::
DatasetAction
newDatasetAction :: DatasetAction
newDatasetAction =
DatasetAction' :: Maybe SqlQueryDatasetAction
-> Maybe Text -> Maybe ContainerDatasetAction -> DatasetAction
DatasetAction'
{ $sel:queryAction:DatasetAction' :: Maybe SqlQueryDatasetAction
queryAction = Maybe SqlQueryDatasetAction
forall a. Maybe a
Prelude.Nothing,
$sel:actionName:DatasetAction' :: Maybe Text
actionName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:containerAction:DatasetAction' :: Maybe ContainerDatasetAction
containerAction = Maybe ContainerDatasetAction
forall a. Maybe a
Prelude.Nothing
}
datasetAction_queryAction :: Lens.Lens' DatasetAction (Prelude.Maybe SqlQueryDatasetAction)
datasetAction_queryAction :: (Maybe SqlQueryDatasetAction -> f (Maybe SqlQueryDatasetAction))
-> DatasetAction -> f DatasetAction
datasetAction_queryAction = (DatasetAction -> Maybe SqlQueryDatasetAction)
-> (DatasetAction -> Maybe SqlQueryDatasetAction -> DatasetAction)
-> Lens
DatasetAction
DatasetAction
(Maybe SqlQueryDatasetAction)
(Maybe SqlQueryDatasetAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatasetAction' {Maybe SqlQueryDatasetAction
queryAction :: Maybe SqlQueryDatasetAction
$sel:queryAction:DatasetAction' :: DatasetAction -> Maybe SqlQueryDatasetAction
queryAction} -> Maybe SqlQueryDatasetAction
queryAction) (\s :: DatasetAction
s@DatasetAction' {} Maybe SqlQueryDatasetAction
a -> DatasetAction
s {$sel:queryAction:DatasetAction' :: Maybe SqlQueryDatasetAction
queryAction = Maybe SqlQueryDatasetAction
a} :: DatasetAction)
datasetAction_actionName :: Lens.Lens' DatasetAction (Prelude.Maybe Prelude.Text)
datasetAction_actionName :: (Maybe Text -> f (Maybe Text)) -> DatasetAction -> f DatasetAction
datasetAction_actionName = (DatasetAction -> Maybe Text)
-> (DatasetAction -> Maybe Text -> DatasetAction)
-> Lens DatasetAction DatasetAction (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatasetAction' {Maybe Text
actionName :: Maybe Text
$sel:actionName:DatasetAction' :: DatasetAction -> Maybe Text
actionName} -> Maybe Text
actionName) (\s :: DatasetAction
s@DatasetAction' {} Maybe Text
a -> DatasetAction
s {$sel:actionName:DatasetAction' :: Maybe Text
actionName = Maybe Text
a} :: DatasetAction)
datasetAction_containerAction :: Lens.Lens' DatasetAction (Prelude.Maybe ContainerDatasetAction)
datasetAction_containerAction :: (Maybe ContainerDatasetAction -> f (Maybe ContainerDatasetAction))
-> DatasetAction -> f DatasetAction
datasetAction_containerAction = (DatasetAction -> Maybe ContainerDatasetAction)
-> (DatasetAction -> Maybe ContainerDatasetAction -> DatasetAction)
-> Lens
DatasetAction
DatasetAction
(Maybe ContainerDatasetAction)
(Maybe ContainerDatasetAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatasetAction' {Maybe ContainerDatasetAction
containerAction :: Maybe ContainerDatasetAction
$sel:containerAction:DatasetAction' :: DatasetAction -> Maybe ContainerDatasetAction
containerAction} -> Maybe ContainerDatasetAction
containerAction) (\s :: DatasetAction
s@DatasetAction' {} Maybe ContainerDatasetAction
a -> DatasetAction
s {$sel:containerAction:DatasetAction' :: Maybe ContainerDatasetAction
containerAction = Maybe ContainerDatasetAction
a} :: DatasetAction)
instance Core.FromJSON DatasetAction where
parseJSON :: Value -> Parser DatasetAction
parseJSON =
String
-> (Object -> Parser DatasetAction)
-> Value
-> Parser DatasetAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"DatasetAction"
( \Object
x ->
Maybe SqlQueryDatasetAction
-> Maybe Text -> Maybe ContainerDatasetAction -> DatasetAction
DatasetAction'
(Maybe SqlQueryDatasetAction
-> Maybe Text -> Maybe ContainerDatasetAction -> DatasetAction)
-> Parser (Maybe SqlQueryDatasetAction)
-> Parser
(Maybe Text -> Maybe ContainerDatasetAction -> DatasetAction)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe SqlQueryDatasetAction)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"queryAction")
Parser
(Maybe Text -> Maybe ContainerDatasetAction -> DatasetAction)
-> Parser (Maybe Text)
-> Parser (Maybe ContainerDatasetAction -> DatasetAction)
forall (f :: * -> *) a b. Applicative f => 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
"actionName")
Parser (Maybe ContainerDatasetAction -> DatasetAction)
-> Parser (Maybe ContainerDatasetAction) -> Parser DatasetAction
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ContainerDatasetAction)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"containerAction")
)
instance Prelude.Hashable DatasetAction
instance Prelude.NFData DatasetAction
instance Core.ToJSON DatasetAction where
toJSON :: DatasetAction -> Value
toJSON DatasetAction' {Maybe Text
Maybe SqlQueryDatasetAction
Maybe ContainerDatasetAction
containerAction :: Maybe ContainerDatasetAction
actionName :: Maybe Text
queryAction :: Maybe SqlQueryDatasetAction
$sel:containerAction:DatasetAction' :: DatasetAction -> Maybe ContainerDatasetAction
$sel:actionName:DatasetAction' :: DatasetAction -> Maybe Text
$sel:queryAction:DatasetAction' :: DatasetAction -> Maybe SqlQueryDatasetAction
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"queryAction" Text -> SqlQueryDatasetAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SqlQueryDatasetAction -> Pair)
-> Maybe SqlQueryDatasetAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SqlQueryDatasetAction
queryAction,
(Text
"actionName" 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
actionName,
(Text
"containerAction" Text -> ContainerDatasetAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(ContainerDatasetAction -> Pair)
-> Maybe ContainerDatasetAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ContainerDatasetAction
containerAction
]
)