{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CloudSearchDomains.Types.SuggestModel
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CloudSearchDomains.Types.SuggestModel where

import Amazonka.CloudSearchDomains.Types.SuggestionMatch
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

-- | Container for the suggestion information returned in a
-- @SuggestResponse@.
--
-- /See:/ 'newSuggestModel' smart constructor.
data SuggestModel = SuggestModel'
  { -- | The number of documents that were found to match the query string.
    SuggestModel -> Maybe Integer
found :: Prelude.Maybe Prelude.Integer,
    -- | The query string specified in the suggest request.
    SuggestModel -> Maybe Text
query :: Prelude.Maybe Prelude.Text,
    -- | The documents that match the query string.
    SuggestModel -> Maybe [SuggestionMatch]
suggestions :: Prelude.Maybe [SuggestionMatch]
  }
  deriving (SuggestModel -> SuggestModel -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SuggestModel -> SuggestModel -> Bool
$c/= :: SuggestModel -> SuggestModel -> Bool
== :: SuggestModel -> SuggestModel -> Bool
$c== :: SuggestModel -> SuggestModel -> Bool
Prelude.Eq, ReadPrec [SuggestModel]
ReadPrec SuggestModel
Int -> ReadS SuggestModel
ReadS [SuggestModel]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SuggestModel]
$creadListPrec :: ReadPrec [SuggestModel]
readPrec :: ReadPrec SuggestModel
$creadPrec :: ReadPrec SuggestModel
readList :: ReadS [SuggestModel]
$creadList :: ReadS [SuggestModel]
readsPrec :: Int -> ReadS SuggestModel
$creadsPrec :: Int -> ReadS SuggestModel
Prelude.Read, Int -> SuggestModel -> ShowS
[SuggestModel] -> ShowS
SuggestModel -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SuggestModel] -> ShowS
$cshowList :: [SuggestModel] -> ShowS
show :: SuggestModel -> String
$cshow :: SuggestModel -> String
showsPrec :: Int -> SuggestModel -> ShowS
$cshowsPrec :: Int -> SuggestModel -> ShowS
Prelude.Show, forall x. Rep SuggestModel x -> SuggestModel
forall x. SuggestModel -> Rep SuggestModel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SuggestModel x -> SuggestModel
$cfrom :: forall x. SuggestModel -> Rep SuggestModel x
Prelude.Generic)

-- |
-- Create a value of 'SuggestModel' 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:
--
-- 'found', 'suggestModel_found' - The number of documents that were found to match the query string.
--
-- 'query', 'suggestModel_query' - The query string specified in the suggest request.
--
-- 'suggestions', 'suggestModel_suggestions' - The documents that match the query string.
newSuggestModel ::
  SuggestModel
newSuggestModel :: SuggestModel
newSuggestModel =
  SuggestModel'
    { $sel:found:SuggestModel' :: Maybe Integer
found = forall a. Maybe a
Prelude.Nothing,
      $sel:query:SuggestModel' :: Maybe Text
query = forall a. Maybe a
Prelude.Nothing,
      $sel:suggestions:SuggestModel' :: Maybe [SuggestionMatch]
suggestions = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of documents that were found to match the query string.
suggestModel_found :: Lens.Lens' SuggestModel (Prelude.Maybe Prelude.Integer)
suggestModel_found :: Lens' SuggestModel (Maybe Integer)
suggestModel_found = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuggestModel' {Maybe Integer
found :: Maybe Integer
$sel:found:SuggestModel' :: SuggestModel -> Maybe Integer
found} -> Maybe Integer
found) (\s :: SuggestModel
s@SuggestModel' {} Maybe Integer
a -> SuggestModel
s {$sel:found:SuggestModel' :: Maybe Integer
found = Maybe Integer
a} :: SuggestModel)

-- | The query string specified in the suggest request.
suggestModel_query :: Lens.Lens' SuggestModel (Prelude.Maybe Prelude.Text)
suggestModel_query :: Lens' SuggestModel (Maybe Text)
suggestModel_query = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuggestModel' {Maybe Text
query :: Maybe Text
$sel:query:SuggestModel' :: SuggestModel -> Maybe Text
query} -> Maybe Text
query) (\s :: SuggestModel
s@SuggestModel' {} Maybe Text
a -> SuggestModel
s {$sel:query:SuggestModel' :: Maybe Text
query = Maybe Text
a} :: SuggestModel)

-- | The documents that match the query string.
suggestModel_suggestions :: Lens.Lens' SuggestModel (Prelude.Maybe [SuggestionMatch])
suggestModel_suggestions :: Lens' SuggestModel (Maybe [SuggestionMatch])
suggestModel_suggestions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuggestModel' {Maybe [SuggestionMatch]
suggestions :: Maybe [SuggestionMatch]
$sel:suggestions:SuggestModel' :: SuggestModel -> Maybe [SuggestionMatch]
suggestions} -> Maybe [SuggestionMatch]
suggestions) (\s :: SuggestModel
s@SuggestModel' {} Maybe [SuggestionMatch]
a -> SuggestModel
s {$sel:suggestions:SuggestModel' :: Maybe [SuggestionMatch]
suggestions = Maybe [SuggestionMatch]
a} :: SuggestModel) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON SuggestModel where
  parseJSON :: Value -> Parser SuggestModel
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SuggestModel"
      ( \Object
x ->
          Maybe Integer
-> Maybe Text -> Maybe [SuggestionMatch] -> SuggestModel
SuggestModel'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"found")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"query")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"suggestions" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable SuggestModel where
  hashWithSalt :: Int -> SuggestModel -> Int
hashWithSalt Int
_salt SuggestModel' {Maybe Integer
Maybe [SuggestionMatch]
Maybe Text
suggestions :: Maybe [SuggestionMatch]
query :: Maybe Text
found :: Maybe Integer
$sel:suggestions:SuggestModel' :: SuggestModel -> Maybe [SuggestionMatch]
$sel:query:SuggestModel' :: SuggestModel -> Maybe Text
$sel:found:SuggestModel' :: SuggestModel -> Maybe Integer
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
found
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
query
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [SuggestionMatch]
suggestions

instance Prelude.NFData SuggestModel where
  rnf :: SuggestModel -> ()
rnf SuggestModel' {Maybe Integer
Maybe [SuggestionMatch]
Maybe Text
suggestions :: Maybe [SuggestionMatch]
query :: Maybe Text
found :: Maybe Integer
$sel:suggestions:SuggestModel' :: SuggestModel -> Maybe [SuggestionMatch]
$sel:query:SuggestModel' :: SuggestModel -> Maybe Text
$sel:found:SuggestModel' :: SuggestModel -> Maybe Integer
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
found
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
query
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [SuggestionMatch]
suggestions