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

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

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

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

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

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

instance Prelude.Hashable FetchPageResult

instance Prelude.NFData FetchPageResult