{-# 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.QLDBSession.Types.CommitTransactionResult
-- 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.QLDBSession.Types.CommitTransactionResult where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.QLDBSession.Types.IOUsage
import Amazonka.QLDBSession.Types.TimingInformation

-- | Contains the details of the committed transaction.
--
-- /See:/ 'newCommitTransactionResult' smart constructor.
data CommitTransactionResult = CommitTransactionResult'
  { -- | Contains server-side performance information for the command.
    CommitTransactionResult -> Maybe TimingInformation
timingInformation :: Prelude.Maybe TimingInformation,
    -- | Contains metrics about the number of I\/O requests that were consumed.
    CommitTransactionResult -> Maybe IOUsage
consumedIOs :: Prelude.Maybe IOUsage,
    -- | The commit digest of the committed transaction.
    CommitTransactionResult -> Maybe Base64
commitDigest :: Prelude.Maybe Core.Base64,
    -- | The transaction ID of the committed transaction.
    CommitTransactionResult -> Maybe Text
transactionId :: Prelude.Maybe Prelude.Text
  }
  deriving (CommitTransactionResult -> CommitTransactionResult -> Bool
(CommitTransactionResult -> CommitTransactionResult -> Bool)
-> (CommitTransactionResult -> CommitTransactionResult -> Bool)
-> Eq CommitTransactionResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CommitTransactionResult -> CommitTransactionResult -> Bool
$c/= :: CommitTransactionResult -> CommitTransactionResult -> Bool
== :: CommitTransactionResult -> CommitTransactionResult -> Bool
$c== :: CommitTransactionResult -> CommitTransactionResult -> Bool
Prelude.Eq, ReadPrec [CommitTransactionResult]
ReadPrec CommitTransactionResult
Int -> ReadS CommitTransactionResult
ReadS [CommitTransactionResult]
(Int -> ReadS CommitTransactionResult)
-> ReadS [CommitTransactionResult]
-> ReadPrec CommitTransactionResult
-> ReadPrec [CommitTransactionResult]
-> Read CommitTransactionResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CommitTransactionResult]
$creadListPrec :: ReadPrec [CommitTransactionResult]
readPrec :: ReadPrec CommitTransactionResult
$creadPrec :: ReadPrec CommitTransactionResult
readList :: ReadS [CommitTransactionResult]
$creadList :: ReadS [CommitTransactionResult]
readsPrec :: Int -> ReadS CommitTransactionResult
$creadsPrec :: Int -> ReadS CommitTransactionResult
Prelude.Read, Int -> CommitTransactionResult -> ShowS
[CommitTransactionResult] -> ShowS
CommitTransactionResult -> String
(Int -> CommitTransactionResult -> ShowS)
-> (CommitTransactionResult -> String)
-> ([CommitTransactionResult] -> ShowS)
-> Show CommitTransactionResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CommitTransactionResult] -> ShowS
$cshowList :: [CommitTransactionResult] -> ShowS
show :: CommitTransactionResult -> String
$cshow :: CommitTransactionResult -> String
showsPrec :: Int -> CommitTransactionResult -> ShowS
$cshowsPrec :: Int -> CommitTransactionResult -> ShowS
Prelude.Show, (forall x.
 CommitTransactionResult -> Rep CommitTransactionResult x)
-> (forall x.
    Rep CommitTransactionResult x -> CommitTransactionResult)
-> Generic CommitTransactionResult
forall x. Rep CommitTransactionResult x -> CommitTransactionResult
forall x. CommitTransactionResult -> Rep CommitTransactionResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CommitTransactionResult x -> CommitTransactionResult
$cfrom :: forall x. CommitTransactionResult -> Rep CommitTransactionResult x
Prelude.Generic)

-- |
-- Create a value of 'CommitTransactionResult' 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:
--
-- 'timingInformation', 'commitTransactionResult_timingInformation' - Contains server-side performance information for the command.
--
-- 'consumedIOs', 'commitTransactionResult_consumedIOs' - Contains metrics about the number of I\/O requests that were consumed.
--
-- 'commitDigest', 'commitTransactionResult_commitDigest' - The commit digest of the committed transaction.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
--
-- 'transactionId', 'commitTransactionResult_transactionId' - The transaction ID of the committed transaction.
newCommitTransactionResult ::
  CommitTransactionResult
newCommitTransactionResult :: CommitTransactionResult
newCommitTransactionResult =
  CommitTransactionResult' :: Maybe TimingInformation
-> Maybe IOUsage
-> Maybe Base64
-> Maybe Text
-> CommitTransactionResult
CommitTransactionResult'
    { $sel:timingInformation:CommitTransactionResult' :: Maybe TimingInformation
timingInformation =
        Maybe TimingInformation
forall a. Maybe a
Prelude.Nothing,
      $sel:consumedIOs:CommitTransactionResult' :: Maybe IOUsage
consumedIOs = Maybe IOUsage
forall a. Maybe a
Prelude.Nothing,
      $sel:commitDigest:CommitTransactionResult' :: Maybe Base64
commitDigest = Maybe Base64
forall a. Maybe a
Prelude.Nothing,
      $sel:transactionId:CommitTransactionResult' :: Maybe Text
transactionId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Contains server-side performance information for the command.
commitTransactionResult_timingInformation :: Lens.Lens' CommitTransactionResult (Prelude.Maybe TimingInformation)
commitTransactionResult_timingInformation :: (Maybe TimingInformation -> f (Maybe TimingInformation))
-> CommitTransactionResult -> f CommitTransactionResult
commitTransactionResult_timingInformation = (CommitTransactionResult -> Maybe TimingInformation)
-> (CommitTransactionResult
    -> Maybe TimingInformation -> CommitTransactionResult)
-> Lens
     CommitTransactionResult
     CommitTransactionResult
     (Maybe TimingInformation)
     (Maybe TimingInformation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CommitTransactionResult' {Maybe TimingInformation
timingInformation :: Maybe TimingInformation
$sel:timingInformation:CommitTransactionResult' :: CommitTransactionResult -> Maybe TimingInformation
timingInformation} -> Maybe TimingInformation
timingInformation) (\s :: CommitTransactionResult
s@CommitTransactionResult' {} Maybe TimingInformation
a -> CommitTransactionResult
s {$sel:timingInformation:CommitTransactionResult' :: Maybe TimingInformation
timingInformation = Maybe TimingInformation
a} :: CommitTransactionResult)

-- | Contains metrics about the number of I\/O requests that were consumed.
commitTransactionResult_consumedIOs :: Lens.Lens' CommitTransactionResult (Prelude.Maybe IOUsage)
commitTransactionResult_consumedIOs :: (Maybe IOUsage -> f (Maybe IOUsage))
-> CommitTransactionResult -> f CommitTransactionResult
commitTransactionResult_consumedIOs = (CommitTransactionResult -> Maybe IOUsage)
-> (CommitTransactionResult
    -> Maybe IOUsage -> CommitTransactionResult)
-> Lens
     CommitTransactionResult
     CommitTransactionResult
     (Maybe IOUsage)
     (Maybe IOUsage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CommitTransactionResult' {Maybe IOUsage
consumedIOs :: Maybe IOUsage
$sel:consumedIOs:CommitTransactionResult' :: CommitTransactionResult -> Maybe IOUsage
consumedIOs} -> Maybe IOUsage
consumedIOs) (\s :: CommitTransactionResult
s@CommitTransactionResult' {} Maybe IOUsage
a -> CommitTransactionResult
s {$sel:consumedIOs:CommitTransactionResult' :: Maybe IOUsage
consumedIOs = Maybe IOUsage
a} :: CommitTransactionResult)

-- | The commit digest of the committed transaction.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
commitTransactionResult_commitDigest :: Lens.Lens' CommitTransactionResult (Prelude.Maybe Prelude.ByteString)
commitTransactionResult_commitDigest :: (Maybe ByteString -> f (Maybe ByteString))
-> CommitTransactionResult -> f CommitTransactionResult
commitTransactionResult_commitDigest = (CommitTransactionResult -> Maybe Base64)
-> (CommitTransactionResult
    -> Maybe Base64 -> CommitTransactionResult)
-> Lens
     CommitTransactionResult
     CommitTransactionResult
     (Maybe Base64)
     (Maybe Base64)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CommitTransactionResult' {Maybe Base64
commitDigest :: Maybe Base64
$sel:commitDigest:CommitTransactionResult' :: CommitTransactionResult -> Maybe Base64
commitDigest} -> Maybe Base64
commitDigest) (\s :: CommitTransactionResult
s@CommitTransactionResult' {} Maybe Base64
a -> CommitTransactionResult
s {$sel:commitDigest:CommitTransactionResult' :: Maybe Base64
commitDigest = Maybe Base64
a} :: CommitTransactionResult) ((Maybe Base64 -> f (Maybe Base64))
 -> CommitTransactionResult -> f CommitTransactionResult)
-> ((Maybe ByteString -> f (Maybe ByteString))
    -> Maybe Base64 -> f (Maybe Base64))
-> (Maybe ByteString -> f (Maybe ByteString))
-> CommitTransactionResult
-> f CommitTransactionResult
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso Base64 Base64 ByteString ByteString
-> Iso
     (Maybe Base64) (Maybe Base64) (Maybe ByteString) (Maybe ByteString)
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 Base64 Base64 ByteString ByteString
Iso' Base64 ByteString
Core._Base64

-- | The transaction ID of the committed transaction.
commitTransactionResult_transactionId :: Lens.Lens' CommitTransactionResult (Prelude.Maybe Prelude.Text)
commitTransactionResult_transactionId :: (Maybe Text -> f (Maybe Text))
-> CommitTransactionResult -> f CommitTransactionResult
commitTransactionResult_transactionId = (CommitTransactionResult -> Maybe Text)
-> (CommitTransactionResult
    -> Maybe Text -> CommitTransactionResult)
-> Lens
     CommitTransactionResult
     CommitTransactionResult
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CommitTransactionResult' {Maybe Text
transactionId :: Maybe Text
$sel:transactionId:CommitTransactionResult' :: CommitTransactionResult -> Maybe Text
transactionId} -> Maybe Text
transactionId) (\s :: CommitTransactionResult
s@CommitTransactionResult' {} Maybe Text
a -> CommitTransactionResult
s {$sel:transactionId:CommitTransactionResult' :: Maybe Text
transactionId = Maybe Text
a} :: CommitTransactionResult)

instance Core.FromJSON CommitTransactionResult where
  parseJSON :: Value -> Parser CommitTransactionResult
parseJSON =
    String
-> (Object -> Parser CommitTransactionResult)
-> Value
-> Parser CommitTransactionResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CommitTransactionResult"
      ( \Object
x ->
          Maybe TimingInformation
-> Maybe IOUsage
-> Maybe Base64
-> Maybe Text
-> CommitTransactionResult
CommitTransactionResult'
            (Maybe TimingInformation
 -> Maybe IOUsage
 -> Maybe Base64
 -> Maybe Text
 -> CommitTransactionResult)
-> Parser (Maybe TimingInformation)
-> Parser
     (Maybe IOUsage
      -> Maybe Base64 -> Maybe Text -> CommitTransactionResult)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe TimingInformation)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TimingInformation")
            Parser
  (Maybe IOUsage
   -> Maybe Base64 -> Maybe Text -> CommitTransactionResult)
-> Parser (Maybe IOUsage)
-> Parser (Maybe Base64 -> Maybe Text -> CommitTransactionResult)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe IOUsage)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ConsumedIOs")
            Parser (Maybe Base64 -> Maybe Text -> CommitTransactionResult)
-> Parser (Maybe Base64)
-> Parser (Maybe Text -> CommitTransactionResult)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Base64)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CommitDigest")
            Parser (Maybe Text -> CommitTransactionResult)
-> Parser (Maybe Text) -> Parser CommitTransactionResult
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
"TransactionId")
      )

instance Prelude.Hashable CommitTransactionResult

instance Prelude.NFData CommitTransactionResult