{-# 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.DateOptions
-- 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.DateOptions 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 date field. Dates and times are specified in UTC
-- (Coordinated Universal Time) according to IETF RFC3339:
-- yyyy-mm-ddT00:00:00Z. Present if @IndexFieldType@ specifies the field is
-- of type @date@. All options are enabled by default.
--
-- /See:/ 'newDateOptions' smart constructor.
data DateOptions = DateOptions'
  { -- | A value to use for the field if the field isn\'t specified for a
    -- document.
    DateOptions -> Maybe Text
defaultValue :: Prelude.Maybe Prelude.Text,
    -- | Whether facet information can be returned for the field.
    DateOptions -> Maybe Bool
facetEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Whether the contents of the field can be returned in the search results.
    DateOptions -> Maybe Bool
returnEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Whether the contents of the field are searchable.
    DateOptions -> Maybe Bool
searchEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Whether the field can be used to sort the search results.
    DateOptions -> Maybe Bool
sortEnabled :: Prelude.Maybe Prelude.Bool,
    DateOptions -> Maybe Text
sourceField :: Prelude.Maybe Prelude.Text
  }
  deriving (DateOptions -> DateOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DateOptions -> DateOptions -> Bool
$c/= :: DateOptions -> DateOptions -> Bool
== :: DateOptions -> DateOptions -> Bool
$c== :: DateOptions -> DateOptions -> Bool
Prelude.Eq, ReadPrec [DateOptions]
ReadPrec DateOptions
Int -> ReadS DateOptions
ReadS [DateOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DateOptions]
$creadListPrec :: ReadPrec [DateOptions]
readPrec :: ReadPrec DateOptions
$creadPrec :: ReadPrec DateOptions
readList :: ReadS [DateOptions]
$creadList :: ReadS [DateOptions]
readsPrec :: Int -> ReadS DateOptions
$creadsPrec :: Int -> ReadS DateOptions
Prelude.Read, Int -> DateOptions -> ShowS
[DateOptions] -> ShowS
DateOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DateOptions] -> ShowS
$cshowList :: [DateOptions] -> ShowS
show :: DateOptions -> String
$cshow :: DateOptions -> String
showsPrec :: Int -> DateOptions -> ShowS
$cshowsPrec :: Int -> DateOptions -> ShowS
Prelude.Show, forall x. Rep DateOptions x -> DateOptions
forall x. DateOptions -> Rep DateOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DateOptions x -> DateOptions
$cfrom :: forall x. DateOptions -> Rep DateOptions x
Prelude.Generic)

-- |
-- Create a value of 'DateOptions' 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', 'dateOptions_defaultValue' - A value to use for the field if the field isn\'t specified for a
-- document.
--
-- 'facetEnabled', 'dateOptions_facetEnabled' - Whether facet information can be returned for the field.
--
-- 'returnEnabled', 'dateOptions_returnEnabled' - Whether the contents of the field can be returned in the search results.
--
-- 'searchEnabled', 'dateOptions_searchEnabled' - Whether the contents of the field are searchable.
--
-- 'sortEnabled', 'dateOptions_sortEnabled' - Whether the field can be used to sort the search results.
--
-- 'sourceField', 'dateOptions_sourceField' - Undocumented member.
newDateOptions ::
  DateOptions
newDateOptions :: DateOptions
newDateOptions =
  DateOptions'
    { $sel:defaultValue:DateOptions' :: Maybe Text
defaultValue = forall a. Maybe a
Prelude.Nothing,
      $sel:facetEnabled:DateOptions' :: Maybe Bool
facetEnabled = forall a. Maybe a
Prelude.Nothing,
      $sel:returnEnabled:DateOptions' :: Maybe Bool
returnEnabled = forall a. Maybe a
Prelude.Nothing,
      $sel:searchEnabled:DateOptions' :: Maybe Bool
searchEnabled = forall a. Maybe a
Prelude.Nothing,
      $sel:sortEnabled:DateOptions' :: Maybe Bool
sortEnabled = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceField:DateOptions' :: 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.
dateOptions_defaultValue :: Lens.Lens' DateOptions (Prelude.Maybe Prelude.Text)
dateOptions_defaultValue :: Lens' DateOptions (Maybe Text)
dateOptions_defaultValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DateOptions' {Maybe Text
defaultValue :: Maybe Text
$sel:defaultValue:DateOptions' :: DateOptions -> Maybe Text
defaultValue} -> Maybe Text
defaultValue) (\s :: DateOptions
s@DateOptions' {} Maybe Text
a -> DateOptions
s {$sel:defaultValue:DateOptions' :: Maybe Text
defaultValue = Maybe Text
a} :: DateOptions)

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

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

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

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

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

instance Data.FromXML DateOptions where
  parseXML :: [Node] -> Either String DateOptions
parseXML [Node]
x =
    Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Text
-> DateOptions
DateOptions'
      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 DateOptions where
  hashWithSalt :: Int -> DateOptions -> Int
hashWithSalt Int
_salt DateOptions' {Maybe Bool
Maybe Text
sourceField :: Maybe Text
sortEnabled :: Maybe Bool
searchEnabled :: Maybe Bool
returnEnabled :: Maybe Bool
facetEnabled :: Maybe Bool
defaultValue :: Maybe Text
$sel:sourceField:DateOptions' :: DateOptions -> Maybe Text
$sel:sortEnabled:DateOptions' :: DateOptions -> Maybe Bool
$sel:searchEnabled:DateOptions' :: DateOptions -> Maybe Bool
$sel:returnEnabled:DateOptions' :: DateOptions -> Maybe Bool
$sel:facetEnabled:DateOptions' :: DateOptions -> Maybe Bool
$sel:defaultValue:DateOptions' :: DateOptions -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
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 DateOptions where
  rnf :: DateOptions -> ()
rnf DateOptions' {Maybe Bool
Maybe Text
sourceField :: Maybe Text
sortEnabled :: Maybe Bool
searchEnabled :: Maybe Bool
returnEnabled :: Maybe Bool
facetEnabled :: Maybe Bool
defaultValue :: Maybe Text
$sel:sourceField:DateOptions' :: DateOptions -> Maybe Text
$sel:sortEnabled:DateOptions' :: DateOptions -> Maybe Bool
$sel:searchEnabled:DateOptions' :: DateOptions -> Maybe Bool
$sel:returnEnabled:DateOptions' :: DateOptions -> Maybe Bool
$sel:facetEnabled:DateOptions' :: DateOptions -> Maybe Bool
$sel:defaultValue:DateOptions' :: DateOptions -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
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 DateOptions where
  toQuery :: DateOptions -> QueryString
toQuery DateOptions' {Maybe Bool
Maybe Text
sourceField :: Maybe Text
sortEnabled :: Maybe Bool
searchEnabled :: Maybe Bool
returnEnabled :: Maybe Bool
facetEnabled :: Maybe Bool
defaultValue :: Maybe Text
$sel:sourceField:DateOptions' :: DateOptions -> Maybe Text
$sel:sortEnabled:DateOptions' :: DateOptions -> Maybe Bool
$sel:searchEnabled:DateOptions' :: DateOptions -> Maybe Bool
$sel:returnEnabled:DateOptions' :: DateOptions -> Maybe Bool
$sel:facetEnabled:DateOptions' :: DateOptions -> Maybe Bool
$sel:defaultValue:DateOptions' :: DateOptions -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"DefaultValue" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
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
      ]