{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.QLDB.Types.LedgerSummary where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 current status of the ledger.
    LedgerSummary -> Maybe LedgerState
state :: Prelude.Maybe LedgerState,
    -- | The name of the ledger.
    LedgerSummary -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | 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 Core.POSIX
  }
  deriving (LedgerSummary -> LedgerSummary -> Bool
(LedgerSummary -> LedgerSummary -> Bool)
-> (LedgerSummary -> LedgerSummary -> Bool) -> Eq LedgerSummary
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]
(Int -> ReadS LedgerSummary)
-> ReadS [LedgerSummary]
-> ReadPrec LedgerSummary
-> ReadPrec [LedgerSummary]
-> Read 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
(Int -> LedgerSummary -> ShowS)
-> (LedgerSummary -> String)
-> ([LedgerSummary] -> ShowS)
-> Show LedgerSummary
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. LedgerSummary -> Rep LedgerSummary x)
-> (forall x. Rep LedgerSummary x -> LedgerSummary)
-> Generic LedgerSummary
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:
--
-- 'state', 'ledgerSummary_state' - The current status of the ledger.
--
-- 'name', 'ledgerSummary_name' - The name of the ledger.
--
-- '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.)
newLedgerSummary ::
  LedgerSummary
newLedgerSummary :: LedgerSummary
newLedgerSummary =
  LedgerSummary' :: Maybe LedgerState -> Maybe Text -> Maybe POSIX -> LedgerSummary
LedgerSummary'
    { $sel:state:LedgerSummary' :: Maybe LedgerState
state = Maybe LedgerState
forall a. Maybe a
Prelude.Nothing,
      $sel:name:LedgerSummary' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationDateTime:LedgerSummary' :: Maybe POSIX
creationDateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The current status of the ledger.
ledgerSummary_state :: Lens.Lens' LedgerSummary (Prelude.Maybe LedgerState)
ledgerSummary_state :: (Maybe LedgerState -> f (Maybe LedgerState))
-> LedgerSummary -> f LedgerSummary
ledgerSummary_state = (LedgerSummary -> Maybe LedgerState)
-> (LedgerSummary -> Maybe LedgerState -> LedgerSummary)
-> Lens
     LedgerSummary LedgerSummary (Maybe LedgerState) (Maybe LedgerState)
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)

-- | The name of the ledger.
ledgerSummary_name :: Lens.Lens' LedgerSummary (Prelude.Maybe Prelude.Text)
ledgerSummary_name :: (Maybe Text -> f (Maybe Text)) -> LedgerSummary -> f LedgerSummary
ledgerSummary_name = (LedgerSummary -> Maybe Text)
-> (LedgerSummary -> Maybe Text -> LedgerSummary)
-> Lens LedgerSummary LedgerSummary (Maybe Text) (Maybe Text)
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 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 :: (Maybe UTCTime -> f (Maybe UTCTime))
-> LedgerSummary -> f LedgerSummary
ledgerSummary_creationDateTime = (LedgerSummary -> Maybe POSIX)
-> (LedgerSummary -> Maybe POSIX -> LedgerSummary)
-> Lens LedgerSummary LedgerSummary (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX))
 -> LedgerSummary -> f LedgerSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> LedgerSummary
-> f LedgerSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON LedgerSummary where
  parseJSON :: Value -> Parser LedgerSummary
parseJSON =
    String
-> (Object -> Parser LedgerSummary)
-> Value
-> Parser LedgerSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LedgerSummary"
      ( \Object
x ->
          Maybe LedgerState -> Maybe Text -> Maybe POSIX -> LedgerSummary
LedgerSummary'
            (Maybe LedgerState -> Maybe Text -> Maybe POSIX -> LedgerSummary)
-> Parser (Maybe LedgerState)
-> Parser (Maybe Text -> Maybe POSIX -> LedgerSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe LedgerState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"State")
            Parser (Maybe Text -> Maybe POSIX -> LedgerSummary)
-> Parser (Maybe Text) -> Parser (Maybe POSIX -> LedgerSummary)
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
"Name")
            Parser (Maybe POSIX -> LedgerSummary)
-> Parser (Maybe POSIX) -> Parser LedgerSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CreationDateTime")
      )

instance Prelude.Hashable LedgerSummary

instance Prelude.NFData LedgerSummary