{-# 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.QLDB.Types.LedgerSummary
-- 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.QLDB.Types.LedgerSummary 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.QLDB.Types.LedgerState

-- | Information about a ledger, including its name, state, and when it was
-- created.
--
-- /See:/ 'newLedgerSummary' smart constructor.
data LedgerSummary = LedgerSummary'
  { -- | The date and time, in epoch time format, when the ledger was created.
    -- (Epoch time format is the number of seconds elapsed since 12:00:00 AM
    -- January 1, 1970 UTC.)
    LedgerSummary -> Maybe POSIX
creationDateTime :: Prelude.Maybe Data.POSIX,
    -- | The name of the ledger.
    LedgerSummary -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The current status of the ledger.
    LedgerSummary -> Maybe LedgerState
state :: Prelude.Maybe LedgerState
  }
  deriving (LedgerSummary -> LedgerSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LedgerSummary -> LedgerSummary -> Bool
$c/= :: LedgerSummary -> LedgerSummary -> Bool
== :: LedgerSummary -> LedgerSummary -> Bool
$c== :: LedgerSummary -> LedgerSummary -> Bool
Prelude.Eq, ReadPrec [LedgerSummary]
ReadPrec LedgerSummary
Int -> ReadS LedgerSummary
ReadS [LedgerSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LedgerSummary]
$creadListPrec :: ReadPrec [LedgerSummary]
readPrec :: ReadPrec LedgerSummary
$creadPrec :: ReadPrec LedgerSummary
readList :: ReadS [LedgerSummary]
$creadList :: ReadS [LedgerSummary]
readsPrec :: Int -> ReadS LedgerSummary
$creadsPrec :: Int -> ReadS LedgerSummary
Prelude.Read, Int -> LedgerSummary -> ShowS
[LedgerSummary] -> ShowS
LedgerSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LedgerSummary] -> ShowS
$cshowList :: [LedgerSummary] -> ShowS
show :: LedgerSummary -> String
$cshow :: LedgerSummary -> String
showsPrec :: Int -> LedgerSummary -> ShowS
$cshowsPrec :: Int -> LedgerSummary -> ShowS
Prelude.Show, forall x. Rep LedgerSummary x -> LedgerSummary
forall x. LedgerSummary -> Rep LedgerSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LedgerSummary x -> LedgerSummary
$cfrom :: forall x. LedgerSummary -> Rep LedgerSummary x
Prelude.Generic)

-- |
-- Create a value of 'LedgerSummary' 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:
--
-- 'creationDateTime', 'ledgerSummary_creationDateTime' - The date and time, in epoch time format, when the ledger was created.
-- (Epoch time format is the number of seconds elapsed since 12:00:00 AM
-- January 1, 1970 UTC.)
--
-- 'name', 'ledgerSummary_name' - The name of the ledger.
--
-- 'state', 'ledgerSummary_state' - The current status of the ledger.
newLedgerSummary ::
  LedgerSummary
newLedgerSummary :: LedgerSummary
newLedgerSummary =
  LedgerSummary'
    { $sel:creationDateTime:LedgerSummary' :: Maybe POSIX
creationDateTime = forall a. Maybe a
Prelude.Nothing,
      $sel:name:LedgerSummary' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:state:LedgerSummary' :: Maybe LedgerState
state = forall a. Maybe a
Prelude.Nothing
    }

-- | The date and time, in epoch time format, when the ledger was created.
-- (Epoch time format is the number of seconds elapsed since 12:00:00 AM
-- January 1, 1970 UTC.)
ledgerSummary_creationDateTime :: Lens.Lens' LedgerSummary (Prelude.Maybe Prelude.UTCTime)
ledgerSummary_creationDateTime :: Lens' LedgerSummary (Maybe UTCTime)
ledgerSummary_creationDateTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LedgerSummary' {Maybe POSIX
creationDateTime :: Maybe POSIX
$sel:creationDateTime:LedgerSummary' :: LedgerSummary -> Maybe POSIX
creationDateTime} -> Maybe POSIX
creationDateTime) (\s :: LedgerSummary
s@LedgerSummary' {} Maybe POSIX
a -> LedgerSummary
s {$sel:creationDateTime:LedgerSummary' :: Maybe POSIX
creationDateTime = Maybe POSIX
a} :: LedgerSummary) 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 ledger.
ledgerSummary_name :: Lens.Lens' LedgerSummary (Prelude.Maybe Prelude.Text)
ledgerSummary_name :: Lens' LedgerSummary (Maybe Text)
ledgerSummary_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LedgerSummary' {Maybe Text
name :: Maybe Text
$sel:name:LedgerSummary' :: LedgerSummary -> Maybe Text
name} -> Maybe Text
name) (\s :: LedgerSummary
s@LedgerSummary' {} Maybe Text
a -> LedgerSummary
s {$sel:name:LedgerSummary' :: Maybe Text
name = Maybe Text
a} :: LedgerSummary)

-- | The current status of the ledger.
ledgerSummary_state :: Lens.Lens' LedgerSummary (Prelude.Maybe LedgerState)
ledgerSummary_state :: Lens' LedgerSummary (Maybe LedgerState)
ledgerSummary_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LedgerSummary' {Maybe LedgerState
state :: Maybe LedgerState
$sel:state:LedgerSummary' :: LedgerSummary -> Maybe LedgerState
state} -> Maybe LedgerState
state) (\s :: LedgerSummary
s@LedgerSummary' {} Maybe LedgerState
a -> LedgerSummary
s {$sel:state:LedgerSummary' :: Maybe LedgerState
state = Maybe LedgerState
a} :: LedgerSummary)

instance Data.FromJSON LedgerSummary where
  parseJSON :: Value -> Parser LedgerSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LedgerSummary"
      ( \Object
x ->
          Maybe POSIX -> Maybe Text -> Maybe LedgerState -> LedgerSummary
LedgerSummary'
            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
"CreationDateTime")
            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
"Name")
            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
"State")
      )

instance Prelude.Hashable LedgerSummary where
  hashWithSalt :: Int -> LedgerSummary -> Int
hashWithSalt Int
_salt LedgerSummary' {Maybe Text
Maybe POSIX
Maybe LedgerState
state :: Maybe LedgerState
name :: Maybe Text
creationDateTime :: Maybe POSIX
$sel:state:LedgerSummary' :: LedgerSummary -> Maybe LedgerState
$sel:name:LedgerSummary' :: LedgerSummary -> Maybe Text
$sel:creationDateTime:LedgerSummary' :: LedgerSummary -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
creationDateTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe LedgerState
state

instance Prelude.NFData LedgerSummary where
  rnf :: LedgerSummary -> ()
rnf LedgerSummary' {Maybe Text
Maybe POSIX
Maybe LedgerState
state :: Maybe LedgerState
name :: Maybe Text
creationDateTime :: Maybe POSIX
$sel:state:LedgerSummary' :: LedgerSummary -> Maybe LedgerState
$sel:name:LedgerSummary' :: LedgerSummary -> Maybe Text
$sel:creationDateTime:LedgerSummary' :: LedgerSummary -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
creationDateTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe LedgerState
state