{-# 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.LexModels.Types.KendraConfiguration
-- 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.LexModels.Types.KendraConfiguration 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

-- | Provides configuration information for the AMAZON.KendraSearchIntent
-- intent. When you use this intent, Amazon Lex searches the specified
-- Amazon Kendra index and returns documents from the index that match the
-- user\'s utterance. For more information, see
-- <http://docs.aws.amazon.com/lex/latest/dg/built-in-intent-kendra-search.html AMAZON.KendraSearchIntent>.
--
-- /See:/ 'newKendraConfiguration' smart constructor.
data KendraConfiguration = KendraConfiguration'
  { -- | A query filter that Amazon Lex sends to Amazon Kendra to filter the
    -- response from the query. The filter is in the format defined by Amazon
    -- Kendra. For more information, see
    -- <http://docs.aws.amazon.com/kendra/latest/dg/filtering.html Filtering queries>.
    --
    -- You can override this filter string with a new filter string at runtime.
    KendraConfiguration -> Maybe Text
queryFilterString :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the Amazon Kendra index that you want
    -- the AMAZON.KendraSearchIntent intent to search. The index must be in the
    -- same account and Region as the Amazon Lex bot. If the Amazon Kendra
    -- index does not exist, you get an exception when you call the @PutIntent@
    -- operation.
    KendraConfiguration -> Text
kendraIndex :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of an IAM role that has permission to
    -- search the Amazon Kendra index. The role must be in the same account and
    -- Region as the Amazon Lex bot. If the role does not exist, you get an
    -- exception when you call the @PutIntent@ operation.
    KendraConfiguration -> Text
role' :: Prelude.Text
  }
  deriving (KendraConfiguration -> KendraConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KendraConfiguration -> KendraConfiguration -> Bool
$c/= :: KendraConfiguration -> KendraConfiguration -> Bool
== :: KendraConfiguration -> KendraConfiguration -> Bool
$c== :: KendraConfiguration -> KendraConfiguration -> Bool
Prelude.Eq, ReadPrec [KendraConfiguration]
ReadPrec KendraConfiguration
Int -> ReadS KendraConfiguration
ReadS [KendraConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KendraConfiguration]
$creadListPrec :: ReadPrec [KendraConfiguration]
readPrec :: ReadPrec KendraConfiguration
$creadPrec :: ReadPrec KendraConfiguration
readList :: ReadS [KendraConfiguration]
$creadList :: ReadS [KendraConfiguration]
readsPrec :: Int -> ReadS KendraConfiguration
$creadsPrec :: Int -> ReadS KendraConfiguration
Prelude.Read, Int -> KendraConfiguration -> ShowS
[KendraConfiguration] -> ShowS
KendraConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KendraConfiguration] -> ShowS
$cshowList :: [KendraConfiguration] -> ShowS
show :: KendraConfiguration -> String
$cshow :: KendraConfiguration -> String
showsPrec :: Int -> KendraConfiguration -> ShowS
$cshowsPrec :: Int -> KendraConfiguration -> ShowS
Prelude.Show, forall x. Rep KendraConfiguration x -> KendraConfiguration
forall x. KendraConfiguration -> Rep KendraConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep KendraConfiguration x -> KendraConfiguration
$cfrom :: forall x. KendraConfiguration -> Rep KendraConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'KendraConfiguration' 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:
--
-- 'queryFilterString', 'kendraConfiguration_queryFilterString' - A query filter that Amazon Lex sends to Amazon Kendra to filter the
-- response from the query. The filter is in the format defined by Amazon
-- Kendra. For more information, see
-- <http://docs.aws.amazon.com/kendra/latest/dg/filtering.html Filtering queries>.
--
-- You can override this filter string with a new filter string at runtime.
--
-- 'kendraIndex', 'kendraConfiguration_kendraIndex' - The Amazon Resource Name (ARN) of the Amazon Kendra index that you want
-- the AMAZON.KendraSearchIntent intent to search. The index must be in the
-- same account and Region as the Amazon Lex bot. If the Amazon Kendra
-- index does not exist, you get an exception when you call the @PutIntent@
-- operation.
--
-- 'role'', 'kendraConfiguration_role' - The Amazon Resource Name (ARN) of an IAM role that has permission to
-- search the Amazon Kendra index. The role must be in the same account and
-- Region as the Amazon Lex bot. If the role does not exist, you get an
-- exception when you call the @PutIntent@ operation.
newKendraConfiguration ::
  -- | 'kendraIndex'
  Prelude.Text ->
  -- | 'role''
  Prelude.Text ->
  KendraConfiguration
newKendraConfiguration :: Text -> Text -> KendraConfiguration
newKendraConfiguration Text
pKendraIndex_ Text
pRole_ =
  KendraConfiguration'
    { $sel:queryFilterString:KendraConfiguration' :: Maybe Text
queryFilterString =
        forall a. Maybe a
Prelude.Nothing,
      $sel:kendraIndex:KendraConfiguration' :: Text
kendraIndex = Text
pKendraIndex_,
      $sel:role':KendraConfiguration' :: Text
role' = Text
pRole_
    }

-- | A query filter that Amazon Lex sends to Amazon Kendra to filter the
-- response from the query. The filter is in the format defined by Amazon
-- Kendra. For more information, see
-- <http://docs.aws.amazon.com/kendra/latest/dg/filtering.html Filtering queries>.
--
-- You can override this filter string with a new filter string at runtime.
kendraConfiguration_queryFilterString :: Lens.Lens' KendraConfiguration (Prelude.Maybe Prelude.Text)
kendraConfiguration_queryFilterString :: Lens' KendraConfiguration (Maybe Text)
kendraConfiguration_queryFilterString = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KendraConfiguration' {Maybe Text
queryFilterString :: Maybe Text
$sel:queryFilterString:KendraConfiguration' :: KendraConfiguration -> Maybe Text
queryFilterString} -> Maybe Text
queryFilterString) (\s :: KendraConfiguration
s@KendraConfiguration' {} Maybe Text
a -> KendraConfiguration
s {$sel:queryFilterString:KendraConfiguration' :: Maybe Text
queryFilterString = Maybe Text
a} :: KendraConfiguration)

-- | The Amazon Resource Name (ARN) of the Amazon Kendra index that you want
-- the AMAZON.KendraSearchIntent intent to search. The index must be in the
-- same account and Region as the Amazon Lex bot. If the Amazon Kendra
-- index does not exist, you get an exception when you call the @PutIntent@
-- operation.
kendraConfiguration_kendraIndex :: Lens.Lens' KendraConfiguration Prelude.Text
kendraConfiguration_kendraIndex :: Lens' KendraConfiguration Text
kendraConfiguration_kendraIndex = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KendraConfiguration' {Text
kendraIndex :: Text
$sel:kendraIndex:KendraConfiguration' :: KendraConfiguration -> Text
kendraIndex} -> Text
kendraIndex) (\s :: KendraConfiguration
s@KendraConfiguration' {} Text
a -> KendraConfiguration
s {$sel:kendraIndex:KendraConfiguration' :: Text
kendraIndex = Text
a} :: KendraConfiguration)

-- | The Amazon Resource Name (ARN) of an IAM role that has permission to
-- search the Amazon Kendra index. The role must be in the same account and
-- Region as the Amazon Lex bot. If the role does not exist, you get an
-- exception when you call the @PutIntent@ operation.
kendraConfiguration_role :: Lens.Lens' KendraConfiguration Prelude.Text
kendraConfiguration_role :: Lens' KendraConfiguration Text
kendraConfiguration_role = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KendraConfiguration' {Text
role' :: Text
$sel:role':KendraConfiguration' :: KendraConfiguration -> Text
role'} -> Text
role') (\s :: KendraConfiguration
s@KendraConfiguration' {} Text
a -> KendraConfiguration
s {$sel:role':KendraConfiguration' :: Text
role' = Text
a} :: KendraConfiguration)

instance Data.FromJSON KendraConfiguration where
  parseJSON :: Value -> Parser KendraConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"KendraConfiguration"
      ( \Object
x ->
          Maybe Text -> Text -> Text -> KendraConfiguration
KendraConfiguration'
            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
"queryFilterString")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"kendraIndex")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"role")
      )

instance Prelude.Hashable KendraConfiguration where
  hashWithSalt :: Int -> KendraConfiguration -> Int
hashWithSalt Int
_salt KendraConfiguration' {Maybe Text
Text
role' :: Text
kendraIndex :: Text
queryFilterString :: Maybe Text
$sel:role':KendraConfiguration' :: KendraConfiguration -> Text
$sel:kendraIndex:KendraConfiguration' :: KendraConfiguration -> Text
$sel:queryFilterString:KendraConfiguration' :: KendraConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
queryFilterString
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
kendraIndex
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
role'

instance Prelude.NFData KendraConfiguration where
  rnf :: KendraConfiguration -> ()
rnf KendraConfiguration' {Maybe Text
Text
role' :: Text
kendraIndex :: Text
queryFilterString :: Maybe Text
$sel:role':KendraConfiguration' :: KendraConfiguration -> Text
$sel:kendraIndex:KendraConfiguration' :: KendraConfiguration -> Text
$sel:queryFilterString:KendraConfiguration' :: KendraConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
queryFilterString
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
kendraIndex
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
role'

instance Data.ToJSON KendraConfiguration where
  toJSON :: KendraConfiguration -> Value
toJSON KendraConfiguration' {Maybe Text
Text
role' :: Text
kendraIndex :: Text
queryFilterString :: Maybe Text
$sel:role':KendraConfiguration' :: KendraConfiguration -> Text
$sel:kendraIndex:KendraConfiguration' :: KendraConfiguration -> Text
$sel:queryFilterString:KendraConfiguration' :: KendraConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"queryFilterString" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
queryFilterString,
            forall a. a -> Maybe a
Prelude.Just (Key
"kendraIndex" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
kendraIndex),
            forall a. a -> Maybe a
Prelude.Just (Key
"role" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
role')
          ]
      )