{-# 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.StartTransactionResult
-- 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.StartTransactionResult where

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

-- | Contains the details of the started transaction.
--
-- /See:/ 'newStartTransactionResult' smart constructor.
data StartTransactionResult = StartTransactionResult'
  { -- | Contains server-side performance information for the command.
    StartTransactionResult -> Maybe TimingInformation
timingInformation :: Prelude.Maybe TimingInformation,
    -- | The transaction ID of the started transaction.
    StartTransactionResult -> Maybe Text
transactionId :: Prelude.Maybe Prelude.Text
  }
  deriving (StartTransactionResult -> StartTransactionResult -> Bool
(StartTransactionResult -> StartTransactionResult -> Bool)
-> (StartTransactionResult -> StartTransactionResult -> Bool)
-> Eq StartTransactionResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartTransactionResult -> StartTransactionResult -> Bool
$c/= :: StartTransactionResult -> StartTransactionResult -> Bool
== :: StartTransactionResult -> StartTransactionResult -> Bool
$c== :: StartTransactionResult -> StartTransactionResult -> Bool
Prelude.Eq, ReadPrec [StartTransactionResult]
ReadPrec StartTransactionResult
Int -> ReadS StartTransactionResult
ReadS [StartTransactionResult]
(Int -> ReadS StartTransactionResult)
-> ReadS [StartTransactionResult]
-> ReadPrec StartTransactionResult
-> ReadPrec [StartTransactionResult]
-> Read StartTransactionResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartTransactionResult]
$creadListPrec :: ReadPrec [StartTransactionResult]
readPrec :: ReadPrec StartTransactionResult
$creadPrec :: ReadPrec StartTransactionResult
readList :: ReadS [StartTransactionResult]
$creadList :: ReadS [StartTransactionResult]
readsPrec :: Int -> ReadS StartTransactionResult
$creadsPrec :: Int -> ReadS StartTransactionResult
Prelude.Read, Int -> StartTransactionResult -> ShowS
[StartTransactionResult] -> ShowS
StartTransactionResult -> String
(Int -> StartTransactionResult -> ShowS)
-> (StartTransactionResult -> String)
-> ([StartTransactionResult] -> ShowS)
-> Show StartTransactionResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartTransactionResult] -> ShowS
$cshowList :: [StartTransactionResult] -> ShowS
show :: StartTransactionResult -> String
$cshow :: StartTransactionResult -> String
showsPrec :: Int -> StartTransactionResult -> ShowS
$cshowsPrec :: Int -> StartTransactionResult -> ShowS
Prelude.Show, (forall x. StartTransactionResult -> Rep StartTransactionResult x)
-> (forall x.
    Rep StartTransactionResult x -> StartTransactionResult)
-> Generic StartTransactionResult
forall x. Rep StartTransactionResult x -> StartTransactionResult
forall x. StartTransactionResult -> Rep StartTransactionResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartTransactionResult x -> StartTransactionResult
$cfrom :: forall x. StartTransactionResult -> Rep StartTransactionResult x
Prelude.Generic)

-- |
-- Create a value of 'StartTransactionResult' 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', 'startTransactionResult_timingInformation' - Contains server-side performance information for the command.
--
-- 'transactionId', 'startTransactionResult_transactionId' - The transaction ID of the started transaction.
newStartTransactionResult ::
  StartTransactionResult
newStartTransactionResult :: StartTransactionResult
newStartTransactionResult =
  StartTransactionResult' :: Maybe TimingInformation -> Maybe Text -> StartTransactionResult
StartTransactionResult'
    { $sel:timingInformation:StartTransactionResult' :: Maybe TimingInformation
timingInformation =
        Maybe TimingInformation
forall a. Maybe a
Prelude.Nothing,
      $sel:transactionId:StartTransactionResult' :: Maybe Text
transactionId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

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

instance Core.FromJSON StartTransactionResult where
  parseJSON :: Value -> Parser StartTransactionResult
parseJSON =
    String
-> (Object -> Parser StartTransactionResult)
-> Value
-> Parser StartTransactionResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"StartTransactionResult"
      ( \Object
x ->
          Maybe TimingInformation -> Maybe Text -> StartTransactionResult
StartTransactionResult'
            (Maybe TimingInformation -> Maybe Text -> StartTransactionResult)
-> Parser (Maybe TimingInformation)
-> Parser (Maybe Text -> StartTransactionResult)
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 Text -> StartTransactionResult)
-> Parser (Maybe Text) -> Parser StartTransactionResult
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 StartTransactionResult

instance Prelude.NFData StartTransactionResult