{-# 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.ExecuteStatementResult
-- 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.ExecuteStatementResult 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.Page
import Amazonka.QLDBSession.Types.TimingInformation

-- | Contains the details of the executed statement.
--
-- /See:/ 'newExecuteStatementResult' smart constructor.
data ExecuteStatementResult = ExecuteStatementResult'
  { -- | Contains server-side performance information for the command.
    ExecuteStatementResult -> Maybe TimingInformation
timingInformation :: Prelude.Maybe TimingInformation,
    -- | Contains metrics about the number of I\/O requests that were consumed.
    ExecuteStatementResult -> Maybe IOUsage
consumedIOs :: Prelude.Maybe IOUsage,
    -- | Contains the details of the first fetched page.
    ExecuteStatementResult -> Maybe Page
firstPage :: Prelude.Maybe Page
  }
  deriving (ExecuteStatementResult -> ExecuteStatementResult -> Bool
(ExecuteStatementResult -> ExecuteStatementResult -> Bool)
-> (ExecuteStatementResult -> ExecuteStatementResult -> Bool)
-> Eq ExecuteStatementResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecuteStatementResult -> ExecuteStatementResult -> Bool
$c/= :: ExecuteStatementResult -> ExecuteStatementResult -> Bool
== :: ExecuteStatementResult -> ExecuteStatementResult -> Bool
$c== :: ExecuteStatementResult -> ExecuteStatementResult -> Bool
Prelude.Eq, ReadPrec [ExecuteStatementResult]
ReadPrec ExecuteStatementResult
Int -> ReadS ExecuteStatementResult
ReadS [ExecuteStatementResult]
(Int -> ReadS ExecuteStatementResult)
-> ReadS [ExecuteStatementResult]
-> ReadPrec ExecuteStatementResult
-> ReadPrec [ExecuteStatementResult]
-> Read ExecuteStatementResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExecuteStatementResult]
$creadListPrec :: ReadPrec [ExecuteStatementResult]
readPrec :: ReadPrec ExecuteStatementResult
$creadPrec :: ReadPrec ExecuteStatementResult
readList :: ReadS [ExecuteStatementResult]
$creadList :: ReadS [ExecuteStatementResult]
readsPrec :: Int -> ReadS ExecuteStatementResult
$creadsPrec :: Int -> ReadS ExecuteStatementResult
Prelude.Read, Int -> ExecuteStatementResult -> ShowS
[ExecuteStatementResult] -> ShowS
ExecuteStatementResult -> String
(Int -> ExecuteStatementResult -> ShowS)
-> (ExecuteStatementResult -> String)
-> ([ExecuteStatementResult] -> ShowS)
-> Show ExecuteStatementResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExecuteStatementResult] -> ShowS
$cshowList :: [ExecuteStatementResult] -> ShowS
show :: ExecuteStatementResult -> String
$cshow :: ExecuteStatementResult -> String
showsPrec :: Int -> ExecuteStatementResult -> ShowS
$cshowsPrec :: Int -> ExecuteStatementResult -> ShowS
Prelude.Show, (forall x. ExecuteStatementResult -> Rep ExecuteStatementResult x)
-> (forall x.
    Rep ExecuteStatementResult x -> ExecuteStatementResult)
-> Generic ExecuteStatementResult
forall x. Rep ExecuteStatementResult x -> ExecuteStatementResult
forall x. ExecuteStatementResult -> Rep ExecuteStatementResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExecuteStatementResult x -> ExecuteStatementResult
$cfrom :: forall x. ExecuteStatementResult -> Rep ExecuteStatementResult x
Prelude.Generic)

-- |
-- Create a value of 'ExecuteStatementResult' 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', 'executeStatementResult_timingInformation' - Contains server-side performance information for the command.
--
-- 'consumedIOs', 'executeStatementResult_consumedIOs' - Contains metrics about the number of I\/O requests that were consumed.
--
-- 'firstPage', 'executeStatementResult_firstPage' - Contains the details of the first fetched page.
newExecuteStatementResult ::
  ExecuteStatementResult
newExecuteStatementResult :: ExecuteStatementResult
newExecuteStatementResult =
  ExecuteStatementResult' :: Maybe TimingInformation
-> Maybe IOUsage -> Maybe Page -> ExecuteStatementResult
ExecuteStatementResult'
    { $sel:timingInformation:ExecuteStatementResult' :: Maybe TimingInformation
timingInformation =
        Maybe TimingInformation
forall a. Maybe a
Prelude.Nothing,
      $sel:consumedIOs:ExecuteStatementResult' :: Maybe IOUsage
consumedIOs = Maybe IOUsage
forall a. Maybe a
Prelude.Nothing,
      $sel:firstPage:ExecuteStatementResult' :: Maybe Page
firstPage = Maybe Page
forall a. Maybe a
Prelude.Nothing
    }

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

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

-- | Contains the details of the first fetched page.
executeStatementResult_firstPage :: Lens.Lens' ExecuteStatementResult (Prelude.Maybe Page)
executeStatementResult_firstPage :: (Maybe Page -> f (Maybe Page))
-> ExecuteStatementResult -> f ExecuteStatementResult
executeStatementResult_firstPage = (ExecuteStatementResult -> Maybe Page)
-> (ExecuteStatementResult -> Maybe Page -> ExecuteStatementResult)
-> Lens
     ExecuteStatementResult
     ExecuteStatementResult
     (Maybe Page)
     (Maybe Page)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteStatementResult' {Maybe Page
firstPage :: Maybe Page
$sel:firstPage:ExecuteStatementResult' :: ExecuteStatementResult -> Maybe Page
firstPage} -> Maybe Page
firstPage) (\s :: ExecuteStatementResult
s@ExecuteStatementResult' {} Maybe Page
a -> ExecuteStatementResult
s {$sel:firstPage:ExecuteStatementResult' :: Maybe Page
firstPage = Maybe Page
a} :: ExecuteStatementResult)

instance Core.FromJSON ExecuteStatementResult where
  parseJSON :: Value -> Parser ExecuteStatementResult
parseJSON =
    String
-> (Object -> Parser ExecuteStatementResult)
-> Value
-> Parser ExecuteStatementResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ExecuteStatementResult"
      ( \Object
x ->
          Maybe TimingInformation
-> Maybe IOUsage -> Maybe Page -> ExecuteStatementResult
ExecuteStatementResult'
            (Maybe TimingInformation
 -> Maybe IOUsage -> Maybe Page -> ExecuteStatementResult)
-> Parser (Maybe TimingInformation)
-> Parser (Maybe IOUsage -> Maybe Page -> ExecuteStatementResult)
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 Page -> ExecuteStatementResult)
-> Parser (Maybe IOUsage)
-> Parser (Maybe Page -> ExecuteStatementResult)
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 Page -> ExecuteStatementResult)
-> Parser (Maybe Page) -> Parser ExecuteStatementResult
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Page)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FirstPage")
      )

instance Prelude.Hashable ExecuteStatementResult

instance Prelude.NFData ExecuteStatementResult