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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | A list of source fields to map to the field.
    TextArrayOptions -> Maybe Text
sourceFields :: Prelude.Maybe Prelude.Text,
    -- | Whether the contents of the field can be returned in the search results.
    TextArrayOptions -> Maybe Bool
returnEnabled :: Prelude.Maybe Prelude.Bool,
    -- | The name of an analysis scheme for a @text-array@ field.
    TextArrayOptions -> Maybe Text
analysisScheme :: Prelude.Maybe Prelude.Text,
    -- | Whether highlights can be returned for the field.
    TextArrayOptions -> Maybe Bool
highlightEnabled :: Prelude.Maybe Prelude.Bool,
    -- | A value to use for the field if the field isn\'t specified for a
    -- document.
    TextArrayOptions -> Maybe Text
defaultValue :: Prelude.Maybe Prelude.Text
  }
  deriving (TextArrayOptions -> TextArrayOptions -> Bool
(TextArrayOptions -> TextArrayOptions -> Bool)
-> (TextArrayOptions -> TextArrayOptions -> Bool)
-> Eq TextArrayOptions
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]
(Int -> ReadS TextArrayOptions)
-> ReadS [TextArrayOptions]
-> ReadPrec TextArrayOptions
-> ReadPrec [TextArrayOptions]
-> Read 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
(Int -> TextArrayOptions -> ShowS)
-> (TextArrayOptions -> String)
-> ([TextArrayOptions] -> ShowS)
-> Show TextArrayOptions
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. TextArrayOptions -> Rep TextArrayOptions x)
-> (forall x. Rep TextArrayOptions x -> TextArrayOptions)
-> Generic TextArrayOptions
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:
--
-- 'sourceFields', 'textArrayOptions_sourceFields' - A list of source fields to map to the field.
--
-- 'returnEnabled', 'textArrayOptions_returnEnabled' - Whether the contents of the field can be returned in the search results.
--
-- 'analysisScheme', 'textArrayOptions_analysisScheme' - The name of an analysis scheme for a @text-array@ field.
--
-- 'highlightEnabled', 'textArrayOptions_highlightEnabled' - Whether highlights can be returned for the field.
--
-- 'defaultValue', 'textArrayOptions_defaultValue' - A value to use for the field if the field isn\'t specified for a
-- document.
newTextArrayOptions ::
  TextArrayOptions
newTextArrayOptions :: TextArrayOptions
newTextArrayOptions =
  TextArrayOptions' :: Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe Bool
-> Maybe Text
-> TextArrayOptions
TextArrayOptions'
    { $sel:sourceFields:TextArrayOptions' :: Maybe Text
sourceFields = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:returnEnabled:TextArrayOptions' :: Maybe Bool
returnEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:analysisScheme:TextArrayOptions' :: Maybe Text
analysisScheme = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:highlightEnabled:TextArrayOptions' :: Maybe Bool
highlightEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultValue:TextArrayOptions' :: Maybe Text
defaultValue = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A list of source fields to map to the field.
textArrayOptions_sourceFields :: Lens.Lens' TextArrayOptions (Prelude.Maybe Prelude.Text)
textArrayOptions_sourceFields :: (Maybe Text -> f (Maybe Text))
-> TextArrayOptions -> f TextArrayOptions
textArrayOptions_sourceFields = (TextArrayOptions -> Maybe Text)
-> (TextArrayOptions -> Maybe Text -> TextArrayOptions)
-> Lens TextArrayOptions TextArrayOptions (Maybe Text) (Maybe Text)
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)

-- | Whether the contents of the field can be returned in the search results.
textArrayOptions_returnEnabled :: Lens.Lens' TextArrayOptions (Prelude.Maybe Prelude.Bool)
textArrayOptions_returnEnabled :: (Maybe Bool -> f (Maybe Bool))
-> TextArrayOptions -> f TextArrayOptions
textArrayOptions_returnEnabled = (TextArrayOptions -> Maybe Bool)
-> (TextArrayOptions -> Maybe Bool -> TextArrayOptions)
-> Lens TextArrayOptions TextArrayOptions (Maybe Bool) (Maybe Bool)
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)

-- | The name of an analysis scheme for a @text-array@ field.
textArrayOptions_analysisScheme :: Lens.Lens' TextArrayOptions (Prelude.Maybe Prelude.Text)
textArrayOptions_analysisScheme :: (Maybe Text -> f (Maybe Text))
-> TextArrayOptions -> f TextArrayOptions
textArrayOptions_analysisScheme = (TextArrayOptions -> Maybe Text)
-> (TextArrayOptions -> Maybe Text -> TextArrayOptions)
-> Lens TextArrayOptions TextArrayOptions (Maybe Text) (Maybe Text)
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)

-- | Whether highlights can be returned for the field.
textArrayOptions_highlightEnabled :: Lens.Lens' TextArrayOptions (Prelude.Maybe Prelude.Bool)
textArrayOptions_highlightEnabled :: (Maybe Bool -> f (Maybe Bool))
-> TextArrayOptions -> f TextArrayOptions
textArrayOptions_highlightEnabled = (TextArrayOptions -> Maybe Bool)
-> (TextArrayOptions -> Maybe Bool -> TextArrayOptions)
-> Lens TextArrayOptions TextArrayOptions (Maybe Bool) (Maybe Bool)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> TextArrayOptions -> f TextArrayOptions
textArrayOptions_defaultValue = (TextArrayOptions -> Maybe Text)
-> (TextArrayOptions -> Maybe Text -> TextArrayOptions)
-> Lens TextArrayOptions TextArrayOptions (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable TextArrayOptions

instance Prelude.NFData TextArrayOptions

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