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

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

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

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

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

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

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

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

instance Prelude.NFData DateArrayOptions

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