{-# 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-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)
--
-- 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.Lens as Lens
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
(DeleteHostedZone -> DeleteHostedZone -> Bool)
-> (DeleteHostedZone -> DeleteHostedZone -> Bool)
-> Eq DeleteHostedZone
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]
(Int -> ReadS DeleteHostedZone)
-> ReadS [DeleteHostedZone]
-> ReadPrec DeleteHostedZone
-> ReadPrec [DeleteHostedZone]
-> Read 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
(Int -> DeleteHostedZone -> ShowS)
-> (DeleteHostedZone -> String)
-> ([DeleteHostedZone] -> ShowS)
-> Show DeleteHostedZone
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. DeleteHostedZone -> Rep DeleteHostedZone x)
-> (forall x. Rep DeleteHostedZone x -> DeleteHostedZone)
-> Generic DeleteHostedZone
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' :: ResourceId -> DeleteHostedZone
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 :: (ResourceId -> f ResourceId)
-> DeleteHostedZone -> f DeleteHostedZone
deleteHostedZone_id = (DeleteHostedZone -> ResourceId)
-> (DeleteHostedZone -> ResourceId -> DeleteHostedZone)
-> Lens DeleteHostedZone DeleteHostedZone ResourceId ResourceId
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 :: DeleteHostedZone -> Request DeleteHostedZone
request = Service -> DeleteHostedZone -> Request DeleteHostedZone
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteHostedZone
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteHostedZone)))
response =
    (Int
 -> ResponseHeaders
 -> [Node]
 -> Either String (AWSResponse DeleteHostedZone))
-> Logger
-> Service
-> Proxy DeleteHostedZone
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteHostedZone)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> ChangeInfo -> DeleteHostedZoneResponse
DeleteHostedZoneResponse'
            (Int -> ChangeInfo -> DeleteHostedZoneResponse)
-> Either String Int
-> Either String (ChangeInfo -> DeleteHostedZoneResponse)
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 (ChangeInfo -> DeleteHostedZoneResponse)
-> Either String ChangeInfo
-> Either String DeleteHostedZoneResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String ChangeInfo
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"ChangeInfo")
      )

instance Prelude.Hashable DeleteHostedZone

instance Prelude.NFData DeleteHostedZone

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

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

instance Core.ToQuery DeleteHostedZone where
  toQuery :: DeleteHostedZone -> QueryString
toQuery = QueryString -> DeleteHostedZone -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteHostedZoneResponse -> DeleteHostedZoneResponse -> Bool)
-> (DeleteHostedZoneResponse -> DeleteHostedZoneResponse -> Bool)
-> Eq DeleteHostedZoneResponse
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]
(Int -> ReadS DeleteHostedZoneResponse)
-> ReadS [DeleteHostedZoneResponse]
-> ReadPrec DeleteHostedZoneResponse
-> ReadPrec [DeleteHostedZoneResponse]
-> Read 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
(Int -> DeleteHostedZoneResponse -> ShowS)
-> (DeleteHostedZoneResponse -> String)
-> ([DeleteHostedZoneResponse] -> ShowS)
-> Show DeleteHostedZoneResponse
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.
 DeleteHostedZoneResponse -> Rep DeleteHostedZoneResponse x)
-> (forall x.
    Rep DeleteHostedZoneResponse x -> DeleteHostedZoneResponse)
-> Generic DeleteHostedZoneResponse
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' :: Int -> ChangeInfo -> DeleteHostedZoneResponse
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 :: (Int -> f Int)
-> DeleteHostedZoneResponse -> f DeleteHostedZoneResponse
deleteHostedZoneResponse_httpStatus = (DeleteHostedZoneResponse -> Int)
-> (DeleteHostedZoneResponse -> Int -> DeleteHostedZoneResponse)
-> Lens DeleteHostedZoneResponse DeleteHostedZoneResponse Int Int
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 :: (ChangeInfo -> f ChangeInfo)
-> DeleteHostedZoneResponse -> f DeleteHostedZoneResponse
deleteHostedZoneResponse_changeInfo = (DeleteHostedZoneResponse -> ChangeInfo)
-> (DeleteHostedZoneResponse
    -> ChangeInfo -> DeleteHostedZoneResponse)
-> Lens
     DeleteHostedZoneResponse
     DeleteHostedZoneResponse
     ChangeInfo
     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