{-# 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.TemplateConfiguration
-- 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.TemplateConfiguration 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.Template
import qualified Amazonka.Prelude as Prelude

-- | Provides a template for the configuration information to connect to your
-- data source.
--
-- /See:/ 'newTemplateConfiguration' smart constructor.
data TemplateConfiguration = TemplateConfiguration'
  { -- | The template schema used for the data source, where templates schemas
    -- are supported.
    --
    -- See
    -- <https://docs.aws.amazon.com/kendra/latest/dg/ds-schemas.html Data source template schemas>.
    TemplateConfiguration -> Maybe Template
template :: Prelude.Maybe Template
  }
  deriving (TemplateConfiguration -> TemplateConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TemplateConfiguration -> TemplateConfiguration -> Bool
$c/= :: TemplateConfiguration -> TemplateConfiguration -> Bool
== :: TemplateConfiguration -> TemplateConfiguration -> Bool
$c== :: TemplateConfiguration -> TemplateConfiguration -> Bool
Prelude.Eq, ReadPrec [TemplateConfiguration]
ReadPrec TemplateConfiguration
Int -> ReadS TemplateConfiguration
ReadS [TemplateConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TemplateConfiguration]
$creadListPrec :: ReadPrec [TemplateConfiguration]
readPrec :: ReadPrec TemplateConfiguration
$creadPrec :: ReadPrec TemplateConfiguration
readList :: ReadS [TemplateConfiguration]
$creadList :: ReadS [TemplateConfiguration]
readsPrec :: Int -> ReadS TemplateConfiguration
$creadsPrec :: Int -> ReadS TemplateConfiguration
Prelude.Read, Int -> TemplateConfiguration -> ShowS
[TemplateConfiguration] -> ShowS
TemplateConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TemplateConfiguration] -> ShowS
$cshowList :: [TemplateConfiguration] -> ShowS
show :: TemplateConfiguration -> String
$cshow :: TemplateConfiguration -> String
showsPrec :: Int -> TemplateConfiguration -> ShowS
$cshowsPrec :: Int -> TemplateConfiguration -> ShowS
Prelude.Show, forall x. Rep TemplateConfiguration x -> TemplateConfiguration
forall x. TemplateConfiguration -> Rep TemplateConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TemplateConfiguration x -> TemplateConfiguration
$cfrom :: forall x. TemplateConfiguration -> Rep TemplateConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'TemplateConfiguration' 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:
--
-- 'template', 'templateConfiguration_template' - The template schema used for the data source, where templates schemas
-- are supported.
--
-- See
-- <https://docs.aws.amazon.com/kendra/latest/dg/ds-schemas.html Data source template schemas>.
newTemplateConfiguration ::
  TemplateConfiguration
newTemplateConfiguration :: TemplateConfiguration
newTemplateConfiguration =
  TemplateConfiguration' {$sel:template:TemplateConfiguration' :: Maybe Template
template = forall a. Maybe a
Prelude.Nothing}

-- | The template schema used for the data source, where templates schemas
-- are supported.
--
-- See
-- <https://docs.aws.amazon.com/kendra/latest/dg/ds-schemas.html Data source template schemas>.
templateConfiguration_template :: Lens.Lens' TemplateConfiguration (Prelude.Maybe Template)
templateConfiguration_template :: Lens' TemplateConfiguration (Maybe Template)
templateConfiguration_template = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TemplateConfiguration' {Maybe Template
template :: Maybe Template
$sel:template:TemplateConfiguration' :: TemplateConfiguration -> Maybe Template
template} -> Maybe Template
template) (\s :: TemplateConfiguration
s@TemplateConfiguration' {} Maybe Template
a -> TemplateConfiguration
s {$sel:template:TemplateConfiguration' :: Maybe Template
template = Maybe Template
a} :: TemplateConfiguration)

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

instance Prelude.Hashable TemplateConfiguration where
  hashWithSalt :: Int -> TemplateConfiguration -> Int
hashWithSalt Int
_salt TemplateConfiguration' {Maybe Template
template :: Maybe Template
$sel:template:TemplateConfiguration' :: TemplateConfiguration -> Maybe Template
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Template
template

instance Prelude.NFData TemplateConfiguration where
  rnf :: TemplateConfiguration -> ()
rnf TemplateConfiguration' {Maybe Template
template :: Maybe Template
$sel:template:TemplateConfiguration' :: TemplateConfiguration -> Maybe Template
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Template
template

instance Data.ToJSON TemplateConfiguration where
  toJSON :: TemplateConfiguration -> Value
toJSON TemplateConfiguration' {Maybe Template
template :: Maybe Template
$sel:template:TemplateConfiguration' :: TemplateConfiguration -> Maybe Template
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"Template" 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 Template
template]
      )