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

-- | Configuration of attachment settings for the Confluence data source.
-- Attachment settings are optional, if you don\'t specify settings
-- attachments, Amazon Kendra won\'t index them.
--
-- /See:/ 'newConfluenceAttachmentConfiguration' smart constructor.
data ConfluenceAttachmentConfiguration = ConfluenceAttachmentConfiguration'
  { -- | Maps attributes or field names of Confluence attachments to Amazon
    -- Kendra index field names. To create custom fields, use the @UpdateIndex@
    -- API before you map to Confluence fields. For more information, see
    -- <https://docs.aws.amazon.com/kendra/latest/dg/field-mapping.html Mapping data source fields>.
    -- The Confluence data source field names must exist in your Confluence
    -- custom metadata.
    --
    -- If you specify the @AttachentFieldMappings@ parameter, you must specify
    -- at least one field mapping.
    ConfluenceAttachmentConfiguration
-> Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
attachmentFieldMappings :: Prelude.Maybe (Prelude.NonEmpty ConfluenceAttachmentToIndexFieldMapping),
    -- | @TRUE@ to index attachments of pages and blogs in Confluence.
    ConfluenceAttachmentConfiguration -> Maybe Bool
crawlAttachments :: Prelude.Maybe Prelude.Bool
  }
  deriving (ConfluenceAttachmentConfiguration
-> ConfluenceAttachmentConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfluenceAttachmentConfiguration
-> ConfluenceAttachmentConfiguration -> Bool
$c/= :: ConfluenceAttachmentConfiguration
-> ConfluenceAttachmentConfiguration -> Bool
== :: ConfluenceAttachmentConfiguration
-> ConfluenceAttachmentConfiguration -> Bool
$c== :: ConfluenceAttachmentConfiguration
-> ConfluenceAttachmentConfiguration -> Bool
Prelude.Eq, ReadPrec [ConfluenceAttachmentConfiguration]
ReadPrec ConfluenceAttachmentConfiguration
Int -> ReadS ConfluenceAttachmentConfiguration
ReadS [ConfluenceAttachmentConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfluenceAttachmentConfiguration]
$creadListPrec :: ReadPrec [ConfluenceAttachmentConfiguration]
readPrec :: ReadPrec ConfluenceAttachmentConfiguration
$creadPrec :: ReadPrec ConfluenceAttachmentConfiguration
readList :: ReadS [ConfluenceAttachmentConfiguration]
$creadList :: ReadS [ConfluenceAttachmentConfiguration]
readsPrec :: Int -> ReadS ConfluenceAttachmentConfiguration
$creadsPrec :: Int -> ReadS ConfluenceAttachmentConfiguration
Prelude.Read, Int -> ConfluenceAttachmentConfiguration -> ShowS
[ConfluenceAttachmentConfiguration] -> ShowS
ConfluenceAttachmentConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfluenceAttachmentConfiguration] -> ShowS
$cshowList :: [ConfluenceAttachmentConfiguration] -> ShowS
show :: ConfluenceAttachmentConfiguration -> String
$cshow :: ConfluenceAttachmentConfiguration -> String
showsPrec :: Int -> ConfluenceAttachmentConfiguration -> ShowS
$cshowsPrec :: Int -> ConfluenceAttachmentConfiguration -> ShowS
Prelude.Show, forall x.
Rep ConfluenceAttachmentConfiguration x
-> ConfluenceAttachmentConfiguration
forall x.
ConfluenceAttachmentConfiguration
-> Rep ConfluenceAttachmentConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ConfluenceAttachmentConfiguration x
-> ConfluenceAttachmentConfiguration
$cfrom :: forall x.
ConfluenceAttachmentConfiguration
-> Rep ConfluenceAttachmentConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ConfluenceAttachmentConfiguration' 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:
--
-- 'attachmentFieldMappings', 'confluenceAttachmentConfiguration_attachmentFieldMappings' - Maps attributes or field names of Confluence attachments to Amazon
-- Kendra index field names. To create custom fields, use the @UpdateIndex@
-- API before you map to Confluence fields. For more information, see
-- <https://docs.aws.amazon.com/kendra/latest/dg/field-mapping.html Mapping data source fields>.
-- The Confluence data source field names must exist in your Confluence
-- custom metadata.
--
-- If you specify the @AttachentFieldMappings@ parameter, you must specify
-- at least one field mapping.
--
-- 'crawlAttachments', 'confluenceAttachmentConfiguration_crawlAttachments' - @TRUE@ to index attachments of pages and blogs in Confluence.
newConfluenceAttachmentConfiguration ::
  ConfluenceAttachmentConfiguration
newConfluenceAttachmentConfiguration :: ConfluenceAttachmentConfiguration
newConfluenceAttachmentConfiguration =
  ConfluenceAttachmentConfiguration'
    { $sel:attachmentFieldMappings:ConfluenceAttachmentConfiguration' :: Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
attachmentFieldMappings =
        forall a. Maybe a
Prelude.Nothing,
      $sel:crawlAttachments:ConfluenceAttachmentConfiguration' :: Maybe Bool
crawlAttachments = forall a. Maybe a
Prelude.Nothing
    }

-- | Maps attributes or field names of Confluence attachments to Amazon
-- Kendra index field names. To create custom fields, use the @UpdateIndex@
-- API before you map to Confluence fields. For more information, see
-- <https://docs.aws.amazon.com/kendra/latest/dg/field-mapping.html Mapping data source fields>.
-- The Confluence data source field names must exist in your Confluence
-- custom metadata.
--
-- If you specify the @AttachentFieldMappings@ parameter, you must specify
-- at least one field mapping.
confluenceAttachmentConfiguration_attachmentFieldMappings :: Lens.Lens' ConfluenceAttachmentConfiguration (Prelude.Maybe (Prelude.NonEmpty ConfluenceAttachmentToIndexFieldMapping))
confluenceAttachmentConfiguration_attachmentFieldMappings :: Lens'
  ConfluenceAttachmentConfiguration
  (Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping))
confluenceAttachmentConfiguration_attachmentFieldMappings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfluenceAttachmentConfiguration' {Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
attachmentFieldMappings :: Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
$sel:attachmentFieldMappings:ConfluenceAttachmentConfiguration' :: ConfluenceAttachmentConfiguration
-> Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
attachmentFieldMappings} -> Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
attachmentFieldMappings) (\s :: ConfluenceAttachmentConfiguration
s@ConfluenceAttachmentConfiguration' {} Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
a -> ConfluenceAttachmentConfiguration
s {$sel:attachmentFieldMappings:ConfluenceAttachmentConfiguration' :: Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
attachmentFieldMappings = Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
a} :: ConfluenceAttachmentConfiguration) 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

-- | @TRUE@ to index attachments of pages and blogs in Confluence.
confluenceAttachmentConfiguration_crawlAttachments :: Lens.Lens' ConfluenceAttachmentConfiguration (Prelude.Maybe Prelude.Bool)
confluenceAttachmentConfiguration_crawlAttachments :: Lens' ConfluenceAttachmentConfiguration (Maybe Bool)
confluenceAttachmentConfiguration_crawlAttachments = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfluenceAttachmentConfiguration' {Maybe Bool
crawlAttachments :: Maybe Bool
$sel:crawlAttachments:ConfluenceAttachmentConfiguration' :: ConfluenceAttachmentConfiguration -> Maybe Bool
crawlAttachments} -> Maybe Bool
crawlAttachments) (\s :: ConfluenceAttachmentConfiguration
s@ConfluenceAttachmentConfiguration' {} Maybe Bool
a -> ConfluenceAttachmentConfiguration
s {$sel:crawlAttachments:ConfluenceAttachmentConfiguration' :: Maybe Bool
crawlAttachments = Maybe Bool
a} :: ConfluenceAttachmentConfiguration)

instance
  Data.FromJSON
    ConfluenceAttachmentConfiguration
  where
  parseJSON :: Value -> Parser ConfluenceAttachmentConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ConfluenceAttachmentConfiguration"
      ( \Object
x ->
          Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
-> Maybe Bool -> ConfluenceAttachmentConfiguration
ConfluenceAttachmentConfiguration'
            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
"AttachmentFieldMappings")
            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
"CrawlAttachments")
      )

instance
  Prelude.Hashable
    ConfluenceAttachmentConfiguration
  where
  hashWithSalt :: Int -> ConfluenceAttachmentConfiguration -> Int
hashWithSalt
    Int
_salt
    ConfluenceAttachmentConfiguration' {Maybe Bool
Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
crawlAttachments :: Maybe Bool
attachmentFieldMappings :: Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
$sel:crawlAttachments:ConfluenceAttachmentConfiguration' :: ConfluenceAttachmentConfiguration -> Maybe Bool
$sel:attachmentFieldMappings:ConfluenceAttachmentConfiguration' :: ConfluenceAttachmentConfiguration
-> Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
attachmentFieldMappings
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
crawlAttachments

instance
  Prelude.NFData
    ConfluenceAttachmentConfiguration
  where
  rnf :: ConfluenceAttachmentConfiguration -> ()
rnf ConfluenceAttachmentConfiguration' {Maybe Bool
Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
crawlAttachments :: Maybe Bool
attachmentFieldMappings :: Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
$sel:crawlAttachments:ConfluenceAttachmentConfiguration' :: ConfluenceAttachmentConfiguration -> Maybe Bool
$sel:attachmentFieldMappings:ConfluenceAttachmentConfiguration' :: ConfluenceAttachmentConfiguration
-> Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
attachmentFieldMappings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
crawlAttachments

instance
  Data.ToJSON
    ConfluenceAttachmentConfiguration
  where
  toJSON :: ConfluenceAttachmentConfiguration -> Value
toJSON ConfluenceAttachmentConfiguration' {Maybe Bool
Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
crawlAttachments :: Maybe Bool
attachmentFieldMappings :: Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
$sel:crawlAttachments:ConfluenceAttachmentConfiguration' :: ConfluenceAttachmentConfiguration -> Maybe Bool
$sel:attachmentFieldMappings:ConfluenceAttachmentConfiguration' :: ConfluenceAttachmentConfiguration
-> Maybe (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AttachmentFieldMappings" 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 (NonEmpty ConfluenceAttachmentToIndexFieldMapping)
attachmentFieldMappings,
            (Key
"CrawlAttachments" 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 Bool
crawlAttachments
          ]
      )