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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Options for a latlon field. A latlon field contains a location stored as
-- a latitude and longitude value pair. Present if @IndexFieldType@
-- specifies the field is of type @latlon@. All options are enabled by
-- default.
--
-- /See:/ 'newLatLonOptions' smart constructor.
data LatLonOptions = LatLonOptions'
  { LatLonOptions -> Maybe Text
sourceField :: Prelude.Maybe Prelude.Text,
    -- | Whether the contents of the field can be returned in the search results.
    LatLonOptions -> Maybe Bool
returnEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Whether facet information can be returned for the field.
    LatLonOptions -> Maybe Bool
facetEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Whether the contents of the field are searchable.
    LatLonOptions -> Maybe Bool
searchEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Whether the field can be used to sort the search results.
    LatLonOptions -> Maybe Bool
sortEnabled :: Prelude.Maybe Prelude.Bool,
    -- | A value to use for the field if the field isn\'t specified for a
    -- document.
    LatLonOptions -> Maybe Text
defaultValue :: Prelude.Maybe Prelude.Text
  }
  deriving (LatLonOptions -> LatLonOptions -> Bool
(LatLonOptions -> LatLonOptions -> Bool)
-> (LatLonOptions -> LatLonOptions -> Bool) -> Eq LatLonOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LatLonOptions -> LatLonOptions -> Bool
$c/= :: LatLonOptions -> LatLonOptions -> Bool
== :: LatLonOptions -> LatLonOptions -> Bool
$c== :: LatLonOptions -> LatLonOptions -> Bool
Prelude.Eq, ReadPrec [LatLonOptions]
ReadPrec LatLonOptions
Int -> ReadS LatLonOptions
ReadS [LatLonOptions]
(Int -> ReadS LatLonOptions)
-> ReadS [LatLonOptions]
-> ReadPrec LatLonOptions
-> ReadPrec [LatLonOptions]
-> Read LatLonOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LatLonOptions]
$creadListPrec :: ReadPrec [LatLonOptions]
readPrec :: ReadPrec LatLonOptions
$creadPrec :: ReadPrec LatLonOptions
readList :: ReadS [LatLonOptions]
$creadList :: ReadS [LatLonOptions]
readsPrec :: Int -> ReadS LatLonOptions
$creadsPrec :: Int -> ReadS LatLonOptions
Prelude.Read, Int -> LatLonOptions -> ShowS
[LatLonOptions] -> ShowS
LatLonOptions -> String
(Int -> LatLonOptions -> ShowS)
-> (LatLonOptions -> String)
-> ([LatLonOptions] -> ShowS)
-> Show LatLonOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LatLonOptions] -> ShowS
$cshowList :: [LatLonOptions] -> ShowS
show :: LatLonOptions -> String
$cshow :: LatLonOptions -> String
showsPrec :: Int -> LatLonOptions -> ShowS
$cshowsPrec :: Int -> LatLonOptions -> ShowS
Prelude.Show, (forall x. LatLonOptions -> Rep LatLonOptions x)
-> (forall x. Rep LatLonOptions x -> LatLonOptions)
-> Generic LatLonOptions
forall x. Rep LatLonOptions x -> LatLonOptions
forall x. LatLonOptions -> Rep LatLonOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LatLonOptions x -> LatLonOptions
$cfrom :: forall x. LatLonOptions -> Rep LatLonOptions x
Prelude.Generic)

-- |
-- Create a value of 'LatLonOptions' 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', 'latLonOptions_sourceField' - Undocumented member.
--
-- 'returnEnabled', 'latLonOptions_returnEnabled' - Whether the contents of the field can be returned in the search results.
--
-- 'facetEnabled', 'latLonOptions_facetEnabled' - Whether facet information can be returned for the field.
--
-- 'searchEnabled', 'latLonOptions_searchEnabled' - Whether the contents of the field are searchable.
--
-- 'sortEnabled', 'latLonOptions_sortEnabled' - Whether the field can be used to sort the search results.
--
-- 'defaultValue', 'latLonOptions_defaultValue' - A value to use for the field if the field isn\'t specified for a
-- document.
newLatLonOptions ::
  LatLonOptions
newLatLonOptions :: LatLonOptions
newLatLonOptions =
  LatLonOptions' :: Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Text
-> LatLonOptions
LatLonOptions'
    { $sel:sourceField:LatLonOptions' :: Maybe Text
sourceField = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:returnEnabled:LatLonOptions' :: Maybe Bool
returnEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:facetEnabled:LatLonOptions' :: Maybe Bool
facetEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:searchEnabled:LatLonOptions' :: Maybe Bool
searchEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:sortEnabled:LatLonOptions' :: Maybe Bool
sortEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultValue:LatLonOptions' :: Maybe Text
defaultValue = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

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

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

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

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

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

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

instance Prelude.NFData LatLonOptions

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