{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.DefineAnalysisScheme
-- 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)
--
-- Configures an analysis scheme that can be applied to a @text@ or
-- @text-array@ field to define language-specific text processing options.
-- For more information, see
-- <http://docs.aws.amazon.com/cloudsearch/latest/developerguide/configuring-analysis-schemes.html Configuring Analysis Schemes>
-- in the /Amazon CloudSearch Developer Guide/.
module Amazonka.CloudSearch.DefineAnalysisScheme
  ( -- * Creating a Request
    DefineAnalysisScheme (..),
    newDefineAnalysisScheme,

    -- * Request Lenses
    defineAnalysisScheme_domainName,
    defineAnalysisScheme_analysisScheme,

    -- * Destructuring the Response
    DefineAnalysisSchemeResponse (..),
    newDefineAnalysisSchemeResponse,

    -- * Response Lenses
    defineAnalysisSchemeResponse_httpStatus,
    defineAnalysisSchemeResponse_analysisScheme,
  )
where

import Amazonka.CloudSearch.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Container for the parameters to the @DefineAnalysisScheme@ operation.
-- Specifies the name of the domain you want to update and the analysis
-- scheme configuration.
--
-- /See:/ 'newDefineAnalysisScheme' smart constructor.
data DefineAnalysisScheme = DefineAnalysisScheme'
  { DefineAnalysisScheme -> Text
domainName :: Prelude.Text,
    DefineAnalysisScheme -> AnalysisScheme
analysisScheme :: AnalysisScheme
  }
  deriving (DefineAnalysisScheme -> DefineAnalysisScheme -> Bool
(DefineAnalysisScheme -> DefineAnalysisScheme -> Bool)
-> (DefineAnalysisScheme -> DefineAnalysisScheme -> Bool)
-> Eq DefineAnalysisScheme
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DefineAnalysisScheme -> DefineAnalysisScheme -> Bool
$c/= :: DefineAnalysisScheme -> DefineAnalysisScheme -> Bool
== :: DefineAnalysisScheme -> DefineAnalysisScheme -> Bool
$c== :: DefineAnalysisScheme -> DefineAnalysisScheme -> Bool
Prelude.Eq, ReadPrec [DefineAnalysisScheme]
ReadPrec DefineAnalysisScheme
Int -> ReadS DefineAnalysisScheme
ReadS [DefineAnalysisScheme]
(Int -> ReadS DefineAnalysisScheme)
-> ReadS [DefineAnalysisScheme]
-> ReadPrec DefineAnalysisScheme
-> ReadPrec [DefineAnalysisScheme]
-> Read DefineAnalysisScheme
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DefineAnalysisScheme]
$creadListPrec :: ReadPrec [DefineAnalysisScheme]
readPrec :: ReadPrec DefineAnalysisScheme
$creadPrec :: ReadPrec DefineAnalysisScheme
readList :: ReadS [DefineAnalysisScheme]
$creadList :: ReadS [DefineAnalysisScheme]
readsPrec :: Int -> ReadS DefineAnalysisScheme
$creadsPrec :: Int -> ReadS DefineAnalysisScheme
Prelude.Read, Int -> DefineAnalysisScheme -> ShowS
[DefineAnalysisScheme] -> ShowS
DefineAnalysisScheme -> String
(Int -> DefineAnalysisScheme -> ShowS)
-> (DefineAnalysisScheme -> String)
-> ([DefineAnalysisScheme] -> ShowS)
-> Show DefineAnalysisScheme
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DefineAnalysisScheme] -> ShowS
$cshowList :: [DefineAnalysisScheme] -> ShowS
show :: DefineAnalysisScheme -> String
$cshow :: DefineAnalysisScheme -> String
showsPrec :: Int -> DefineAnalysisScheme -> ShowS
$cshowsPrec :: Int -> DefineAnalysisScheme -> ShowS
Prelude.Show, (forall x. DefineAnalysisScheme -> Rep DefineAnalysisScheme x)
-> (forall x. Rep DefineAnalysisScheme x -> DefineAnalysisScheme)
-> Generic DefineAnalysisScheme
forall x. Rep DefineAnalysisScheme x -> DefineAnalysisScheme
forall x. DefineAnalysisScheme -> Rep DefineAnalysisScheme x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DefineAnalysisScheme x -> DefineAnalysisScheme
$cfrom :: forall x. DefineAnalysisScheme -> Rep DefineAnalysisScheme x
Prelude.Generic)

-- |
-- Create a value of 'DefineAnalysisScheme' 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:
--
-- 'domainName', 'defineAnalysisScheme_domainName' - Undocumented member.
--
-- 'analysisScheme', 'defineAnalysisScheme_analysisScheme' - Undocumented member.
newDefineAnalysisScheme ::
  -- | 'domainName'
  Prelude.Text ->
  -- | 'analysisScheme'
  AnalysisScheme ->
  DefineAnalysisScheme
newDefineAnalysisScheme :: Text -> AnalysisScheme -> DefineAnalysisScheme
newDefineAnalysisScheme Text
pDomainName_ AnalysisScheme
pAnalysisScheme_ =
  DefineAnalysisScheme' :: Text -> AnalysisScheme -> DefineAnalysisScheme
DefineAnalysisScheme'
    { $sel:domainName:DefineAnalysisScheme' :: Text
domainName = Text
pDomainName_,
      $sel:analysisScheme:DefineAnalysisScheme' :: AnalysisScheme
analysisScheme = AnalysisScheme
pAnalysisScheme_
    }

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

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

instance Core.AWSRequest DefineAnalysisScheme where
  type
    AWSResponse DefineAnalysisScheme =
      DefineAnalysisSchemeResponse
  request :: DefineAnalysisScheme -> Request DefineAnalysisScheme
request = Service -> DefineAnalysisScheme -> Request DefineAnalysisScheme
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DefineAnalysisScheme
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DefineAnalysisScheme)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DefineAnalysisScheme))
-> Logger
-> Service
-> Proxy DefineAnalysisScheme
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DefineAnalysisScheme)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"DefineAnalysisSchemeResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> AnalysisSchemeStatus -> DefineAnalysisSchemeResponse
DefineAnalysisSchemeResponse'
            (Int -> AnalysisSchemeStatus -> DefineAnalysisSchemeResponse)
-> Either String Int
-> Either
     String (AnalysisSchemeStatus -> DefineAnalysisSchemeResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either
  String (AnalysisSchemeStatus -> DefineAnalysisSchemeResponse)
-> Either String AnalysisSchemeStatus
-> Either String DefineAnalysisSchemeResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String AnalysisSchemeStatus
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"AnalysisScheme")
      )

instance Prelude.Hashable DefineAnalysisScheme

instance Prelude.NFData DefineAnalysisScheme

instance Core.ToHeaders DefineAnalysisScheme where
  toHeaders :: DefineAnalysisScheme -> ResponseHeaders
toHeaders = ResponseHeaders -> DefineAnalysisScheme -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath DefineAnalysisScheme where
  toPath :: DefineAnalysisScheme -> ByteString
toPath = ByteString -> DefineAnalysisScheme -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery DefineAnalysisScheme where
  toQuery :: DefineAnalysisScheme -> QueryString
toQuery DefineAnalysisScheme' {Text
AnalysisScheme
analysisScheme :: AnalysisScheme
domainName :: Text
$sel:analysisScheme:DefineAnalysisScheme' :: DefineAnalysisScheme -> AnalysisScheme
$sel:domainName:DefineAnalysisScheme' :: DefineAnalysisScheme -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DefineAnalysisScheme" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2013-01-01" :: Prelude.ByteString),
        ByteString
"DomainName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
domainName,
        ByteString
"AnalysisScheme" ByteString -> AnalysisScheme -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: AnalysisScheme
analysisScheme
      ]

-- | The result of a @DefineAnalysisScheme@ request. Contains the status of
-- the newly-configured analysis scheme.
--
-- /See:/ 'newDefineAnalysisSchemeResponse' smart constructor.
data DefineAnalysisSchemeResponse = DefineAnalysisSchemeResponse'
  { -- | The response's http status code.
    DefineAnalysisSchemeResponse -> Int
httpStatus :: Prelude.Int,
    DefineAnalysisSchemeResponse -> AnalysisSchemeStatus
analysisScheme :: AnalysisSchemeStatus
  }
  deriving (DefineAnalysisSchemeResponse
-> DefineAnalysisSchemeResponse -> Bool
(DefineAnalysisSchemeResponse
 -> DefineAnalysisSchemeResponse -> Bool)
-> (DefineAnalysisSchemeResponse
    -> DefineAnalysisSchemeResponse -> Bool)
-> Eq DefineAnalysisSchemeResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DefineAnalysisSchemeResponse
-> DefineAnalysisSchemeResponse -> Bool
$c/= :: DefineAnalysisSchemeResponse
-> DefineAnalysisSchemeResponse -> Bool
== :: DefineAnalysisSchemeResponse
-> DefineAnalysisSchemeResponse -> Bool
$c== :: DefineAnalysisSchemeResponse
-> DefineAnalysisSchemeResponse -> Bool
Prelude.Eq, ReadPrec [DefineAnalysisSchemeResponse]
ReadPrec DefineAnalysisSchemeResponse
Int -> ReadS DefineAnalysisSchemeResponse
ReadS [DefineAnalysisSchemeResponse]
(Int -> ReadS DefineAnalysisSchemeResponse)
-> ReadS [DefineAnalysisSchemeResponse]
-> ReadPrec DefineAnalysisSchemeResponse
-> ReadPrec [DefineAnalysisSchemeResponse]
-> Read DefineAnalysisSchemeResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DefineAnalysisSchemeResponse]
$creadListPrec :: ReadPrec [DefineAnalysisSchemeResponse]
readPrec :: ReadPrec DefineAnalysisSchemeResponse
$creadPrec :: ReadPrec DefineAnalysisSchemeResponse
readList :: ReadS [DefineAnalysisSchemeResponse]
$creadList :: ReadS [DefineAnalysisSchemeResponse]
readsPrec :: Int -> ReadS DefineAnalysisSchemeResponse
$creadsPrec :: Int -> ReadS DefineAnalysisSchemeResponse
Prelude.Read, Int -> DefineAnalysisSchemeResponse -> ShowS
[DefineAnalysisSchemeResponse] -> ShowS
DefineAnalysisSchemeResponse -> String
(Int -> DefineAnalysisSchemeResponse -> ShowS)
-> (DefineAnalysisSchemeResponse -> String)
-> ([DefineAnalysisSchemeResponse] -> ShowS)
-> Show DefineAnalysisSchemeResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DefineAnalysisSchemeResponse] -> ShowS
$cshowList :: [DefineAnalysisSchemeResponse] -> ShowS
show :: DefineAnalysisSchemeResponse -> String
$cshow :: DefineAnalysisSchemeResponse -> String
showsPrec :: Int -> DefineAnalysisSchemeResponse -> ShowS
$cshowsPrec :: Int -> DefineAnalysisSchemeResponse -> ShowS
Prelude.Show, (forall x.
 DefineAnalysisSchemeResponse -> Rep DefineAnalysisSchemeResponse x)
-> (forall x.
    Rep DefineAnalysisSchemeResponse x -> DefineAnalysisSchemeResponse)
-> Generic DefineAnalysisSchemeResponse
forall x.
Rep DefineAnalysisSchemeResponse x -> DefineAnalysisSchemeResponse
forall x.
DefineAnalysisSchemeResponse -> Rep DefineAnalysisSchemeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DefineAnalysisSchemeResponse x -> DefineAnalysisSchemeResponse
$cfrom :: forall x.
DefineAnalysisSchemeResponse -> Rep DefineAnalysisSchemeResponse x
Prelude.Generic)

-- |
-- Create a value of 'DefineAnalysisSchemeResponse' 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:
--
-- 'httpStatus', 'defineAnalysisSchemeResponse_httpStatus' - The response's http status code.
--
-- 'analysisScheme', 'defineAnalysisSchemeResponse_analysisScheme' - Undocumented member.
newDefineAnalysisSchemeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'analysisScheme'
  AnalysisSchemeStatus ->
  DefineAnalysisSchemeResponse
newDefineAnalysisSchemeResponse :: Int -> AnalysisSchemeStatus -> DefineAnalysisSchemeResponse
newDefineAnalysisSchemeResponse
  Int
pHttpStatus_
  AnalysisSchemeStatus
pAnalysisScheme_ =
    DefineAnalysisSchemeResponse' :: Int -> AnalysisSchemeStatus -> DefineAnalysisSchemeResponse
DefineAnalysisSchemeResponse'
      { $sel:httpStatus:DefineAnalysisSchemeResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:analysisScheme:DefineAnalysisSchemeResponse' :: AnalysisSchemeStatus
analysisScheme = AnalysisSchemeStatus
pAnalysisScheme_
      }

-- | The response's http status code.
defineAnalysisSchemeResponse_httpStatus :: Lens.Lens' DefineAnalysisSchemeResponse Prelude.Int
defineAnalysisSchemeResponse_httpStatus :: (Int -> f Int)
-> DefineAnalysisSchemeResponse -> f DefineAnalysisSchemeResponse
defineAnalysisSchemeResponse_httpStatus = (DefineAnalysisSchemeResponse -> Int)
-> (DefineAnalysisSchemeResponse
    -> Int -> DefineAnalysisSchemeResponse)
-> Lens
     DefineAnalysisSchemeResponse DefineAnalysisSchemeResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DefineAnalysisSchemeResponse' {Int
httpStatus :: Int
$sel:httpStatus:DefineAnalysisSchemeResponse' :: DefineAnalysisSchemeResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DefineAnalysisSchemeResponse
s@DefineAnalysisSchemeResponse' {} Int
a -> DefineAnalysisSchemeResponse
s {$sel:httpStatus:DefineAnalysisSchemeResponse' :: Int
httpStatus = Int
a} :: DefineAnalysisSchemeResponse)

-- | Undocumented member.
defineAnalysisSchemeResponse_analysisScheme :: Lens.Lens' DefineAnalysisSchemeResponse AnalysisSchemeStatus
defineAnalysisSchemeResponse_analysisScheme :: (AnalysisSchemeStatus -> f AnalysisSchemeStatus)
-> DefineAnalysisSchemeResponse -> f DefineAnalysisSchemeResponse
defineAnalysisSchemeResponse_analysisScheme = (DefineAnalysisSchemeResponse -> AnalysisSchemeStatus)
-> (DefineAnalysisSchemeResponse
    -> AnalysisSchemeStatus -> DefineAnalysisSchemeResponse)
-> Lens
     DefineAnalysisSchemeResponse
     DefineAnalysisSchemeResponse
     AnalysisSchemeStatus
     AnalysisSchemeStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DefineAnalysisSchemeResponse' {AnalysisSchemeStatus
analysisScheme :: AnalysisSchemeStatus
$sel:analysisScheme:DefineAnalysisSchemeResponse' :: DefineAnalysisSchemeResponse -> AnalysisSchemeStatus
analysisScheme} -> AnalysisSchemeStatus
analysisScheme) (\s :: DefineAnalysisSchemeResponse
s@DefineAnalysisSchemeResponse' {} AnalysisSchemeStatus
a -> DefineAnalysisSchemeResponse
s {$sel:analysisScheme:DefineAnalysisSchemeResponse' :: AnalysisSchemeStatus
analysisScheme = AnalysisSchemeStatus
a} :: DefineAnalysisSchemeResponse)

instance Prelude.NFData DefineAnalysisSchemeResponse