{-# 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.Kendra.Types.Suggestion
-- 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.Kendra.Types.Suggestion where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Kendra.Types.SuggestionValue
import qualified Amazonka.Prelude as Prelude

-- | A single query suggestion.
--
-- /See:/ 'newSuggestion' smart constructor.
data Suggestion = Suggestion'
  { -- | The UUID (universally unique identifier) of a single query suggestion.
    Suggestion -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The value for the UUID (universally unique identifier) of a single query
    -- suggestion.
    --
    -- The value is the text string of a suggestion.
    Suggestion -> Maybe SuggestionValue
value :: Prelude.Maybe SuggestionValue
  }
  deriving (Suggestion -> Suggestion -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Suggestion -> Suggestion -> Bool
$c/= :: Suggestion -> Suggestion -> Bool
== :: Suggestion -> Suggestion -> Bool
$c== :: Suggestion -> Suggestion -> Bool
Prelude.Eq, ReadPrec [Suggestion]
ReadPrec Suggestion
Int -> ReadS Suggestion
ReadS [Suggestion]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Suggestion]
$creadListPrec :: ReadPrec [Suggestion]
readPrec :: ReadPrec Suggestion
$creadPrec :: ReadPrec Suggestion
readList :: ReadS [Suggestion]
$creadList :: ReadS [Suggestion]
readsPrec :: Int -> ReadS Suggestion
$creadsPrec :: Int -> ReadS Suggestion
Prelude.Read, Int -> Suggestion -> ShowS
[Suggestion] -> ShowS
Suggestion -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Suggestion] -> ShowS
$cshowList :: [Suggestion] -> ShowS
show :: Suggestion -> String
$cshow :: Suggestion -> String
showsPrec :: Int -> Suggestion -> ShowS
$cshowsPrec :: Int -> Suggestion -> ShowS
Prelude.Show, forall x. Rep Suggestion x -> Suggestion
forall x. Suggestion -> Rep Suggestion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Suggestion x -> Suggestion
$cfrom :: forall x. Suggestion -> Rep Suggestion x
Prelude.Generic)

-- |
-- Create a value of 'Suggestion' 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:
--
-- 'id', 'suggestion_id' - The UUID (universally unique identifier) of a single query suggestion.
--
-- 'value', 'suggestion_value' - The value for the UUID (universally unique identifier) of a single query
-- suggestion.
--
-- The value is the text string of a suggestion.
newSuggestion ::
  Suggestion
newSuggestion :: Suggestion
newSuggestion =
  Suggestion'
    { $sel:id:Suggestion' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:value:Suggestion' :: Maybe SuggestionValue
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The UUID (universally unique identifier) of a single query suggestion.
suggestion_id :: Lens.Lens' Suggestion (Prelude.Maybe Prelude.Text)
suggestion_id :: Lens' Suggestion (Maybe Text)
suggestion_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Suggestion' {Maybe Text
id :: Maybe Text
$sel:id:Suggestion' :: Suggestion -> Maybe Text
id} -> Maybe Text
id) (\s :: Suggestion
s@Suggestion' {} Maybe Text
a -> Suggestion
s {$sel:id:Suggestion' :: Maybe Text
id = Maybe Text
a} :: Suggestion)

-- | The value for the UUID (universally unique identifier) of a single query
-- suggestion.
--
-- The value is the text string of a suggestion.
suggestion_value :: Lens.Lens' Suggestion (Prelude.Maybe SuggestionValue)
suggestion_value :: Lens' Suggestion (Maybe SuggestionValue)
suggestion_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Suggestion' {Maybe SuggestionValue
value :: Maybe SuggestionValue
$sel:value:Suggestion' :: Suggestion -> Maybe SuggestionValue
value} -> Maybe SuggestionValue
value) (\s :: Suggestion
s@Suggestion' {} Maybe SuggestionValue
a -> Suggestion
s {$sel:value:Suggestion' :: Maybe SuggestionValue
value = Maybe SuggestionValue
a} :: Suggestion)

instance Data.FromJSON Suggestion where
  parseJSON :: Value -> Parser Suggestion
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Suggestion"
      ( \Object
x ->
          Maybe Text -> Maybe SuggestionValue -> Suggestion
Suggestion'
            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
"Id")
            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
"Value")
      )

instance Prelude.Hashable Suggestion where
  hashWithSalt :: Int -> Suggestion -> Int
hashWithSalt Int
_salt Suggestion' {Maybe Text
Maybe SuggestionValue
value :: Maybe SuggestionValue
id :: Maybe Text
$sel:value:Suggestion' :: Suggestion -> Maybe SuggestionValue
$sel:id:Suggestion' :: Suggestion -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SuggestionValue
value

instance Prelude.NFData Suggestion where
  rnf :: Suggestion -> ()
rnf Suggestion' {Maybe Text
Maybe SuggestionValue
value :: Maybe SuggestionValue
id :: Maybe Text
$sel:value:Suggestion' :: Suggestion -> Maybe SuggestionValue
$sel:id:Suggestion' :: Suggestion -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SuggestionValue
value