{-# 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 #-}
module Amazonka.SDB.Select
(
Select (..),
newSelect,
select_consistentRead,
select_nextToken,
select_selectExpression,
SelectResponse (..),
newSelectResponse,
selectResponse_items,
selectResponse_nextToken,
selectResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SDB.Types
data Select = Select'
{
Select -> Maybe Bool
consistentRead :: Prelude.Maybe Prelude.Bool,
Select -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
Select -> Text
selectExpression :: Prelude.Text
}
deriving (Select -> Select -> Bool
(Select -> Select -> Bool)
-> (Select -> Select -> Bool) -> Eq Select
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Select -> Select -> Bool
$c/= :: Select -> Select -> Bool
== :: Select -> Select -> Bool
$c== :: Select -> Select -> Bool
Prelude.Eq, ReadPrec [Select]
ReadPrec Select
Int -> ReadS Select
ReadS [Select]
(Int -> ReadS Select)
-> ReadS [Select]
-> ReadPrec Select
-> ReadPrec [Select]
-> Read Select
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Select]
$creadListPrec :: ReadPrec [Select]
readPrec :: ReadPrec Select
$creadPrec :: ReadPrec Select
readList :: ReadS [Select]
$creadList :: ReadS [Select]
readsPrec :: Int -> ReadS Select
$creadsPrec :: Int -> ReadS Select
Prelude.Read, Int -> Select -> ShowS
[Select] -> ShowS
Select -> String
(Int -> Select -> ShowS)
-> (Select -> String) -> ([Select] -> ShowS) -> Show Select
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Select] -> ShowS
$cshowList :: [Select] -> ShowS
show :: Select -> String
$cshow :: Select -> String
showsPrec :: Int -> Select -> ShowS
$cshowsPrec :: Int -> Select -> ShowS
Prelude.Show, (forall x. Select -> Rep Select x)
-> (forall x. Rep Select x -> Select) -> Generic Select
forall x. Rep Select x -> Select
forall x. Select -> Rep Select x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Select x -> Select
$cfrom :: forall x. Select -> Rep Select x
Prelude.Generic)
newSelect ::
Prelude.Text ->
Select
newSelect :: Text -> Select
newSelect Text
pSelectExpression_ =
Select' :: Maybe Bool -> Maybe Text -> Text -> Select
Select'
{ $sel:consistentRead:Select' :: Maybe Bool
consistentRead = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
$sel:nextToken:Select' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:selectExpression:Select' :: Text
selectExpression = Text
pSelectExpression_
}
select_consistentRead :: Lens.Lens' Select (Prelude.Maybe Prelude.Bool)
select_consistentRead :: (Maybe Bool -> f (Maybe Bool)) -> Select -> f Select
select_consistentRead = (Select -> Maybe Bool)
-> (Select -> Maybe Bool -> Select)
-> Lens Select Select (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Select' {Maybe Bool
consistentRead :: Maybe Bool
$sel:consistentRead:Select' :: Select -> Maybe Bool
consistentRead} -> Maybe Bool
consistentRead) (\s :: Select
s@Select' {} Maybe Bool
a -> Select
s {$sel:consistentRead:Select' :: Maybe Bool
consistentRead = Maybe Bool
a} :: Select)
select_nextToken :: Lens.Lens' Select (Prelude.Maybe Prelude.Text)
select_nextToken :: (Maybe Text -> f (Maybe Text)) -> Select -> f Select
select_nextToken = (Select -> Maybe Text)
-> (Select -> Maybe Text -> Select)
-> Lens Select Select (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Select' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:Select' :: Select -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: Select
s@Select' {} Maybe Text
a -> Select
s {$sel:nextToken:Select' :: Maybe Text
nextToken = Maybe Text
a} :: Select)
select_selectExpression :: Lens.Lens' Select Prelude.Text
select_selectExpression :: (Text -> f Text) -> Select -> f Select
select_selectExpression = (Select -> Text)
-> (Select -> Text -> Select) -> Lens Select Select Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Select' {Text
selectExpression :: Text
$sel:selectExpression:Select' :: Select -> Text
selectExpression} -> Text
selectExpression) (\s :: Select
s@Select' {} Text
a -> Select
s {$sel:selectExpression:Select' :: Text
selectExpression = Text
a} :: Select)
instance Core.AWSPager Select where
page :: Select -> AWSResponse Select -> Maybe Select
page Select
rq AWSResponse Select
rs
| Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse Select
SelectResponse
rs
SelectResponse
-> Getting (First Text) SelectResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> SelectResponse -> Const (First Text) SelectResponse
Lens' SelectResponse (Maybe Text)
selectResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
-> SelectResponse -> Const (First Text) SelectResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) SelectResponse 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 Select
forall a. Maybe a
Prelude.Nothing
| Maybe [Item] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse Select
SelectResponse
rs
SelectResponse
-> Getting (First [Item]) SelectResponse [Item] -> Maybe [Item]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Item] -> Const (First [Item]) (Maybe [Item]))
-> SelectResponse -> Const (First [Item]) SelectResponse
Lens' SelectResponse (Maybe [Item])
selectResponse_items ((Maybe [Item] -> Const (First [Item]) (Maybe [Item]))
-> SelectResponse -> Const (First [Item]) SelectResponse)
-> (([Item] -> Const (First [Item]) [Item])
-> Maybe [Item] -> Const (First [Item]) (Maybe [Item]))
-> Getting (First [Item]) SelectResponse [Item]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Item] -> Const (First [Item]) [Item])
-> Maybe [Item] -> Const (First [Item]) (Maybe [Item])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
Maybe Select
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
Select -> Maybe Select
forall a. a -> Maybe a
Prelude.Just (Select -> Maybe Select) -> Select -> Maybe Select
forall a b. (a -> b) -> a -> b
Prelude.$
Select
rq
Select -> (Select -> Select) -> Select
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text)) -> Select -> Identity Select
Lens Select Select (Maybe Text) (Maybe Text)
select_nextToken
((Maybe Text -> Identity (Maybe Text))
-> Select -> Identity Select)
-> Maybe Text -> Select -> Select
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse Select
SelectResponse
rs
SelectResponse
-> Getting (First Text) SelectResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> SelectResponse -> Const (First Text) SelectResponse
Lens' SelectResponse (Maybe Text)
selectResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
-> SelectResponse -> Const (First Text) SelectResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) SelectResponse 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 Select where
type AWSResponse Select = SelectResponse
request :: Select -> Request Select
request = Service -> Select -> Request Select
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
response :: Logger
-> Service
-> Proxy Select
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse Select)))
response =
Text
-> (Int
-> ResponseHeaders -> [Node] -> Either String (AWSResponse Select))
-> Logger
-> Service
-> Proxy Select
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse Select)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
-> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
Text
"SelectResult"
( \Int
s ResponseHeaders
h [Node]
x ->
Maybe [Item] -> Maybe Text -> Int -> SelectResponse
SelectResponse'
(Maybe [Item] -> Maybe Text -> Int -> SelectResponse)
-> Either String (Maybe [Item])
-> Either String (Maybe Text -> Int -> SelectResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (([Node] -> Either String [Item])
-> [Node] -> Either String (Maybe [Item])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Item]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"Item") [Node]
x)
Either String (Maybe Text -> Int -> SelectResponse)
-> Either String (Maybe Text)
-> Either String (Int -> SelectResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"NextToken")
Either String (Int -> SelectResponse)
-> Either String Int -> Either String SelectResponse
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))
)
instance Prelude.Hashable Select
instance Prelude.NFData Select
instance Core.ToHeaders Select where
toHeaders :: Select -> ResponseHeaders
toHeaders = ResponseHeaders -> Select -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToPath Select where
toPath :: Select -> ByteString
toPath = ByteString -> Select -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery Select where
toQuery :: Select -> QueryString
toQuery Select' {Maybe Bool
Maybe Text
Text
selectExpression :: Text
nextToken :: Maybe Text
consistentRead :: Maybe Bool
$sel:selectExpression:Select' :: Select -> Text
$sel:nextToken:Select' :: Select -> Maybe Text
$sel:consistentRead:Select' :: Select -> Maybe Bool
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"Action" ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"Select" :: Prelude.ByteString),
ByteString
"Version"
ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2009-04-15" :: Prelude.ByteString),
ByteString
"ConsistentRead" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
consistentRead,
ByteString
"NextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
ByteString
"SelectExpression" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
selectExpression
]
data SelectResponse = SelectResponse'
{
SelectResponse -> Maybe [Item]
items :: Prelude.Maybe [Item],
SelectResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
SelectResponse -> Int
httpStatus :: Prelude.Int
}
deriving (SelectResponse -> SelectResponse -> Bool
(SelectResponse -> SelectResponse -> Bool)
-> (SelectResponse -> SelectResponse -> Bool) -> Eq SelectResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SelectResponse -> SelectResponse -> Bool
$c/= :: SelectResponse -> SelectResponse -> Bool
== :: SelectResponse -> SelectResponse -> Bool
$c== :: SelectResponse -> SelectResponse -> Bool
Prelude.Eq, ReadPrec [SelectResponse]
ReadPrec SelectResponse
Int -> ReadS SelectResponse
ReadS [SelectResponse]
(Int -> ReadS SelectResponse)
-> ReadS [SelectResponse]
-> ReadPrec SelectResponse
-> ReadPrec [SelectResponse]
-> Read SelectResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SelectResponse]
$creadListPrec :: ReadPrec [SelectResponse]
readPrec :: ReadPrec SelectResponse
$creadPrec :: ReadPrec SelectResponse
readList :: ReadS [SelectResponse]
$creadList :: ReadS [SelectResponse]
readsPrec :: Int -> ReadS SelectResponse
$creadsPrec :: Int -> ReadS SelectResponse
Prelude.Read, Int -> SelectResponse -> ShowS
[SelectResponse] -> ShowS
SelectResponse -> String
(Int -> SelectResponse -> ShowS)
-> (SelectResponse -> String)
-> ([SelectResponse] -> ShowS)
-> Show SelectResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SelectResponse] -> ShowS
$cshowList :: [SelectResponse] -> ShowS
show :: SelectResponse -> String
$cshow :: SelectResponse -> String
showsPrec :: Int -> SelectResponse -> ShowS
$cshowsPrec :: Int -> SelectResponse -> ShowS
Prelude.Show, (forall x. SelectResponse -> Rep SelectResponse x)
-> (forall x. Rep SelectResponse x -> SelectResponse)
-> Generic SelectResponse
forall x. Rep SelectResponse x -> SelectResponse
forall x. SelectResponse -> Rep SelectResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SelectResponse x -> SelectResponse
$cfrom :: forall x. SelectResponse -> Rep SelectResponse x
Prelude.Generic)
newSelectResponse ::
Prelude.Int ->
SelectResponse
newSelectResponse :: Int -> SelectResponse
newSelectResponse Int
pHttpStatus_ =
SelectResponse' :: Maybe [Item] -> Maybe Text -> Int -> SelectResponse
SelectResponse'
{ $sel:items:SelectResponse' :: Maybe [Item]
items = Maybe [Item]
forall a. Maybe a
Prelude.Nothing,
$sel:nextToken:SelectResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:SelectResponse' :: Int
httpStatus = Int
pHttpStatus_
}
selectResponse_items :: Lens.Lens' SelectResponse (Prelude.Maybe [Item])
selectResponse_items :: (Maybe [Item] -> f (Maybe [Item]))
-> SelectResponse -> f SelectResponse
selectResponse_items = (SelectResponse -> Maybe [Item])
-> (SelectResponse -> Maybe [Item] -> SelectResponse)
-> Lens' SelectResponse (Maybe [Item])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SelectResponse' {Maybe [Item]
items :: Maybe [Item]
$sel:items:SelectResponse' :: SelectResponse -> Maybe [Item]
items} -> Maybe [Item]
items) (\s :: SelectResponse
s@SelectResponse' {} Maybe [Item]
a -> SelectResponse
s {$sel:items:SelectResponse' :: Maybe [Item]
items = Maybe [Item]
a} :: SelectResponse) ((Maybe [Item] -> f (Maybe [Item]))
-> SelectResponse -> f SelectResponse)
-> ((Maybe [Item] -> f (Maybe [Item]))
-> Maybe [Item] -> f (Maybe [Item]))
-> (Maybe [Item] -> f (Maybe [Item]))
-> SelectResponse
-> f SelectResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Item] [Item] [Item] [Item]
-> Iso (Maybe [Item]) (Maybe [Item]) (Maybe [Item]) (Maybe [Item])
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 [Item] [Item] [Item] [Item]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
selectResponse_nextToken :: Lens.Lens' SelectResponse (Prelude.Maybe Prelude.Text)
selectResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> SelectResponse -> f SelectResponse
selectResponse_nextToken = (SelectResponse -> Maybe Text)
-> (SelectResponse -> Maybe Text -> SelectResponse)
-> Lens' SelectResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SelectResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:SelectResponse' :: SelectResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: SelectResponse
s@SelectResponse' {} Maybe Text
a -> SelectResponse
s {$sel:nextToken:SelectResponse' :: Maybe Text
nextToken = Maybe Text
a} :: SelectResponse)
selectResponse_httpStatus :: Lens.Lens' SelectResponse Prelude.Int
selectResponse_httpStatus :: (Int -> f Int) -> SelectResponse -> f SelectResponse
selectResponse_httpStatus = (SelectResponse -> Int)
-> (SelectResponse -> Int -> SelectResponse)
-> Lens SelectResponse SelectResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SelectResponse' {Int
httpStatus :: Int
$sel:httpStatus:SelectResponse' :: SelectResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: SelectResponse
s@SelectResponse' {} Int
a -> SelectResponse
s {$sel:httpStatus:SelectResponse' :: Int
httpStatus = Int
a} :: SelectResponse)
instance Prelude.NFData SelectResponse