{-# 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.CloudSearch.Types.TextArrayOptions
-- 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.CloudSearch.Types.TextArrayOptions 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

-- | Options for a field that contains an array of text strings. Present if
-- @IndexFieldType@ specifies the field is of type @text-array@. A
-- @text-array@ field is always searchable. All options are enabled by
-- default.
--
-- /See:/ 'newTextArrayOptions' smart constructor.
data TextArrayOptions = TextArrayOptions'
  { -- | The name of an analysis scheme for a @text-array@ field.
    TextArrayOptions -> Maybe Text
analysisScheme :: Prelude.Maybe Prelude.Text,
    -- | A value to use for the field if the field isn\'t specified for a
    -- document.
    TextArrayOptions -> Maybe Text
defaultValue :: Prelude.Maybe Prelude.Text,
    -- | Whether highlights can be returned for the field.
    TextArrayOptions -> Maybe Bool
highlightEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Whether the contents of the field can be returned in the search results.
    TextArrayOptions -> Maybe Bool
returnEnabled :: Prelude.Maybe Prelude.Bool,
    -- | A list of source fields to map to the field.
    TextArrayOptions -> Maybe Text
sourceFields :: Prelude.Maybe Prelude.Text
  }
  deriving (TextArrayOptions -> TextArrayOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TextArrayOptions -> TextArrayOptions -> Bool
$c/= :: TextArrayOptions -> TextArrayOptions -> Bool
== :: TextArrayOptions -> TextArrayOptions -> Bool
$c== :: TextArrayOptions -> TextArrayOptions -> Bool
Prelude.Eq, ReadPrec [TextArrayOptions]
ReadPrec TextArrayOptions
Int -> ReadS TextArrayOptions
ReadS [TextArrayOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TextArrayOptions]
$creadListPrec :: ReadPrec [TextArrayOptions]
readPrec :: ReadPrec TextArrayOptions
$creadPrec :: ReadPrec TextArrayOptions
readList :: ReadS [TextArrayOptions]
$creadList :: ReadS [TextArrayOptions]
readsPrec :: Int -> ReadS TextArrayOptions
$creadsPrec :: Int -> ReadS TextArrayOptions
Prelude.Read, Int -> TextArrayOptions -> ShowS
[TextArrayOptions] -> ShowS
TextArrayOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TextArrayOptions] -> ShowS
$cshowList :: [TextArrayOptions] -> ShowS
show :: TextArrayOptions -> String
$cshow :: TextArrayOptions -> String
showsPrec :: Int -> TextArrayOptions -> ShowS
$cshowsPrec :: Int -> TextArrayOptions -> ShowS
Prelude.Show, forall x. Rep TextArrayOptions x -> TextArrayOptions
forall x. TextArrayOptions -> Rep TextArrayOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TextArrayOptions x -> TextArrayOptions
$cfrom :: forall x. TextArrayOptions -> Rep TextArrayOptions x
Prelude.Generic)

-- |
-- Create a value of 'TextArrayOptions' 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:
--
-- 'analysisScheme', 'textArrayOptions_analysisScheme' - The name of an analysis scheme for a @text-array@ field.
--
-- 'defaultValue', 'textArrayOptions_defaultValue' - A value to use for the field if the field isn\'t specified for a
-- document.
--
-- 'highlightEnabled', 'textArrayOptions_highlightEnabled' - Whether highlights can be returned for the field.
--
-- 'returnEnabled', 'textArrayOptions_returnEnabled' - Whether the contents of the field can be returned in the search results.
--
-- 'sourceFields', 'textArrayOptions_sourceFields' - A list of source fields to map to the field.
newTextArrayOptions ::
  TextArrayOptions
newTextArrayOptions :: TextArrayOptions
newTextArrayOptions =
  TextArrayOptions'
    { $sel:analysisScheme:TextArrayOptions' :: Maybe Text
analysisScheme = forall a. Maybe a
Prelude.Nothing,
      $sel:defaultValue:TextArrayOptions' :: Maybe Text
defaultValue = forall a. Maybe a
Prelude.Nothing,
      $sel:highlightEnabled:TextArrayOptions' :: Maybe Bool
highlightEnabled = forall a. Maybe a
Prelude.Nothing,
      $sel:returnEnabled:TextArrayOptions' :: Maybe Bool
returnEnabled = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceFields:TextArrayOptions' :: Maybe Text
sourceFields = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of an analysis scheme for a @text-array@ field.
textArrayOptions_analysisScheme :: Lens.Lens' TextArrayOptions (Prelude.Maybe Prelude.Text)
textArrayOptions_analysisScheme :: Lens' TextArrayOptions (Maybe Text)
textArrayOptions_analysisScheme = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TextArrayOptions' {Maybe Text
analysisScheme :: Maybe Text
$sel:analysisScheme:TextArrayOptions' :: TextArrayOptions -> Maybe Text
analysisScheme} -> Maybe Text
analysisScheme) (\s :: TextArrayOptions
s@TextArrayOptions' {} Maybe Text
a -> TextArrayOptions
s {$sel:analysisScheme:TextArrayOptions' :: Maybe Text
analysisScheme = Maybe Text
a} :: TextArrayOptions)

-- | A value to use for the field if the field isn\'t specified for a
-- document.
textArrayOptions_defaultValue :: Lens.Lens' TextArrayOptions (Prelude.Maybe Prelude.Text)
textArrayOptions_defaultValue :: Lens' TextArrayOptions (Maybe Text)
textArrayOptions_defaultValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TextArrayOptions' {Maybe Text
defaultValue :: Maybe Text
$sel:defaultValue:TextArrayOptions' :: TextArrayOptions -> Maybe Text
defaultValue} -> Maybe Text
defaultValue) (\s :: TextArrayOptions
s@TextArrayOptions' {} Maybe Text
a -> TextArrayOptions
s {$sel:defaultValue:TextArrayOptions' :: Maybe Text
defaultValue = Maybe Text
a} :: TextArrayOptions)

-- | Whether highlights can be returned for the field.
textArrayOptions_highlightEnabled :: Lens.Lens' TextArrayOptions (Prelude.Maybe Prelude.Bool)
textArrayOptions_highlightEnabled :: Lens' TextArrayOptions (Maybe Bool)
textArrayOptions_highlightEnabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TextArrayOptions' {Maybe Bool
highlightEnabled :: Maybe Bool
$sel:highlightEnabled:TextArrayOptions' :: TextArrayOptions -> Maybe Bool
highlightEnabled} -> Maybe Bool
highlightEnabled) (\s :: TextArrayOptions
s@TextArrayOptions' {} Maybe Bool
a -> TextArrayOptions
s {$sel:highlightEnabled:TextArrayOptions' :: Maybe Bool
highlightEnabled = Maybe Bool
a} :: TextArrayOptions)

-- | Whether the contents of the field can be returned in the search results.
textArrayOptions_returnEnabled :: Lens.Lens' TextArrayOptions (Prelude.Maybe Prelude.Bool)
textArrayOptions_returnEnabled :: Lens' TextArrayOptions (Maybe Bool)
textArrayOptions_returnEnabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TextArrayOptions' {Maybe Bool
returnEnabled :: Maybe Bool
$sel:returnEnabled:TextArrayOptions' :: TextArrayOptions -> Maybe Bool
returnEnabled} -> Maybe Bool
returnEnabled) (\s :: TextArrayOptions
s@TextArrayOptions' {} Maybe Bool
a -> TextArrayOptions
s {$sel:returnEnabled:TextArrayOptions' :: Maybe Bool
returnEnabled = Maybe Bool
a} :: TextArrayOptions)

-- | A list of source fields to map to the field.
textArrayOptions_sourceFields :: Lens.Lens' TextArrayOptions (Prelude.Maybe Prelude.Text)
textArrayOptions_sourceFields :: Lens' TextArrayOptions (Maybe Text)
textArrayOptions_sourceFields = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TextArrayOptions' {Maybe Text
sourceFields :: Maybe Text
$sel:sourceFields:TextArrayOptions' :: TextArrayOptions -> Maybe Text
sourceFields} -> Maybe Text
sourceFields) (\s :: TextArrayOptions
s@TextArrayOptions' {} Maybe Text
a -> TextArrayOptions
s {$sel:sourceFields:TextArrayOptions' :: Maybe Text
sourceFields = Maybe Text
a} :: TextArrayOptions)

instance Data.FromXML TextArrayOptions where
  parseXML :: [Node] -> Either String TextArrayOptions
parseXML [Node]
x =
    Maybe Text
-> Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Maybe Text
-> TextArrayOptions
TextArrayOptions'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"AnalysisScheme")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"DefaultValue")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"HighlightEnabled")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ReturnEnabled")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"SourceFields")

instance Prelude.Hashable TextArrayOptions where
  hashWithSalt :: Int -> TextArrayOptions -> Int
hashWithSalt Int
_salt TextArrayOptions' {Maybe Bool
Maybe Text
sourceFields :: Maybe Text
returnEnabled :: Maybe Bool
highlightEnabled :: Maybe Bool
defaultValue :: Maybe Text
analysisScheme :: Maybe Text
$sel:sourceFields:TextArrayOptions' :: TextArrayOptions -> Maybe Text
$sel:returnEnabled:TextArrayOptions' :: TextArrayOptions -> Maybe Bool
$sel:highlightEnabled:TextArrayOptions' :: TextArrayOptions -> Maybe Bool
$sel:defaultValue:TextArrayOptions' :: TextArrayOptions -> Maybe Text
$sel:analysisScheme:TextArrayOptions' :: TextArrayOptions -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
analysisScheme
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
defaultValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
highlightEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
returnEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceFields

instance Prelude.NFData TextArrayOptions where
  rnf :: TextArrayOptions -> ()
rnf TextArrayOptions' {Maybe Bool
Maybe Text
sourceFields :: Maybe Text
returnEnabled :: Maybe Bool
highlightEnabled :: Maybe Bool
defaultValue :: Maybe Text
analysisScheme :: Maybe Text
$sel:sourceFields:TextArrayOptions' :: TextArrayOptions -> Maybe Text
$sel:returnEnabled:TextArrayOptions' :: TextArrayOptions -> Maybe Bool
$sel:highlightEnabled:TextArrayOptions' :: TextArrayOptions -> Maybe Bool
$sel:defaultValue:TextArrayOptions' :: TextArrayOptions -> Maybe Text
$sel:analysisScheme:TextArrayOptions' :: TextArrayOptions -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
analysisScheme
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
defaultValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
highlightEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
returnEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourceFields

instance Data.ToQuery TextArrayOptions where
  toQuery :: TextArrayOptions -> QueryString
toQuery TextArrayOptions' {Maybe Bool
Maybe Text
sourceFields :: Maybe Text
returnEnabled :: Maybe Bool
highlightEnabled :: Maybe Bool
defaultValue :: Maybe Text
analysisScheme :: Maybe Text
$sel:sourceFields:TextArrayOptions' :: TextArrayOptions -> Maybe Text
$sel:returnEnabled:TextArrayOptions' :: TextArrayOptions -> Maybe Bool
$sel:highlightEnabled:TextArrayOptions' :: TextArrayOptions -> Maybe Bool
$sel:defaultValue:TextArrayOptions' :: TextArrayOptions -> Maybe Text
$sel:analysisScheme:TextArrayOptions' :: TextArrayOptions -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"AnalysisScheme" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
analysisScheme,
        ByteString
"DefaultValue" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
defaultValue,
        ByteString
"HighlightEnabled" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
highlightEnabled,
        ByteString
"ReturnEnabled" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
returnEnabled,
        ByteString
"SourceFields" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
sourceFields
      ]