{-# 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.Wisdom.QueryAssistant
-- 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)
--
-- Performs a manual search against the specified assistant. To retrieve
-- recommendations for an assistant, use
-- <https://docs.aws.amazon.com/wisdom/latest/APIReference/API_GetRecommendations.html GetRecommendations>.
--
-- This operation returns paginated results.
module Amazonka.Wisdom.QueryAssistant
  ( -- * Creating a Request
    QueryAssistant (..),
    newQueryAssistant,

    -- * Request Lenses
    queryAssistant_nextToken,
    queryAssistant_maxResults,
    queryAssistant_assistantId,
    queryAssistant_queryText,

    -- * Destructuring the Response
    QueryAssistantResponse (..),
    newQueryAssistantResponse,

    -- * Response Lenses
    queryAssistantResponse_nextToken,
    queryAssistantResponse_httpStatus,
    queryAssistantResponse_results,
  )
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.Wisdom.Types

-- | /See:/ 'newQueryAssistant' smart constructor.
data QueryAssistant = QueryAssistant'
  { -- | The token for the next set of results. Use the value returned in the
    -- previous response in the next request to retrieve the next set of
    -- results.
    QueryAssistant -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return per page.
    QueryAssistant -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The identifier of the Wisdom assistant. Can be either the ID or the ARN.
    -- URLs cannot contain the ARN.
    QueryAssistant -> Text
assistantId :: Prelude.Text,
    -- | The text to search for.
    QueryAssistant -> Sensitive Text
queryText :: Core.Sensitive Prelude.Text
  }
  deriving (QueryAssistant -> QueryAssistant -> Bool
(QueryAssistant -> QueryAssistant -> Bool)
-> (QueryAssistant -> QueryAssistant -> Bool) -> Eq QueryAssistant
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QueryAssistant -> QueryAssistant -> Bool
$c/= :: QueryAssistant -> QueryAssistant -> Bool
== :: QueryAssistant -> QueryAssistant -> Bool
$c== :: QueryAssistant -> QueryAssistant -> Bool
Prelude.Eq, Int -> QueryAssistant -> ShowS
[QueryAssistant] -> ShowS
QueryAssistant -> String
(Int -> QueryAssistant -> ShowS)
-> (QueryAssistant -> String)
-> ([QueryAssistant] -> ShowS)
-> Show QueryAssistant
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [QueryAssistant] -> ShowS
$cshowList :: [QueryAssistant] -> ShowS
show :: QueryAssistant -> String
$cshow :: QueryAssistant -> String
showsPrec :: Int -> QueryAssistant -> ShowS
$cshowsPrec :: Int -> QueryAssistant -> ShowS
Prelude.Show, (forall x. QueryAssistant -> Rep QueryAssistant x)
-> (forall x. Rep QueryAssistant x -> QueryAssistant)
-> Generic QueryAssistant
forall x. Rep QueryAssistant x -> QueryAssistant
forall x. QueryAssistant -> Rep QueryAssistant x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep QueryAssistant x -> QueryAssistant
$cfrom :: forall x. QueryAssistant -> Rep QueryAssistant x
Prelude.Generic)

-- |
-- Create a value of 'QueryAssistant' 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', 'queryAssistant_nextToken' - The token for the next set of results. Use the value returned in the
-- previous response in the next request to retrieve the next set of
-- results.
--
-- 'maxResults', 'queryAssistant_maxResults' - The maximum number of results to return per page.
--
-- 'assistantId', 'queryAssistant_assistantId' - The identifier of the Wisdom assistant. Can be either the ID or the ARN.
-- URLs cannot contain the ARN.
--
-- 'queryText', 'queryAssistant_queryText' - The text to search for.
newQueryAssistant ::
  -- | 'assistantId'
  Prelude.Text ->
  -- | 'queryText'
  Prelude.Text ->
  QueryAssistant
newQueryAssistant :: Text -> Text -> QueryAssistant
newQueryAssistant Text
pAssistantId_ Text
pQueryText_ =
  QueryAssistant' :: Maybe Text
-> Maybe Natural -> Text -> Sensitive Text -> QueryAssistant
QueryAssistant'
    { $sel:nextToken:QueryAssistant' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:QueryAssistant' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:assistantId:QueryAssistant' :: Text
assistantId = Text
pAssistantId_,
      $sel:queryText:QueryAssistant' :: Sensitive Text
queryText = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pQueryText_
    }

-- | The token for the next set of results. Use the value returned in the
-- previous response in the next request to retrieve the next set of
-- results.
queryAssistant_nextToken :: Lens.Lens' QueryAssistant (Prelude.Maybe Prelude.Text)
queryAssistant_nextToken :: (Maybe Text -> f (Maybe Text))
-> QueryAssistant -> f QueryAssistant
queryAssistant_nextToken = (QueryAssistant -> Maybe Text)
-> (QueryAssistant -> Maybe Text -> QueryAssistant)
-> Lens QueryAssistant QueryAssistant (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryAssistant' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:QueryAssistant' :: QueryAssistant -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: QueryAssistant
s@QueryAssistant' {} Maybe Text
a -> QueryAssistant
s {$sel:nextToken:QueryAssistant' :: Maybe Text
nextToken = Maybe Text
a} :: QueryAssistant)

-- | The maximum number of results to return per page.
queryAssistant_maxResults :: Lens.Lens' QueryAssistant (Prelude.Maybe Prelude.Natural)
queryAssistant_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> QueryAssistant -> f QueryAssistant
queryAssistant_maxResults = (QueryAssistant -> Maybe Natural)
-> (QueryAssistant -> Maybe Natural -> QueryAssistant)
-> Lens
     QueryAssistant QueryAssistant (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryAssistant' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:QueryAssistant' :: QueryAssistant -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: QueryAssistant
s@QueryAssistant' {} Maybe Natural
a -> QueryAssistant
s {$sel:maxResults:QueryAssistant' :: Maybe Natural
maxResults = Maybe Natural
a} :: QueryAssistant)

-- | The identifier of the Wisdom assistant. Can be either the ID or the ARN.
-- URLs cannot contain the ARN.
queryAssistant_assistantId :: Lens.Lens' QueryAssistant Prelude.Text
queryAssistant_assistantId :: (Text -> f Text) -> QueryAssistant -> f QueryAssistant
queryAssistant_assistantId = (QueryAssistant -> Text)
-> (QueryAssistant -> Text -> QueryAssistant)
-> Lens QueryAssistant QueryAssistant Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryAssistant' {Text
assistantId :: Text
$sel:assistantId:QueryAssistant' :: QueryAssistant -> Text
assistantId} -> Text
assistantId) (\s :: QueryAssistant
s@QueryAssistant' {} Text
a -> QueryAssistant
s {$sel:assistantId:QueryAssistant' :: Text
assistantId = Text
a} :: QueryAssistant)

-- | The text to search for.
queryAssistant_queryText :: Lens.Lens' QueryAssistant Prelude.Text
queryAssistant_queryText :: (Text -> f Text) -> QueryAssistant -> f QueryAssistant
queryAssistant_queryText = (QueryAssistant -> Sensitive Text)
-> (QueryAssistant -> Sensitive Text -> QueryAssistant)
-> Lens
     QueryAssistant QueryAssistant (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryAssistant' {Sensitive Text
queryText :: Sensitive Text
$sel:queryText:QueryAssistant' :: QueryAssistant -> Sensitive Text
queryText} -> Sensitive Text
queryText) (\s :: QueryAssistant
s@QueryAssistant' {} Sensitive Text
a -> QueryAssistant
s {$sel:queryText:QueryAssistant' :: Sensitive Text
queryText = Sensitive Text
a} :: QueryAssistant) ((Sensitive Text -> f (Sensitive Text))
 -> QueryAssistant -> f QueryAssistant)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> QueryAssistant
-> f QueryAssistant
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

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

instance Prelude.Hashable QueryAssistant

instance Prelude.NFData QueryAssistant

instance Core.ToHeaders QueryAssistant where
  toHeaders :: QueryAssistant -> ResponseHeaders
toHeaders =
    ResponseHeaders -> QueryAssistant -> 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 QueryAssistant where
  toJSON :: QueryAssistant -> Value
toJSON QueryAssistant' {Maybe Natural
Maybe Text
Text
Sensitive Text
queryText :: Sensitive Text
assistantId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:queryText:QueryAssistant' :: QueryAssistant -> Sensitive Text
$sel:assistantId:QueryAssistant' :: QueryAssistant -> Text
$sel:maxResults:QueryAssistant' :: QueryAssistant -> Maybe Natural
$sel:nextToken:QueryAssistant' :: QueryAssistant -> 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
"queryText" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
queryText)
          ]
      )

instance Core.ToPath QueryAssistant where
  toPath :: QueryAssistant -> ByteString
toPath QueryAssistant' {Maybe Natural
Maybe Text
Text
Sensitive Text
queryText :: Sensitive Text
assistantId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:queryText:QueryAssistant' :: QueryAssistant -> Sensitive Text
$sel:assistantId:QueryAssistant' :: QueryAssistant -> Text
$sel:maxResults:QueryAssistant' :: QueryAssistant -> Maybe Natural
$sel:nextToken:QueryAssistant' :: QueryAssistant -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/assistants/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
assistantId, ByteString
"/query"]

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

-- | /See:/ 'newQueryAssistantResponse' smart constructor.
data QueryAssistantResponse = QueryAssistantResponse'
  { -- | If there are additional results, this is the token for the next set of
    -- results.
    QueryAssistantResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    QueryAssistantResponse -> Int
httpStatus :: Prelude.Int,
    -- | The results of the query.
    QueryAssistantResponse -> [ResultData]
results :: [ResultData]
  }
  deriving (QueryAssistantResponse -> QueryAssistantResponse -> Bool
(QueryAssistantResponse -> QueryAssistantResponse -> Bool)
-> (QueryAssistantResponse -> QueryAssistantResponse -> Bool)
-> Eq QueryAssistantResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QueryAssistantResponse -> QueryAssistantResponse -> Bool
$c/= :: QueryAssistantResponse -> QueryAssistantResponse -> Bool
== :: QueryAssistantResponse -> QueryAssistantResponse -> Bool
$c== :: QueryAssistantResponse -> QueryAssistantResponse -> Bool
Prelude.Eq, Int -> QueryAssistantResponse -> ShowS
[QueryAssistantResponse] -> ShowS
QueryAssistantResponse -> String
(Int -> QueryAssistantResponse -> ShowS)
-> (QueryAssistantResponse -> String)
-> ([QueryAssistantResponse] -> ShowS)
-> Show QueryAssistantResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [QueryAssistantResponse] -> ShowS
$cshowList :: [QueryAssistantResponse] -> ShowS
show :: QueryAssistantResponse -> String
$cshow :: QueryAssistantResponse -> String
showsPrec :: Int -> QueryAssistantResponse -> ShowS
$cshowsPrec :: Int -> QueryAssistantResponse -> ShowS
Prelude.Show, (forall x. QueryAssistantResponse -> Rep QueryAssistantResponse x)
-> (forall x.
    Rep QueryAssistantResponse x -> QueryAssistantResponse)
-> Generic QueryAssistantResponse
forall x. Rep QueryAssistantResponse x -> QueryAssistantResponse
forall x. QueryAssistantResponse -> Rep QueryAssistantResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep QueryAssistantResponse x -> QueryAssistantResponse
$cfrom :: forall x. QueryAssistantResponse -> Rep QueryAssistantResponse x
Prelude.Generic)

-- |
-- Create a value of 'QueryAssistantResponse' 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', 'queryAssistantResponse_nextToken' - If there are additional results, this is the token for the next set of
-- results.
--
-- 'httpStatus', 'queryAssistantResponse_httpStatus' - The response's http status code.
--
-- 'results', 'queryAssistantResponse_results' - The results of the query.
newQueryAssistantResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  QueryAssistantResponse
newQueryAssistantResponse :: Int -> QueryAssistantResponse
newQueryAssistantResponse Int
pHttpStatus_ =
  QueryAssistantResponse' :: Maybe Text -> Int -> [ResultData] -> QueryAssistantResponse
QueryAssistantResponse'
    { $sel:nextToken:QueryAssistantResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:QueryAssistantResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:results:QueryAssistantResponse' :: [ResultData]
results = [ResultData]
forall a. Monoid a => a
Prelude.mempty
    }

-- | If there are additional results, this is the token for the next set of
-- results.
queryAssistantResponse_nextToken :: Lens.Lens' QueryAssistantResponse (Prelude.Maybe Prelude.Text)
queryAssistantResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> QueryAssistantResponse -> f QueryAssistantResponse
queryAssistantResponse_nextToken = (QueryAssistantResponse -> Maybe Text)
-> (QueryAssistantResponse -> Maybe Text -> QueryAssistantResponse)
-> Lens' QueryAssistantResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryAssistantResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:QueryAssistantResponse' :: QueryAssistantResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: QueryAssistantResponse
s@QueryAssistantResponse' {} Maybe Text
a -> QueryAssistantResponse
s {$sel:nextToken:QueryAssistantResponse' :: Maybe Text
nextToken = Maybe Text
a} :: QueryAssistantResponse)

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

-- | The results of the query.
queryAssistantResponse_results :: Lens.Lens' QueryAssistantResponse [ResultData]
queryAssistantResponse_results :: ([ResultData] -> f [ResultData])
-> QueryAssistantResponse -> f QueryAssistantResponse
queryAssistantResponse_results = (QueryAssistantResponse -> [ResultData])
-> (QueryAssistantResponse
    -> [ResultData] -> QueryAssistantResponse)
-> Lens' QueryAssistantResponse [ResultData]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryAssistantResponse' {[ResultData]
results :: [ResultData]
$sel:results:QueryAssistantResponse' :: QueryAssistantResponse -> [ResultData]
results} -> [ResultData]
results) (\s :: QueryAssistantResponse
s@QueryAssistantResponse' {} [ResultData]
a -> QueryAssistantResponse
s {$sel:results:QueryAssistantResponse' :: [ResultData]
results = [ResultData]
a} :: QueryAssistantResponse) (([ResultData] -> f [ResultData])
 -> QueryAssistantResponse -> f QueryAssistantResponse)
-> (([ResultData] -> f [ResultData])
    -> [ResultData] -> f [ResultData])
-> ([ResultData] -> f [ResultData])
-> QueryAssistantResponse
-> f QueryAssistantResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ResultData] -> f [ResultData]) -> [ResultData] -> f [ResultData]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData QueryAssistantResponse