{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.HoneyCode.ListTableRows
-- 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)
--
-- The ListTableRows API allows you to retrieve a list of all the rows in a
-- table in a workbook.
--
-- This operation returns paginated results.
module Amazonka.HoneyCode.ListTableRows
  ( -- * Creating a Request
    ListTableRows (..),
    newListTableRows,

    -- * Request Lenses
    listTableRows_rowIds,
    listTableRows_nextToken,
    listTableRows_maxResults,
    listTableRows_workbookId,
    listTableRows_tableId,

    -- * Destructuring the Response
    ListTableRowsResponse (..),
    newListTableRowsResponse,

    -- * Response Lenses
    listTableRowsResponse_rowIdsNotFound,
    listTableRowsResponse_nextToken,
    listTableRowsResponse_httpStatus,
    listTableRowsResponse_columnIds,
    listTableRowsResponse_rows,
    listTableRowsResponse_workbookCursor,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.HoneyCode.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListTableRows' smart constructor.
data ListTableRows = ListTableRows'
  { -- | This parameter is optional. If one or more row ids are specified in this
    -- list, then only the specified row ids are returned in the result. If no
    -- row ids are specified here, then all the rows in the table are returned.
    ListTableRows -> Maybe (NonEmpty Text)
rowIds :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | This parameter is optional. If a nextToken is not specified, the API
    -- returns the first page of data.
    --
    -- Pagination tokens expire after 1 hour. If you use a token that was
    -- returned more than an hour back, the API will throw ValidationException.
    ListTableRows -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of rows to return in each page of the results.
    ListTableRows -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The ID of the workbook that contains the table whose rows are being
    -- retrieved.
    --
    -- If a workbook with the specified id could not be found, this API throws
    -- ResourceNotFoundException.
    ListTableRows -> Text
workbookId :: Prelude.Text,
    -- | The ID of the table whose rows are being retrieved.
    --
    -- If a table with the specified id could not be found, this API throws
    -- ResourceNotFoundException.
    ListTableRows -> Text
tableId :: Prelude.Text
  }
  deriving (ListTableRows -> ListTableRows -> Bool
(ListTableRows -> ListTableRows -> Bool)
-> (ListTableRows -> ListTableRows -> Bool) -> Eq ListTableRows
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTableRows -> ListTableRows -> Bool
$c/= :: ListTableRows -> ListTableRows -> Bool
== :: ListTableRows -> ListTableRows -> Bool
$c== :: ListTableRows -> ListTableRows -> Bool
Prelude.Eq, ReadPrec [ListTableRows]
ReadPrec ListTableRows
Int -> ReadS ListTableRows
ReadS [ListTableRows]
(Int -> ReadS ListTableRows)
-> ReadS [ListTableRows]
-> ReadPrec ListTableRows
-> ReadPrec [ListTableRows]
-> Read ListTableRows
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTableRows]
$creadListPrec :: ReadPrec [ListTableRows]
readPrec :: ReadPrec ListTableRows
$creadPrec :: ReadPrec ListTableRows
readList :: ReadS [ListTableRows]
$creadList :: ReadS [ListTableRows]
readsPrec :: Int -> ReadS ListTableRows
$creadsPrec :: Int -> ReadS ListTableRows
Prelude.Read, Int -> ListTableRows -> ShowS
[ListTableRows] -> ShowS
ListTableRows -> String
(Int -> ListTableRows -> ShowS)
-> (ListTableRows -> String)
-> ([ListTableRows] -> ShowS)
-> Show ListTableRows
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTableRows] -> ShowS
$cshowList :: [ListTableRows] -> ShowS
show :: ListTableRows -> String
$cshow :: ListTableRows -> String
showsPrec :: Int -> ListTableRows -> ShowS
$cshowsPrec :: Int -> ListTableRows -> ShowS
Prelude.Show, (forall x. ListTableRows -> Rep ListTableRows x)
-> (forall x. Rep ListTableRows x -> ListTableRows)
-> Generic ListTableRows
forall x. Rep ListTableRows x -> ListTableRows
forall x. ListTableRows -> Rep ListTableRows x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTableRows x -> ListTableRows
$cfrom :: forall x. ListTableRows -> Rep ListTableRows x
Prelude.Generic)

-- |
-- Create a value of 'ListTableRows' 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:
--
-- 'rowIds', 'listTableRows_rowIds' - This parameter is optional. If one or more row ids are specified in this
-- list, then only the specified row ids are returned in the result. If no
-- row ids are specified here, then all the rows in the table are returned.
--
-- 'nextToken', 'listTableRows_nextToken' - This parameter is optional. If a nextToken is not specified, the API
-- returns the first page of data.
--
-- Pagination tokens expire after 1 hour. If you use a token that was
-- returned more than an hour back, the API will throw ValidationException.
--
-- 'maxResults', 'listTableRows_maxResults' - The maximum number of rows to return in each page of the results.
--
-- 'workbookId', 'listTableRows_workbookId' - The ID of the workbook that contains the table whose rows are being
-- retrieved.
--
-- If a workbook with the specified id could not be found, this API throws
-- ResourceNotFoundException.
--
-- 'tableId', 'listTableRows_tableId' - The ID of the table whose rows are being retrieved.
--
-- If a table with the specified id could not be found, this API throws
-- ResourceNotFoundException.
newListTableRows ::
  -- | 'workbookId'
  Prelude.Text ->
  -- | 'tableId'
  Prelude.Text ->
  ListTableRows
newListTableRows :: Text -> Text -> ListTableRows
newListTableRows Text
pWorkbookId_ Text
pTableId_ =
  ListTableRows' :: Maybe (NonEmpty Text)
-> Maybe Text -> Maybe Natural -> Text -> Text -> ListTableRows
ListTableRows'
    { $sel:rowIds:ListTableRows' :: Maybe (NonEmpty Text)
rowIds = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListTableRows' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListTableRows' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:workbookId:ListTableRows' :: Text
workbookId = Text
pWorkbookId_,
      $sel:tableId:ListTableRows' :: Text
tableId = Text
pTableId_
    }

-- | This parameter is optional. If one or more row ids are specified in this
-- list, then only the specified row ids are returned in the result. If no
-- row ids are specified here, then all the rows in the table are returned.
listTableRows_rowIds :: Lens.Lens' ListTableRows (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
listTableRows_rowIds :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> ListTableRows -> f ListTableRows
listTableRows_rowIds = (ListTableRows -> Maybe (NonEmpty Text))
-> (ListTableRows -> Maybe (NonEmpty Text) -> ListTableRows)
-> Lens
     ListTableRows
     ListTableRows
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTableRows' {Maybe (NonEmpty Text)
rowIds :: Maybe (NonEmpty Text)
$sel:rowIds:ListTableRows' :: ListTableRows -> Maybe (NonEmpty Text)
rowIds} -> Maybe (NonEmpty Text)
rowIds) (\s :: ListTableRows
s@ListTableRows' {} Maybe (NonEmpty Text)
a -> ListTableRows
s {$sel:rowIds:ListTableRows' :: Maybe (NonEmpty Text)
rowIds = Maybe (NonEmpty Text)
a} :: ListTableRows) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> ListTableRows -> f ListTableRows)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> ListTableRows
-> f ListTableRows
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | This parameter is optional. If a nextToken is not specified, the API
-- returns the first page of data.
--
-- Pagination tokens expire after 1 hour. If you use a token that was
-- returned more than an hour back, the API will throw ValidationException.
listTableRows_nextToken :: Lens.Lens' ListTableRows (Prelude.Maybe Prelude.Text)
listTableRows_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListTableRows -> f ListTableRows
listTableRows_nextToken = (ListTableRows -> Maybe Text)
-> (ListTableRows -> Maybe Text -> ListTableRows)
-> Lens ListTableRows ListTableRows (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTableRows' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTableRows' :: ListTableRows -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTableRows
s@ListTableRows' {} Maybe Text
a -> ListTableRows
s {$sel:nextToken:ListTableRows' :: Maybe Text
nextToken = Maybe Text
a} :: ListTableRows)

-- | The maximum number of rows to return in each page of the results.
listTableRows_maxResults :: Lens.Lens' ListTableRows (Prelude.Maybe Prelude.Natural)
listTableRows_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListTableRows -> f ListTableRows
listTableRows_maxResults = (ListTableRows -> Maybe Natural)
-> (ListTableRows -> Maybe Natural -> ListTableRows)
-> Lens ListTableRows ListTableRows (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTableRows' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListTableRows' :: ListTableRows -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListTableRows
s@ListTableRows' {} Maybe Natural
a -> ListTableRows
s {$sel:maxResults:ListTableRows' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListTableRows)

-- | The ID of the workbook that contains the table whose rows are being
-- retrieved.
--
-- If a workbook with the specified id could not be found, this API throws
-- ResourceNotFoundException.
listTableRows_workbookId :: Lens.Lens' ListTableRows Prelude.Text
listTableRows_workbookId :: (Text -> f Text) -> ListTableRows -> f ListTableRows
listTableRows_workbookId = (ListTableRows -> Text)
-> (ListTableRows -> Text -> ListTableRows)
-> Lens ListTableRows ListTableRows Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTableRows' {Text
workbookId :: Text
$sel:workbookId:ListTableRows' :: ListTableRows -> Text
workbookId} -> Text
workbookId) (\s :: ListTableRows
s@ListTableRows' {} Text
a -> ListTableRows
s {$sel:workbookId:ListTableRows' :: Text
workbookId = Text
a} :: ListTableRows)

-- | The ID of the table whose rows are being retrieved.
--
-- If a table with the specified id could not be found, this API throws
-- ResourceNotFoundException.
listTableRows_tableId :: Lens.Lens' ListTableRows Prelude.Text
listTableRows_tableId :: (Text -> f Text) -> ListTableRows -> f ListTableRows
listTableRows_tableId = (ListTableRows -> Text)
-> (ListTableRows -> Text -> ListTableRows)
-> Lens ListTableRows ListTableRows Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTableRows' {Text
tableId :: Text
$sel:tableId:ListTableRows' :: ListTableRows -> Text
tableId} -> Text
tableId) (\s :: ListTableRows
s@ListTableRows' {} Text
a -> ListTableRows
s {$sel:tableId:ListTableRows' :: Text
tableId = Text
a} :: ListTableRows)

instance Core.AWSPager ListTableRows where
  page :: ListTableRows -> AWSResponse ListTableRows -> Maybe ListTableRows
page ListTableRows
rq AWSResponse ListTableRows
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListTableRows
ListTableRowsResponse
rs
            ListTableRowsResponse
-> Getting (First Text) ListTableRowsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListTableRowsResponse
-> Const (First Text) ListTableRowsResponse
Lens' ListTableRowsResponse (Maybe Text)
listTableRowsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListTableRowsResponse
 -> Const (First Text) ListTableRowsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListTableRowsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListTableRows
forall a. Maybe a
Prelude.Nothing
    | [TableRow] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop (AWSResponse ListTableRows
ListTableRowsResponse
rs ListTableRowsResponse
-> Getting [TableRow] ListTableRowsResponse [TableRow]
-> [TableRow]
forall s a. s -> Getting a s a -> a
Lens.^. Getting [TableRow] ListTableRowsResponse [TableRow]
Lens' ListTableRowsResponse [TableRow]
listTableRowsResponse_rows) =
      Maybe ListTableRows
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListTableRows -> Maybe ListTableRows
forall a. a -> Maybe a
Prelude.Just (ListTableRows -> Maybe ListTableRows)
-> ListTableRows -> Maybe ListTableRows
forall a b. (a -> b) -> a -> b
Prelude.$
        ListTableRows
rq
          ListTableRows -> (ListTableRows -> ListTableRows) -> ListTableRows
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListTableRows -> Identity ListTableRows
Lens ListTableRows ListTableRows (Maybe Text) (Maybe Text)
listTableRows_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListTableRows -> Identity ListTableRows)
-> Maybe Text -> ListTableRows -> ListTableRows
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListTableRows
ListTableRowsResponse
rs
          ListTableRowsResponse
-> Getting (First Text) ListTableRowsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListTableRowsResponse
-> Const (First Text) ListTableRowsResponse
Lens' ListTableRowsResponse (Maybe Text)
listTableRowsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListTableRowsResponse
 -> Const (First Text) ListTableRowsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListTableRowsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListTableRows where
  type
    AWSResponse ListTableRows =
      ListTableRowsResponse
  request :: ListTableRows -> Request ListTableRows
request = Service -> ListTableRows -> Request ListTableRows
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListTableRows
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListTableRows)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListTableRows))
-> Logger
-> Service
-> Proxy ListTableRows
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListTableRows)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe (NonEmpty Text)
-> Maybe Text
-> Int
-> NonEmpty Text
-> [TableRow]
-> Integer
-> ListTableRowsResponse
ListTableRowsResponse'
            (Maybe (NonEmpty Text)
 -> Maybe Text
 -> Int
 -> NonEmpty Text
 -> [TableRow]
 -> Integer
 -> ListTableRowsResponse)
-> Either String (Maybe (NonEmpty Text))
-> Either
     String
     (Maybe Text
      -> Int
      -> NonEmpty Text
      -> [TableRow]
      -> Integer
      -> ListTableRowsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (NonEmpty Text))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"rowIdsNotFound")
            Either
  String
  (Maybe Text
   -> Int
   -> NonEmpty Text
   -> [TableRow]
   -> Integer
   -> ListTableRowsResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Int
      -> NonEmpty Text -> [TableRow] -> Integer -> ListTableRowsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"nextToken")
            Either
  String
  (Int
   -> NonEmpty Text -> [TableRow] -> Integer -> ListTableRowsResponse)
-> Either String Int
-> Either
     String
     (NonEmpty Text -> [TableRow] -> Integer -> ListTableRowsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either
  String
  (NonEmpty Text -> [TableRow] -> Integer -> ListTableRowsResponse)
-> Either String (NonEmpty Text)
-> Either String ([TableRow] -> Integer -> ListTableRowsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (NonEmpty Text)
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"columnIds")
            Either String ([TableRow] -> Integer -> ListTableRowsResponse)
-> Either String [TableRow]
-> Either String (Integer -> ListTableRowsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe [TableRow])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"rows" Either String (Maybe [TableRow])
-> [TableRow] -> Either String [TableRow]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [TableRow]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Integer -> ListTableRowsResponse)
-> Either String Integer -> Either String ListTableRowsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Integer
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"workbookCursor")
      )

instance Prelude.Hashable ListTableRows

instance Prelude.NFData ListTableRows

instance Core.ToHeaders ListTableRows where
  toHeaders :: ListTableRows -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListTableRows -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON ListTableRows where
  toJSON :: ListTableRows -> Value
toJSON ListTableRows' {Maybe Natural
Maybe (NonEmpty Text)
Maybe Text
Text
tableId :: Text
workbookId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
rowIds :: Maybe (NonEmpty Text)
$sel:tableId:ListTableRows' :: ListTableRows -> Text
$sel:workbookId:ListTableRows' :: ListTableRows -> Text
$sel:maxResults:ListTableRows' :: ListTableRows -> Maybe Natural
$sel:nextToken:ListTableRows' :: ListTableRows -> Maybe Text
$sel:rowIds:ListTableRows' :: ListTableRows -> Maybe (NonEmpty Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"rowIds" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
rowIds,
            (Text
"nextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"maxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults
          ]
      )

instance Core.ToPath ListTableRows where
  toPath :: ListTableRows -> ByteString
toPath ListTableRows' {Maybe Natural
Maybe (NonEmpty Text)
Maybe Text
Text
tableId :: Text
workbookId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
rowIds :: Maybe (NonEmpty Text)
$sel:tableId:ListTableRows' :: ListTableRows -> Text
$sel:workbookId:ListTableRows' :: ListTableRows -> Text
$sel:maxResults:ListTableRows' :: ListTableRows -> Maybe Natural
$sel:nextToken:ListTableRows' :: ListTableRows -> Maybe Text
$sel:rowIds:ListTableRows' :: ListTableRows -> Maybe (NonEmpty Text)
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/workbooks/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
workbookId,
        ByteString
"/tables/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
tableId,
        ByteString
"/rows/list"
      ]

instance Core.ToQuery ListTableRows where
  toQuery :: ListTableRows -> QueryString
toQuery = QueryString -> ListTableRows -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newListTableRowsResponse' smart constructor.
data ListTableRowsResponse = ListTableRowsResponse'
  { -- | The list of row ids included in the request that were not found in the
    -- table.
    ListTableRowsResponse -> Maybe (NonEmpty Text)
rowIdsNotFound :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | Provides the pagination token to load the next page if there are more
    -- results matching the request. If a pagination token is not present in
    -- the response, it means that all data matching the request has been
    -- loaded.
    ListTableRowsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListTableRowsResponse -> Int
httpStatus :: Prelude.Int,
    -- | The list of columns in the table whose row data is returned in the
    -- result.
    ListTableRowsResponse -> NonEmpty Text
columnIds :: Prelude.NonEmpty Prelude.Text,
    -- | The list of rows in the table. Note that this result is paginated, so
    -- this list contains a maximum of 100 rows.
    ListTableRowsResponse -> [TableRow]
rows :: [TableRow],
    -- | Indicates the cursor of the workbook at which the data returned by this
    -- request is read. Workbook cursor keeps increasing with every update and
    -- the increments are not sequential.
    ListTableRowsResponse -> Integer
workbookCursor :: Prelude.Integer
  }
  deriving (ListTableRowsResponse -> ListTableRowsResponse -> Bool
(ListTableRowsResponse -> ListTableRowsResponse -> Bool)
-> (ListTableRowsResponse -> ListTableRowsResponse -> Bool)
-> Eq ListTableRowsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTableRowsResponse -> ListTableRowsResponse -> Bool
$c/= :: ListTableRowsResponse -> ListTableRowsResponse -> Bool
== :: ListTableRowsResponse -> ListTableRowsResponse -> Bool
$c== :: ListTableRowsResponse -> ListTableRowsResponse -> Bool
Prelude.Eq, Int -> ListTableRowsResponse -> ShowS
[ListTableRowsResponse] -> ShowS
ListTableRowsResponse -> String
(Int -> ListTableRowsResponse -> ShowS)
-> (ListTableRowsResponse -> String)
-> ([ListTableRowsResponse] -> ShowS)
-> Show ListTableRowsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTableRowsResponse] -> ShowS
$cshowList :: [ListTableRowsResponse] -> ShowS
show :: ListTableRowsResponse -> String
$cshow :: ListTableRowsResponse -> String
showsPrec :: Int -> ListTableRowsResponse -> ShowS
$cshowsPrec :: Int -> ListTableRowsResponse -> ShowS
Prelude.Show, (forall x. ListTableRowsResponse -> Rep ListTableRowsResponse x)
-> (forall x. Rep ListTableRowsResponse x -> ListTableRowsResponse)
-> Generic ListTableRowsResponse
forall x. Rep ListTableRowsResponse x -> ListTableRowsResponse
forall x. ListTableRowsResponse -> Rep ListTableRowsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTableRowsResponse x -> ListTableRowsResponse
$cfrom :: forall x. ListTableRowsResponse -> Rep ListTableRowsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListTableRowsResponse' 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:
--
-- 'rowIdsNotFound', 'listTableRowsResponse_rowIdsNotFound' - The list of row ids included in the request that were not found in the
-- table.
--
-- 'nextToken', 'listTableRowsResponse_nextToken' - Provides the pagination token to load the next page if there are more
-- results matching the request. If a pagination token is not present in
-- the response, it means that all data matching the request has been
-- loaded.
--
-- 'httpStatus', 'listTableRowsResponse_httpStatus' - The response's http status code.
--
-- 'columnIds', 'listTableRowsResponse_columnIds' - The list of columns in the table whose row data is returned in the
-- result.
--
-- 'rows', 'listTableRowsResponse_rows' - The list of rows in the table. Note that this result is paginated, so
-- this list contains a maximum of 100 rows.
--
-- 'workbookCursor', 'listTableRowsResponse_workbookCursor' - Indicates the cursor of the workbook at which the data returned by this
-- request is read. Workbook cursor keeps increasing with every update and
-- the increments are not sequential.
newListTableRowsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'columnIds'
  Prelude.NonEmpty Prelude.Text ->
  -- | 'workbookCursor'
  Prelude.Integer ->
  ListTableRowsResponse
newListTableRowsResponse :: Int -> NonEmpty Text -> Integer -> ListTableRowsResponse
newListTableRowsResponse
  Int
pHttpStatus_
  NonEmpty Text
pColumnIds_
  Integer
pWorkbookCursor_ =
    ListTableRowsResponse' :: Maybe (NonEmpty Text)
-> Maybe Text
-> Int
-> NonEmpty Text
-> [TableRow]
-> Integer
-> ListTableRowsResponse
ListTableRowsResponse'
      { $sel:rowIdsNotFound:ListTableRowsResponse' :: Maybe (NonEmpty Text)
rowIdsNotFound =
          Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:nextToken:ListTableRowsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:ListTableRowsResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:columnIds:ListTableRowsResponse' :: NonEmpty Text
columnIds = Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pColumnIds_,
        $sel:rows:ListTableRowsResponse' :: [TableRow]
rows = [TableRow]
forall a. Monoid a => a
Prelude.mempty,
        $sel:workbookCursor:ListTableRowsResponse' :: Integer
workbookCursor = Integer
pWorkbookCursor_
      }

-- | The list of row ids included in the request that were not found in the
-- table.
listTableRowsResponse_rowIdsNotFound :: Lens.Lens' ListTableRowsResponse (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
listTableRowsResponse_rowIdsNotFound :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> ListTableRowsResponse -> f ListTableRowsResponse
listTableRowsResponse_rowIdsNotFound = (ListTableRowsResponse -> Maybe (NonEmpty Text))
-> (ListTableRowsResponse
    -> Maybe (NonEmpty Text) -> ListTableRowsResponse)
-> Lens
     ListTableRowsResponse
     ListTableRowsResponse
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTableRowsResponse' {Maybe (NonEmpty Text)
rowIdsNotFound :: Maybe (NonEmpty Text)
$sel:rowIdsNotFound:ListTableRowsResponse' :: ListTableRowsResponse -> Maybe (NonEmpty Text)
rowIdsNotFound} -> Maybe (NonEmpty Text)
rowIdsNotFound) (\s :: ListTableRowsResponse
s@ListTableRowsResponse' {} Maybe (NonEmpty Text)
a -> ListTableRowsResponse
s {$sel:rowIdsNotFound:ListTableRowsResponse' :: Maybe (NonEmpty Text)
rowIdsNotFound = Maybe (NonEmpty Text)
a} :: ListTableRowsResponse) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> ListTableRowsResponse -> f ListTableRowsResponse)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> ListTableRowsResponse
-> f ListTableRowsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Provides the pagination token to load the next page if there are more
-- results matching the request. If a pagination token is not present in
-- the response, it means that all data matching the request has been
-- loaded.
listTableRowsResponse_nextToken :: Lens.Lens' ListTableRowsResponse (Prelude.Maybe Prelude.Text)
listTableRowsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListTableRowsResponse -> f ListTableRowsResponse
listTableRowsResponse_nextToken = (ListTableRowsResponse -> Maybe Text)
-> (ListTableRowsResponse -> Maybe Text -> ListTableRowsResponse)
-> Lens' ListTableRowsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTableRowsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTableRowsResponse' :: ListTableRowsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTableRowsResponse
s@ListTableRowsResponse' {} Maybe Text
a -> ListTableRowsResponse
s {$sel:nextToken:ListTableRowsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListTableRowsResponse)

-- | The response's http status code.
listTableRowsResponse_httpStatus :: Lens.Lens' ListTableRowsResponse Prelude.Int
listTableRowsResponse_httpStatus :: (Int -> f Int) -> ListTableRowsResponse -> f ListTableRowsResponse
listTableRowsResponse_httpStatus = (ListTableRowsResponse -> Int)
-> (ListTableRowsResponse -> Int -> ListTableRowsResponse)
-> Lens ListTableRowsResponse ListTableRowsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTableRowsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListTableRowsResponse' :: ListTableRowsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListTableRowsResponse
s@ListTableRowsResponse' {} Int
a -> ListTableRowsResponse
s {$sel:httpStatus:ListTableRowsResponse' :: Int
httpStatus = Int
a} :: ListTableRowsResponse)

-- | The list of columns in the table whose row data is returned in the
-- result.
listTableRowsResponse_columnIds :: Lens.Lens' ListTableRowsResponse (Prelude.NonEmpty Prelude.Text)
listTableRowsResponse_columnIds :: (NonEmpty Text -> f (NonEmpty Text))
-> ListTableRowsResponse -> f ListTableRowsResponse
listTableRowsResponse_columnIds = (ListTableRowsResponse -> NonEmpty Text)
-> (ListTableRowsResponse
    -> NonEmpty Text -> ListTableRowsResponse)
-> Lens
     ListTableRowsResponse
     ListTableRowsResponse
     (NonEmpty Text)
     (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTableRowsResponse' {NonEmpty Text
columnIds :: NonEmpty Text
$sel:columnIds:ListTableRowsResponse' :: ListTableRowsResponse -> NonEmpty Text
columnIds} -> NonEmpty Text
columnIds) (\s :: ListTableRowsResponse
s@ListTableRowsResponse' {} NonEmpty Text
a -> ListTableRowsResponse
s {$sel:columnIds:ListTableRowsResponse' :: NonEmpty Text
columnIds = NonEmpty Text
a} :: ListTableRowsResponse) ((NonEmpty Text -> f (NonEmpty Text))
 -> ListTableRowsResponse -> f ListTableRowsResponse)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> ListTableRowsResponse
-> f ListTableRowsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The list of rows in the table. Note that this result is paginated, so
-- this list contains a maximum of 100 rows.
listTableRowsResponse_rows :: Lens.Lens' ListTableRowsResponse [TableRow]
listTableRowsResponse_rows :: ([TableRow] -> f [TableRow])
-> ListTableRowsResponse -> f ListTableRowsResponse
listTableRowsResponse_rows = (ListTableRowsResponse -> [TableRow])
-> (ListTableRowsResponse -> [TableRow] -> ListTableRowsResponse)
-> Lens' ListTableRowsResponse [TableRow]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTableRowsResponse' {[TableRow]
rows :: [TableRow]
$sel:rows:ListTableRowsResponse' :: ListTableRowsResponse -> [TableRow]
rows} -> [TableRow]
rows) (\s :: ListTableRowsResponse
s@ListTableRowsResponse' {} [TableRow]
a -> ListTableRowsResponse
s {$sel:rows:ListTableRowsResponse' :: [TableRow]
rows = [TableRow]
a} :: ListTableRowsResponse) (([TableRow] -> f [TableRow])
 -> ListTableRowsResponse -> f ListTableRowsResponse)
-> (([TableRow] -> f [TableRow]) -> [TableRow] -> f [TableRow])
-> ([TableRow] -> f [TableRow])
-> ListTableRowsResponse
-> f ListTableRowsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([TableRow] -> f [TableRow]) -> [TableRow] -> f [TableRow]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Indicates the cursor of the workbook at which the data returned by this
-- request is read. Workbook cursor keeps increasing with every update and
-- the increments are not sequential.
listTableRowsResponse_workbookCursor :: Lens.Lens' ListTableRowsResponse Prelude.Integer
listTableRowsResponse_workbookCursor :: (Integer -> f Integer)
-> ListTableRowsResponse -> f ListTableRowsResponse
listTableRowsResponse_workbookCursor = (ListTableRowsResponse -> Integer)
-> (ListTableRowsResponse -> Integer -> ListTableRowsResponse)
-> Lens ListTableRowsResponse ListTableRowsResponse Integer Integer
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTableRowsResponse' {Integer
workbookCursor :: Integer
$sel:workbookCursor:ListTableRowsResponse' :: ListTableRowsResponse -> Integer
workbookCursor} -> Integer
workbookCursor) (\s :: ListTableRowsResponse
s@ListTableRowsResponse' {} Integer
a -> ListTableRowsResponse
s {$sel:workbookCursor:ListTableRowsResponse' :: Integer
workbookCursor = Integer
a} :: ListTableRowsResponse)

instance Prelude.NFData ListTableRowsResponse