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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { DateOptions -> Maybe Text
sourceField :: Prelude.Maybe Prelude.Text,
    -- | Whether the contents of the field can be returned in the search results.
    DateOptions -> Maybe Bool
returnEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Whether facet information can be returned for the field.
    DateOptions -> Maybe Bool
facetEnabled :: 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,
    -- | A value to use for the field if the field isn\'t specified for a
    -- document.
    DateOptions -> Maybe Text
defaultValue :: Prelude.Maybe Prelude.Text
  }
  deriving (DateOptions -> DateOptions -> Bool
(DateOptions -> DateOptions -> Bool)
-> (DateOptions -> DateOptions -> Bool) -> Eq DateOptions
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]
(Int -> ReadS DateOptions)
-> ReadS [DateOptions]
-> ReadPrec DateOptions
-> ReadPrec [DateOptions]
-> Read 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
(Int -> DateOptions -> ShowS)
-> (DateOptions -> String)
-> ([DateOptions] -> ShowS)
-> Show DateOptions
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. DateOptions -> Rep DateOptions x)
-> (forall x. Rep DateOptions x -> DateOptions)
-> Generic DateOptions
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:
--
-- 'sourceField', 'dateOptions_sourceField' - Undocumented member.
--
-- 'returnEnabled', 'dateOptions_returnEnabled' - Whether the contents of the field can be returned in the search results.
--
-- 'facetEnabled', 'dateOptions_facetEnabled' - Whether facet information can be returned for the field.
--
-- '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.
--
-- 'defaultValue', 'dateOptions_defaultValue' - A value to use for the field if the field isn\'t specified for a
-- document.
newDateOptions ::
  DateOptions
newDateOptions :: DateOptions
newDateOptions =
  DateOptions' :: Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Text
-> DateOptions
DateOptions'
    { $sel:sourceField:DateOptions' :: Maybe Text
sourceField = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:returnEnabled:DateOptions' :: Maybe Bool
returnEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:facetEnabled:DateOptions' :: Maybe Bool
facetEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:searchEnabled:DateOptions' :: Maybe Bool
searchEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:sortEnabled:DateOptions' :: Maybe Bool
sortEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultValue:DateOptions' :: Maybe Text
defaultValue = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
dateOptions_sourceField :: Lens.Lens' DateOptions (Prelude.Maybe Prelude.Text)
dateOptions_sourceField :: (Maybe Text -> f (Maybe Text)) -> DateOptions -> f DateOptions
dateOptions_sourceField = (DateOptions -> Maybe Text)
-> (DateOptions -> Maybe Text -> DateOptions)
-> Lens DateOptions DateOptions (Maybe Text) (Maybe Text)
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)

-- | Whether the contents of the field can be returned in the search results.
dateOptions_returnEnabled :: Lens.Lens' DateOptions (Prelude.Maybe Prelude.Bool)
dateOptions_returnEnabled :: (Maybe Bool -> f (Maybe Bool)) -> DateOptions -> f DateOptions
dateOptions_returnEnabled = (DateOptions -> Maybe Bool)
-> (DateOptions -> Maybe Bool -> DateOptions)
-> Lens DateOptions DateOptions (Maybe Bool) (Maybe Bool)
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 facet information can be returned for the field.
dateOptions_facetEnabled :: Lens.Lens' DateOptions (Prelude.Maybe Prelude.Bool)
dateOptions_facetEnabled :: (Maybe Bool -> f (Maybe Bool)) -> DateOptions -> f DateOptions
dateOptions_facetEnabled = (DateOptions -> Maybe Bool)
-> (DateOptions -> Maybe Bool -> DateOptions)
-> Lens DateOptions DateOptions (Maybe Bool) (Maybe Bool)
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 are searchable.
dateOptions_searchEnabled :: Lens.Lens' DateOptions (Prelude.Maybe Prelude.Bool)
dateOptions_searchEnabled :: (Maybe Bool -> f (Maybe Bool)) -> DateOptions -> f DateOptions
dateOptions_searchEnabled = (DateOptions -> Maybe Bool)
-> (DateOptions -> Maybe Bool -> DateOptions)
-> Lens DateOptions DateOptions (Maybe Bool) (Maybe Bool)
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 :: (Maybe Bool -> f (Maybe Bool)) -> DateOptions -> f DateOptions
dateOptions_sortEnabled = (DateOptions -> Maybe Bool)
-> (DateOptions -> Maybe Bool -> DateOptions)
-> Lens DateOptions DateOptions (Maybe Bool) (Maybe Bool)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> DateOptions -> f DateOptions
dateOptions_defaultValue = (DateOptions -> Maybe Text)
-> (DateOptions -> Maybe Text -> DateOptions)
-> Lens DateOptions DateOptions (Maybe Text) (Maybe Text)
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)

instance Core.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'
      (Maybe Text
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Text
 -> DateOptions)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Text
      -> DateOptions)
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 Text
   -> DateOptions)
-> Either String (Maybe Bool)
-> Either
     String
     (Maybe Bool
      -> Maybe Bool -> Maybe Bool -> Maybe Text -> DateOptions)
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 Text -> DateOptions)
-> Either String (Maybe Bool)
-> Either
     String (Maybe Bool -> Maybe Bool -> Maybe Text -> DateOptions)
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 Text -> DateOptions)
-> Either String (Maybe Bool)
-> Either String (Maybe Bool -> Maybe Text -> DateOptions)
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 Text -> DateOptions)
-> Either String (Maybe Bool)
-> Either String (Maybe Text -> DateOptions)
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 Text -> DateOptions)
-> Either String (Maybe Text) -> Either String DateOptions
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 DateOptions

instance Prelude.NFData DateOptions

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