{-# 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.IoT.Types.TimestreamAction where
import qualified Amazonka.Core as Core
import Amazonka.IoT.Types.TimestreamDimension
import Amazonka.IoT.Types.TimestreamTimestamp
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data TimestreamAction = TimestreamAction'
{
TimestreamAction -> Maybe TimestreamTimestamp
timestamp :: Prelude.Maybe TimestreamTimestamp,
TimestreamAction -> Text
roleArn :: Prelude.Text,
TimestreamAction -> Text
databaseName :: Prelude.Text,
TimestreamAction -> Text
tableName :: Prelude.Text,
TimestreamAction -> NonEmpty TimestreamDimension
dimensions :: Prelude.NonEmpty TimestreamDimension
}
deriving (TimestreamAction -> TimestreamAction -> Bool
(TimestreamAction -> TimestreamAction -> Bool)
-> (TimestreamAction -> TimestreamAction -> Bool)
-> Eq TimestreamAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimestreamAction -> TimestreamAction -> Bool
$c/= :: TimestreamAction -> TimestreamAction -> Bool
== :: TimestreamAction -> TimestreamAction -> Bool
$c== :: TimestreamAction -> TimestreamAction -> Bool
Prelude.Eq, ReadPrec [TimestreamAction]
ReadPrec TimestreamAction
Int -> ReadS TimestreamAction
ReadS [TimestreamAction]
(Int -> ReadS TimestreamAction)
-> ReadS [TimestreamAction]
-> ReadPrec TimestreamAction
-> ReadPrec [TimestreamAction]
-> Read TimestreamAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TimestreamAction]
$creadListPrec :: ReadPrec [TimestreamAction]
readPrec :: ReadPrec TimestreamAction
$creadPrec :: ReadPrec TimestreamAction
readList :: ReadS [TimestreamAction]
$creadList :: ReadS [TimestreamAction]
readsPrec :: Int -> ReadS TimestreamAction
$creadsPrec :: Int -> ReadS TimestreamAction
Prelude.Read, Int -> TimestreamAction -> ShowS
[TimestreamAction] -> ShowS
TimestreamAction -> String
(Int -> TimestreamAction -> ShowS)
-> (TimestreamAction -> String)
-> ([TimestreamAction] -> ShowS)
-> Show TimestreamAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimestreamAction] -> ShowS
$cshowList :: [TimestreamAction] -> ShowS
show :: TimestreamAction -> String
$cshow :: TimestreamAction -> String
showsPrec :: Int -> TimestreamAction -> ShowS
$cshowsPrec :: Int -> TimestreamAction -> ShowS
Prelude.Show, (forall x. TimestreamAction -> Rep TimestreamAction x)
-> (forall x. Rep TimestreamAction x -> TimestreamAction)
-> Generic TimestreamAction
forall x. Rep TimestreamAction x -> TimestreamAction
forall x. TimestreamAction -> Rep TimestreamAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TimestreamAction x -> TimestreamAction
$cfrom :: forall x. TimestreamAction -> Rep TimestreamAction x
Prelude.Generic)
newTimestreamAction ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
Prelude.NonEmpty TimestreamDimension ->
TimestreamAction
newTimestreamAction :: Text
-> Text -> Text -> NonEmpty TimestreamDimension -> TimestreamAction
newTimestreamAction
Text
pRoleArn_
Text
pDatabaseName_
Text
pTableName_
NonEmpty TimestreamDimension
pDimensions_ =
TimestreamAction' :: Maybe TimestreamTimestamp
-> Text
-> Text
-> Text
-> NonEmpty TimestreamDimension
-> TimestreamAction
TimestreamAction'
{ $sel:timestamp:TimestreamAction' :: Maybe TimestreamTimestamp
timestamp = Maybe TimestreamTimestamp
forall a. Maybe a
Prelude.Nothing,
$sel:roleArn:TimestreamAction' :: Text
roleArn = Text
pRoleArn_,
$sel:databaseName:TimestreamAction' :: Text
databaseName = Text
pDatabaseName_,
$sel:tableName:TimestreamAction' :: Text
tableName = Text
pTableName_,
$sel:dimensions:TimestreamAction' :: NonEmpty TimestreamDimension
dimensions = Tagged
(NonEmpty TimestreamDimension)
(Identity (NonEmpty TimestreamDimension))
-> Tagged
(NonEmpty TimestreamDimension)
(Identity (NonEmpty TimestreamDimension))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
(NonEmpty TimestreamDimension)
(Identity (NonEmpty TimestreamDimension))
-> Tagged
(NonEmpty TimestreamDimension)
(Identity (NonEmpty TimestreamDimension)))
-> NonEmpty TimestreamDimension -> NonEmpty TimestreamDimension
forall t b. AReview t b -> b -> t
Lens.# NonEmpty TimestreamDimension
pDimensions_
}
timestreamAction_timestamp :: Lens.Lens' TimestreamAction (Prelude.Maybe TimestreamTimestamp)
timestreamAction_timestamp :: (Maybe TimestreamTimestamp -> f (Maybe TimestreamTimestamp))
-> TimestreamAction -> f TimestreamAction
timestreamAction_timestamp = (TimestreamAction -> Maybe TimestreamTimestamp)
-> (TimestreamAction
-> Maybe TimestreamTimestamp -> TimestreamAction)
-> Lens
TimestreamAction
TimestreamAction
(Maybe TimestreamTimestamp)
(Maybe TimestreamTimestamp)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimestreamAction' {Maybe TimestreamTimestamp
timestamp :: Maybe TimestreamTimestamp
$sel:timestamp:TimestreamAction' :: TimestreamAction -> Maybe TimestreamTimestamp
timestamp} -> Maybe TimestreamTimestamp
timestamp) (\s :: TimestreamAction
s@TimestreamAction' {} Maybe TimestreamTimestamp
a -> TimestreamAction
s {$sel:timestamp:TimestreamAction' :: Maybe TimestreamTimestamp
timestamp = Maybe TimestreamTimestamp
a} :: TimestreamAction)
timestreamAction_roleArn :: Lens.Lens' TimestreamAction Prelude.Text
timestreamAction_roleArn :: (Text -> f Text) -> TimestreamAction -> f TimestreamAction
timestreamAction_roleArn = (TimestreamAction -> Text)
-> (TimestreamAction -> Text -> TimestreamAction)
-> Lens TimestreamAction TimestreamAction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimestreamAction' {Text
roleArn :: Text
$sel:roleArn:TimestreamAction' :: TimestreamAction -> Text
roleArn} -> Text
roleArn) (\s :: TimestreamAction
s@TimestreamAction' {} Text
a -> TimestreamAction
s {$sel:roleArn:TimestreamAction' :: Text
roleArn = Text
a} :: TimestreamAction)
timestreamAction_databaseName :: Lens.Lens' TimestreamAction Prelude.Text
timestreamAction_databaseName :: (Text -> f Text) -> TimestreamAction -> f TimestreamAction
timestreamAction_databaseName = (TimestreamAction -> Text)
-> (TimestreamAction -> Text -> TimestreamAction)
-> Lens TimestreamAction TimestreamAction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimestreamAction' {Text
databaseName :: Text
$sel:databaseName:TimestreamAction' :: TimestreamAction -> Text
databaseName} -> Text
databaseName) (\s :: TimestreamAction
s@TimestreamAction' {} Text
a -> TimestreamAction
s {$sel:databaseName:TimestreamAction' :: Text
databaseName = Text
a} :: TimestreamAction)
timestreamAction_tableName :: Lens.Lens' TimestreamAction Prelude.Text
timestreamAction_tableName :: (Text -> f Text) -> TimestreamAction -> f TimestreamAction
timestreamAction_tableName = (TimestreamAction -> Text)
-> (TimestreamAction -> Text -> TimestreamAction)
-> Lens TimestreamAction TimestreamAction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimestreamAction' {Text
tableName :: Text
$sel:tableName:TimestreamAction' :: TimestreamAction -> Text
tableName} -> Text
tableName) (\s :: TimestreamAction
s@TimestreamAction' {} Text
a -> TimestreamAction
s {$sel:tableName:TimestreamAction' :: Text
tableName = Text
a} :: TimestreamAction)
timestreamAction_dimensions :: Lens.Lens' TimestreamAction (Prelude.NonEmpty TimestreamDimension)
timestreamAction_dimensions :: (NonEmpty TimestreamDimension -> f (NonEmpty TimestreamDimension))
-> TimestreamAction -> f TimestreamAction
timestreamAction_dimensions = (TimestreamAction -> NonEmpty TimestreamDimension)
-> (TimestreamAction
-> NonEmpty TimestreamDimension -> TimestreamAction)
-> Lens
TimestreamAction
TimestreamAction
(NonEmpty TimestreamDimension)
(NonEmpty TimestreamDimension)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimestreamAction' {NonEmpty TimestreamDimension
dimensions :: NonEmpty TimestreamDimension
$sel:dimensions:TimestreamAction' :: TimestreamAction -> NonEmpty TimestreamDimension
dimensions} -> NonEmpty TimestreamDimension
dimensions) (\s :: TimestreamAction
s@TimestreamAction' {} NonEmpty TimestreamDimension
a -> TimestreamAction
s {$sel:dimensions:TimestreamAction' :: NonEmpty TimestreamDimension
dimensions = NonEmpty TimestreamDimension
a} :: TimestreamAction) ((NonEmpty TimestreamDimension -> f (NonEmpty TimestreamDimension))
-> TimestreamAction -> f TimestreamAction)
-> ((NonEmpty TimestreamDimension
-> f (NonEmpty TimestreamDimension))
-> NonEmpty TimestreamDimension
-> f (NonEmpty TimestreamDimension))
-> (NonEmpty TimestreamDimension
-> f (NonEmpty TimestreamDimension))
-> TimestreamAction
-> f TimestreamAction
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty TimestreamDimension -> f (NonEmpty TimestreamDimension))
-> NonEmpty TimestreamDimension -> f (NonEmpty TimestreamDimension)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromJSON TimestreamAction where
parseJSON :: Value -> Parser TimestreamAction
parseJSON =
String
-> (Object -> Parser TimestreamAction)
-> Value
-> Parser TimestreamAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"TimestreamAction"
( \Object
x ->
Maybe TimestreamTimestamp
-> Text
-> Text
-> Text
-> NonEmpty TimestreamDimension
-> TimestreamAction
TimestreamAction'
(Maybe TimestreamTimestamp
-> Text
-> Text
-> Text
-> NonEmpty TimestreamDimension
-> TimestreamAction)
-> Parser (Maybe TimestreamTimestamp)
-> Parser
(Text
-> Text
-> Text
-> NonEmpty TimestreamDimension
-> TimestreamAction)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe TimestreamTimestamp)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"timestamp")
Parser
(Text
-> Text
-> Text
-> NonEmpty TimestreamDimension
-> TimestreamAction)
-> Parser Text
-> Parser
(Text -> Text -> NonEmpty TimestreamDimension -> TimestreamAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"roleArn")
Parser
(Text -> Text -> NonEmpty TimestreamDimension -> TimestreamAction)
-> Parser Text
-> Parser
(Text -> NonEmpty TimestreamDimension -> TimestreamAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"databaseName")
Parser (Text -> NonEmpty TimestreamDimension -> TimestreamAction)
-> Parser Text
-> Parser (NonEmpty TimestreamDimension -> TimestreamAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"tableName")
Parser (NonEmpty TimestreamDimension -> TimestreamAction)
-> Parser (NonEmpty TimestreamDimension) -> Parser TimestreamAction
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (NonEmpty TimestreamDimension)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"dimensions")
)
instance Prelude.Hashable TimestreamAction
instance Prelude.NFData TimestreamAction
instance Core.ToJSON TimestreamAction where
toJSON :: TimestreamAction -> Value
toJSON TimestreamAction' {Maybe TimestreamTimestamp
NonEmpty TimestreamDimension
Text
dimensions :: NonEmpty TimestreamDimension
tableName :: Text
databaseName :: Text
roleArn :: Text
timestamp :: Maybe TimestreamTimestamp
$sel:dimensions:TimestreamAction' :: TimestreamAction -> NonEmpty TimestreamDimension
$sel:tableName:TimestreamAction' :: TimestreamAction -> Text
$sel:databaseName:TimestreamAction' :: TimestreamAction -> Text
$sel:roleArn:TimestreamAction' :: TimestreamAction -> Text
$sel:timestamp:TimestreamAction' :: TimestreamAction -> Maybe TimestreamTimestamp
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"timestamp" Text -> TimestreamTimestamp -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TimestreamTimestamp -> Pair)
-> Maybe TimestreamTimestamp -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TimestreamTimestamp
timestamp,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"roleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
roleArn),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"databaseName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
databaseName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"tableName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
tableName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"dimensions" Text -> NonEmpty TimestreamDimension -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty TimestreamDimension
dimensions)
]
)