{-# 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.LiteralOptions
-- 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.LiteralOptions where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

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

-- |
-- Create a value of 'LiteralOptions' 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:
--
-- 'sourceField', 'literalOptions_sourceField' - Undocumented member.
--
-- 'returnEnabled', 'literalOptions_returnEnabled' - Whether the contents of the field can be returned in the search results.
--
-- 'facetEnabled', 'literalOptions_facetEnabled' - Whether facet information can be returned for the field.
--
-- 'searchEnabled', 'literalOptions_searchEnabled' - Whether the contents of the field are searchable.
--
-- 'sortEnabled', 'literalOptions_sortEnabled' - Whether the field can be used to sort the search results.
--
-- 'defaultValue', 'literalOptions_defaultValue' - A value to use for the field if the field isn\'t specified for a
-- document.
newLiteralOptions ::
  LiteralOptions
newLiteralOptions :: LiteralOptions
newLiteralOptions =
  LiteralOptions' :: Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Text
-> LiteralOptions
LiteralOptions'
    { $sel:sourceField:LiteralOptions' :: Maybe Text
sourceField = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:returnEnabled:LiteralOptions' :: Maybe Bool
returnEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:facetEnabled:LiteralOptions' :: Maybe Bool
facetEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:searchEnabled:LiteralOptions' :: Maybe Bool
searchEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:sortEnabled:LiteralOptions' :: Maybe Bool
sortEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultValue:LiteralOptions' :: Maybe Text
defaultValue = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
literalOptions_sourceField :: Lens.Lens' LiteralOptions (Prelude.Maybe Prelude.Text)
literalOptions_sourceField :: (Maybe Text -> f (Maybe Text))
-> LiteralOptions -> f LiteralOptions
literalOptions_sourceField = (LiteralOptions -> Maybe Text)
-> (LiteralOptions -> Maybe Text -> LiteralOptions)
-> Lens LiteralOptions LiteralOptions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LiteralOptions' {Maybe Text
sourceField :: Maybe Text
$sel:sourceField:LiteralOptions' :: LiteralOptions -> Maybe Text
sourceField} -> Maybe Text
sourceField) (\s :: LiteralOptions
s@LiteralOptions' {} Maybe Text
a -> LiteralOptions
s {$sel:sourceField:LiteralOptions' :: Maybe Text
sourceField = Maybe Text
a} :: LiteralOptions)

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

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

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

-- | Whether the field can be used to sort the search results.
literalOptions_sortEnabled :: Lens.Lens' LiteralOptions (Prelude.Maybe Prelude.Bool)
literalOptions_sortEnabled :: (Maybe Bool -> f (Maybe Bool))
-> LiteralOptions -> f LiteralOptions
literalOptions_sortEnabled = (LiteralOptions -> Maybe Bool)
-> (LiteralOptions -> Maybe Bool -> LiteralOptions)
-> Lens LiteralOptions LiteralOptions (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LiteralOptions' {Maybe Bool
sortEnabled :: Maybe Bool
$sel:sortEnabled:LiteralOptions' :: LiteralOptions -> Maybe Bool
sortEnabled} -> Maybe Bool
sortEnabled) (\s :: LiteralOptions
s@LiteralOptions' {} Maybe Bool
a -> LiteralOptions
s {$sel:sortEnabled:LiteralOptions' :: Maybe Bool
sortEnabled = Maybe Bool
a} :: LiteralOptions)

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

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

instance Prelude.NFData LiteralOptions

instance Core.ToQuery LiteralOptions where
  toQuery :: LiteralOptions -> QueryString
toQuery LiteralOptions' {Maybe Bool
Maybe Text
defaultValue :: Maybe Text
sortEnabled :: Maybe Bool
searchEnabled :: Maybe Bool
facetEnabled :: Maybe Bool
returnEnabled :: Maybe Bool
sourceField :: Maybe Text
$sel:defaultValue:LiteralOptions' :: LiteralOptions -> Maybe Text
$sel:sortEnabled:LiteralOptions' :: LiteralOptions -> Maybe Bool
$sel:searchEnabled:LiteralOptions' :: LiteralOptions -> Maybe Bool
$sel:facetEnabled:LiteralOptions' :: LiteralOptions -> Maybe Bool
$sel:returnEnabled:LiteralOptions' :: LiteralOptions -> Maybe Bool
$sel:sourceField:LiteralOptions' :: LiteralOptions -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"SourceField" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
sourceField,
        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
"SortEnabled" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
sortEnabled,
        ByteString
"DefaultValue" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
defaultValue
      ]