{-# 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-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.IntOptions 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 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'
  { -- | 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,
    -- | Whether facet information can be returned for the field.
    IntOptions -> Maybe Bool
facetEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Whether the contents of the field can be returned in the search results.
    IntOptions -> Maybe Bool
returnEnabled :: 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,
    -- | The name of the source field to map to the field.
    IntOptions -> Maybe Text
sourceField :: Prelude.Maybe Prelude.Text
  }
  deriving (IntOptions -> IntOptions -> Bool
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]
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
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. 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:
--
-- '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.
--
-- 'facetEnabled', 'intOptions_facetEnabled' - Whether facet information can be returned for the field.
--
-- 'returnEnabled', 'intOptions_returnEnabled' - Whether the contents of the field can be returned in the search results.
--
-- '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.
--
-- 'sourceField', 'intOptions_sourceField' - The name of the source field to map to the field.
newIntOptions ::
  IntOptions
newIntOptions :: IntOptions
newIntOptions =
  IntOptions'
    { $sel:defaultValue:IntOptions' :: Maybe Integer
defaultValue = forall a. Maybe a
Prelude.Nothing,
      $sel:facetEnabled:IntOptions' :: Maybe Bool
facetEnabled = forall a. Maybe a
Prelude.Nothing,
      $sel:returnEnabled:IntOptions' :: Maybe Bool
returnEnabled = forall a. Maybe a
Prelude.Nothing,
      $sel:searchEnabled:IntOptions' :: Maybe Bool
searchEnabled = forall a. Maybe a
Prelude.Nothing,
      $sel:sortEnabled:IntOptions' :: Maybe Bool
sortEnabled = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceField:IntOptions' :: Maybe Text
sourceField = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' IntOptions (Maybe Integer)
intOptions_defaultValue = 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)

-- | Whether facet information can be returned for the field.
intOptions_facetEnabled :: Lens.Lens' IntOptions (Prelude.Maybe Prelude.Bool)
intOptions_facetEnabled :: Lens' IntOptions (Maybe Bool)
intOptions_facetEnabled = 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 can be returned in the search results.
intOptions_returnEnabled :: Lens.Lens' IntOptions (Prelude.Maybe Prelude.Bool)
intOptions_returnEnabled :: Lens' IntOptions (Maybe Bool)
intOptions_returnEnabled = 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 the contents of the field are searchable.
intOptions_searchEnabled :: Lens.Lens' IntOptions (Prelude.Maybe Prelude.Bool)
intOptions_searchEnabled :: Lens' IntOptions (Maybe Bool)
intOptions_searchEnabled = 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 :: Lens' IntOptions (Maybe Bool)
intOptions_sortEnabled = 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)

-- | The name of the source field to map to the field.
intOptions_sourceField :: Lens.Lens' IntOptions (Prelude.Maybe Prelude.Text)
intOptions_sourceField :: Lens' IntOptions (Maybe Text)
intOptions_sourceField = 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)

instance Data.FromXML IntOptions where
  parseXML :: [Node] -> Either String IntOptions
parseXML [Node]
x =
    Maybe Integer
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Text
-> IntOptions
IntOptions'
      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
"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
"FacetEnabled")
      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
"SearchEnabled")
      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
"SortEnabled")
      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
"SourceField")

instance Prelude.Hashable IntOptions where
  hashWithSalt :: Int -> IntOptions -> Int
hashWithSalt Int
_salt IntOptions' {Maybe Bool
Maybe Integer
Maybe Text
sourceField :: Maybe Text
sortEnabled :: Maybe Bool
searchEnabled :: Maybe Bool
returnEnabled :: Maybe Bool
facetEnabled :: Maybe Bool
defaultValue :: Maybe Integer
$sel:sourceField:IntOptions' :: IntOptions -> Maybe Text
$sel:sortEnabled:IntOptions' :: IntOptions -> Maybe Bool
$sel:searchEnabled:IntOptions' :: IntOptions -> Maybe Bool
$sel:returnEnabled:IntOptions' :: IntOptions -> Maybe Bool
$sel:facetEnabled:IntOptions' :: IntOptions -> Maybe Bool
$sel:defaultValue:IntOptions' :: IntOptions -> Maybe Integer
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
defaultValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
facetEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
returnEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
searchEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
sortEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceField

instance Prelude.NFData IntOptions where
  rnf :: IntOptions -> ()
rnf IntOptions' {Maybe Bool
Maybe Integer
Maybe Text
sourceField :: Maybe Text
sortEnabled :: Maybe Bool
searchEnabled :: Maybe Bool
returnEnabled :: Maybe Bool
facetEnabled :: Maybe Bool
defaultValue :: Maybe Integer
$sel:sourceField:IntOptions' :: IntOptions -> Maybe Text
$sel:sortEnabled:IntOptions' :: IntOptions -> Maybe Bool
$sel:searchEnabled:IntOptions' :: IntOptions -> Maybe Bool
$sel:returnEnabled:IntOptions' :: IntOptions -> Maybe Bool
$sel:facetEnabled:IntOptions' :: IntOptions -> Maybe Bool
$sel:defaultValue:IntOptions' :: IntOptions -> Maybe Integer
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
defaultValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
facetEnabled
      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 Bool
searchEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
sortEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourceField

instance Data.ToQuery IntOptions where
  toQuery :: IntOptions -> QueryString
toQuery IntOptions' {Maybe Bool
Maybe Integer
Maybe Text
sourceField :: Maybe Text
sortEnabled :: Maybe Bool
searchEnabled :: Maybe Bool
returnEnabled :: Maybe Bool
facetEnabled :: Maybe Bool
defaultValue :: Maybe Integer
$sel:sourceField:IntOptions' :: IntOptions -> Maybe Text
$sel:sortEnabled:IntOptions' :: IntOptions -> Maybe Bool
$sel:searchEnabled:IntOptions' :: IntOptions -> Maybe Bool
$sel:returnEnabled:IntOptions' :: IntOptions -> Maybe Bool
$sel:facetEnabled:IntOptions' :: IntOptions -> Maybe Bool
$sel:defaultValue:IntOptions' :: IntOptions -> Maybe Integer
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"DefaultValue" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Integer
defaultValue,
        ByteString
"FacetEnabled" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
facetEnabled,
        ByteString
"ReturnEnabled" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
returnEnabled,
        ByteString
"SearchEnabled" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
searchEnabled,
        ByteString
"SortEnabled" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
sortEnabled,
        ByteString
"SourceField" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
sourceField
      ]