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

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

-- | Contains details of the fetched page.
--
-- /See:/ 'newPage' smart constructor.
data Page = Page'
  { -- | The token of the next page.
    Page -> Maybe Text
nextPageToken :: Prelude.Maybe Prelude.Text,
    -- | A structure that contains values in multiple encoding formats.
    Page -> Maybe [ValueHolder]
values :: Prelude.Maybe [ValueHolder]
  }
  deriving (Page -> Page -> Bool
(Page -> Page -> Bool) -> (Page -> Page -> Bool) -> Eq Page
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Page -> Page -> Bool
$c/= :: Page -> Page -> Bool
== :: Page -> Page -> Bool
$c== :: Page -> Page -> Bool
Prelude.Eq, ReadPrec [Page]
ReadPrec Page
Int -> ReadS Page
ReadS [Page]
(Int -> ReadS Page)
-> ReadS [Page] -> ReadPrec Page -> ReadPrec [Page] -> Read Page
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Page]
$creadListPrec :: ReadPrec [Page]
readPrec :: ReadPrec Page
$creadPrec :: ReadPrec Page
readList :: ReadS [Page]
$creadList :: ReadS [Page]
readsPrec :: Int -> ReadS Page
$creadsPrec :: Int -> ReadS Page
Prelude.Read, Int -> Page -> ShowS
[Page] -> ShowS
Page -> String
(Int -> Page -> ShowS)
-> (Page -> String) -> ([Page] -> ShowS) -> Show Page
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Page] -> ShowS
$cshowList :: [Page] -> ShowS
show :: Page -> String
$cshow :: Page -> String
showsPrec :: Int -> Page -> ShowS
$cshowsPrec :: Int -> Page -> ShowS
Prelude.Show, (forall x. Page -> Rep Page x)
-> (forall x. Rep Page x -> Page) -> Generic Page
forall x. Rep Page x -> Page
forall x. Page -> Rep Page x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Page x -> Page
$cfrom :: forall x. Page -> Rep Page x
Prelude.Generic)

-- |
-- Create a value of 'Page' 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:
--
-- 'nextPageToken', 'page_nextPageToken' - The token of the next page.
--
-- 'values', 'page_values' - A structure that contains values in multiple encoding formats.
newPage ::
  Page
newPage :: Page
newPage =
  Page' :: Maybe Text -> Maybe [ValueHolder] -> Page
Page'
    { $sel:nextPageToken:Page' :: Maybe Text
nextPageToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:values:Page' :: Maybe [ValueHolder]
values = Maybe [ValueHolder]
forall a. Maybe a
Prelude.Nothing
    }

-- | The token of the next page.
page_nextPageToken :: Lens.Lens' Page (Prelude.Maybe Prelude.Text)
page_nextPageToken :: (Maybe Text -> f (Maybe Text)) -> Page -> f Page
page_nextPageToken = (Page -> Maybe Text)
-> (Page -> Maybe Text -> Page)
-> Lens Page Page (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Page' {Maybe Text
nextPageToken :: Maybe Text
$sel:nextPageToken:Page' :: Page -> Maybe Text
nextPageToken} -> Maybe Text
nextPageToken) (\s :: Page
s@Page' {} Maybe Text
a -> Page
s {$sel:nextPageToken:Page' :: Maybe Text
nextPageToken = Maybe Text
a} :: Page)

-- | A structure that contains values in multiple encoding formats.
page_values :: Lens.Lens' Page (Prelude.Maybe [ValueHolder])
page_values :: (Maybe [ValueHolder] -> f (Maybe [ValueHolder])) -> Page -> f Page
page_values = (Page -> Maybe [ValueHolder])
-> (Page -> Maybe [ValueHolder] -> Page)
-> Lens Page Page (Maybe [ValueHolder]) (Maybe [ValueHolder])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Page' {Maybe [ValueHolder]
values :: Maybe [ValueHolder]
$sel:values:Page' :: Page -> Maybe [ValueHolder]
values} -> Maybe [ValueHolder]
values) (\s :: Page
s@Page' {} Maybe [ValueHolder]
a -> Page
s {$sel:values:Page' :: Maybe [ValueHolder]
values = Maybe [ValueHolder]
a} :: Page) ((Maybe [ValueHolder] -> f (Maybe [ValueHolder]))
 -> Page -> f Page)
-> ((Maybe [ValueHolder] -> f (Maybe [ValueHolder]))
    -> Maybe [ValueHolder] -> f (Maybe [ValueHolder]))
-> (Maybe [ValueHolder] -> f (Maybe [ValueHolder]))
-> Page
-> f Page
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [ValueHolder] [ValueHolder] [ValueHolder] [ValueHolder]
-> Iso
     (Maybe [ValueHolder])
     (Maybe [ValueHolder])
     (Maybe [ValueHolder])
     (Maybe [ValueHolder])
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 [ValueHolder] [ValueHolder] [ValueHolder] [ValueHolder]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON Page where
  parseJSON :: Value -> Parser Page
parseJSON =
    String -> (Object -> Parser Page) -> Value -> Parser Page
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Page"
      ( \Object
x ->
          Maybe Text -> Maybe [ValueHolder] -> Page
Page'
            (Maybe Text -> Maybe [ValueHolder] -> Page)
-> Parser (Maybe Text) -> Parser (Maybe [ValueHolder] -> Page)
forall (f :: * -> *) a b. Functor 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
"NextPageToken")
            Parser (Maybe [ValueHolder] -> Page)
-> Parser (Maybe [ValueHolder]) -> Parser Page
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [ValueHolder]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Values" Parser (Maybe (Maybe [ValueHolder]))
-> Maybe [ValueHolder] -> Parser (Maybe [ValueHolder])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ValueHolder]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable Page

instance Prelude.NFData Page