{-# 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.Route53Domains.DeleteDomain
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- This operation deletes the specified domain. This action is permanent.
-- For more information, see
-- <https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/domain-delete.html Deleting a domain name registration>.
--
-- To transfer the domain registration to another registrar, use the
-- transfer process that’s provided by the registrar to which you want to
-- transfer the registration. Otherwise, the following apply:
--
-- 1.  You can’t get a refund for the cost of a deleted domain
--     registration.
--
-- 2.  The registry for the top-level domain might hold the domain name for
--     a brief time before releasing it for other users to register (varies
--     by registry).
--
-- 3.  When the registration has been deleted, we\'ll send you a
--     confirmation to the registrant contact. The email will come from
--     @noreply\@domainnameverification.net@ or
--     @noreply\@registrar.amazon.com@.
module Amazonka.Route53Domains.DeleteDomain
  ( -- * Creating a Request
    DeleteDomain (..),
    newDeleteDomain,

    -- * Request Lenses
    deleteDomain_domainName,

    -- * Destructuring the Response
    DeleteDomainResponse (..),
    newDeleteDomainResponse,

    -- * Response Lenses
    deleteDomainResponse_operationId,
    deleteDomainResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.Route53Domains.Types

-- | /See:/ 'newDeleteDomain' smart constructor.
data DeleteDomain = DeleteDomain'
  { -- | Name of the domain to be deleted.
    DeleteDomain -> Text
domainName :: Prelude.Text
  }
  deriving (DeleteDomain -> DeleteDomain -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteDomain -> DeleteDomain -> Bool
$c/= :: DeleteDomain -> DeleteDomain -> Bool
== :: DeleteDomain -> DeleteDomain -> Bool
$c== :: DeleteDomain -> DeleteDomain -> Bool
Prelude.Eq, ReadPrec [DeleteDomain]
ReadPrec DeleteDomain
Int -> ReadS DeleteDomain
ReadS [DeleteDomain]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteDomain]
$creadListPrec :: ReadPrec [DeleteDomain]
readPrec :: ReadPrec DeleteDomain
$creadPrec :: ReadPrec DeleteDomain
readList :: ReadS [DeleteDomain]
$creadList :: ReadS [DeleteDomain]
readsPrec :: Int -> ReadS DeleteDomain
$creadsPrec :: Int -> ReadS DeleteDomain
Prelude.Read, Int -> DeleteDomain -> ShowS
[DeleteDomain] -> ShowS
DeleteDomain -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteDomain] -> ShowS
$cshowList :: [DeleteDomain] -> ShowS
show :: DeleteDomain -> String
$cshow :: DeleteDomain -> String
showsPrec :: Int -> DeleteDomain -> ShowS
$cshowsPrec :: Int -> DeleteDomain -> ShowS
Prelude.Show, forall x. Rep DeleteDomain x -> DeleteDomain
forall x. DeleteDomain -> Rep DeleteDomain x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteDomain x -> DeleteDomain
$cfrom :: forall x. DeleteDomain -> Rep DeleteDomain x
Prelude.Generic)

-- |
-- Create a value of 'DeleteDomain' 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', 'deleteDomain_domainName' - Name of the domain to be deleted.
newDeleteDomain ::
  -- | 'domainName'
  Prelude.Text ->
  DeleteDomain
newDeleteDomain :: Text -> DeleteDomain
newDeleteDomain Text
pDomainName_ =
  DeleteDomain' {$sel:domainName:DeleteDomain' :: Text
domainName = Text
pDomainName_}

-- | Name of the domain to be deleted.
deleteDomain_domainName :: Lens.Lens' DeleteDomain Prelude.Text
deleteDomain_domainName :: Lens' DeleteDomain Text
deleteDomain_domainName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDomain' {Text
domainName :: Text
$sel:domainName:DeleteDomain' :: DeleteDomain -> Text
domainName} -> Text
domainName) (\s :: DeleteDomain
s@DeleteDomain' {} Text
a -> DeleteDomain
s {$sel:domainName:DeleteDomain' :: Text
domainName = Text
a} :: DeleteDomain)

instance Core.AWSRequest DeleteDomain where
  type AWSResponse DeleteDomain = DeleteDomainResponse
  request :: (Service -> Service) -> DeleteDomain -> Request DeleteDomain
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteDomain
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteDomain)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> DeleteDomainResponse
DeleteDomainResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"OperationId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteDomain where
  hashWithSalt :: Int -> DeleteDomain -> Int
hashWithSalt Int
_salt DeleteDomain' {Text
domainName :: Text
$sel:domainName:DeleteDomain' :: DeleteDomain -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domainName

instance Prelude.NFData DeleteDomain where
  rnf :: DeleteDomain -> ()
rnf DeleteDomain' {Text
domainName :: Text
$sel:domainName:DeleteDomain' :: DeleteDomain -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
domainName

instance Data.ToHeaders DeleteDomain where
  toHeaders :: DeleteDomain -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"Route53Domains_v20140515.DeleteDomain" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DeleteDomain where
  toJSON :: DeleteDomain -> Value
toJSON DeleteDomain' {Text
domainName :: Text
$sel:domainName:DeleteDomain' :: DeleteDomain -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"DomainName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
domainName)]
      )

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

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

-- | /See:/ 'newDeleteDomainResponse' smart constructor.
data DeleteDomainResponse = DeleteDomainResponse'
  { -- | Identifier for tracking the progress of the request. To query the
    -- operation status, use
    -- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_domains_GetOperationDetail.html GetOperationDetail>.
    DeleteDomainResponse -> Maybe Text
operationId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DeleteDomainResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteDomainResponse -> DeleteDomainResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteDomainResponse -> DeleteDomainResponse -> Bool
$c/= :: DeleteDomainResponse -> DeleteDomainResponse -> Bool
== :: DeleteDomainResponse -> DeleteDomainResponse -> Bool
$c== :: DeleteDomainResponse -> DeleteDomainResponse -> Bool
Prelude.Eq, ReadPrec [DeleteDomainResponse]
ReadPrec DeleteDomainResponse
Int -> ReadS DeleteDomainResponse
ReadS [DeleteDomainResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteDomainResponse]
$creadListPrec :: ReadPrec [DeleteDomainResponse]
readPrec :: ReadPrec DeleteDomainResponse
$creadPrec :: ReadPrec DeleteDomainResponse
readList :: ReadS [DeleteDomainResponse]
$creadList :: ReadS [DeleteDomainResponse]
readsPrec :: Int -> ReadS DeleteDomainResponse
$creadsPrec :: Int -> ReadS DeleteDomainResponse
Prelude.Read, Int -> DeleteDomainResponse -> ShowS
[DeleteDomainResponse] -> ShowS
DeleteDomainResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteDomainResponse] -> ShowS
$cshowList :: [DeleteDomainResponse] -> ShowS
show :: DeleteDomainResponse -> String
$cshow :: DeleteDomainResponse -> String
showsPrec :: Int -> DeleteDomainResponse -> ShowS
$cshowsPrec :: Int -> DeleteDomainResponse -> ShowS
Prelude.Show, forall x. Rep DeleteDomainResponse x -> DeleteDomainResponse
forall x. DeleteDomainResponse -> Rep DeleteDomainResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteDomainResponse x -> DeleteDomainResponse
$cfrom :: forall x. DeleteDomainResponse -> Rep DeleteDomainResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteDomainResponse' 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:
--
-- 'operationId', 'deleteDomainResponse_operationId' - Identifier for tracking the progress of the request. To query the
-- operation status, use
-- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_domains_GetOperationDetail.html GetOperationDetail>.
--
-- 'httpStatus', 'deleteDomainResponse_httpStatus' - The response's http status code.
newDeleteDomainResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteDomainResponse
newDeleteDomainResponse :: Int -> DeleteDomainResponse
newDeleteDomainResponse Int
pHttpStatus_ =
  DeleteDomainResponse'
    { $sel:operationId:DeleteDomainResponse' :: Maybe Text
operationId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteDomainResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Identifier for tracking the progress of the request. To query the
-- operation status, use
-- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_domains_GetOperationDetail.html GetOperationDetail>.
deleteDomainResponse_operationId :: Lens.Lens' DeleteDomainResponse (Prelude.Maybe Prelude.Text)
deleteDomainResponse_operationId :: Lens' DeleteDomainResponse (Maybe Text)
deleteDomainResponse_operationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDomainResponse' {Maybe Text
operationId :: Maybe Text
$sel:operationId:DeleteDomainResponse' :: DeleteDomainResponse -> Maybe Text
operationId} -> Maybe Text
operationId) (\s :: DeleteDomainResponse
s@DeleteDomainResponse' {} Maybe Text
a -> DeleteDomainResponse
s {$sel:operationId:DeleteDomainResponse' :: Maybe Text
operationId = Maybe Text
a} :: DeleteDomainResponse)

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

instance Prelude.NFData DeleteDomainResponse where
  rnf :: DeleteDomainResponse -> ()
rnf DeleteDomainResponse' {Int
Maybe Text
httpStatus :: Int
operationId :: Maybe Text
$sel:httpStatus:DeleteDomainResponse' :: DeleteDomainResponse -> Int
$sel:operationId:DeleteDomainResponse' :: DeleteDomainResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
operationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus