{-# 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.DeleteExpression
-- 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)
--
-- Removes an @Expression@ from the search domain. For more information,
-- see
-- <http://docs.aws.amazon.com/cloudsearch/latest/developerguide/configuring-expressions.html Configuring Expressions>
-- in the /Amazon CloudSearch Developer Guide/.
module Amazonka.CloudSearch.DeleteExpression
  ( -- * Creating a Request
    DeleteExpression (..),
    newDeleteExpression,

    -- * Request Lenses
    deleteExpression_domainName,
    deleteExpression_expressionName,

    -- * Destructuring the Response
    DeleteExpressionResponse (..),
    newDeleteExpressionResponse,

    -- * Response Lenses
    deleteExpressionResponse_httpStatus,
    deleteExpressionResponse_expression,
  )
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 @DeleteExpression@ operation.
-- Specifies the name of the domain you want to update and the name of the
-- expression you want to delete.
--
-- /See:/ 'newDeleteExpression' smart constructor.
data DeleteExpression = DeleteExpression'
  { DeleteExpression -> Text
domainName :: Prelude.Text,
    -- | The name of the @Expression@ to delete.
    DeleteExpression -> Text
expressionName :: Prelude.Text
  }
  deriving (DeleteExpression -> DeleteExpression -> Bool
(DeleteExpression -> DeleteExpression -> Bool)
-> (DeleteExpression -> DeleteExpression -> Bool)
-> Eq DeleteExpression
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteExpression -> DeleteExpression -> Bool
$c/= :: DeleteExpression -> DeleteExpression -> Bool
== :: DeleteExpression -> DeleteExpression -> Bool
$c== :: DeleteExpression -> DeleteExpression -> Bool
Prelude.Eq, ReadPrec [DeleteExpression]
ReadPrec DeleteExpression
Int -> ReadS DeleteExpression
ReadS [DeleteExpression]
(Int -> ReadS DeleteExpression)
-> ReadS [DeleteExpression]
-> ReadPrec DeleteExpression
-> ReadPrec [DeleteExpression]
-> Read DeleteExpression
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteExpression]
$creadListPrec :: ReadPrec [DeleteExpression]
readPrec :: ReadPrec DeleteExpression
$creadPrec :: ReadPrec DeleteExpression
readList :: ReadS [DeleteExpression]
$creadList :: ReadS [DeleteExpression]
readsPrec :: Int -> ReadS DeleteExpression
$creadsPrec :: Int -> ReadS DeleteExpression
Prelude.Read, Int -> DeleteExpression -> ShowS
[DeleteExpression] -> ShowS
DeleteExpression -> String
(Int -> DeleteExpression -> ShowS)
-> (DeleteExpression -> String)
-> ([DeleteExpression] -> ShowS)
-> Show DeleteExpression
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteExpression] -> ShowS
$cshowList :: [DeleteExpression] -> ShowS
show :: DeleteExpression -> String
$cshow :: DeleteExpression -> String
showsPrec :: Int -> DeleteExpression -> ShowS
$cshowsPrec :: Int -> DeleteExpression -> ShowS
Prelude.Show, (forall x. DeleteExpression -> Rep DeleteExpression x)
-> (forall x. Rep DeleteExpression x -> DeleteExpression)
-> Generic DeleteExpression
forall x. Rep DeleteExpression x -> DeleteExpression
forall x. DeleteExpression -> Rep DeleteExpression x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteExpression x -> DeleteExpression
$cfrom :: forall x. DeleteExpression -> Rep DeleteExpression x
Prelude.Generic)

-- |
-- Create a value of 'DeleteExpression' 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', 'deleteExpression_domainName' - Undocumented member.
--
-- 'expressionName', 'deleteExpression_expressionName' - The name of the @Expression@ to delete.
newDeleteExpression ::
  -- | 'domainName'
  Prelude.Text ->
  -- | 'expressionName'
  Prelude.Text ->
  DeleteExpression
newDeleteExpression :: Text -> Text -> DeleteExpression
newDeleteExpression Text
pDomainName_ Text
pExpressionName_ =
  DeleteExpression' :: Text -> Text -> DeleteExpression
DeleteExpression'
    { $sel:domainName:DeleteExpression' :: Text
domainName = Text
pDomainName_,
      $sel:expressionName:DeleteExpression' :: Text
expressionName = Text
pExpressionName_
    }

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

-- | The name of the @Expression@ to delete.
deleteExpression_expressionName :: Lens.Lens' DeleteExpression Prelude.Text
deleteExpression_expressionName :: (Text -> f Text) -> DeleteExpression -> f DeleteExpression
deleteExpression_expressionName = (DeleteExpression -> Text)
-> (DeleteExpression -> Text -> DeleteExpression)
-> Lens DeleteExpression DeleteExpression Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteExpression' {Text
expressionName :: Text
$sel:expressionName:DeleteExpression' :: DeleteExpression -> Text
expressionName} -> Text
expressionName) (\s :: DeleteExpression
s@DeleteExpression' {} Text
a -> DeleteExpression
s {$sel:expressionName:DeleteExpression' :: Text
expressionName = Text
a} :: DeleteExpression)

instance Core.AWSRequest DeleteExpression where
  type
    AWSResponse DeleteExpression =
      DeleteExpressionResponse
  request :: DeleteExpression -> Request DeleteExpression
request = Service -> DeleteExpression -> Request DeleteExpression
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteExpression
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteExpression)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DeleteExpression))
-> Logger
-> Service
-> Proxy DeleteExpression
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteExpression)))
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
"DeleteExpressionResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> ExpressionStatus -> DeleteExpressionResponse
DeleteExpressionResponse'
            (Int -> ExpressionStatus -> DeleteExpressionResponse)
-> Either String Int
-> Either String (ExpressionStatus -> DeleteExpressionResponse)
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 (ExpressionStatus -> DeleteExpressionResponse)
-> Either String ExpressionStatus
-> Either String DeleteExpressionResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String ExpressionStatus
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Expression")
      )

instance Prelude.Hashable DeleteExpression

instance Prelude.NFData DeleteExpression

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

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

instance Core.ToQuery DeleteExpression where
  toQuery :: DeleteExpression -> QueryString
toQuery DeleteExpression' {Text
expressionName :: Text
domainName :: Text
$sel:expressionName:DeleteExpression' :: DeleteExpression -> Text
$sel:domainName:DeleteExpression' :: DeleteExpression -> 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
"DeleteExpression" :: 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
"ExpressionName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
expressionName
      ]

-- | The result of a @DeleteExpression@ request. Specifies the expression
-- being deleted.
--
-- /See:/ 'newDeleteExpressionResponse' smart constructor.
data DeleteExpressionResponse = DeleteExpressionResponse'
  { -- | The response's http status code.
    DeleteExpressionResponse -> Int
httpStatus :: Prelude.Int,
    -- | The status of the expression being deleted.
    DeleteExpressionResponse -> ExpressionStatus
expression :: ExpressionStatus
  }
  deriving (DeleteExpressionResponse -> DeleteExpressionResponse -> Bool
(DeleteExpressionResponse -> DeleteExpressionResponse -> Bool)
-> (DeleteExpressionResponse -> DeleteExpressionResponse -> Bool)
-> Eq DeleteExpressionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteExpressionResponse -> DeleteExpressionResponse -> Bool
$c/= :: DeleteExpressionResponse -> DeleteExpressionResponse -> Bool
== :: DeleteExpressionResponse -> DeleteExpressionResponse -> Bool
$c== :: DeleteExpressionResponse -> DeleteExpressionResponse -> Bool
Prelude.Eq, ReadPrec [DeleteExpressionResponse]
ReadPrec DeleteExpressionResponse
Int -> ReadS DeleteExpressionResponse
ReadS [DeleteExpressionResponse]
(Int -> ReadS DeleteExpressionResponse)
-> ReadS [DeleteExpressionResponse]
-> ReadPrec DeleteExpressionResponse
-> ReadPrec [DeleteExpressionResponse]
-> Read DeleteExpressionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteExpressionResponse]
$creadListPrec :: ReadPrec [DeleteExpressionResponse]
readPrec :: ReadPrec DeleteExpressionResponse
$creadPrec :: ReadPrec DeleteExpressionResponse
readList :: ReadS [DeleteExpressionResponse]
$creadList :: ReadS [DeleteExpressionResponse]
readsPrec :: Int -> ReadS DeleteExpressionResponse
$creadsPrec :: Int -> ReadS DeleteExpressionResponse
Prelude.Read, Int -> DeleteExpressionResponse -> ShowS
[DeleteExpressionResponse] -> ShowS
DeleteExpressionResponse -> String
(Int -> DeleteExpressionResponse -> ShowS)
-> (DeleteExpressionResponse -> String)
-> ([DeleteExpressionResponse] -> ShowS)
-> Show DeleteExpressionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteExpressionResponse] -> ShowS
$cshowList :: [DeleteExpressionResponse] -> ShowS
show :: DeleteExpressionResponse -> String
$cshow :: DeleteExpressionResponse -> String
showsPrec :: Int -> DeleteExpressionResponse -> ShowS
$cshowsPrec :: Int -> DeleteExpressionResponse -> ShowS
Prelude.Show, (forall x.
 DeleteExpressionResponse -> Rep DeleteExpressionResponse x)
-> (forall x.
    Rep DeleteExpressionResponse x -> DeleteExpressionResponse)
-> Generic DeleteExpressionResponse
forall x.
Rep DeleteExpressionResponse x -> DeleteExpressionResponse
forall x.
DeleteExpressionResponse -> Rep DeleteExpressionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteExpressionResponse x -> DeleteExpressionResponse
$cfrom :: forall x.
DeleteExpressionResponse -> Rep DeleteExpressionResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteExpressionResponse' 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', 'deleteExpressionResponse_httpStatus' - The response's http status code.
--
-- 'expression', 'deleteExpressionResponse_expression' - The status of the expression being deleted.
newDeleteExpressionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'expression'
  ExpressionStatus ->
  DeleteExpressionResponse
newDeleteExpressionResponse :: Int -> ExpressionStatus -> DeleteExpressionResponse
newDeleteExpressionResponse Int
pHttpStatus_ ExpressionStatus
pExpression_ =
  DeleteExpressionResponse' :: Int -> ExpressionStatus -> DeleteExpressionResponse
DeleteExpressionResponse'
    { $sel:httpStatus:DeleteExpressionResponse' :: Int
httpStatus =
        Int
pHttpStatus_,
      $sel:expression:DeleteExpressionResponse' :: ExpressionStatus
expression = ExpressionStatus
pExpression_
    }

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

-- | The status of the expression being deleted.
deleteExpressionResponse_expression :: Lens.Lens' DeleteExpressionResponse ExpressionStatus
deleteExpressionResponse_expression :: (ExpressionStatus -> f ExpressionStatus)
-> DeleteExpressionResponse -> f DeleteExpressionResponse
deleteExpressionResponse_expression = (DeleteExpressionResponse -> ExpressionStatus)
-> (DeleteExpressionResponse
    -> ExpressionStatus -> DeleteExpressionResponse)
-> Lens
     DeleteExpressionResponse
     DeleteExpressionResponse
     ExpressionStatus
     ExpressionStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteExpressionResponse' {ExpressionStatus
expression :: ExpressionStatus
$sel:expression:DeleteExpressionResponse' :: DeleteExpressionResponse -> ExpressionStatus
expression} -> ExpressionStatus
expression) (\s :: DeleteExpressionResponse
s@DeleteExpressionResponse' {} ExpressionStatus
a -> DeleteExpressionResponse
s {$sel:expression:DeleteExpressionResponse' :: ExpressionStatus
expression = ExpressionStatus
a} :: DeleteExpressionResponse)

instance Prelude.NFData DeleteExpressionResponse