{-# 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-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)
module Amazonka.LexModels.Types.KendraConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(KendraConfiguration -> KendraConfiguration -> Bool)
-> (KendraConfiguration -> KendraConfiguration -> Bool)
-> Eq KendraConfiguration
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]
(Int -> ReadS KendraConfiguration)
-> ReadS [KendraConfiguration]
-> ReadPrec KendraConfiguration
-> ReadPrec [KendraConfiguration]
-> Read 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
(Int -> KendraConfiguration -> ShowS)
-> (KendraConfiguration -> String)
-> ([KendraConfiguration] -> ShowS)
-> Show KendraConfiguration
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. KendraConfiguration -> Rep KendraConfiguration x)
-> (forall x. Rep KendraConfiguration x -> KendraConfiguration)
-> Generic KendraConfiguration
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' :: Maybe Text -> Text -> Text -> KendraConfiguration
KendraConfiguration'
    { $sel:queryFilterString:KendraConfiguration' :: Maybe Text
queryFilterString =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> KendraConfiguration -> f KendraConfiguration
kendraConfiguration_queryFilterString = (KendraConfiguration -> Maybe Text)
-> (KendraConfiguration -> Maybe Text -> KendraConfiguration)
-> Lens
     KendraConfiguration KendraConfiguration (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> KendraConfiguration -> f KendraConfiguration
kendraConfiguration_kendraIndex = (KendraConfiguration -> Text)
-> (KendraConfiguration -> Text -> KendraConfiguration)
-> Lens KendraConfiguration KendraConfiguration Text Text
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 :: (Text -> f Text) -> KendraConfiguration -> f KendraConfiguration
kendraConfiguration_role = (KendraConfiguration -> Text)
-> (KendraConfiguration -> Text -> KendraConfiguration)
-> Lens KendraConfiguration KendraConfiguration Text Text
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 Core.FromJSON KendraConfiguration where
  parseJSON :: Value -> Parser KendraConfiguration
parseJSON =
    String
-> (Object -> Parser KendraConfiguration)
-> Value
-> Parser KendraConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"KendraConfiguration"
      ( \Object
x ->
          Maybe Text -> Text -> Text -> KendraConfiguration
KendraConfiguration'
            (Maybe Text -> Text -> Text -> KendraConfiguration)
-> Parser (Maybe Text)
-> Parser (Text -> Text -> KendraConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"queryFilterString")
            Parser (Text -> Text -> KendraConfiguration)
-> Parser Text -> Parser (Text -> KendraConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"kendraIndex")
            Parser (Text -> KendraConfiguration)
-> Parser Text -> Parser KendraConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"role")
      )

instance Prelude.Hashable KendraConfiguration

instance Prelude.NFData KendraConfiguration

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"queryFilterString" 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
queryFilterString,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"kendraIndex" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
kendraIndex),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"role" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
role')
          ]
      )