{-# 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.RedshiftData.ListStatements
-- 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)
--
-- List of SQL statements. By default, only finished statements are shown.
-- A token is returned to page through the statement list.
--
-- This operation returns paginated results.
module Amazonka.RedshiftData.ListStatements
  ( -- * Creating a Request
    ListStatements (..),
    newListStatements,

    -- * Request Lenses
    listStatements_status,
    listStatements_nextToken,
    listStatements_statementName,
    listStatements_roleLevel,
    listStatements_maxResults,

    -- * Destructuring the Response
    ListStatementsResponse (..),
    newListStatementsResponse,

    -- * Response Lenses
    listStatementsResponse_nextToken,
    listStatementsResponse_httpStatus,
    listStatementsResponse_statements,
  )
where

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

-- | /See:/ 'newListStatements' smart constructor.
data ListStatements = ListStatements'
  { -- | The status of the SQL statement to list. Status values are defined as
    -- follows:
    --
    -- -   ABORTED - The query run was stopped by the user.
    --
    -- -   ALL - A status value that includes all query statuses. This value
    --     can be used to filter results.
    --
    -- -   FAILED - The query run failed.
    --
    -- -   FINISHED - The query has finished running.
    --
    -- -   PICKED - The query has been chosen to be run.
    --
    -- -   STARTED - The query run has started.
    --
    -- -   SUBMITTED - The query was submitted, but not yet processed.
    ListStatements -> Maybe StatusString
status :: Prelude.Maybe StatusString,
    -- | A value that indicates the starting point for the next set of response
    -- records in a subsequent request. If a value is returned in a response,
    -- you can retrieve the next set of records by providing this returned
    -- NextToken value in the next NextToken parameter and retrying the
    -- command. If the NextToken field is empty, all response records have been
    -- retrieved for the request.
    ListStatements -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The name of the SQL statement specified as input to
    -- @BatchExecuteStatement@ or @ExecuteStatement@ to identify the query. You
    -- can list multiple statements by providing a prefix that matches the
    -- beginning of the statement name. For example, to list myStatement1,
    -- myStatement2, myStatement3, and so on, then provide the a value of
    -- @myStatement@. Data API does a case-sensitive match of SQL statement
    -- names to the prefix value you provide.
    ListStatements -> Maybe Text
statementName :: Prelude.Maybe Prelude.Text,
    -- | A value that filters which statements to return in the response. If
    -- true, all statements run by the caller\'s IAM role are returned. If
    -- false, only statements run by the caller\'s IAM role in the current IAM
    -- session are returned. The default is true.
    ListStatements -> Maybe Bool
roleLevel :: Prelude.Maybe Prelude.Bool,
    -- | The maximum number of SQL statements to return in the response. If more
    -- SQL statements exist than fit in one response, then @NextToken@ is
    -- returned to page through the results.
    ListStatements -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (ListStatements -> ListStatements -> Bool
(ListStatements -> ListStatements -> Bool)
-> (ListStatements -> ListStatements -> Bool) -> Eq ListStatements
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListStatements -> ListStatements -> Bool
$c/= :: ListStatements -> ListStatements -> Bool
== :: ListStatements -> ListStatements -> Bool
$c== :: ListStatements -> ListStatements -> Bool
Prelude.Eq, ReadPrec [ListStatements]
ReadPrec ListStatements
Int -> ReadS ListStatements
ReadS [ListStatements]
(Int -> ReadS ListStatements)
-> ReadS [ListStatements]
-> ReadPrec ListStatements
-> ReadPrec [ListStatements]
-> Read ListStatements
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListStatements]
$creadListPrec :: ReadPrec [ListStatements]
readPrec :: ReadPrec ListStatements
$creadPrec :: ReadPrec ListStatements
readList :: ReadS [ListStatements]
$creadList :: ReadS [ListStatements]
readsPrec :: Int -> ReadS ListStatements
$creadsPrec :: Int -> ReadS ListStatements
Prelude.Read, Int -> ListStatements -> ShowS
[ListStatements] -> ShowS
ListStatements -> String
(Int -> ListStatements -> ShowS)
-> (ListStatements -> String)
-> ([ListStatements] -> ShowS)
-> Show ListStatements
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListStatements] -> ShowS
$cshowList :: [ListStatements] -> ShowS
show :: ListStatements -> String
$cshow :: ListStatements -> String
showsPrec :: Int -> ListStatements -> ShowS
$cshowsPrec :: Int -> ListStatements -> ShowS
Prelude.Show, (forall x. ListStatements -> Rep ListStatements x)
-> (forall x. Rep ListStatements x -> ListStatements)
-> Generic ListStatements
forall x. Rep ListStatements x -> ListStatements
forall x. ListStatements -> Rep ListStatements x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListStatements x -> ListStatements
$cfrom :: forall x. ListStatements -> Rep ListStatements x
Prelude.Generic)

-- |
-- Create a value of 'ListStatements' 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:
--
-- 'status', 'listStatements_status' - The status of the SQL statement to list. Status values are defined as
-- follows:
--
-- -   ABORTED - The query run was stopped by the user.
--
-- -   ALL - A status value that includes all query statuses. This value
--     can be used to filter results.
--
-- -   FAILED - The query run failed.
--
-- -   FINISHED - The query has finished running.
--
-- -   PICKED - The query has been chosen to be run.
--
-- -   STARTED - The query run has started.
--
-- -   SUBMITTED - The query was submitted, but not yet processed.
--
-- 'nextToken', 'listStatements_nextToken' - A value that indicates the starting point for the next set of response
-- records in a subsequent request. If a value is returned in a response,
-- you can retrieve the next set of records by providing this returned
-- NextToken value in the next NextToken parameter and retrying the
-- command. If the NextToken field is empty, all response records have been
-- retrieved for the request.
--
-- 'statementName', 'listStatements_statementName' - The name of the SQL statement specified as input to
-- @BatchExecuteStatement@ or @ExecuteStatement@ to identify the query. You
-- can list multiple statements by providing a prefix that matches the
-- beginning of the statement name. For example, to list myStatement1,
-- myStatement2, myStatement3, and so on, then provide the a value of
-- @myStatement@. Data API does a case-sensitive match of SQL statement
-- names to the prefix value you provide.
--
-- 'roleLevel', 'listStatements_roleLevel' - A value that filters which statements to return in the response. If
-- true, all statements run by the caller\'s IAM role are returned. If
-- false, only statements run by the caller\'s IAM role in the current IAM
-- session are returned. The default is true.
--
-- 'maxResults', 'listStatements_maxResults' - The maximum number of SQL statements to return in the response. If more
-- SQL statements exist than fit in one response, then @NextToken@ is
-- returned to page through the results.
newListStatements ::
  ListStatements
newListStatements :: ListStatements
newListStatements =
  ListStatements' :: Maybe StatusString
-> Maybe Text
-> Maybe Text
-> Maybe Bool
-> Maybe Natural
-> ListStatements
ListStatements'
    { $sel:status:ListStatements' :: Maybe StatusString
status = Maybe StatusString
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListStatements' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:statementName:ListStatements' :: Maybe Text
statementName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:roleLevel:ListStatements' :: Maybe Bool
roleLevel = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListStatements' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of the SQL statement to list. Status values are defined as
-- follows:
--
-- -   ABORTED - The query run was stopped by the user.
--
-- -   ALL - A status value that includes all query statuses. This value
--     can be used to filter results.
--
-- -   FAILED - The query run failed.
--
-- -   FINISHED - The query has finished running.
--
-- -   PICKED - The query has been chosen to be run.
--
-- -   STARTED - The query run has started.
--
-- -   SUBMITTED - The query was submitted, but not yet processed.
listStatements_status :: Lens.Lens' ListStatements (Prelude.Maybe StatusString)
listStatements_status :: (Maybe StatusString -> f (Maybe StatusString))
-> ListStatements -> f ListStatements
listStatements_status = (ListStatements -> Maybe StatusString)
-> (ListStatements -> Maybe StatusString -> ListStatements)
-> Lens
     ListStatements
     ListStatements
     (Maybe StatusString)
     (Maybe StatusString)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStatements' {Maybe StatusString
status :: Maybe StatusString
$sel:status:ListStatements' :: ListStatements -> Maybe StatusString
status} -> Maybe StatusString
status) (\s :: ListStatements
s@ListStatements' {} Maybe StatusString
a -> ListStatements
s {$sel:status:ListStatements' :: Maybe StatusString
status = Maybe StatusString
a} :: ListStatements)

-- | A value that indicates the starting point for the next set of response
-- records in a subsequent request. If a value is returned in a response,
-- you can retrieve the next set of records by providing this returned
-- NextToken value in the next NextToken parameter and retrying the
-- command. If the NextToken field is empty, all response records have been
-- retrieved for the request.
listStatements_nextToken :: Lens.Lens' ListStatements (Prelude.Maybe Prelude.Text)
listStatements_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListStatements -> f ListStatements
listStatements_nextToken = (ListStatements -> Maybe Text)
-> (ListStatements -> Maybe Text -> ListStatements)
-> Lens ListStatements ListStatements (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStatements' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListStatements' :: ListStatements -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListStatements
s@ListStatements' {} Maybe Text
a -> ListStatements
s {$sel:nextToken:ListStatements' :: Maybe Text
nextToken = Maybe Text
a} :: ListStatements)

-- | The name of the SQL statement specified as input to
-- @BatchExecuteStatement@ or @ExecuteStatement@ to identify the query. You
-- can list multiple statements by providing a prefix that matches the
-- beginning of the statement name. For example, to list myStatement1,
-- myStatement2, myStatement3, and so on, then provide the a value of
-- @myStatement@. Data API does a case-sensitive match of SQL statement
-- names to the prefix value you provide.
listStatements_statementName :: Lens.Lens' ListStatements (Prelude.Maybe Prelude.Text)
listStatements_statementName :: (Maybe Text -> f (Maybe Text))
-> ListStatements -> f ListStatements
listStatements_statementName = (ListStatements -> Maybe Text)
-> (ListStatements -> Maybe Text -> ListStatements)
-> Lens ListStatements ListStatements (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStatements' {Maybe Text
statementName :: Maybe Text
$sel:statementName:ListStatements' :: ListStatements -> Maybe Text
statementName} -> Maybe Text
statementName) (\s :: ListStatements
s@ListStatements' {} Maybe Text
a -> ListStatements
s {$sel:statementName:ListStatements' :: Maybe Text
statementName = Maybe Text
a} :: ListStatements)

-- | A value that filters which statements to return in the response. If
-- true, all statements run by the caller\'s IAM role are returned. If
-- false, only statements run by the caller\'s IAM role in the current IAM
-- session are returned. The default is true.
listStatements_roleLevel :: Lens.Lens' ListStatements (Prelude.Maybe Prelude.Bool)
listStatements_roleLevel :: (Maybe Bool -> f (Maybe Bool))
-> ListStatements -> f ListStatements
listStatements_roleLevel = (ListStatements -> Maybe Bool)
-> (ListStatements -> Maybe Bool -> ListStatements)
-> Lens ListStatements ListStatements (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStatements' {Maybe Bool
roleLevel :: Maybe Bool
$sel:roleLevel:ListStatements' :: ListStatements -> Maybe Bool
roleLevel} -> Maybe Bool
roleLevel) (\s :: ListStatements
s@ListStatements' {} Maybe Bool
a -> ListStatements
s {$sel:roleLevel:ListStatements' :: Maybe Bool
roleLevel = Maybe Bool
a} :: ListStatements)

-- | The maximum number of SQL statements to return in the response. If more
-- SQL statements exist than fit in one response, then @NextToken@ is
-- returned to page through the results.
listStatements_maxResults :: Lens.Lens' ListStatements (Prelude.Maybe Prelude.Natural)
listStatements_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListStatements -> f ListStatements
listStatements_maxResults = (ListStatements -> Maybe Natural)
-> (ListStatements -> Maybe Natural -> ListStatements)
-> Lens
     ListStatements ListStatements (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStatements' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListStatements' :: ListStatements -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListStatements
s@ListStatements' {} Maybe Natural
a -> ListStatements
s {$sel:maxResults:ListStatements' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListStatements)

instance Core.AWSPager ListStatements where
  page :: ListStatements
-> AWSResponse ListStatements -> Maybe ListStatements
page ListStatements
rq AWSResponse ListStatements
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListStatements
ListStatementsResponse
rs
            ListStatementsResponse
-> Getting (First Text) ListStatementsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListStatementsResponse
-> Const (First Text) ListStatementsResponse
Lens' ListStatementsResponse (Maybe Text)
listStatementsResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListStatementsResponse
 -> Const (First Text) ListStatementsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListStatementsResponse 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 ListStatements
forall a. Maybe a
Prelude.Nothing
    | [StatementData] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        (AWSResponse ListStatements
ListStatementsResponse
rs ListStatementsResponse
-> Getting [StatementData] ListStatementsResponse [StatementData]
-> [StatementData]
forall s a. s -> Getting a s a -> a
Lens.^. Getting [StatementData] ListStatementsResponse [StatementData]
Lens' ListStatementsResponse [StatementData]
listStatementsResponse_statements) =
      Maybe ListStatements
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListStatements -> Maybe ListStatements
forall a. a -> Maybe a
Prelude.Just (ListStatements -> Maybe ListStatements)
-> ListStatements -> Maybe ListStatements
forall a b. (a -> b) -> a -> b
Prelude.$
        ListStatements
rq
          ListStatements
-> (ListStatements -> ListStatements) -> ListStatements
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListStatements -> Identity ListStatements
Lens ListStatements ListStatements (Maybe Text) (Maybe Text)
listStatements_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListStatements -> Identity ListStatements)
-> Maybe Text -> ListStatements -> ListStatements
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListStatements
ListStatementsResponse
rs
          ListStatementsResponse
-> Getting (First Text) ListStatementsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListStatementsResponse
-> Const (First Text) ListStatementsResponse
Lens' ListStatementsResponse (Maybe Text)
listStatementsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListStatementsResponse
 -> Const (First Text) ListStatementsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListStatementsResponse 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 ListStatements where
  type
    AWSResponse ListStatements =
      ListStatementsResponse
  request :: ListStatements -> Request ListStatements
request = Service -> ListStatements -> Request ListStatements
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListStatements
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListStatements)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListStatements))
-> Logger
-> Service
-> Proxy ListStatements
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListStatements)))
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 -> [StatementData] -> ListStatementsResponse
ListStatementsResponse'
            (Maybe Text -> Int -> [StatementData] -> ListStatementsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> [StatementData] -> ListStatementsResponse)
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 -> [StatementData] -> ListStatementsResponse)
-> Either String Int
-> Either String ([StatementData] -> ListStatementsResponse)
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 ([StatementData] -> ListStatementsResponse)
-> Either String [StatementData]
-> Either String ListStatementsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe [StatementData])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Statements" Either String (Maybe [StatementData])
-> [StatementData] -> Either String [StatementData]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [StatementData]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ListStatements

instance Prelude.NFData ListStatements

instance Core.ToHeaders ListStatements where
  toHeaders :: ListStatements -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListStatements -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"RedshiftData.ListStatements" ::
                          Prelude.ByteString
                      ),
            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 ListStatements where
  toJSON :: ListStatements -> Value
toJSON ListStatements' {Maybe Bool
Maybe Natural
Maybe Text
Maybe StatusString
maxResults :: Maybe Natural
roleLevel :: Maybe Bool
statementName :: Maybe Text
nextToken :: Maybe Text
status :: Maybe StatusString
$sel:maxResults:ListStatements' :: ListStatements -> Maybe Natural
$sel:roleLevel:ListStatements' :: ListStatements -> Maybe Bool
$sel:statementName:ListStatements' :: ListStatements -> Maybe Text
$sel:nextToken:ListStatements' :: ListStatements -> Maybe Text
$sel:status:ListStatements' :: ListStatements -> Maybe StatusString
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Status" Text -> StatusString -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (StatusString -> Pair) -> Maybe StatusString -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StatusString
status,
            (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
"StatementName" 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
statementName,
            (Text
"RoleLevel" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
roleLevel,
            (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 ListStatements where
  toPath :: ListStatements -> ByteString
toPath = ByteString -> ListStatements -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newListStatementsResponse' smart constructor.
data ListStatementsResponse = ListStatementsResponse'
  { -- | A value that indicates the starting point for the next set of response
    -- records in a subsequent request. If a value is returned in a response,
    -- you can retrieve the next set of records by providing this returned
    -- NextToken value in the next NextToken parameter and retrying the
    -- command. If the NextToken field is empty, all response records have been
    -- retrieved for the request.
    ListStatementsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListStatementsResponse -> Int
httpStatus :: Prelude.Int,
    -- | The SQL statements.
    ListStatementsResponse -> [StatementData]
statements :: [StatementData]
  }
  deriving (ListStatementsResponse -> ListStatementsResponse -> Bool
(ListStatementsResponse -> ListStatementsResponse -> Bool)
-> (ListStatementsResponse -> ListStatementsResponse -> Bool)
-> Eq ListStatementsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListStatementsResponse -> ListStatementsResponse -> Bool
$c/= :: ListStatementsResponse -> ListStatementsResponse -> Bool
== :: ListStatementsResponse -> ListStatementsResponse -> Bool
$c== :: ListStatementsResponse -> ListStatementsResponse -> Bool
Prelude.Eq, ReadPrec [ListStatementsResponse]
ReadPrec ListStatementsResponse
Int -> ReadS ListStatementsResponse
ReadS [ListStatementsResponse]
(Int -> ReadS ListStatementsResponse)
-> ReadS [ListStatementsResponse]
-> ReadPrec ListStatementsResponse
-> ReadPrec [ListStatementsResponse]
-> Read ListStatementsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListStatementsResponse]
$creadListPrec :: ReadPrec [ListStatementsResponse]
readPrec :: ReadPrec ListStatementsResponse
$creadPrec :: ReadPrec ListStatementsResponse
readList :: ReadS [ListStatementsResponse]
$creadList :: ReadS [ListStatementsResponse]
readsPrec :: Int -> ReadS ListStatementsResponse
$creadsPrec :: Int -> ReadS ListStatementsResponse
Prelude.Read, Int -> ListStatementsResponse -> ShowS
[ListStatementsResponse] -> ShowS
ListStatementsResponse -> String
(Int -> ListStatementsResponse -> ShowS)
-> (ListStatementsResponse -> String)
-> ([ListStatementsResponse] -> ShowS)
-> Show ListStatementsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListStatementsResponse] -> ShowS
$cshowList :: [ListStatementsResponse] -> ShowS
show :: ListStatementsResponse -> String
$cshow :: ListStatementsResponse -> String
showsPrec :: Int -> ListStatementsResponse -> ShowS
$cshowsPrec :: Int -> ListStatementsResponse -> ShowS
Prelude.Show, (forall x. ListStatementsResponse -> Rep ListStatementsResponse x)
-> (forall x.
    Rep ListStatementsResponse x -> ListStatementsResponse)
-> Generic ListStatementsResponse
forall x. Rep ListStatementsResponse x -> ListStatementsResponse
forall x. ListStatementsResponse -> Rep ListStatementsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListStatementsResponse x -> ListStatementsResponse
$cfrom :: forall x. ListStatementsResponse -> Rep ListStatementsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListStatementsResponse' 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', 'listStatementsResponse_nextToken' - A value that indicates the starting point for the next set of response
-- records in a subsequent request. If a value is returned in a response,
-- you can retrieve the next set of records by providing this returned
-- NextToken value in the next NextToken parameter and retrying the
-- command. If the NextToken field is empty, all response records have been
-- retrieved for the request.
--
-- 'httpStatus', 'listStatementsResponse_httpStatus' - The response's http status code.
--
-- 'statements', 'listStatementsResponse_statements' - The SQL statements.
newListStatementsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListStatementsResponse
newListStatementsResponse :: Int -> ListStatementsResponse
newListStatementsResponse Int
pHttpStatus_ =
  ListStatementsResponse' :: Maybe Text -> Int -> [StatementData] -> ListStatementsResponse
ListStatementsResponse'
    { $sel:nextToken:ListStatementsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListStatementsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:statements:ListStatementsResponse' :: [StatementData]
statements = [StatementData]
forall a. Monoid a => a
Prelude.mempty
    }

-- | A value that indicates the starting point for the next set of response
-- records in a subsequent request. If a value is returned in a response,
-- you can retrieve the next set of records by providing this returned
-- NextToken value in the next NextToken parameter and retrying the
-- command. If the NextToken field is empty, all response records have been
-- retrieved for the request.
listStatementsResponse_nextToken :: Lens.Lens' ListStatementsResponse (Prelude.Maybe Prelude.Text)
listStatementsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListStatementsResponse -> f ListStatementsResponse
listStatementsResponse_nextToken = (ListStatementsResponse -> Maybe Text)
-> (ListStatementsResponse -> Maybe Text -> ListStatementsResponse)
-> Lens' ListStatementsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStatementsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListStatementsResponse' :: ListStatementsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListStatementsResponse
s@ListStatementsResponse' {} Maybe Text
a -> ListStatementsResponse
s {$sel:nextToken:ListStatementsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListStatementsResponse)

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

-- | The SQL statements.
listStatementsResponse_statements :: Lens.Lens' ListStatementsResponse [StatementData]
listStatementsResponse_statements :: ([StatementData] -> f [StatementData])
-> ListStatementsResponse -> f ListStatementsResponse
listStatementsResponse_statements = (ListStatementsResponse -> [StatementData])
-> (ListStatementsResponse
    -> [StatementData] -> ListStatementsResponse)
-> Lens' ListStatementsResponse [StatementData]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStatementsResponse' {[StatementData]
statements :: [StatementData]
$sel:statements:ListStatementsResponse' :: ListStatementsResponse -> [StatementData]
statements} -> [StatementData]
statements) (\s :: ListStatementsResponse
s@ListStatementsResponse' {} [StatementData]
a -> ListStatementsResponse
s {$sel:statements:ListStatementsResponse' :: [StatementData]
statements = [StatementData]
a} :: ListStatementsResponse) (([StatementData] -> f [StatementData])
 -> ListStatementsResponse -> f ListStatementsResponse)
-> (([StatementData] -> f [StatementData])
    -> [StatementData] -> f [StatementData])
-> ([StatementData] -> f [StatementData])
-> ListStatementsResponse
-> f ListStatementsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([StatementData] -> f [StatementData])
-> [StatementData] -> f [StatementData]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData ListStatementsResponse