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

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

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

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

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

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

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

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

instance Prelude.NFData IntArrayOptions

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