{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.TimeStreamWrite.Types.Table
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.TimeStreamWrite.Types.Table 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.TimeStreamWrite.Types.MagneticStoreWriteProperties
import Amazonka.TimeStreamWrite.Types.RetentionProperties
import Amazonka.TimeStreamWrite.Types.TableStatus

-- | Table represents a database table in Timestream. Tables contain one or
-- more related time series. You can modify the retention duration of the
-- memory store and the magnetic store for a table.
--
-- /See:/ 'newTable' smart constructor.
data Table = Table'
  { -- | The Amazon Resource Name that uniquely identifies this table.
    Table -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The time when the Timestream table was created.
    Table -> Maybe POSIX
creationTime :: Prelude.Maybe Data.POSIX,
    -- | The name of the Timestream database that contains this table.
    Table -> Maybe Text
databaseName :: Prelude.Maybe Prelude.Text,
    -- | The time when the Timestream table was last updated.
    Table -> Maybe POSIX
lastUpdatedTime :: Prelude.Maybe Data.POSIX,
    -- | Contains properties to set on the table when enabling magnetic store
    -- writes.
    Table -> Maybe MagneticStoreWriteProperties
magneticStoreWriteProperties :: Prelude.Maybe MagneticStoreWriteProperties,
    -- | The retention duration for the memory store and magnetic store.
    Table -> Maybe RetentionProperties
retentionProperties :: Prelude.Maybe RetentionProperties,
    -- | The name of the Timestream table.
    Table -> Maybe Text
tableName :: Prelude.Maybe Prelude.Text,
    -- | The current state of the table:
    --
    -- -   @DELETING@ - The table is being deleted.
    --
    -- -   @ACTIVE@ - The table is ready for use.
    Table -> Maybe TableStatus
tableStatus :: Prelude.Maybe TableStatus
  }
  deriving (Table -> Table -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Table -> Table -> Bool
$c/= :: Table -> Table -> Bool
== :: Table -> Table -> Bool
$c== :: Table -> Table -> Bool
Prelude.Eq, ReadPrec [Table]
ReadPrec Table
Int -> ReadS Table
ReadS [Table]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Table]
$creadListPrec :: ReadPrec [Table]
readPrec :: ReadPrec Table
$creadPrec :: ReadPrec Table
readList :: ReadS [Table]
$creadList :: ReadS [Table]
readsPrec :: Int -> ReadS Table
$creadsPrec :: Int -> ReadS Table
Prelude.Read, Int -> Table -> ShowS
[Table] -> ShowS
Table -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Table] -> ShowS
$cshowList :: [Table] -> ShowS
show :: Table -> String
$cshow :: Table -> String
showsPrec :: Int -> Table -> ShowS
$cshowsPrec :: Int -> Table -> ShowS
Prelude.Show, forall x. Rep Table x -> Table
forall x. Table -> Rep Table x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Table x -> Table
$cfrom :: forall x. Table -> Rep Table x
Prelude.Generic)

-- |
-- Create a value of 'Table' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'arn', 'table_arn' - The Amazon Resource Name that uniquely identifies this table.
--
-- 'creationTime', 'table_creationTime' - The time when the Timestream table was created.
--
-- 'databaseName', 'table_databaseName' - The name of the Timestream database that contains this table.
--
-- 'lastUpdatedTime', 'table_lastUpdatedTime' - The time when the Timestream table was last updated.
--
-- 'magneticStoreWriteProperties', 'table_magneticStoreWriteProperties' - Contains properties to set on the table when enabling magnetic store
-- writes.
--
-- 'retentionProperties', 'table_retentionProperties' - The retention duration for the memory store and magnetic store.
--
-- 'tableName', 'table_tableName' - The name of the Timestream table.
--
-- 'tableStatus', 'table_tableStatus' - The current state of the table:
--
-- -   @DELETING@ - The table is being deleted.
--
-- -   @ACTIVE@ - The table is ready for use.
newTable ::
  Table
newTable :: Table
newTable =
  Table'
    { $sel:arn:Table' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:creationTime:Table' :: Maybe POSIX
creationTime = forall a. Maybe a
Prelude.Nothing,
      $sel:databaseName:Table' :: Maybe Text
databaseName = forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdatedTime:Table' :: Maybe POSIX
lastUpdatedTime = forall a. Maybe a
Prelude.Nothing,
      $sel:magneticStoreWriteProperties:Table' :: Maybe MagneticStoreWriteProperties
magneticStoreWriteProperties = forall a. Maybe a
Prelude.Nothing,
      $sel:retentionProperties:Table' :: Maybe RetentionProperties
retentionProperties = forall a. Maybe a
Prelude.Nothing,
      $sel:tableName:Table' :: Maybe Text
tableName = forall a. Maybe a
Prelude.Nothing,
      $sel:tableStatus:Table' :: Maybe TableStatus
tableStatus = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name that uniquely identifies this table.
table_arn :: Lens.Lens' Table (Prelude.Maybe Prelude.Text)
table_arn :: Lens' Table (Maybe Text)
table_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Table' {Maybe Text
arn :: Maybe Text
$sel:arn:Table' :: Table -> Maybe Text
arn} -> Maybe Text
arn) (\s :: Table
s@Table' {} Maybe Text
a -> Table
s {$sel:arn:Table' :: Maybe Text
arn = Maybe Text
a} :: Table)

-- | The time when the Timestream table was created.
table_creationTime :: Lens.Lens' Table (Prelude.Maybe Prelude.UTCTime)
table_creationTime :: Lens' Table (Maybe UTCTime)
table_creationTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Table' {Maybe POSIX
creationTime :: Maybe POSIX
$sel:creationTime:Table' :: Table -> Maybe POSIX
creationTime} -> Maybe POSIX
creationTime) (\s :: Table
s@Table' {} Maybe POSIX
a -> Table
s {$sel:creationTime:Table' :: Maybe POSIX
creationTime = Maybe POSIX
a} :: Table) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The name of the Timestream database that contains this table.
table_databaseName :: Lens.Lens' Table (Prelude.Maybe Prelude.Text)
table_databaseName :: Lens' Table (Maybe Text)
table_databaseName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Table' {Maybe Text
databaseName :: Maybe Text
$sel:databaseName:Table' :: Table -> Maybe Text
databaseName} -> Maybe Text
databaseName) (\s :: Table
s@Table' {} Maybe Text
a -> Table
s {$sel:databaseName:Table' :: Maybe Text
databaseName = Maybe Text
a} :: Table)

-- | The time when the Timestream table was last updated.
table_lastUpdatedTime :: Lens.Lens' Table (Prelude.Maybe Prelude.UTCTime)
table_lastUpdatedTime :: Lens' Table (Maybe UTCTime)
table_lastUpdatedTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Table' {Maybe POSIX
lastUpdatedTime :: Maybe POSIX
$sel:lastUpdatedTime:Table' :: Table -> Maybe POSIX
lastUpdatedTime} -> Maybe POSIX
lastUpdatedTime) (\s :: Table
s@Table' {} Maybe POSIX
a -> Table
s {$sel:lastUpdatedTime:Table' :: Maybe POSIX
lastUpdatedTime = Maybe POSIX
a} :: Table) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | Contains properties to set on the table when enabling magnetic store
-- writes.
table_magneticStoreWriteProperties :: Lens.Lens' Table (Prelude.Maybe MagneticStoreWriteProperties)
table_magneticStoreWriteProperties :: Lens' Table (Maybe MagneticStoreWriteProperties)
table_magneticStoreWriteProperties = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Table' {Maybe MagneticStoreWriteProperties
magneticStoreWriteProperties :: Maybe MagneticStoreWriteProperties
$sel:magneticStoreWriteProperties:Table' :: Table -> Maybe MagneticStoreWriteProperties
magneticStoreWriteProperties} -> Maybe MagneticStoreWriteProperties
magneticStoreWriteProperties) (\s :: Table
s@Table' {} Maybe MagneticStoreWriteProperties
a -> Table
s {$sel:magneticStoreWriteProperties:Table' :: Maybe MagneticStoreWriteProperties
magneticStoreWriteProperties = Maybe MagneticStoreWriteProperties
a} :: Table)

-- | The retention duration for the memory store and magnetic store.
table_retentionProperties :: Lens.Lens' Table (Prelude.Maybe RetentionProperties)
table_retentionProperties :: Lens' Table (Maybe RetentionProperties)
table_retentionProperties = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Table' {Maybe RetentionProperties
retentionProperties :: Maybe RetentionProperties
$sel:retentionProperties:Table' :: Table -> Maybe RetentionProperties
retentionProperties} -> Maybe RetentionProperties
retentionProperties) (\s :: Table
s@Table' {} Maybe RetentionProperties
a -> Table
s {$sel:retentionProperties:Table' :: Maybe RetentionProperties
retentionProperties = Maybe RetentionProperties
a} :: Table)

-- | The name of the Timestream table.
table_tableName :: Lens.Lens' Table (Prelude.Maybe Prelude.Text)
table_tableName :: Lens' Table (Maybe Text)
table_tableName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Table' {Maybe Text
tableName :: Maybe Text
$sel:tableName:Table' :: Table -> Maybe Text
tableName} -> Maybe Text
tableName) (\s :: Table
s@Table' {} Maybe Text
a -> Table
s {$sel:tableName:Table' :: Maybe Text
tableName = Maybe Text
a} :: Table)

-- | The current state of the table:
--
-- -   @DELETING@ - The table is being deleted.
--
-- -   @ACTIVE@ - The table is ready for use.
table_tableStatus :: Lens.Lens' Table (Prelude.Maybe TableStatus)
table_tableStatus :: Lens' Table (Maybe TableStatus)
table_tableStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Table' {Maybe TableStatus
tableStatus :: Maybe TableStatus
$sel:tableStatus:Table' :: Table -> Maybe TableStatus
tableStatus} -> Maybe TableStatus
tableStatus) (\s :: Table
s@Table' {} Maybe TableStatus
a -> Table
s {$sel:tableStatus:Table' :: Maybe TableStatus
tableStatus = Maybe TableStatus
a} :: Table)

instance Data.FromJSON Table where
  parseJSON :: Value -> Parser Table
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Table"
      ( \Object
x ->
          Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe MagneticStoreWriteProperties
-> Maybe RetentionProperties
-> Maybe Text
-> Maybe TableStatus
-> Table
Table'
            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
"Arn")
            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
"CreationTime")
            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
"DatabaseName")
            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
"LastUpdatedTime")
            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
"MagneticStoreWriteProperties")
            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
"RetentionProperties")
            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
"TableName")
            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
"TableStatus")
      )

instance Prelude.Hashable Table where
  hashWithSalt :: Int -> Table -> Int
hashWithSalt Int
_salt Table' {Maybe Text
Maybe POSIX
Maybe RetentionProperties
Maybe MagneticStoreWriteProperties
Maybe TableStatus
tableStatus :: Maybe TableStatus
tableName :: Maybe Text
retentionProperties :: Maybe RetentionProperties
magneticStoreWriteProperties :: Maybe MagneticStoreWriteProperties
lastUpdatedTime :: Maybe POSIX
databaseName :: Maybe Text
creationTime :: Maybe POSIX
arn :: Maybe Text
$sel:tableStatus:Table' :: Table -> Maybe TableStatus
$sel:tableName:Table' :: Table -> Maybe Text
$sel:retentionProperties:Table' :: Table -> Maybe RetentionProperties
$sel:magneticStoreWriteProperties:Table' :: Table -> Maybe MagneticStoreWriteProperties
$sel:lastUpdatedTime:Table' :: Table -> Maybe POSIX
$sel:databaseName:Table' :: Table -> Maybe Text
$sel:creationTime:Table' :: Table -> Maybe POSIX
$sel:arn:Table' :: Table -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
creationTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
databaseName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastUpdatedTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe MagneticStoreWriteProperties
magneticStoreWriteProperties
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RetentionProperties
retentionProperties
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
tableName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TableStatus
tableStatus

instance Prelude.NFData Table where
  rnf :: Table -> ()
rnf Table' {Maybe Text
Maybe POSIX
Maybe RetentionProperties
Maybe MagneticStoreWriteProperties
Maybe TableStatus
tableStatus :: Maybe TableStatus
tableName :: Maybe Text
retentionProperties :: Maybe RetentionProperties
magneticStoreWriteProperties :: Maybe MagneticStoreWriteProperties
lastUpdatedTime :: Maybe POSIX
databaseName :: Maybe Text
creationTime :: Maybe POSIX
arn :: Maybe Text
$sel:tableStatus:Table' :: Table -> Maybe TableStatus
$sel:tableName:Table' :: Table -> Maybe Text
$sel:retentionProperties:Table' :: Table -> Maybe RetentionProperties
$sel:magneticStoreWriteProperties:Table' :: Table -> Maybe MagneticStoreWriteProperties
$sel:lastUpdatedTime:Table' :: Table -> Maybe POSIX
$sel:databaseName:Table' :: Table -> Maybe Text
$sel:creationTime:Table' :: Table -> Maybe POSIX
$sel:arn:Table' :: Table -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
creationTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
databaseName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastUpdatedTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe MagneticStoreWriteProperties
magneticStoreWriteProperties
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RetentionProperties
retentionProperties
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
tableName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TableStatus
tableStatus