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

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

-- | Options for a 64-bit signed integer field. Present if @IndexFieldType@
-- specifies the field is of type @int@. All options are enabled by
-- default.
--
-- /See:/ 'newIntOptions' smart constructor.
data IntOptions = IntOptions'
  { -- | The name of the source field to map to the field.
    IntOptions -> Maybe Text
sourceField :: Prelude.Maybe Prelude.Text,
    -- | Whether the contents of the field can be returned in the search results.
    IntOptions -> Maybe Bool
returnEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Whether facet information can be returned for the field.
    IntOptions -> Maybe Bool
facetEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Whether the contents of the field are searchable.
    IntOptions -> Maybe Bool
searchEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Whether the field can be used to sort the search results.
    IntOptions -> Maybe Bool
sortEnabled :: Prelude.Maybe Prelude.Bool,
    -- | A value to use for the field if the field isn\'t specified for a
    -- document. This can be important if you are using the field in an
    -- expression and that field is not present in every document.
    IntOptions -> Maybe Integer
defaultValue :: Prelude.Maybe Prelude.Integer
  }
  deriving (IntOptions -> IntOptions -> Bool
(IntOptions -> IntOptions -> Bool)
-> (IntOptions -> IntOptions -> Bool) -> Eq IntOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IntOptions -> IntOptions -> Bool
$c/= :: IntOptions -> IntOptions -> Bool
== :: IntOptions -> IntOptions -> Bool
$c== :: IntOptions -> IntOptions -> Bool
Prelude.Eq, ReadPrec [IntOptions]
ReadPrec IntOptions
Int -> ReadS IntOptions
ReadS [IntOptions]
(Int -> ReadS IntOptions)
-> ReadS [IntOptions]
-> ReadPrec IntOptions
-> ReadPrec [IntOptions]
-> Read IntOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IntOptions]
$creadListPrec :: ReadPrec [IntOptions]
readPrec :: ReadPrec IntOptions
$creadPrec :: ReadPrec IntOptions
readList :: ReadS [IntOptions]
$creadList :: ReadS [IntOptions]
readsPrec :: Int -> ReadS IntOptions
$creadsPrec :: Int -> ReadS IntOptions
Prelude.Read, Int -> IntOptions -> ShowS
[IntOptions] -> ShowS
IntOptions -> String
(Int -> IntOptions -> ShowS)
-> (IntOptions -> String)
-> ([IntOptions] -> ShowS)
-> Show IntOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IntOptions] -> ShowS
$cshowList :: [IntOptions] -> ShowS
show :: IntOptions -> String
$cshow :: IntOptions -> String
showsPrec :: Int -> IntOptions -> ShowS
$cshowsPrec :: Int -> IntOptions -> ShowS
Prelude.Show, (forall x. IntOptions -> Rep IntOptions x)
-> (forall x. Rep IntOptions x -> IntOptions) -> Generic IntOptions
forall x. Rep IntOptions x -> IntOptions
forall x. IntOptions -> Rep IntOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IntOptions x -> IntOptions
$cfrom :: forall x. IntOptions -> Rep IntOptions x
Prelude.Generic)

-- |
-- Create a value of 'IntOptions' 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', 'intOptions_sourceField' - The name of the source field to map to the field.
--
-- 'returnEnabled', 'intOptions_returnEnabled' - Whether the contents of the field can be returned in the search results.
--
-- 'facetEnabled', 'intOptions_facetEnabled' - Whether facet information can be returned for the field.
--
-- 'searchEnabled', 'intOptions_searchEnabled' - Whether the contents of the field are searchable.
--
-- 'sortEnabled', 'intOptions_sortEnabled' - Whether the field can be used to sort the search results.
--
-- 'defaultValue', 'intOptions_defaultValue' - A value to use for the field if the field isn\'t specified for a
-- document. This can be important if you are using the field in an
-- expression and that field is not present in every document.
newIntOptions ::
  IntOptions
newIntOptions :: IntOptions
newIntOptions =
  IntOptions' :: Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Integer
-> IntOptions
IntOptions'
    { $sel:sourceField:IntOptions' :: Maybe Text
sourceField = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:returnEnabled:IntOptions' :: Maybe Bool
returnEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:facetEnabled:IntOptions' :: Maybe Bool
facetEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:searchEnabled:IntOptions' :: Maybe Bool
searchEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:sortEnabled:IntOptions' :: Maybe Bool
sortEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultValue:IntOptions' :: Maybe Integer
defaultValue = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the source field to map to the field.
intOptions_sourceField :: Lens.Lens' IntOptions (Prelude.Maybe Prelude.Text)
intOptions_sourceField :: (Maybe Text -> f (Maybe Text)) -> IntOptions -> f IntOptions
intOptions_sourceField = (IntOptions -> Maybe Text)
-> (IntOptions -> Maybe Text -> IntOptions)
-> Lens IntOptions IntOptions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntOptions' {Maybe Text
sourceField :: Maybe Text
$sel:sourceField:IntOptions' :: IntOptions -> Maybe Text
sourceField} -> Maybe Text
sourceField) (\s :: IntOptions
s@IntOptions' {} Maybe Text
a -> IntOptions
s {$sel:sourceField:IntOptions' :: Maybe Text
sourceField = Maybe Text
a} :: IntOptions)

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

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

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

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

-- | A value to use for the field if the field isn\'t specified for a
-- document. This can be important if you are using the field in an
-- expression and that field is not present in every document.
intOptions_defaultValue :: Lens.Lens' IntOptions (Prelude.Maybe Prelude.Integer)
intOptions_defaultValue :: (Maybe Integer -> f (Maybe Integer)) -> IntOptions -> f IntOptions
intOptions_defaultValue = (IntOptions -> Maybe Integer)
-> (IntOptions -> Maybe Integer -> IntOptions)
-> Lens IntOptions IntOptions (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntOptions' {Maybe Integer
defaultValue :: Maybe Integer
$sel:defaultValue:IntOptions' :: IntOptions -> Maybe Integer
defaultValue} -> Maybe Integer
defaultValue) (\s :: IntOptions
s@IntOptions' {} Maybe Integer
a -> IntOptions
s {$sel:defaultValue:IntOptions' :: Maybe Integer
defaultValue = Maybe Integer
a} :: IntOptions)

instance Core.FromXML IntOptions where
  parseXML :: [Node] -> Either String IntOptions
parseXML [Node]
x =
    Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Integer
-> IntOptions
IntOptions'
      (Maybe Text
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Integer
 -> IntOptions)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Integer
      -> IntOptions)
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 Integer
   -> IntOptions)
-> Either String (Maybe Bool)
-> Either
     String
     (Maybe Bool
      -> Maybe Bool -> Maybe Bool -> Maybe Integer -> IntOptions)
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 Integer -> IntOptions)
-> Either String (Maybe Bool)
-> Either
     String (Maybe Bool -> Maybe Bool -> Maybe Integer -> IntOptions)
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 Integer -> IntOptions)
-> Either String (Maybe Bool)
-> Either String (Maybe Bool -> Maybe Integer -> IntOptions)
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 Integer -> IntOptions)
-> Either String (Maybe Bool)
-> Either String (Maybe Integer -> IntOptions)
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 Integer -> IntOptions)
-> Either String (Maybe Integer) -> Either String IntOptions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Integer)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DefaultValue")

instance Prelude.Hashable IntOptions

instance Prelude.NFData IntOptions

instance Core.ToQuery IntOptions where
  toQuery :: IntOptions -> QueryString
toQuery IntOptions' {Maybe Bool
Maybe Integer
Maybe Text
defaultValue :: Maybe Integer
sortEnabled :: Maybe Bool
searchEnabled :: Maybe Bool
facetEnabled :: Maybe Bool
returnEnabled :: Maybe Bool
sourceField :: Maybe Text
$sel:defaultValue:IntOptions' :: IntOptions -> Maybe Integer
$sel:sortEnabled:IntOptions' :: IntOptions -> Maybe Bool
$sel:searchEnabled:IntOptions' :: IntOptions -> Maybe Bool
$sel:facetEnabled:IntOptions' :: IntOptions -> Maybe Bool
$sel:returnEnabled:IntOptions' :: IntOptions -> Maybe Bool
$sel:sourceField:IntOptions' :: IntOptions -> 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 Integer -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Integer
defaultValue
      ]