{-# 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.CloudSearchDomains.Suggest
(
Suggest (..),
newSuggest,
suggest_size,
suggest_query,
suggest_suggester,
SuggestResponse (..),
newSuggestResponse,
suggestResponse_suggest,
suggestResponse_status,
suggestResponse_httpStatus,
)
where
import Amazonka.CloudSearchDomains.Types
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
data Suggest = Suggest'
{
Suggest -> Maybe Integer
size :: Prelude.Maybe Prelude.Integer,
Suggest -> Text
query :: Prelude.Text,
Suggest -> Text
suggester :: Prelude.Text
}
deriving (Suggest -> Suggest -> Bool
(Suggest -> Suggest -> Bool)
-> (Suggest -> Suggest -> Bool) -> Eq Suggest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Suggest -> Suggest -> Bool
$c/= :: Suggest -> Suggest -> Bool
== :: Suggest -> Suggest -> Bool
$c== :: Suggest -> Suggest -> Bool
Prelude.Eq, ReadPrec [Suggest]
ReadPrec Suggest
Int -> ReadS Suggest
ReadS [Suggest]
(Int -> ReadS Suggest)
-> ReadS [Suggest]
-> ReadPrec Suggest
-> ReadPrec [Suggest]
-> Read Suggest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Suggest]
$creadListPrec :: ReadPrec [Suggest]
readPrec :: ReadPrec Suggest
$creadPrec :: ReadPrec Suggest
readList :: ReadS [Suggest]
$creadList :: ReadS [Suggest]
readsPrec :: Int -> ReadS Suggest
$creadsPrec :: Int -> ReadS Suggest
Prelude.Read, Int -> Suggest -> ShowS
[Suggest] -> ShowS
Suggest -> String
(Int -> Suggest -> ShowS)
-> (Suggest -> String) -> ([Suggest] -> ShowS) -> Show Suggest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Suggest] -> ShowS
$cshowList :: [Suggest] -> ShowS
show :: Suggest -> String
$cshow :: Suggest -> String
showsPrec :: Int -> Suggest -> ShowS
$cshowsPrec :: Int -> Suggest -> ShowS
Prelude.Show, (forall x. Suggest -> Rep Suggest x)
-> (forall x. Rep Suggest x -> Suggest) -> Generic Suggest
forall x. Rep Suggest x -> Suggest
forall x. Suggest -> Rep Suggest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Suggest x -> Suggest
$cfrom :: forall x. Suggest -> Rep Suggest x
Prelude.Generic)
newSuggest ::
Prelude.Text ->
Prelude.Text ->
Suggest
newSuggest :: Text -> Text -> Suggest
newSuggest Text
pQuery_ Text
pSuggester_ =
Suggest' :: Maybe Integer -> Text -> Text -> Suggest
Suggest'
{ $sel:size:Suggest' :: Maybe Integer
size = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
$sel:query:Suggest' :: Text
query = Text
pQuery_,
$sel:suggester:Suggest' :: Text
suggester = Text
pSuggester_
}
suggest_size :: Lens.Lens' Suggest (Prelude.Maybe Prelude.Integer)
suggest_size :: (Maybe Integer -> f (Maybe Integer)) -> Suggest -> f Suggest
suggest_size = (Suggest -> Maybe Integer)
-> (Suggest -> Maybe Integer -> Suggest)
-> Lens Suggest Suggest (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Suggest' {Maybe Integer
size :: Maybe Integer
$sel:size:Suggest' :: Suggest -> Maybe Integer
size} -> Maybe Integer
size) (\s :: Suggest
s@Suggest' {} Maybe Integer
a -> Suggest
s {$sel:size:Suggest' :: Maybe Integer
size = Maybe Integer
a} :: Suggest)
suggest_query :: Lens.Lens' Suggest Prelude.Text
suggest_query :: (Text -> f Text) -> Suggest -> f Suggest
suggest_query = (Suggest -> Text)
-> (Suggest -> Text -> Suggest) -> Lens Suggest Suggest Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Suggest' {Text
query :: Text
$sel:query:Suggest' :: Suggest -> Text
query} -> Text
query) (\s :: Suggest
s@Suggest' {} Text
a -> Suggest
s {$sel:query:Suggest' :: Text
query = Text
a} :: Suggest)
suggest_suggester :: Lens.Lens' Suggest Prelude.Text
suggest_suggester :: (Text -> f Text) -> Suggest -> f Suggest
suggest_suggester = (Suggest -> Text)
-> (Suggest -> Text -> Suggest) -> Lens Suggest Suggest Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Suggest' {Text
suggester :: Text
$sel:suggester:Suggest' :: Suggest -> Text
suggester} -> Text
suggester) (\s :: Suggest
s@Suggest' {} Text
a -> Suggest
s {$sel:suggester:Suggest' :: Text
suggester = Text
a} :: Suggest)
instance Core.AWSRequest Suggest where
type AWSResponse Suggest = SuggestResponse
request :: Suggest -> Request Suggest
request = Service -> Suggest -> Request Suggest
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
response :: Logger
-> Service
-> Proxy Suggest
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse Suggest)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse Suggest))
-> Logger
-> Service
-> Proxy Suggest
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse Suggest)))
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 SuggestModel -> Maybe SuggestStatus -> Int -> SuggestResponse
SuggestResponse'
(Maybe SuggestModel
-> Maybe SuggestStatus -> Int -> SuggestResponse)
-> Either String (Maybe SuggestModel)
-> Either String (Maybe SuggestStatus -> Int -> SuggestResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe SuggestModel)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"suggest")
Either String (Maybe SuggestStatus -> Int -> SuggestResponse)
-> Either String (Maybe SuggestStatus)
-> Either String (Int -> SuggestResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe SuggestStatus)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"status")
Either String (Int -> SuggestResponse)
-> Either String Int -> Either String SuggestResponse
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 Suggest
instance Prelude.NFData Suggest
instance Core.ToHeaders Suggest where
toHeaders :: Suggest -> ResponseHeaders
toHeaders =
ResponseHeaders -> Suggest -> 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.ToPath Suggest where
toPath :: Suggest -> ByteString
toPath = ByteString -> Suggest -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/2013-01-01/suggest"
instance Core.ToQuery Suggest where
toQuery :: Suggest -> QueryString
toQuery Suggest' {Maybe Integer
Text
suggester :: Text
query :: Text
size :: Maybe Integer
$sel:suggester:Suggest' :: Suggest -> Text
$sel:query:Suggest' :: Suggest -> Text
$sel:size:Suggest' :: Suggest -> Maybe Integer
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"size" ByteString -> Maybe Integer -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Integer
size,
ByteString
"q" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
query,
ByteString
"suggester" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
suggester,
QueryString
"format=sdk&pretty=true"
]
data SuggestResponse = SuggestResponse'
{
SuggestResponse -> Maybe SuggestModel
suggest :: Prelude.Maybe SuggestModel,
SuggestResponse -> Maybe SuggestStatus
status :: Prelude.Maybe SuggestStatus,
SuggestResponse -> Int
httpStatus :: Prelude.Int
}
deriving (SuggestResponse -> SuggestResponse -> Bool
(SuggestResponse -> SuggestResponse -> Bool)
-> (SuggestResponse -> SuggestResponse -> Bool)
-> Eq SuggestResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SuggestResponse -> SuggestResponse -> Bool
$c/= :: SuggestResponse -> SuggestResponse -> Bool
== :: SuggestResponse -> SuggestResponse -> Bool
$c== :: SuggestResponse -> SuggestResponse -> Bool
Prelude.Eq, ReadPrec [SuggestResponse]
ReadPrec SuggestResponse
Int -> ReadS SuggestResponse
ReadS [SuggestResponse]
(Int -> ReadS SuggestResponse)
-> ReadS [SuggestResponse]
-> ReadPrec SuggestResponse
-> ReadPrec [SuggestResponse]
-> Read SuggestResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SuggestResponse]
$creadListPrec :: ReadPrec [SuggestResponse]
readPrec :: ReadPrec SuggestResponse
$creadPrec :: ReadPrec SuggestResponse
readList :: ReadS [SuggestResponse]
$creadList :: ReadS [SuggestResponse]
readsPrec :: Int -> ReadS SuggestResponse
$creadsPrec :: Int -> ReadS SuggestResponse
Prelude.Read, Int -> SuggestResponse -> ShowS
[SuggestResponse] -> ShowS
SuggestResponse -> String
(Int -> SuggestResponse -> ShowS)
-> (SuggestResponse -> String)
-> ([SuggestResponse] -> ShowS)
-> Show SuggestResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SuggestResponse] -> ShowS
$cshowList :: [SuggestResponse] -> ShowS
show :: SuggestResponse -> String
$cshow :: SuggestResponse -> String
showsPrec :: Int -> SuggestResponse -> ShowS
$cshowsPrec :: Int -> SuggestResponse -> ShowS
Prelude.Show, (forall x. SuggestResponse -> Rep SuggestResponse x)
-> (forall x. Rep SuggestResponse x -> SuggestResponse)
-> Generic SuggestResponse
forall x. Rep SuggestResponse x -> SuggestResponse
forall x. SuggestResponse -> Rep SuggestResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SuggestResponse x -> SuggestResponse
$cfrom :: forall x. SuggestResponse -> Rep SuggestResponse x
Prelude.Generic)
newSuggestResponse ::
Prelude.Int ->
SuggestResponse
newSuggestResponse :: Int -> SuggestResponse
newSuggestResponse Int
pHttpStatus_ =
SuggestResponse' :: Maybe SuggestModel -> Maybe SuggestStatus -> Int -> SuggestResponse
SuggestResponse'
{ $sel:suggest:SuggestResponse' :: Maybe SuggestModel
suggest = Maybe SuggestModel
forall a. Maybe a
Prelude.Nothing,
$sel:status:SuggestResponse' :: Maybe SuggestStatus
status = Maybe SuggestStatus
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:SuggestResponse' :: Int
httpStatus = Int
pHttpStatus_
}
suggestResponse_suggest :: Lens.Lens' SuggestResponse (Prelude.Maybe SuggestModel)
suggestResponse_suggest :: (Maybe SuggestModel -> f (Maybe SuggestModel))
-> SuggestResponse -> f SuggestResponse
suggestResponse_suggest = (SuggestResponse -> Maybe SuggestModel)
-> (SuggestResponse -> Maybe SuggestModel -> SuggestResponse)
-> Lens
SuggestResponse
SuggestResponse
(Maybe SuggestModel)
(Maybe SuggestModel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuggestResponse' {Maybe SuggestModel
suggest :: Maybe SuggestModel
$sel:suggest:SuggestResponse' :: SuggestResponse -> Maybe SuggestModel
suggest} -> Maybe SuggestModel
suggest) (\s :: SuggestResponse
s@SuggestResponse' {} Maybe SuggestModel
a -> SuggestResponse
s {$sel:suggest:SuggestResponse' :: Maybe SuggestModel
suggest = Maybe SuggestModel
a} :: SuggestResponse)
suggestResponse_status :: Lens.Lens' SuggestResponse (Prelude.Maybe SuggestStatus)
suggestResponse_status :: (Maybe SuggestStatus -> f (Maybe SuggestStatus))
-> SuggestResponse -> f SuggestResponse
suggestResponse_status = (SuggestResponse -> Maybe SuggestStatus)
-> (SuggestResponse -> Maybe SuggestStatus -> SuggestResponse)
-> Lens
SuggestResponse
SuggestResponse
(Maybe SuggestStatus)
(Maybe SuggestStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuggestResponse' {Maybe SuggestStatus
status :: Maybe SuggestStatus
$sel:status:SuggestResponse' :: SuggestResponse -> Maybe SuggestStatus
status} -> Maybe SuggestStatus
status) (\s :: SuggestResponse
s@SuggestResponse' {} Maybe SuggestStatus
a -> SuggestResponse
s {$sel:status:SuggestResponse' :: Maybe SuggestStatus
status = Maybe SuggestStatus
a} :: SuggestResponse)
suggestResponse_httpStatus :: Lens.Lens' SuggestResponse Prelude.Int
suggestResponse_httpStatus :: (Int -> f Int) -> SuggestResponse -> f SuggestResponse
suggestResponse_httpStatus = (SuggestResponse -> Int)
-> (SuggestResponse -> Int -> SuggestResponse)
-> Lens SuggestResponse SuggestResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuggestResponse' {Int
httpStatus :: Int
$sel:httpStatus:SuggestResponse' :: SuggestResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: SuggestResponse
s@SuggestResponse' {} Int
a -> SuggestResponse
s {$sel:httpStatus:SuggestResponse' :: Int
httpStatus = Int
a} :: SuggestResponse)
instance Prelude.NFData SuggestResponse