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

import Amazonka.CloudSearch.Types.AnalysisOptions
import Amazonka.CloudSearch.Types.AnalysisSchemeLanguage
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Configuration information for an analysis scheme. Each analysis scheme
-- has a unique name and specifies the language of the text to be
-- processed. The following options can be configured for an analysis
-- scheme: @Synonyms@, @Stopwords@, @StemmingDictionary@,
-- @JapaneseTokenizationDictionary@ and @AlgorithmicStemming@.
--
-- /See:/ 'newAnalysisScheme' smart constructor.
data AnalysisScheme = AnalysisScheme'
  { AnalysisScheme -> Maybe AnalysisOptions
analysisOptions :: Prelude.Maybe AnalysisOptions,
    AnalysisScheme -> Text
analysisSchemeName :: Prelude.Text,
    AnalysisScheme -> AnalysisSchemeLanguage
analysisSchemeLanguage :: AnalysisSchemeLanguage
  }
  deriving (AnalysisScheme -> AnalysisScheme -> Bool
(AnalysisScheme -> AnalysisScheme -> Bool)
-> (AnalysisScheme -> AnalysisScheme -> Bool) -> Eq AnalysisScheme
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnalysisScheme -> AnalysisScheme -> Bool
$c/= :: AnalysisScheme -> AnalysisScheme -> Bool
== :: AnalysisScheme -> AnalysisScheme -> Bool
$c== :: AnalysisScheme -> AnalysisScheme -> Bool
Prelude.Eq, ReadPrec [AnalysisScheme]
ReadPrec AnalysisScheme
Int -> ReadS AnalysisScheme
ReadS [AnalysisScheme]
(Int -> ReadS AnalysisScheme)
-> ReadS [AnalysisScheme]
-> ReadPrec AnalysisScheme
-> ReadPrec [AnalysisScheme]
-> Read AnalysisScheme
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnalysisScheme]
$creadListPrec :: ReadPrec [AnalysisScheme]
readPrec :: ReadPrec AnalysisScheme
$creadPrec :: ReadPrec AnalysisScheme
readList :: ReadS [AnalysisScheme]
$creadList :: ReadS [AnalysisScheme]
readsPrec :: Int -> ReadS AnalysisScheme
$creadsPrec :: Int -> ReadS AnalysisScheme
Prelude.Read, Int -> AnalysisScheme -> ShowS
[AnalysisScheme] -> ShowS
AnalysisScheme -> String
(Int -> AnalysisScheme -> ShowS)
-> (AnalysisScheme -> String)
-> ([AnalysisScheme] -> ShowS)
-> Show AnalysisScheme
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnalysisScheme] -> ShowS
$cshowList :: [AnalysisScheme] -> ShowS
show :: AnalysisScheme -> String
$cshow :: AnalysisScheme -> String
showsPrec :: Int -> AnalysisScheme -> ShowS
$cshowsPrec :: Int -> AnalysisScheme -> ShowS
Prelude.Show, (forall x. AnalysisScheme -> Rep AnalysisScheme x)
-> (forall x. Rep AnalysisScheme x -> AnalysisScheme)
-> Generic AnalysisScheme
forall x. Rep AnalysisScheme x -> AnalysisScheme
forall x. AnalysisScheme -> Rep AnalysisScheme x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AnalysisScheme x -> AnalysisScheme
$cfrom :: forall x. AnalysisScheme -> Rep AnalysisScheme x
Prelude.Generic)

-- |
-- Create a value of 'AnalysisScheme' 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:
--
-- 'analysisOptions', 'analysisScheme_analysisOptions' - Undocumented member.
--
-- 'analysisSchemeName', 'analysisScheme_analysisSchemeName' - Undocumented member.
--
-- 'analysisSchemeLanguage', 'analysisScheme_analysisSchemeLanguage' - Undocumented member.
newAnalysisScheme ::
  -- | 'analysisSchemeName'
  Prelude.Text ->
  -- | 'analysisSchemeLanguage'
  AnalysisSchemeLanguage ->
  AnalysisScheme
newAnalysisScheme :: Text -> AnalysisSchemeLanguage -> AnalysisScheme
newAnalysisScheme
  Text
pAnalysisSchemeName_
  AnalysisSchemeLanguage
pAnalysisSchemeLanguage_ =
    AnalysisScheme' :: Maybe AnalysisOptions
-> Text -> AnalysisSchemeLanguage -> AnalysisScheme
AnalysisScheme'
      { $sel:analysisOptions:AnalysisScheme' :: Maybe AnalysisOptions
analysisOptions = Maybe AnalysisOptions
forall a. Maybe a
Prelude.Nothing,
        $sel:analysisSchemeName:AnalysisScheme' :: Text
analysisSchemeName = Text
pAnalysisSchemeName_,
        $sel:analysisSchemeLanguage:AnalysisScheme' :: AnalysisSchemeLanguage
analysisSchemeLanguage = AnalysisSchemeLanguage
pAnalysisSchemeLanguage_
      }

-- | Undocumented member.
analysisScheme_analysisOptions :: Lens.Lens' AnalysisScheme (Prelude.Maybe AnalysisOptions)
analysisScheme_analysisOptions :: (Maybe AnalysisOptions -> f (Maybe AnalysisOptions))
-> AnalysisScheme -> f AnalysisScheme
analysisScheme_analysisOptions = (AnalysisScheme -> Maybe AnalysisOptions)
-> (AnalysisScheme -> Maybe AnalysisOptions -> AnalysisScheme)
-> Lens
     AnalysisScheme
     AnalysisScheme
     (Maybe AnalysisOptions)
     (Maybe AnalysisOptions)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalysisScheme' {Maybe AnalysisOptions
analysisOptions :: Maybe AnalysisOptions
$sel:analysisOptions:AnalysisScheme' :: AnalysisScheme -> Maybe AnalysisOptions
analysisOptions} -> Maybe AnalysisOptions
analysisOptions) (\s :: AnalysisScheme
s@AnalysisScheme' {} Maybe AnalysisOptions
a -> AnalysisScheme
s {$sel:analysisOptions:AnalysisScheme' :: Maybe AnalysisOptions
analysisOptions = Maybe AnalysisOptions
a} :: AnalysisScheme)

-- | Undocumented member.
analysisScheme_analysisSchemeName :: Lens.Lens' AnalysisScheme Prelude.Text
analysisScheme_analysisSchemeName :: (Text -> f Text) -> AnalysisScheme -> f AnalysisScheme
analysisScheme_analysisSchemeName = (AnalysisScheme -> Text)
-> (AnalysisScheme -> Text -> AnalysisScheme)
-> Lens AnalysisScheme AnalysisScheme Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalysisScheme' {Text
analysisSchemeName :: Text
$sel:analysisSchemeName:AnalysisScheme' :: AnalysisScheme -> Text
analysisSchemeName} -> Text
analysisSchemeName) (\s :: AnalysisScheme
s@AnalysisScheme' {} Text
a -> AnalysisScheme
s {$sel:analysisSchemeName:AnalysisScheme' :: Text
analysisSchemeName = Text
a} :: AnalysisScheme)

-- | Undocumented member.
analysisScheme_analysisSchemeLanguage :: Lens.Lens' AnalysisScheme AnalysisSchemeLanguage
analysisScheme_analysisSchemeLanguage :: (AnalysisSchemeLanguage -> f AnalysisSchemeLanguage)
-> AnalysisScheme -> f AnalysisScheme
analysisScheme_analysisSchemeLanguage = (AnalysisScheme -> AnalysisSchemeLanguage)
-> (AnalysisScheme -> AnalysisSchemeLanguage -> AnalysisScheme)
-> Lens
     AnalysisScheme
     AnalysisScheme
     AnalysisSchemeLanguage
     AnalysisSchemeLanguage
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalysisScheme' {AnalysisSchemeLanguage
analysisSchemeLanguage :: AnalysisSchemeLanguage
$sel:analysisSchemeLanguage:AnalysisScheme' :: AnalysisScheme -> AnalysisSchemeLanguage
analysisSchemeLanguage} -> AnalysisSchemeLanguage
analysisSchemeLanguage) (\s :: AnalysisScheme
s@AnalysisScheme' {} AnalysisSchemeLanguage
a -> AnalysisScheme
s {$sel:analysisSchemeLanguage:AnalysisScheme' :: AnalysisSchemeLanguage
analysisSchemeLanguage = AnalysisSchemeLanguage
a} :: AnalysisScheme)

instance Core.FromXML AnalysisScheme where
  parseXML :: [Node] -> Either String AnalysisScheme
parseXML [Node]
x =
    Maybe AnalysisOptions
-> Text -> AnalysisSchemeLanguage -> AnalysisScheme
AnalysisScheme'
      (Maybe AnalysisOptions
 -> Text -> AnalysisSchemeLanguage -> AnalysisScheme)
-> Either String (Maybe AnalysisOptions)
-> Either String (Text -> AnalysisSchemeLanguage -> AnalysisScheme)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe AnalysisOptions)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"AnalysisOptions")
      Either String (Text -> AnalysisSchemeLanguage -> AnalysisScheme)
-> Either String Text
-> Either String (AnalysisSchemeLanguage -> AnalysisScheme)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"AnalysisSchemeName")
      Either String (AnalysisSchemeLanguage -> AnalysisScheme)
-> Either String AnalysisSchemeLanguage
-> Either String AnalysisScheme
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String AnalysisSchemeLanguage
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"AnalysisSchemeLanguage")

instance Prelude.Hashable AnalysisScheme

instance Prelude.NFData AnalysisScheme

instance Core.ToQuery AnalysisScheme where
  toQuery :: AnalysisScheme -> QueryString
toQuery AnalysisScheme' {Maybe AnalysisOptions
Text
AnalysisSchemeLanguage
analysisSchemeLanguage :: AnalysisSchemeLanguage
analysisSchemeName :: Text
analysisOptions :: Maybe AnalysisOptions
$sel:analysisSchemeLanguage:AnalysisScheme' :: AnalysisScheme -> AnalysisSchemeLanguage
$sel:analysisSchemeName:AnalysisScheme' :: AnalysisScheme -> Text
$sel:analysisOptions:AnalysisScheme' :: AnalysisScheme -> Maybe AnalysisOptions
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"AnalysisOptions" ByteString -> Maybe AnalysisOptions -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe AnalysisOptions
analysisOptions,
        ByteString
"AnalysisSchemeName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
analysisSchemeName,
        ByteString
"AnalysisSchemeLanguage"
          ByteString -> AnalysisSchemeLanguage -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: AnalysisSchemeLanguage
analysisSchemeLanguage
      ]