{-# 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.LiteralArrayOptions
-- 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.LiteralArrayOptions 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 literal strings. Present
-- if @IndexFieldType@ specifies the field is of type @literal-array@. All
-- options are enabled by default.
--
-- /See:/ 'newLiteralArrayOptions' smart constructor.
data LiteralArrayOptions = LiteralArrayOptions'
  { -- | A list of source fields to map to the field.
    LiteralArrayOptions -> Maybe Text
sourceFields :: Prelude.Maybe Prelude.Text,
    -- | Whether the contents of the field can be returned in the search results.
    LiteralArrayOptions -> Maybe Bool
returnEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Whether facet information can be returned for the field.
    LiteralArrayOptions -> Maybe Bool
facetEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Whether the contents of the field are searchable.
    LiteralArrayOptions -> Maybe Bool
searchEnabled :: Prelude.Maybe Prelude.Bool,
    -- | A value to use for the field if the field isn\'t specified for a
    -- document.
    LiteralArrayOptions -> Maybe Text
defaultValue :: Prelude.Maybe Prelude.Text
  }
  deriving (LiteralArrayOptions -> LiteralArrayOptions -> Bool
(LiteralArrayOptions -> LiteralArrayOptions -> Bool)
-> (LiteralArrayOptions -> LiteralArrayOptions -> Bool)
-> Eq LiteralArrayOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LiteralArrayOptions -> LiteralArrayOptions -> Bool
$c/= :: LiteralArrayOptions -> LiteralArrayOptions -> Bool
== :: LiteralArrayOptions -> LiteralArrayOptions -> Bool
$c== :: LiteralArrayOptions -> LiteralArrayOptions -> Bool
Prelude.Eq, ReadPrec [LiteralArrayOptions]
ReadPrec LiteralArrayOptions
Int -> ReadS LiteralArrayOptions
ReadS [LiteralArrayOptions]
(Int -> ReadS LiteralArrayOptions)
-> ReadS [LiteralArrayOptions]
-> ReadPrec LiteralArrayOptions
-> ReadPrec [LiteralArrayOptions]
-> Read LiteralArrayOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LiteralArrayOptions]
$creadListPrec :: ReadPrec [LiteralArrayOptions]
readPrec :: ReadPrec LiteralArrayOptions
$creadPrec :: ReadPrec LiteralArrayOptions
readList :: ReadS [LiteralArrayOptions]
$creadList :: ReadS [LiteralArrayOptions]
readsPrec :: Int -> ReadS LiteralArrayOptions
$creadsPrec :: Int -> ReadS LiteralArrayOptions
Prelude.Read, Int -> LiteralArrayOptions -> ShowS
[LiteralArrayOptions] -> ShowS
LiteralArrayOptions -> String
(Int -> LiteralArrayOptions -> ShowS)
-> (LiteralArrayOptions -> String)
-> ([LiteralArrayOptions] -> ShowS)
-> Show LiteralArrayOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LiteralArrayOptions] -> ShowS
$cshowList :: [LiteralArrayOptions] -> ShowS
show :: LiteralArrayOptions -> String
$cshow :: LiteralArrayOptions -> String
showsPrec :: Int -> LiteralArrayOptions -> ShowS
$cshowsPrec :: Int -> LiteralArrayOptions -> ShowS
Prelude.Show, (forall x. LiteralArrayOptions -> Rep LiteralArrayOptions x)
-> (forall x. Rep LiteralArrayOptions x -> LiteralArrayOptions)
-> Generic LiteralArrayOptions
forall x. Rep LiteralArrayOptions x -> LiteralArrayOptions
forall x. LiteralArrayOptions -> Rep LiteralArrayOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LiteralArrayOptions x -> LiteralArrayOptions
$cfrom :: forall x. LiteralArrayOptions -> Rep LiteralArrayOptions x
Prelude.Generic)

-- |
-- Create a value of 'LiteralArrayOptions' 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', 'literalArrayOptions_sourceFields' - A list of source fields to map to the field.
--
-- 'returnEnabled', 'literalArrayOptions_returnEnabled' - Whether the contents of the field can be returned in the search results.
--
-- 'facetEnabled', 'literalArrayOptions_facetEnabled' - Whether facet information can be returned for the field.
--
-- 'searchEnabled', 'literalArrayOptions_searchEnabled' - Whether the contents of the field are searchable.
--
-- 'defaultValue', 'literalArrayOptions_defaultValue' - A value to use for the field if the field isn\'t specified for a
-- document.
newLiteralArrayOptions ::
  LiteralArrayOptions
newLiteralArrayOptions :: LiteralArrayOptions
newLiteralArrayOptions =
  LiteralArrayOptions' :: Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Text
-> LiteralArrayOptions
LiteralArrayOptions'
    { $sel:sourceFields:LiteralArrayOptions' :: Maybe Text
sourceFields =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:returnEnabled:LiteralArrayOptions' :: Maybe Bool
returnEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:facetEnabled:LiteralArrayOptions' :: Maybe Bool
facetEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:searchEnabled:LiteralArrayOptions' :: Maybe Bool
searchEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultValue:LiteralArrayOptions' :: Maybe Text
defaultValue = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

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

-- | Whether facet information can be returned for the field.
literalArrayOptions_facetEnabled :: Lens.Lens' LiteralArrayOptions (Prelude.Maybe Prelude.Bool)
literalArrayOptions_facetEnabled :: (Maybe Bool -> f (Maybe Bool))
-> LiteralArrayOptions -> f LiteralArrayOptions
literalArrayOptions_facetEnabled = (LiteralArrayOptions -> Maybe Bool)
-> (LiteralArrayOptions -> Maybe Bool -> LiteralArrayOptions)
-> Lens
     LiteralArrayOptions LiteralArrayOptions (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LiteralArrayOptions' {Maybe Bool
facetEnabled :: Maybe Bool
$sel:facetEnabled:LiteralArrayOptions' :: LiteralArrayOptions -> Maybe Bool
facetEnabled} -> Maybe Bool
facetEnabled) (\s :: LiteralArrayOptions
s@LiteralArrayOptions' {} Maybe Bool
a -> LiteralArrayOptions
s {$sel:facetEnabled:LiteralArrayOptions' :: Maybe Bool
facetEnabled = Maybe Bool
a} :: LiteralArrayOptions)

-- | Whether the contents of the field are searchable.
literalArrayOptions_searchEnabled :: Lens.Lens' LiteralArrayOptions (Prelude.Maybe Prelude.Bool)
literalArrayOptions_searchEnabled :: (Maybe Bool -> f (Maybe Bool))
-> LiteralArrayOptions -> f LiteralArrayOptions
literalArrayOptions_searchEnabled = (LiteralArrayOptions -> Maybe Bool)
-> (LiteralArrayOptions -> Maybe Bool -> LiteralArrayOptions)
-> Lens
     LiteralArrayOptions LiteralArrayOptions (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LiteralArrayOptions' {Maybe Bool
searchEnabled :: Maybe Bool
$sel:searchEnabled:LiteralArrayOptions' :: LiteralArrayOptions -> Maybe Bool
searchEnabled} -> Maybe Bool
searchEnabled) (\s :: LiteralArrayOptions
s@LiteralArrayOptions' {} Maybe Bool
a -> LiteralArrayOptions
s {$sel:searchEnabled:LiteralArrayOptions' :: Maybe Bool
searchEnabled = Maybe Bool
a} :: LiteralArrayOptions)

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

instance Core.FromXML LiteralArrayOptions where
  parseXML :: [Node] -> Either String LiteralArrayOptions
parseXML [Node]
x =
    Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Text
-> LiteralArrayOptions
LiteralArrayOptions'
      (Maybe Text
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Text
 -> LiteralArrayOptions)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Bool
      -> Maybe Bool -> Maybe Bool -> Maybe Text -> LiteralArrayOptions)
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 Bool -> Maybe Bool -> Maybe Text -> LiteralArrayOptions)
-> Either String (Maybe Bool)
-> Either
     String
     (Maybe Bool -> Maybe Bool -> Maybe Text -> LiteralArrayOptions)
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 Bool -> Maybe Bool -> Maybe Text -> LiteralArrayOptions)
-> Either String (Maybe Bool)
-> Either String (Maybe Bool -> Maybe Text -> LiteralArrayOptions)
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
"FacetEnabled")
      Either String (Maybe Bool -> Maybe Text -> LiteralArrayOptions)
-> Either String (Maybe Bool)
-> Either String (Maybe Text -> LiteralArrayOptions)
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
"SearchEnabled")
      Either String (Maybe Text -> LiteralArrayOptions)
-> Either String (Maybe Text) -> Either String LiteralArrayOptions
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 LiteralArrayOptions

instance Prelude.NFData LiteralArrayOptions

instance Core.ToQuery LiteralArrayOptions where
  toQuery :: LiteralArrayOptions -> QueryString
toQuery LiteralArrayOptions' {Maybe Bool
Maybe Text
defaultValue :: Maybe Text
searchEnabled :: Maybe Bool
facetEnabled :: Maybe Bool
returnEnabled :: Maybe Bool
sourceFields :: Maybe Text
$sel:defaultValue:LiteralArrayOptions' :: LiteralArrayOptions -> Maybe Text
$sel:searchEnabled:LiteralArrayOptions' :: LiteralArrayOptions -> Maybe Bool
$sel:facetEnabled:LiteralArrayOptions' :: LiteralArrayOptions -> Maybe Bool
$sel:returnEnabled:LiteralArrayOptions' :: LiteralArrayOptions -> Maybe Bool
$sel:sourceFields:LiteralArrayOptions' :: LiteralArrayOptions -> 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
"FacetEnabled" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
facetEnabled,
        ByteString
"SearchEnabled" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
searchEnabled,
        ByteString
"DefaultValue" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
defaultValue
      ]