{-# 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.QueryTableRows
-- 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 QueryTableRows API allows you to use a filter formula to query for
-- specific rows in a table.
--
-- This operation returns paginated results.
module Amazonka.HoneyCode.QueryTableRows
  ( -- * Creating a Request
    QueryTableRows (..),
    newQueryTableRows,

    -- * Request Lenses
    queryTableRows_nextToken,
    queryTableRows_maxResults,
    queryTableRows_workbookId,
    queryTableRows_tableId,
    queryTableRows_filterFormula,

    -- * Destructuring the Response
    QueryTableRowsResponse (..),
    newQueryTableRowsResponse,

    -- * Response Lenses
    queryTableRowsResponse_nextToken,
    queryTableRowsResponse_httpStatus,
    queryTableRowsResponse_columnIds,
    queryTableRowsResponse_rows,
    queryTableRowsResponse_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:/ 'newQueryTableRows' smart constructor.
data QueryTableRows = QueryTableRows'
  { -- | 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.
    QueryTableRows -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of rows to return in each page of the results.
    QueryTableRows -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The ID of the workbook whose table rows are being queried.
    --
    -- If a workbook with the specified id could not be found, this API throws
    -- ResourceNotFoundException.
    QueryTableRows -> Text
workbookId :: Prelude.Text,
    -- | The ID of the table whose rows are being queried.
    --
    -- If a table with the specified id could not be found, this API throws
    -- ResourceNotFoundException.
    QueryTableRows -> Text
tableId :: Prelude.Text,
    -- | An object that represents a filter formula along with the id of the
    -- context row under which the filter function needs to evaluate.
    QueryTableRows -> Filter
filterFormula :: Filter
  }
  deriving (QueryTableRows -> QueryTableRows -> Bool
(QueryTableRows -> QueryTableRows -> Bool)
-> (QueryTableRows -> QueryTableRows -> Bool) -> Eq QueryTableRows
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QueryTableRows -> QueryTableRows -> Bool
$c/= :: QueryTableRows -> QueryTableRows -> Bool
== :: QueryTableRows -> QueryTableRows -> Bool
$c== :: QueryTableRows -> QueryTableRows -> Bool
Prelude.Eq, Int -> QueryTableRows -> ShowS
[QueryTableRows] -> ShowS
QueryTableRows -> String
(Int -> QueryTableRows -> ShowS)
-> (QueryTableRows -> String)
-> ([QueryTableRows] -> ShowS)
-> Show QueryTableRows
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [QueryTableRows] -> ShowS
$cshowList :: [QueryTableRows] -> ShowS
show :: QueryTableRows -> String
$cshow :: QueryTableRows -> String
showsPrec :: Int -> QueryTableRows -> ShowS
$cshowsPrec :: Int -> QueryTableRows -> ShowS
Prelude.Show, (forall x. QueryTableRows -> Rep QueryTableRows x)
-> (forall x. Rep QueryTableRows x -> QueryTableRows)
-> Generic QueryTableRows
forall x. Rep QueryTableRows x -> QueryTableRows
forall x. QueryTableRows -> Rep QueryTableRows x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep QueryTableRows x -> QueryTableRows
$cfrom :: forall x. QueryTableRows -> Rep QueryTableRows x
Prelude.Generic)

-- |
-- Create a value of 'QueryTableRows' 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:
--
-- 'nextToken', 'queryTableRows_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', 'queryTableRows_maxResults' - The maximum number of rows to return in each page of the results.
--
-- 'workbookId', 'queryTableRows_workbookId' - The ID of the workbook whose table rows are being queried.
--
-- If a workbook with the specified id could not be found, this API throws
-- ResourceNotFoundException.
--
-- 'tableId', 'queryTableRows_tableId' - The ID of the table whose rows are being queried.
--
-- If a table with the specified id could not be found, this API throws
-- ResourceNotFoundException.
--
-- 'filterFormula', 'queryTableRows_filterFormula' - An object that represents a filter formula along with the id of the
-- context row under which the filter function needs to evaluate.
newQueryTableRows ::
  -- | 'workbookId'
  Prelude.Text ->
  -- | 'tableId'
  Prelude.Text ->
  -- | 'filterFormula'
  Filter ->
  QueryTableRows
newQueryTableRows :: Text -> Text -> Filter -> QueryTableRows
newQueryTableRows
  Text
pWorkbookId_
  Text
pTableId_
  Filter
pFilterFormula_ =
    QueryTableRows' :: Maybe Text
-> Maybe Natural -> Text -> Text -> Filter -> QueryTableRows
QueryTableRows'
      { $sel:nextToken:QueryTableRows' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:maxResults:QueryTableRows' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:workbookId:QueryTableRows' :: Text
workbookId = Text
pWorkbookId_,
        $sel:tableId:QueryTableRows' :: Text
tableId = Text
pTableId_,
        $sel:filterFormula:QueryTableRows' :: Filter
filterFormula = Filter
pFilterFormula_
      }

-- | 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.
queryTableRows_nextToken :: Lens.Lens' QueryTableRows (Prelude.Maybe Prelude.Text)
queryTableRows_nextToken :: (Maybe Text -> f (Maybe Text))
-> QueryTableRows -> f QueryTableRows
queryTableRows_nextToken = (QueryTableRows -> Maybe Text)
-> (QueryTableRows -> Maybe Text -> QueryTableRows)
-> Lens QueryTableRows QueryTableRows (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryTableRows' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:QueryTableRows' :: QueryTableRows -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: QueryTableRows
s@QueryTableRows' {} Maybe Text
a -> QueryTableRows
s {$sel:nextToken:QueryTableRows' :: Maybe Text
nextToken = Maybe Text
a} :: QueryTableRows)

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

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

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

-- | An object that represents a filter formula along with the id of the
-- context row under which the filter function needs to evaluate.
queryTableRows_filterFormula :: Lens.Lens' QueryTableRows Filter
queryTableRows_filterFormula :: (Filter -> f Filter) -> QueryTableRows -> f QueryTableRows
queryTableRows_filterFormula = (QueryTableRows -> Filter)
-> (QueryTableRows -> Filter -> QueryTableRows)
-> Lens QueryTableRows QueryTableRows Filter Filter
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryTableRows' {Filter
filterFormula :: Filter
$sel:filterFormula:QueryTableRows' :: QueryTableRows -> Filter
filterFormula} -> Filter
filterFormula) (\s :: QueryTableRows
s@QueryTableRows' {} Filter
a -> QueryTableRows
s {$sel:filterFormula:QueryTableRows' :: Filter
filterFormula = Filter
a} :: QueryTableRows)

instance Core.AWSPager QueryTableRows where
  page :: QueryTableRows
-> AWSResponse QueryTableRows -> Maybe QueryTableRows
page QueryTableRows
rq AWSResponse QueryTableRows
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse QueryTableRows
QueryTableRowsResponse
rs
            QueryTableRowsResponse
-> Getting (First Text) QueryTableRowsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> QueryTableRowsResponse
-> Const (First Text) QueryTableRowsResponse
Lens' QueryTableRowsResponse (Maybe Text)
queryTableRowsResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> QueryTableRowsResponse
 -> Const (First Text) QueryTableRowsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) QueryTableRowsResponse 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 QueryTableRows
forall a. Maybe a
Prelude.Nothing
    | [TableRow] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop (AWSResponse QueryTableRows
QueryTableRowsResponse
rs QueryTableRowsResponse
-> Getting [TableRow] QueryTableRowsResponse [TableRow]
-> [TableRow]
forall s a. s -> Getting a s a -> a
Lens.^. Getting [TableRow] QueryTableRowsResponse [TableRow]
Lens' QueryTableRowsResponse [TableRow]
queryTableRowsResponse_rows) =
      Maybe QueryTableRows
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      QueryTableRows -> Maybe QueryTableRows
forall a. a -> Maybe a
Prelude.Just (QueryTableRows -> Maybe QueryTableRows)
-> QueryTableRows -> Maybe QueryTableRows
forall a b. (a -> b) -> a -> b
Prelude.$
        QueryTableRows
rq
          QueryTableRows
-> (QueryTableRows -> QueryTableRows) -> QueryTableRows
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> QueryTableRows -> Identity QueryTableRows
Lens QueryTableRows QueryTableRows (Maybe Text) (Maybe Text)
queryTableRows_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> QueryTableRows -> Identity QueryTableRows)
-> Maybe Text -> QueryTableRows -> QueryTableRows
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse QueryTableRows
QueryTableRowsResponse
rs
          QueryTableRowsResponse
-> Getting (First Text) QueryTableRowsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> QueryTableRowsResponse
-> Const (First Text) QueryTableRowsResponse
Lens' QueryTableRowsResponse (Maybe Text)
queryTableRowsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> QueryTableRowsResponse
 -> Const (First Text) QueryTableRowsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) QueryTableRowsResponse 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 QueryTableRows where
  type
    AWSResponse QueryTableRows =
      QueryTableRowsResponse
  request :: QueryTableRows -> Request QueryTableRows
request = Service -> QueryTableRows -> Request QueryTableRows
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy QueryTableRows
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse QueryTableRows)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse QueryTableRows))
-> Logger
-> Service
-> Proxy QueryTableRows
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse QueryTableRows)))
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 Text
-> Int
-> NonEmpty Text
-> [TableRow]
-> Integer
-> QueryTableRowsResponse
QueryTableRowsResponse'
            (Maybe Text
 -> Int
 -> NonEmpty Text
 -> [TableRow]
 -> Integer
 -> QueryTableRowsResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Int
      -> NonEmpty Text
      -> [TableRow]
      -> Integer
      -> QueryTableRowsResponse)
forall (f :: * -> *) a b. Functor 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
   -> QueryTableRowsResponse)
-> Either String Int
-> Either
     String
     (NonEmpty Text -> [TableRow] -> Integer -> QueryTableRowsResponse)
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 -> QueryTableRowsResponse)
-> Either String (NonEmpty Text)
-> Either String ([TableRow] -> Integer -> QueryTableRowsResponse)
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 -> QueryTableRowsResponse)
-> Either String [TableRow]
-> Either String (Integer -> QueryTableRowsResponse)
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 -> QueryTableRowsResponse)
-> Either String Integer -> Either String QueryTableRowsResponse
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 QueryTableRows

instance Prelude.NFData QueryTableRows

instance Core.ToHeaders QueryTableRows where
  toHeaders :: QueryTableRows -> ResponseHeaders
toHeaders =
    ResponseHeaders -> QueryTableRows -> 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 QueryTableRows where
  toJSON :: QueryTableRows -> Value
toJSON QueryTableRows' {Maybe Natural
Maybe Text
Text
Filter
filterFormula :: Filter
tableId :: Text
workbookId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:filterFormula:QueryTableRows' :: QueryTableRows -> Filter
$sel:tableId:QueryTableRows' :: QueryTableRows -> Text
$sel:workbookId:QueryTableRows' :: QueryTableRows -> Text
$sel:maxResults:QueryTableRows' :: QueryTableRows -> Maybe Natural
$sel:nextToken:QueryTableRows' :: QueryTableRows -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"filterFormula" Text -> Filter -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Filter
filterFormula)
          ]
      )

instance Core.ToPath QueryTableRows where
  toPath :: QueryTableRows -> ByteString
toPath QueryTableRows' {Maybe Natural
Maybe Text
Text
Filter
filterFormula :: Filter
tableId :: Text
workbookId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:filterFormula:QueryTableRows' :: QueryTableRows -> Filter
$sel:tableId:QueryTableRows' :: QueryTableRows -> Text
$sel:workbookId:QueryTableRows' :: QueryTableRows -> Text
$sel:maxResults:QueryTableRows' :: QueryTableRows -> Maybe Natural
$sel:nextToken:QueryTableRows' :: QueryTableRows -> Maybe 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/query"
      ]

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

-- | /See:/ 'newQueryTableRowsResponse' smart constructor.
data QueryTableRowsResponse = QueryTableRowsResponse'
  { -- | 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.
    QueryTableRowsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    QueryTableRowsResponse -> Int
httpStatus :: Prelude.Int,
    -- | The list of columns in the table whose row data is returned in the
    -- result.
    QueryTableRowsResponse -> NonEmpty Text
columnIds :: Prelude.NonEmpty Prelude.Text,
    -- | The list of rows in the table that match the query filter.
    QueryTableRowsResponse -> [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.
    QueryTableRowsResponse -> Integer
workbookCursor :: Prelude.Integer
  }
  deriving (QueryTableRowsResponse -> QueryTableRowsResponse -> Bool
(QueryTableRowsResponse -> QueryTableRowsResponse -> Bool)
-> (QueryTableRowsResponse -> QueryTableRowsResponse -> Bool)
-> Eq QueryTableRowsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QueryTableRowsResponse -> QueryTableRowsResponse -> Bool
$c/= :: QueryTableRowsResponse -> QueryTableRowsResponse -> Bool
== :: QueryTableRowsResponse -> QueryTableRowsResponse -> Bool
$c== :: QueryTableRowsResponse -> QueryTableRowsResponse -> Bool
Prelude.Eq, Int -> QueryTableRowsResponse -> ShowS
[QueryTableRowsResponse] -> ShowS
QueryTableRowsResponse -> String
(Int -> QueryTableRowsResponse -> ShowS)
-> (QueryTableRowsResponse -> String)
-> ([QueryTableRowsResponse] -> ShowS)
-> Show QueryTableRowsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [QueryTableRowsResponse] -> ShowS
$cshowList :: [QueryTableRowsResponse] -> ShowS
show :: QueryTableRowsResponse -> String
$cshow :: QueryTableRowsResponse -> String
showsPrec :: Int -> QueryTableRowsResponse -> ShowS
$cshowsPrec :: Int -> QueryTableRowsResponse -> ShowS
Prelude.Show, (forall x. QueryTableRowsResponse -> Rep QueryTableRowsResponse x)
-> (forall x.
    Rep QueryTableRowsResponse x -> QueryTableRowsResponse)
-> Generic QueryTableRowsResponse
forall x. Rep QueryTableRowsResponse x -> QueryTableRowsResponse
forall x. QueryTableRowsResponse -> Rep QueryTableRowsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep QueryTableRowsResponse x -> QueryTableRowsResponse
$cfrom :: forall x. QueryTableRowsResponse -> Rep QueryTableRowsResponse x
Prelude.Generic)

-- |
-- Create a value of 'QueryTableRowsResponse' 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:
--
-- 'nextToken', 'queryTableRowsResponse_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', 'queryTableRowsResponse_httpStatus' - The response's http status code.
--
-- 'columnIds', 'queryTableRowsResponse_columnIds' - The list of columns in the table whose row data is returned in the
-- result.
--
-- 'rows', 'queryTableRowsResponse_rows' - The list of rows in the table that match the query filter.
--
-- 'workbookCursor', 'queryTableRowsResponse_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.
newQueryTableRowsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'columnIds'
  Prelude.NonEmpty Prelude.Text ->
  -- | 'workbookCursor'
  Prelude.Integer ->
  QueryTableRowsResponse
newQueryTableRowsResponse :: Int -> NonEmpty Text -> Integer -> QueryTableRowsResponse
newQueryTableRowsResponse
  Int
pHttpStatus_
  NonEmpty Text
pColumnIds_
  Integer
pWorkbookCursor_ =
    QueryTableRowsResponse' :: Maybe Text
-> Int
-> NonEmpty Text
-> [TableRow]
-> Integer
-> QueryTableRowsResponse
QueryTableRowsResponse'
      { $sel:nextToken:QueryTableRowsResponse' :: Maybe Text
nextToken =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:QueryTableRowsResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:columnIds:QueryTableRowsResponse' :: 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:QueryTableRowsResponse' :: [TableRow]
rows = [TableRow]
forall a. Monoid a => a
Prelude.mempty,
        $sel:workbookCursor:QueryTableRowsResponse' :: Integer
workbookCursor = Integer
pWorkbookCursor_
      }

-- | 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.
queryTableRowsResponse_nextToken :: Lens.Lens' QueryTableRowsResponse (Prelude.Maybe Prelude.Text)
queryTableRowsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> QueryTableRowsResponse -> f QueryTableRowsResponse
queryTableRowsResponse_nextToken = (QueryTableRowsResponse -> Maybe Text)
-> (QueryTableRowsResponse -> Maybe Text -> QueryTableRowsResponse)
-> Lens' QueryTableRowsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryTableRowsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:QueryTableRowsResponse' :: QueryTableRowsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: QueryTableRowsResponse
s@QueryTableRowsResponse' {} Maybe Text
a -> QueryTableRowsResponse
s {$sel:nextToken:QueryTableRowsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: QueryTableRowsResponse)

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

-- | The list of columns in the table whose row data is returned in the
-- result.
queryTableRowsResponse_columnIds :: Lens.Lens' QueryTableRowsResponse (Prelude.NonEmpty Prelude.Text)
queryTableRowsResponse_columnIds :: (NonEmpty Text -> f (NonEmpty Text))
-> QueryTableRowsResponse -> f QueryTableRowsResponse
queryTableRowsResponse_columnIds = (QueryTableRowsResponse -> NonEmpty Text)
-> (QueryTableRowsResponse
    -> NonEmpty Text -> QueryTableRowsResponse)
-> Lens
     QueryTableRowsResponse
     QueryTableRowsResponse
     (NonEmpty Text)
     (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryTableRowsResponse' {NonEmpty Text
columnIds :: NonEmpty Text
$sel:columnIds:QueryTableRowsResponse' :: QueryTableRowsResponse -> NonEmpty Text
columnIds} -> NonEmpty Text
columnIds) (\s :: QueryTableRowsResponse
s@QueryTableRowsResponse' {} NonEmpty Text
a -> QueryTableRowsResponse
s {$sel:columnIds:QueryTableRowsResponse' :: NonEmpty Text
columnIds = NonEmpty Text
a} :: QueryTableRowsResponse) ((NonEmpty Text -> f (NonEmpty Text))
 -> QueryTableRowsResponse -> f QueryTableRowsResponse)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> QueryTableRowsResponse
-> f QueryTableRowsResponse
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 that match the query filter.
queryTableRowsResponse_rows :: Lens.Lens' QueryTableRowsResponse [TableRow]
queryTableRowsResponse_rows :: ([TableRow] -> f [TableRow])
-> QueryTableRowsResponse -> f QueryTableRowsResponse
queryTableRowsResponse_rows = (QueryTableRowsResponse -> [TableRow])
-> (QueryTableRowsResponse -> [TableRow] -> QueryTableRowsResponse)
-> Lens' QueryTableRowsResponse [TableRow]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryTableRowsResponse' {[TableRow]
rows :: [TableRow]
$sel:rows:QueryTableRowsResponse' :: QueryTableRowsResponse -> [TableRow]
rows} -> [TableRow]
rows) (\s :: QueryTableRowsResponse
s@QueryTableRowsResponse' {} [TableRow]
a -> QueryTableRowsResponse
s {$sel:rows:QueryTableRowsResponse' :: [TableRow]
rows = [TableRow]
a} :: QueryTableRowsResponse) (([TableRow] -> f [TableRow])
 -> QueryTableRowsResponse -> f QueryTableRowsResponse)
-> (([TableRow] -> f [TableRow]) -> [TableRow] -> f [TableRow])
-> ([TableRow] -> f [TableRow])
-> QueryTableRowsResponse
-> f QueryTableRowsResponse
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.
queryTableRowsResponse_workbookCursor :: Lens.Lens' QueryTableRowsResponse Prelude.Integer
queryTableRowsResponse_workbookCursor :: (Integer -> f Integer)
-> QueryTableRowsResponse -> f QueryTableRowsResponse
queryTableRowsResponse_workbookCursor = (QueryTableRowsResponse -> Integer)
-> (QueryTableRowsResponse -> Integer -> QueryTableRowsResponse)
-> Lens
     QueryTableRowsResponse QueryTableRowsResponse Integer Integer
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryTableRowsResponse' {Integer
workbookCursor :: Integer
$sel:workbookCursor:QueryTableRowsResponse' :: QueryTableRowsResponse -> Integer
workbookCursor} -> Integer
workbookCursor) (\s :: QueryTableRowsResponse
s@QueryTableRowsResponse' {} Integer
a -> QueryTableRowsResponse
s {$sel:workbookCursor:QueryTableRowsResponse' :: Integer
workbookCursor = Integer
a} :: QueryTableRowsResponse)

instance Prelude.NFData QueryTableRowsResponse