{-# 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.ElasticSearch.DeleteElasticsearchDomain
-- 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)
--
-- Permanently deletes the specified Elasticsearch domain and all of its
-- data. Once a domain is deleted, it cannot be recovered.
module Amazonka.ElasticSearch.DeleteElasticsearchDomain
  ( -- * Creating a Request
    DeleteElasticsearchDomain (..),
    newDeleteElasticsearchDomain,

    -- * Request Lenses
    deleteElasticsearchDomain_domainName,

    -- * Destructuring the Response
    DeleteElasticsearchDomainResponse (..),
    newDeleteElasticsearchDomainResponse,

    -- * Response Lenses
    deleteElasticsearchDomainResponse_domainStatus,
    deleteElasticsearchDomainResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.ElasticSearch.Types
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 @DeleteElasticsearchDomain@
-- operation. Specifies the name of the Elasticsearch domain that you want
-- to delete.
--
-- /See:/ 'newDeleteElasticsearchDomain' smart constructor.
data DeleteElasticsearchDomain = DeleteElasticsearchDomain'
  { -- | The name of the Elasticsearch domain that you want to permanently
    -- delete.
    DeleteElasticsearchDomain -> Text
domainName :: Prelude.Text
  }
  deriving (DeleteElasticsearchDomain -> DeleteElasticsearchDomain -> Bool
(DeleteElasticsearchDomain -> DeleteElasticsearchDomain -> Bool)
-> (DeleteElasticsearchDomain -> DeleteElasticsearchDomain -> Bool)
-> Eq DeleteElasticsearchDomain
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteElasticsearchDomain -> DeleteElasticsearchDomain -> Bool
$c/= :: DeleteElasticsearchDomain -> DeleteElasticsearchDomain -> Bool
== :: DeleteElasticsearchDomain -> DeleteElasticsearchDomain -> Bool
$c== :: DeleteElasticsearchDomain -> DeleteElasticsearchDomain -> Bool
Prelude.Eq, ReadPrec [DeleteElasticsearchDomain]
ReadPrec DeleteElasticsearchDomain
Int -> ReadS DeleteElasticsearchDomain
ReadS [DeleteElasticsearchDomain]
(Int -> ReadS DeleteElasticsearchDomain)
-> ReadS [DeleteElasticsearchDomain]
-> ReadPrec DeleteElasticsearchDomain
-> ReadPrec [DeleteElasticsearchDomain]
-> Read DeleteElasticsearchDomain
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteElasticsearchDomain]
$creadListPrec :: ReadPrec [DeleteElasticsearchDomain]
readPrec :: ReadPrec DeleteElasticsearchDomain
$creadPrec :: ReadPrec DeleteElasticsearchDomain
readList :: ReadS [DeleteElasticsearchDomain]
$creadList :: ReadS [DeleteElasticsearchDomain]
readsPrec :: Int -> ReadS DeleteElasticsearchDomain
$creadsPrec :: Int -> ReadS DeleteElasticsearchDomain
Prelude.Read, Int -> DeleteElasticsearchDomain -> ShowS
[DeleteElasticsearchDomain] -> ShowS
DeleteElasticsearchDomain -> String
(Int -> DeleteElasticsearchDomain -> ShowS)
-> (DeleteElasticsearchDomain -> String)
-> ([DeleteElasticsearchDomain] -> ShowS)
-> Show DeleteElasticsearchDomain
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteElasticsearchDomain] -> ShowS
$cshowList :: [DeleteElasticsearchDomain] -> ShowS
show :: DeleteElasticsearchDomain -> String
$cshow :: DeleteElasticsearchDomain -> String
showsPrec :: Int -> DeleteElasticsearchDomain -> ShowS
$cshowsPrec :: Int -> DeleteElasticsearchDomain -> ShowS
Prelude.Show, (forall x.
 DeleteElasticsearchDomain -> Rep DeleteElasticsearchDomain x)
-> (forall x.
    Rep DeleteElasticsearchDomain x -> DeleteElasticsearchDomain)
-> Generic DeleteElasticsearchDomain
forall x.
Rep DeleteElasticsearchDomain x -> DeleteElasticsearchDomain
forall x.
DeleteElasticsearchDomain -> Rep DeleteElasticsearchDomain x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteElasticsearchDomain x -> DeleteElasticsearchDomain
$cfrom :: forall x.
DeleteElasticsearchDomain -> Rep DeleteElasticsearchDomain x
Prelude.Generic)

-- |
-- Create a value of 'DeleteElasticsearchDomain' 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', 'deleteElasticsearchDomain_domainName' - The name of the Elasticsearch domain that you want to permanently
-- delete.
newDeleteElasticsearchDomain ::
  -- | 'domainName'
  Prelude.Text ->
  DeleteElasticsearchDomain
newDeleteElasticsearchDomain :: Text -> DeleteElasticsearchDomain
newDeleteElasticsearchDomain Text
pDomainName_ =
  DeleteElasticsearchDomain' :: Text -> DeleteElasticsearchDomain
DeleteElasticsearchDomain'
    { $sel:domainName:DeleteElasticsearchDomain' :: Text
domainName =
        Text
pDomainName_
    }

-- | The name of the Elasticsearch domain that you want to permanently
-- delete.
deleteElasticsearchDomain_domainName :: Lens.Lens' DeleteElasticsearchDomain Prelude.Text
deleteElasticsearchDomain_domainName :: (Text -> f Text)
-> DeleteElasticsearchDomain -> f DeleteElasticsearchDomain
deleteElasticsearchDomain_domainName = (DeleteElasticsearchDomain -> Text)
-> (DeleteElasticsearchDomain -> Text -> DeleteElasticsearchDomain)
-> Lens
     DeleteElasticsearchDomain DeleteElasticsearchDomain Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteElasticsearchDomain' {Text
domainName :: Text
$sel:domainName:DeleteElasticsearchDomain' :: DeleteElasticsearchDomain -> Text
domainName} -> Text
domainName) (\s :: DeleteElasticsearchDomain
s@DeleteElasticsearchDomain' {} Text
a -> DeleteElasticsearchDomain
s {$sel:domainName:DeleteElasticsearchDomain' :: Text
domainName = Text
a} :: DeleteElasticsearchDomain)

instance Core.AWSRequest DeleteElasticsearchDomain where
  type
    AWSResponse DeleteElasticsearchDomain =
      DeleteElasticsearchDomainResponse
  request :: DeleteElasticsearchDomain -> Request DeleteElasticsearchDomain
request = Service
-> DeleteElasticsearchDomain -> Request DeleteElasticsearchDomain
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteElasticsearchDomain
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteElasticsearchDomain)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteElasticsearchDomain))
-> Logger
-> Service
-> Proxy DeleteElasticsearchDomain
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteElasticsearchDomain)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe ElasticsearchDomainStatus
-> Int -> DeleteElasticsearchDomainResponse
DeleteElasticsearchDomainResponse'
            (Maybe ElasticsearchDomainStatus
 -> Int -> DeleteElasticsearchDomainResponse)
-> Either String (Maybe ElasticsearchDomainStatus)
-> Either String (Int -> DeleteElasticsearchDomainResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ElasticsearchDomainStatus)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"DomainStatus")
            Either String (Int -> DeleteElasticsearchDomainResponse)
-> Either String Int
-> Either String DeleteElasticsearchDomainResponse
forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable DeleteElasticsearchDomain

instance Prelude.NFData DeleteElasticsearchDomain

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

instance Core.ToPath DeleteElasticsearchDomain where
  toPath :: DeleteElasticsearchDomain -> ByteString
toPath DeleteElasticsearchDomain' {Text
domainName :: Text
$sel:domainName:DeleteElasticsearchDomain' :: DeleteElasticsearchDomain -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/2015-01-01/es/domain/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
domainName]

instance Core.ToQuery DeleteElasticsearchDomain where
  toQuery :: DeleteElasticsearchDomain -> QueryString
toQuery = QueryString -> DeleteElasticsearchDomain -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | The result of a @DeleteElasticsearchDomain@ request. Contains the status
-- of the pending deletion, or no status if the domain and all of its
-- resources have been deleted.
--
-- /See:/ 'newDeleteElasticsearchDomainResponse' smart constructor.
data DeleteElasticsearchDomainResponse = DeleteElasticsearchDomainResponse'
  { -- | The status of the Elasticsearch domain being deleted.
    DeleteElasticsearchDomainResponse
-> Maybe ElasticsearchDomainStatus
domainStatus :: Prelude.Maybe ElasticsearchDomainStatus,
    -- | The response's http status code.
    DeleteElasticsearchDomainResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteElasticsearchDomainResponse
-> DeleteElasticsearchDomainResponse -> Bool
(DeleteElasticsearchDomainResponse
 -> DeleteElasticsearchDomainResponse -> Bool)
-> (DeleteElasticsearchDomainResponse
    -> DeleteElasticsearchDomainResponse -> Bool)
-> Eq DeleteElasticsearchDomainResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteElasticsearchDomainResponse
-> DeleteElasticsearchDomainResponse -> Bool
$c/= :: DeleteElasticsearchDomainResponse
-> DeleteElasticsearchDomainResponse -> Bool
== :: DeleteElasticsearchDomainResponse
-> DeleteElasticsearchDomainResponse -> Bool
$c== :: DeleteElasticsearchDomainResponse
-> DeleteElasticsearchDomainResponse -> Bool
Prelude.Eq, ReadPrec [DeleteElasticsearchDomainResponse]
ReadPrec DeleteElasticsearchDomainResponse
Int -> ReadS DeleteElasticsearchDomainResponse
ReadS [DeleteElasticsearchDomainResponse]
(Int -> ReadS DeleteElasticsearchDomainResponse)
-> ReadS [DeleteElasticsearchDomainResponse]
-> ReadPrec DeleteElasticsearchDomainResponse
-> ReadPrec [DeleteElasticsearchDomainResponse]
-> Read DeleteElasticsearchDomainResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteElasticsearchDomainResponse]
$creadListPrec :: ReadPrec [DeleteElasticsearchDomainResponse]
readPrec :: ReadPrec DeleteElasticsearchDomainResponse
$creadPrec :: ReadPrec DeleteElasticsearchDomainResponse
readList :: ReadS [DeleteElasticsearchDomainResponse]
$creadList :: ReadS [DeleteElasticsearchDomainResponse]
readsPrec :: Int -> ReadS DeleteElasticsearchDomainResponse
$creadsPrec :: Int -> ReadS DeleteElasticsearchDomainResponse
Prelude.Read, Int -> DeleteElasticsearchDomainResponse -> ShowS
[DeleteElasticsearchDomainResponse] -> ShowS
DeleteElasticsearchDomainResponse -> String
(Int -> DeleteElasticsearchDomainResponse -> ShowS)
-> (DeleteElasticsearchDomainResponse -> String)
-> ([DeleteElasticsearchDomainResponse] -> ShowS)
-> Show DeleteElasticsearchDomainResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteElasticsearchDomainResponse] -> ShowS
$cshowList :: [DeleteElasticsearchDomainResponse] -> ShowS
show :: DeleteElasticsearchDomainResponse -> String
$cshow :: DeleteElasticsearchDomainResponse -> String
showsPrec :: Int -> DeleteElasticsearchDomainResponse -> ShowS
$cshowsPrec :: Int -> DeleteElasticsearchDomainResponse -> ShowS
Prelude.Show, (forall x.
 DeleteElasticsearchDomainResponse
 -> Rep DeleteElasticsearchDomainResponse x)
-> (forall x.
    Rep DeleteElasticsearchDomainResponse x
    -> DeleteElasticsearchDomainResponse)
-> Generic DeleteElasticsearchDomainResponse
forall x.
Rep DeleteElasticsearchDomainResponse x
-> DeleteElasticsearchDomainResponse
forall x.
DeleteElasticsearchDomainResponse
-> Rep DeleteElasticsearchDomainResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteElasticsearchDomainResponse x
-> DeleteElasticsearchDomainResponse
$cfrom :: forall x.
DeleteElasticsearchDomainResponse
-> Rep DeleteElasticsearchDomainResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteElasticsearchDomainResponse' 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:
--
-- 'domainStatus', 'deleteElasticsearchDomainResponse_domainStatus' - The status of the Elasticsearch domain being deleted.
--
-- 'httpStatus', 'deleteElasticsearchDomainResponse_httpStatus' - The response's http status code.
newDeleteElasticsearchDomainResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteElasticsearchDomainResponse
newDeleteElasticsearchDomainResponse :: Int -> DeleteElasticsearchDomainResponse
newDeleteElasticsearchDomainResponse Int
pHttpStatus_ =
  DeleteElasticsearchDomainResponse' :: Maybe ElasticsearchDomainStatus
-> Int -> DeleteElasticsearchDomainResponse
DeleteElasticsearchDomainResponse'
    { $sel:domainStatus:DeleteElasticsearchDomainResponse' :: Maybe ElasticsearchDomainStatus
domainStatus =
        Maybe ElasticsearchDomainStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteElasticsearchDomainResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The status of the Elasticsearch domain being deleted.
deleteElasticsearchDomainResponse_domainStatus :: Lens.Lens' DeleteElasticsearchDomainResponse (Prelude.Maybe ElasticsearchDomainStatus)
deleteElasticsearchDomainResponse_domainStatus :: (Maybe ElasticsearchDomainStatus
 -> f (Maybe ElasticsearchDomainStatus))
-> DeleteElasticsearchDomainResponse
-> f DeleteElasticsearchDomainResponse
deleteElasticsearchDomainResponse_domainStatus = (DeleteElasticsearchDomainResponse
 -> Maybe ElasticsearchDomainStatus)
-> (DeleteElasticsearchDomainResponse
    -> Maybe ElasticsearchDomainStatus
    -> DeleteElasticsearchDomainResponse)
-> Lens
     DeleteElasticsearchDomainResponse
     DeleteElasticsearchDomainResponse
     (Maybe ElasticsearchDomainStatus)
     (Maybe ElasticsearchDomainStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteElasticsearchDomainResponse' {Maybe ElasticsearchDomainStatus
domainStatus :: Maybe ElasticsearchDomainStatus
$sel:domainStatus:DeleteElasticsearchDomainResponse' :: DeleteElasticsearchDomainResponse
-> Maybe ElasticsearchDomainStatus
domainStatus} -> Maybe ElasticsearchDomainStatus
domainStatus) (\s :: DeleteElasticsearchDomainResponse
s@DeleteElasticsearchDomainResponse' {} Maybe ElasticsearchDomainStatus
a -> DeleteElasticsearchDomainResponse
s {$sel:domainStatus:DeleteElasticsearchDomainResponse' :: Maybe ElasticsearchDomainStatus
domainStatus = Maybe ElasticsearchDomainStatus
a} :: DeleteElasticsearchDomainResponse)

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

instance
  Prelude.NFData
    DeleteElasticsearchDomainResponse