{-# 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.Wisdom.SearchSessions
(
SearchSessions (..),
newSearchSessions,
searchSessions_maxResults,
searchSessions_nextToken,
searchSessions_assistantId,
searchSessions_searchExpression,
SearchSessionsResponse (..),
newSearchSessionsResponse,
searchSessionsResponse_nextToken,
searchSessionsResponse_httpStatus,
searchSessionsResponse_sessionSummaries,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.Wisdom.Types
data SearchSessions = SearchSessions'
{
SearchSessions -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
SearchSessions -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
SearchSessions -> Text
assistantId :: Prelude.Text,
SearchSessions -> SearchExpression
searchExpression :: SearchExpression
}
deriving (SearchSessions -> SearchSessions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchSessions -> SearchSessions -> Bool
$c/= :: SearchSessions -> SearchSessions -> Bool
== :: SearchSessions -> SearchSessions -> Bool
$c== :: SearchSessions -> SearchSessions -> Bool
Prelude.Eq, ReadPrec [SearchSessions]
ReadPrec SearchSessions
Int -> ReadS SearchSessions
ReadS [SearchSessions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchSessions]
$creadListPrec :: ReadPrec [SearchSessions]
readPrec :: ReadPrec SearchSessions
$creadPrec :: ReadPrec SearchSessions
readList :: ReadS [SearchSessions]
$creadList :: ReadS [SearchSessions]
readsPrec :: Int -> ReadS SearchSessions
$creadsPrec :: Int -> ReadS SearchSessions
Prelude.Read, Int -> SearchSessions -> ShowS
[SearchSessions] -> ShowS
SearchSessions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchSessions] -> ShowS
$cshowList :: [SearchSessions] -> ShowS
show :: SearchSessions -> String
$cshow :: SearchSessions -> String
showsPrec :: Int -> SearchSessions -> ShowS
$cshowsPrec :: Int -> SearchSessions -> ShowS
Prelude.Show, forall x. Rep SearchSessions x -> SearchSessions
forall x. SearchSessions -> Rep SearchSessions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SearchSessions x -> SearchSessions
$cfrom :: forall x. SearchSessions -> Rep SearchSessions x
Prelude.Generic)
newSearchSessions ::
Prelude.Text ->
SearchExpression ->
SearchSessions
newSearchSessions :: Text -> SearchExpression -> SearchSessions
newSearchSessions Text
pAssistantId_ SearchExpression
pSearchExpression_ =
SearchSessions'
{ $sel:maxResults:SearchSessions' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
$sel:nextToken:SearchSessions' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
$sel:assistantId:SearchSessions' :: Text
assistantId = Text
pAssistantId_,
$sel:searchExpression:SearchSessions' :: SearchExpression
searchExpression = SearchExpression
pSearchExpression_
}
searchSessions_maxResults :: Lens.Lens' SearchSessions (Prelude.Maybe Prelude.Natural)
searchSessions_maxResults :: Lens' SearchSessions (Maybe Natural)
searchSessions_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchSessions' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:SearchSessions' :: SearchSessions -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: SearchSessions
s@SearchSessions' {} Maybe Natural
a -> SearchSessions
s {$sel:maxResults:SearchSessions' :: Maybe Natural
maxResults = Maybe Natural
a} :: SearchSessions)
searchSessions_nextToken :: Lens.Lens' SearchSessions (Prelude.Maybe Prelude.Text)
searchSessions_nextToken :: Lens' SearchSessions (Maybe Text)
searchSessions_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchSessions' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:SearchSessions' :: SearchSessions -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: SearchSessions
s@SearchSessions' {} Maybe Text
a -> SearchSessions
s {$sel:nextToken:SearchSessions' :: Maybe Text
nextToken = Maybe Text
a} :: SearchSessions)
searchSessions_assistantId :: Lens.Lens' SearchSessions Prelude.Text
searchSessions_assistantId :: Lens' SearchSessions Text
searchSessions_assistantId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchSessions' {Text
assistantId :: Text
$sel:assistantId:SearchSessions' :: SearchSessions -> Text
assistantId} -> Text
assistantId) (\s :: SearchSessions
s@SearchSessions' {} Text
a -> SearchSessions
s {$sel:assistantId:SearchSessions' :: Text
assistantId = Text
a} :: SearchSessions)
searchSessions_searchExpression :: Lens.Lens' SearchSessions SearchExpression
searchSessions_searchExpression :: Lens' SearchSessions SearchExpression
searchSessions_searchExpression = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchSessions' {SearchExpression
searchExpression :: SearchExpression
$sel:searchExpression:SearchSessions' :: SearchSessions -> SearchExpression
searchExpression} -> SearchExpression
searchExpression) (\s :: SearchSessions
s@SearchSessions' {} SearchExpression
a -> SearchSessions
s {$sel:searchExpression:SearchSessions' :: SearchExpression
searchExpression = SearchExpression
a} :: SearchSessions)
instance Core.AWSPager SearchSessions where
page :: SearchSessions
-> AWSResponse SearchSessions -> Maybe SearchSessions
page SearchSessions
rq AWSResponse SearchSessions
rs
| forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse SearchSessions
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' SearchSessionsResponse (Maybe Text)
searchSessionsResponse_nextToken
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
forall a. Maybe a
Prelude.Nothing
| forall a. AWSTruncated a => a -> Bool
Core.stop
(AWSResponse SearchSessions
rs forall s a. s -> Getting a s a -> a
Lens.^. Lens' SearchSessionsResponse [SessionSummary]
searchSessionsResponse_sessionSummaries) =
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
forall a. a -> Maybe a
Prelude.Just
forall a b. (a -> b) -> a -> b
Prelude.$ SearchSessions
rq
forall a b. a -> (a -> b) -> b
Prelude.& Lens' SearchSessions (Maybe Text)
searchSessions_nextToken
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse SearchSessions
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' SearchSessionsResponse (Maybe Text)
searchSessionsResponse_nextToken
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
instance Core.AWSRequest SearchSessions where
type
AWSResponse SearchSessions =
SearchSessionsResponse
request :: (Service -> Service) -> SearchSessions -> Request SearchSessions
request Service -> Service
overrides =
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy SearchSessions
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SearchSessions)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Text -> Int -> [SessionSummary] -> SearchSessionsResponse
SearchSessionsResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"nextToken")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"sessionSummaries"
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
)
)
instance Prelude.Hashable SearchSessions where
hashWithSalt :: Int -> SearchSessions -> Int
hashWithSalt Int
_salt SearchSessions' {Maybe Natural
Maybe Text
Text
SearchExpression
searchExpression :: SearchExpression
assistantId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:searchExpression:SearchSessions' :: SearchSessions -> SearchExpression
$sel:assistantId:SearchSessions' :: SearchSessions -> Text
$sel:nextToken:SearchSessions' :: SearchSessions -> Maybe Text
$sel:maxResults:SearchSessions' :: SearchSessions -> Maybe Natural
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
assistantId
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SearchExpression
searchExpression
instance Prelude.NFData SearchSessions where
rnf :: SearchSessions -> ()
rnf SearchSessions' {Maybe Natural
Maybe Text
Text
SearchExpression
searchExpression :: SearchExpression
assistantId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:searchExpression:SearchSessions' :: SearchSessions -> SearchExpression
$sel:assistantId:SearchSessions' :: SearchSessions -> Text
$sel:nextToken:SearchSessions' :: SearchSessions -> Maybe Text
$sel:maxResults:SearchSessions' :: SearchSessions -> Maybe Natural
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
assistantId
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf SearchExpression
searchExpression
instance Data.ToHeaders SearchSessions where
toHeaders :: SearchSessions -> ResponseHeaders
toHeaders =
forall a b. a -> b -> a
Prelude.const
( forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Content-Type"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON SearchSessions where
toJSON :: SearchSessions -> Value
toJSON SearchSessions' {Maybe Natural
Maybe Text
Text
SearchExpression
searchExpression :: SearchExpression
assistantId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:searchExpression:SearchSessions' :: SearchSessions -> SearchExpression
$sel:assistantId:SearchSessions' :: SearchSessions -> Text
$sel:nextToken:SearchSessions' :: SearchSessions -> Maybe Text
$sel:maxResults:SearchSessions' :: SearchSessions -> Maybe Natural
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ forall a. a -> Maybe a
Prelude.Just
(Key
"searchExpression" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= SearchExpression
searchExpression)
]
)
instance Data.ToPath SearchSessions where
toPath :: SearchSessions -> ByteString
toPath SearchSessions' {Maybe Natural
Maybe Text
Text
SearchExpression
searchExpression :: SearchExpression
assistantId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:searchExpression:SearchSessions' :: SearchSessions -> SearchExpression
$sel:assistantId:SearchSessions' :: SearchSessions -> Text
$sel:nextToken:SearchSessions' :: SearchSessions -> Maybe Text
$sel:maxResults:SearchSessions' :: SearchSessions -> Maybe Natural
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/assistants/",
forall a. ToByteString a => a -> ByteString
Data.toBS Text
assistantId,
ByteString
"/searchSessions"
]
instance Data.ToQuery SearchSessions where
toQuery :: SearchSessions -> QueryString
toQuery SearchSessions' {Maybe Natural
Maybe Text
Text
SearchExpression
searchExpression :: SearchExpression
assistantId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:searchExpression:SearchSessions' :: SearchSessions -> SearchExpression
$sel:assistantId:SearchSessions' :: SearchSessions -> Text
$sel:nextToken:SearchSessions' :: SearchSessions -> Maybe Text
$sel:maxResults:SearchSessions' :: SearchSessions -> Maybe Natural
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
]
data SearchSessionsResponse = SearchSessionsResponse'
{
SearchSessionsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
SearchSessionsResponse -> Int
httpStatus :: Prelude.Int,
SearchSessionsResponse -> [SessionSummary]
sessionSummaries :: [SessionSummary]
}
deriving (SearchSessionsResponse -> SearchSessionsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchSessionsResponse -> SearchSessionsResponse -> Bool
$c/= :: SearchSessionsResponse -> SearchSessionsResponse -> Bool
== :: SearchSessionsResponse -> SearchSessionsResponse -> Bool
$c== :: SearchSessionsResponse -> SearchSessionsResponse -> Bool
Prelude.Eq, ReadPrec [SearchSessionsResponse]
ReadPrec SearchSessionsResponse
Int -> ReadS SearchSessionsResponse
ReadS [SearchSessionsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchSessionsResponse]
$creadListPrec :: ReadPrec [SearchSessionsResponse]
readPrec :: ReadPrec SearchSessionsResponse
$creadPrec :: ReadPrec SearchSessionsResponse
readList :: ReadS [SearchSessionsResponse]
$creadList :: ReadS [SearchSessionsResponse]
readsPrec :: Int -> ReadS SearchSessionsResponse
$creadsPrec :: Int -> ReadS SearchSessionsResponse
Prelude.Read, Int -> SearchSessionsResponse -> ShowS
[SearchSessionsResponse] -> ShowS
SearchSessionsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchSessionsResponse] -> ShowS
$cshowList :: [SearchSessionsResponse] -> ShowS
show :: SearchSessionsResponse -> String
$cshow :: SearchSessionsResponse -> String
showsPrec :: Int -> SearchSessionsResponse -> ShowS
$cshowsPrec :: Int -> SearchSessionsResponse -> ShowS
Prelude.Show, forall x. Rep SearchSessionsResponse x -> SearchSessionsResponse
forall x. SearchSessionsResponse -> Rep SearchSessionsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SearchSessionsResponse x -> SearchSessionsResponse
$cfrom :: forall x. SearchSessionsResponse -> Rep SearchSessionsResponse x
Prelude.Generic)
newSearchSessionsResponse ::
Prelude.Int ->
SearchSessionsResponse
newSearchSessionsResponse :: Int -> SearchSessionsResponse
newSearchSessionsResponse Int
pHttpStatus_ =
SearchSessionsResponse'
{ $sel:nextToken:SearchSessionsResponse' :: Maybe Text
nextToken =
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:SearchSessionsResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:sessionSummaries:SearchSessionsResponse' :: [SessionSummary]
sessionSummaries = forall a. Monoid a => a
Prelude.mempty
}
searchSessionsResponse_nextToken :: Lens.Lens' SearchSessionsResponse (Prelude.Maybe Prelude.Text)
searchSessionsResponse_nextToken :: Lens' SearchSessionsResponse (Maybe Text)
searchSessionsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchSessionsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:SearchSessionsResponse' :: SearchSessionsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: SearchSessionsResponse
s@SearchSessionsResponse' {} Maybe Text
a -> SearchSessionsResponse
s {$sel:nextToken:SearchSessionsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: SearchSessionsResponse)
searchSessionsResponse_httpStatus :: Lens.Lens' SearchSessionsResponse Prelude.Int
searchSessionsResponse_httpStatus :: Lens' SearchSessionsResponse Int
searchSessionsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchSessionsResponse' {Int
httpStatus :: Int
$sel:httpStatus:SearchSessionsResponse' :: SearchSessionsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: SearchSessionsResponse
s@SearchSessionsResponse' {} Int
a -> SearchSessionsResponse
s {$sel:httpStatus:SearchSessionsResponse' :: Int
httpStatus = Int
a} :: SearchSessionsResponse)
searchSessionsResponse_sessionSummaries :: Lens.Lens' SearchSessionsResponse [SessionSummary]
searchSessionsResponse_sessionSummaries :: Lens' SearchSessionsResponse [SessionSummary]
searchSessionsResponse_sessionSummaries = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchSessionsResponse' {[SessionSummary]
sessionSummaries :: [SessionSummary]
$sel:sessionSummaries:SearchSessionsResponse' :: SearchSessionsResponse -> [SessionSummary]
sessionSummaries} -> [SessionSummary]
sessionSummaries) (\s :: SearchSessionsResponse
s@SearchSessionsResponse' {} [SessionSummary]
a -> SearchSessionsResponse
s {$sel:sessionSummaries:SearchSessionsResponse' :: [SessionSummary]
sessionSummaries = [SessionSummary]
a} :: SearchSessionsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Prelude.NFData SearchSessionsResponse where
rnf :: SearchSessionsResponse -> ()
rnf SearchSessionsResponse' {Int
[SessionSummary]
Maybe Text
sessionSummaries :: [SessionSummary]
httpStatus :: Int
nextToken :: Maybe Text
$sel:sessionSummaries:SearchSessionsResponse' :: SearchSessionsResponse -> [SessionSummary]
$sel:httpStatus:SearchSessionsResponse' :: SearchSessionsResponse -> Int
$sel:nextToken:SearchSessionsResponse' :: SearchSessionsResponse -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [SessionSummary]
sessionSummaries