{-# 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.Route53.DeleteHostedZone
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes a hosted zone.
--
-- If the hosted zone was created by another service, such as Cloud Map,
-- see
-- <https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/DeleteHostedZone.html#delete-public-hosted-zone-created-by-another-service Deleting Public Hosted Zones That Were Created by Another Service>
-- in the /Amazon Route 53 Developer Guide/ for information about how to
-- delete it. (The process is the same for public and private hosted zones
-- that were created by another service.)
--
-- If you want to keep your domain registration but you want to stop
-- routing internet traffic to your website or web application, we
-- recommend that you delete resource record sets in the hosted zone
-- instead of deleting the hosted zone.
--
-- If you delete a hosted zone, you can\'t undelete it. You must create a
-- new hosted zone and update the name servers for your domain
-- registration, which can require up to 48 hours to take effect. (If you
-- delegated responsibility for a subdomain to a hosted zone and you delete
-- the child hosted zone, you must update the name servers in the parent
-- hosted zone.) In addition, if you delete a hosted zone, someone could
-- hijack the domain and route traffic to their own resources using your
-- domain name.
--
-- If you want to avoid the monthly charge for the hosted zone, you can
-- transfer DNS service for the domain to a free DNS service. When you
-- transfer DNS service, you have to update the name servers for the domain
-- registration. If the domain is registered with Route 53, see
-- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_domains_UpdateDomainNameservers.html UpdateDomainNameservers>
-- for information about how to replace Route 53 name servers with name
-- servers for the new DNS service. If the domain is registered with
-- another registrar, use the method provided by the registrar to update
-- name servers for the domain registration. For more information, perform
-- an internet search on \"free DNS service.\"
--
-- You can delete a hosted zone only if it contains only the default SOA
-- record and NS resource record sets. If the hosted zone contains other
-- resource record sets, you must delete them before you can delete the
-- hosted zone. If you try to delete a hosted zone that contains other
-- resource record sets, the request fails, and Route 53 returns a
-- @HostedZoneNotEmpty@ error. For information about deleting records from
-- your hosted zone, see
-- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html ChangeResourceRecordSets>.
--
-- To verify that the hosted zone has been deleted, do one of the
-- following:
--
-- -   Use the @GetHostedZone@ action to request information about the
--     hosted zone.
--
-- -   Use the @ListHostedZones@ action to get a list of the hosted zones
--     associated with the current Amazon Web Services account.
module Amazonka.Route53.DeleteHostedZone
  ( -- * Creating a Request
    DeleteHostedZone (..),
    newDeleteHostedZone,

    -- * Request Lenses
    deleteHostedZone_id,

    -- * Destructuring the Response
    DeleteHostedZoneResponse (..),
    newDeleteHostedZoneResponse,

    -- * Response Lenses
    deleteHostedZoneResponse_httpStatus,
    deleteHostedZoneResponse_changeInfo,
  )
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.Route53.Types

-- | A request to delete a hosted zone.
--
-- /See:/ 'newDeleteHostedZone' smart constructor.
data DeleteHostedZone = DeleteHostedZone'
  { -- | The ID of the hosted zone you want to delete.
    DeleteHostedZone -> ResourceId
id :: ResourceId
  }
  deriving (DeleteHostedZone -> DeleteHostedZone -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteHostedZone -> DeleteHostedZone -> Bool
$c/= :: DeleteHostedZone -> DeleteHostedZone -> Bool
== :: DeleteHostedZone -> DeleteHostedZone -> Bool
$c== :: DeleteHostedZone -> DeleteHostedZone -> Bool
Prelude.Eq, ReadPrec [DeleteHostedZone]
ReadPrec DeleteHostedZone
Int -> ReadS DeleteHostedZone
ReadS [DeleteHostedZone]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteHostedZone]
$creadListPrec :: ReadPrec [DeleteHostedZone]
readPrec :: ReadPrec DeleteHostedZone
$creadPrec :: ReadPrec DeleteHostedZone
readList :: ReadS [DeleteHostedZone]
$creadList :: ReadS [DeleteHostedZone]
readsPrec :: Int -> ReadS DeleteHostedZone
$creadsPrec :: Int -> ReadS DeleteHostedZone
Prelude.Read, Int -> DeleteHostedZone -> ShowS
[DeleteHostedZone] -> ShowS
DeleteHostedZone -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteHostedZone] -> ShowS
$cshowList :: [DeleteHostedZone] -> ShowS
show :: DeleteHostedZone -> String
$cshow :: DeleteHostedZone -> String
showsPrec :: Int -> DeleteHostedZone -> ShowS
$cshowsPrec :: Int -> DeleteHostedZone -> ShowS
Prelude.Show, forall x. Rep DeleteHostedZone x -> DeleteHostedZone
forall x. DeleteHostedZone -> Rep DeleteHostedZone x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteHostedZone x -> DeleteHostedZone
$cfrom :: forall x. DeleteHostedZone -> Rep DeleteHostedZone x
Prelude.Generic)

-- |
-- Create a value of 'DeleteHostedZone' 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:
--
-- 'id', 'deleteHostedZone_id' - The ID of the hosted zone you want to delete.
newDeleteHostedZone ::
  -- | 'id'
  ResourceId ->
  DeleteHostedZone
newDeleteHostedZone :: ResourceId -> DeleteHostedZone
newDeleteHostedZone ResourceId
pId_ =
  DeleteHostedZone' {$sel:id:DeleteHostedZone' :: ResourceId
id = ResourceId
pId_}

-- | The ID of the hosted zone you want to delete.
deleteHostedZone_id :: Lens.Lens' DeleteHostedZone ResourceId
deleteHostedZone_id :: Lens' DeleteHostedZone ResourceId
deleteHostedZone_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteHostedZone' {ResourceId
id :: ResourceId
$sel:id:DeleteHostedZone' :: DeleteHostedZone -> ResourceId
id} -> ResourceId
id) (\s :: DeleteHostedZone
s@DeleteHostedZone' {} ResourceId
a -> DeleteHostedZone
s {$sel:id:DeleteHostedZone' :: ResourceId
id = ResourceId
a} :: DeleteHostedZone)

instance Core.AWSRequest DeleteHostedZone where
  type
    AWSResponse DeleteHostedZone =
      DeleteHostedZoneResponse
  request :: (Service -> Service)
-> DeleteHostedZone -> Request DeleteHostedZone
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteHostedZone
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteHostedZone)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> ChangeInfo -> DeleteHostedZoneResponse
DeleteHostedZoneResponse'
            forall (f :: * -> *) a b. Functor 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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"ChangeInfo")
      )

instance Prelude.Hashable DeleteHostedZone where
  hashWithSalt :: Int -> DeleteHostedZone -> Int
hashWithSalt Int
_salt DeleteHostedZone' {ResourceId
id :: ResourceId
$sel:id:DeleteHostedZone' :: DeleteHostedZone -> ResourceId
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ResourceId
id

instance Prelude.NFData DeleteHostedZone where
  rnf :: DeleteHostedZone -> ()
rnf DeleteHostedZone' {ResourceId
id :: ResourceId
$sel:id:DeleteHostedZone' :: DeleteHostedZone -> ResourceId
..} = forall a. NFData a => a -> ()
Prelude.rnf ResourceId
id

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

instance Data.ToPath DeleteHostedZone where
  toPath :: DeleteHostedZone -> ByteString
toPath DeleteHostedZone' {ResourceId
id :: ResourceId
$sel:id:DeleteHostedZone' :: DeleteHostedZone -> ResourceId
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/2013-04-01/hostedzone/", forall a. ToByteString a => a -> ByteString
Data.toBS ResourceId
id]

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

-- | A complex type that contains the response to a @DeleteHostedZone@
-- request.
--
-- /See:/ 'newDeleteHostedZoneResponse' smart constructor.
data DeleteHostedZoneResponse = DeleteHostedZoneResponse'
  { -- | The response's http status code.
    DeleteHostedZoneResponse -> Int
httpStatus :: Prelude.Int,
    -- | A complex type that contains the ID, the status, and the date and time
    -- of a request to delete a hosted zone.
    DeleteHostedZoneResponse -> ChangeInfo
changeInfo :: ChangeInfo
  }
  deriving (DeleteHostedZoneResponse -> DeleteHostedZoneResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteHostedZoneResponse -> DeleteHostedZoneResponse -> Bool
$c/= :: DeleteHostedZoneResponse -> DeleteHostedZoneResponse -> Bool
== :: DeleteHostedZoneResponse -> DeleteHostedZoneResponse -> Bool
$c== :: DeleteHostedZoneResponse -> DeleteHostedZoneResponse -> Bool
Prelude.Eq, ReadPrec [DeleteHostedZoneResponse]
ReadPrec DeleteHostedZoneResponse
Int -> ReadS DeleteHostedZoneResponse
ReadS [DeleteHostedZoneResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteHostedZoneResponse]
$creadListPrec :: ReadPrec [DeleteHostedZoneResponse]
readPrec :: ReadPrec DeleteHostedZoneResponse
$creadPrec :: ReadPrec DeleteHostedZoneResponse
readList :: ReadS [DeleteHostedZoneResponse]
$creadList :: ReadS [DeleteHostedZoneResponse]
readsPrec :: Int -> ReadS DeleteHostedZoneResponse
$creadsPrec :: Int -> ReadS DeleteHostedZoneResponse
Prelude.Read, Int -> DeleteHostedZoneResponse -> ShowS
[DeleteHostedZoneResponse] -> ShowS
DeleteHostedZoneResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteHostedZoneResponse] -> ShowS
$cshowList :: [DeleteHostedZoneResponse] -> ShowS
show :: DeleteHostedZoneResponse -> String
$cshow :: DeleteHostedZoneResponse -> String
showsPrec :: Int -> DeleteHostedZoneResponse -> ShowS
$cshowsPrec :: Int -> DeleteHostedZoneResponse -> ShowS
Prelude.Show, forall x.
Rep DeleteHostedZoneResponse x -> DeleteHostedZoneResponse
forall x.
DeleteHostedZoneResponse -> Rep DeleteHostedZoneResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteHostedZoneResponse x -> DeleteHostedZoneResponse
$cfrom :: forall x.
DeleteHostedZoneResponse -> Rep DeleteHostedZoneResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteHostedZoneResponse' 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', 'deleteHostedZoneResponse_httpStatus' - The response's http status code.
--
-- 'changeInfo', 'deleteHostedZoneResponse_changeInfo' - A complex type that contains the ID, the status, and the date and time
-- of a request to delete a hosted zone.
newDeleteHostedZoneResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'changeInfo'
  ChangeInfo ->
  DeleteHostedZoneResponse
newDeleteHostedZoneResponse :: Int -> ChangeInfo -> DeleteHostedZoneResponse
newDeleteHostedZoneResponse Int
pHttpStatus_ ChangeInfo
pChangeInfo_ =
  DeleteHostedZoneResponse'
    { $sel:httpStatus:DeleteHostedZoneResponse' :: Int
httpStatus =
        Int
pHttpStatus_,
      $sel:changeInfo:DeleteHostedZoneResponse' :: ChangeInfo
changeInfo = ChangeInfo
pChangeInfo_
    }

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

-- | A complex type that contains the ID, the status, and the date and time
-- of a request to delete a hosted zone.
deleteHostedZoneResponse_changeInfo :: Lens.Lens' DeleteHostedZoneResponse ChangeInfo
deleteHostedZoneResponse_changeInfo :: Lens' DeleteHostedZoneResponse ChangeInfo
deleteHostedZoneResponse_changeInfo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteHostedZoneResponse' {ChangeInfo
changeInfo :: ChangeInfo
$sel:changeInfo:DeleteHostedZoneResponse' :: DeleteHostedZoneResponse -> ChangeInfo
changeInfo} -> ChangeInfo
changeInfo) (\s :: DeleteHostedZoneResponse
s@DeleteHostedZoneResponse' {} ChangeInfo
a -> DeleteHostedZoneResponse
s {$sel:changeInfo:DeleteHostedZoneResponse' :: ChangeInfo
changeInfo = ChangeInfo
a} :: DeleteHostedZoneResponse)

instance Prelude.NFData DeleteHostedZoneResponse where
  rnf :: DeleteHostedZoneResponse -> ()
rnf DeleteHostedZoneResponse' {Int
ChangeInfo
changeInfo :: ChangeInfo
httpStatus :: Int
$sel:changeInfo:DeleteHostedZoneResponse' :: DeleteHostedZoneResponse -> ChangeInfo
$sel:httpStatus:DeleteHostedZoneResponse' :: DeleteHostedZoneResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ChangeInfo
changeInfo