{-# 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.DeleteKeySigningKey
-- 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 key-signing key (KSK). Before you can delete a KSK, you must
-- deactivate it. The KSK must be deactivated before you can delete it
-- regardless of whether the hosted zone is enabled for DNSSEC signing.
--
-- You can use
-- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_DeactivateKeySigningKey.html DeactivateKeySigningKey>
-- to deactivate the key before you delete it.
--
-- Use
-- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_GetDNSSEC.html GetDNSSEC>
-- to verify that the KSK is in an @INACTIVE@ status.
module Amazonka.Route53.DeleteKeySigningKey
  ( -- * Creating a Request
    DeleteKeySigningKey (..),
    newDeleteKeySigningKey,

    -- * Request Lenses
    deleteKeySigningKey_hostedZoneId,
    deleteKeySigningKey_name,

    -- * Destructuring the Response
    DeleteKeySigningKeyResponse (..),
    newDeleteKeySigningKeyResponse,

    -- * Response Lenses
    deleteKeySigningKeyResponse_httpStatus,
    deleteKeySigningKeyResponse_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

-- | /See:/ 'newDeleteKeySigningKey' smart constructor.
data DeleteKeySigningKey = DeleteKeySigningKey'
  { -- | A unique string used to identify a hosted zone.
    DeleteKeySigningKey -> ResourceId
hostedZoneId :: ResourceId,
    -- | A string used to identify a key-signing key (KSK).
    DeleteKeySigningKey -> Text
name :: Prelude.Text
  }
  deriving (DeleteKeySigningKey -> DeleteKeySigningKey -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteKeySigningKey -> DeleteKeySigningKey -> Bool
$c/= :: DeleteKeySigningKey -> DeleteKeySigningKey -> Bool
== :: DeleteKeySigningKey -> DeleteKeySigningKey -> Bool
$c== :: DeleteKeySigningKey -> DeleteKeySigningKey -> Bool
Prelude.Eq, ReadPrec [DeleteKeySigningKey]
ReadPrec DeleteKeySigningKey
Int -> ReadS DeleteKeySigningKey
ReadS [DeleteKeySigningKey]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteKeySigningKey]
$creadListPrec :: ReadPrec [DeleteKeySigningKey]
readPrec :: ReadPrec DeleteKeySigningKey
$creadPrec :: ReadPrec DeleteKeySigningKey
readList :: ReadS [DeleteKeySigningKey]
$creadList :: ReadS [DeleteKeySigningKey]
readsPrec :: Int -> ReadS DeleteKeySigningKey
$creadsPrec :: Int -> ReadS DeleteKeySigningKey
Prelude.Read, Int -> DeleteKeySigningKey -> ShowS
[DeleteKeySigningKey] -> ShowS
DeleteKeySigningKey -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteKeySigningKey] -> ShowS
$cshowList :: [DeleteKeySigningKey] -> ShowS
show :: DeleteKeySigningKey -> String
$cshow :: DeleteKeySigningKey -> String
showsPrec :: Int -> DeleteKeySigningKey -> ShowS
$cshowsPrec :: Int -> DeleteKeySigningKey -> ShowS
Prelude.Show, forall x. Rep DeleteKeySigningKey x -> DeleteKeySigningKey
forall x. DeleteKeySigningKey -> Rep DeleteKeySigningKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteKeySigningKey x -> DeleteKeySigningKey
$cfrom :: forall x. DeleteKeySigningKey -> Rep DeleteKeySigningKey x
Prelude.Generic)

-- |
-- Create a value of 'DeleteKeySigningKey' 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:
--
-- 'hostedZoneId', 'deleteKeySigningKey_hostedZoneId' - A unique string used to identify a hosted zone.
--
-- 'name', 'deleteKeySigningKey_name' - A string used to identify a key-signing key (KSK).
newDeleteKeySigningKey ::
  -- | 'hostedZoneId'
  ResourceId ->
  -- | 'name'
  Prelude.Text ->
  DeleteKeySigningKey
newDeleteKeySigningKey :: ResourceId -> Text -> DeleteKeySigningKey
newDeleteKeySigningKey ResourceId
pHostedZoneId_ Text
pName_ =
  DeleteKeySigningKey'
    { $sel:hostedZoneId:DeleteKeySigningKey' :: ResourceId
hostedZoneId = ResourceId
pHostedZoneId_,
      $sel:name:DeleteKeySigningKey' :: Text
name = Text
pName_
    }

-- | A unique string used to identify a hosted zone.
deleteKeySigningKey_hostedZoneId :: Lens.Lens' DeleteKeySigningKey ResourceId
deleteKeySigningKey_hostedZoneId :: Lens' DeleteKeySigningKey ResourceId
deleteKeySigningKey_hostedZoneId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteKeySigningKey' {ResourceId
hostedZoneId :: ResourceId
$sel:hostedZoneId:DeleteKeySigningKey' :: DeleteKeySigningKey -> ResourceId
hostedZoneId} -> ResourceId
hostedZoneId) (\s :: DeleteKeySigningKey
s@DeleteKeySigningKey' {} ResourceId
a -> DeleteKeySigningKey
s {$sel:hostedZoneId:DeleteKeySigningKey' :: ResourceId
hostedZoneId = ResourceId
a} :: DeleteKeySigningKey)

-- | A string used to identify a key-signing key (KSK).
deleteKeySigningKey_name :: Lens.Lens' DeleteKeySigningKey Prelude.Text
deleteKeySigningKey_name :: Lens' DeleteKeySigningKey Text
deleteKeySigningKey_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteKeySigningKey' {Text
name :: Text
$sel:name:DeleteKeySigningKey' :: DeleteKeySigningKey -> Text
name} -> Text
name) (\s :: DeleteKeySigningKey
s@DeleteKeySigningKey' {} Text
a -> DeleteKeySigningKey
s {$sel:name:DeleteKeySigningKey' :: Text
name = Text
a} :: DeleteKeySigningKey)

instance Core.AWSRequest DeleteKeySigningKey where
  type
    AWSResponse DeleteKeySigningKey =
      DeleteKeySigningKeyResponse
  request :: (Service -> Service)
-> DeleteKeySigningKey -> Request DeleteKeySigningKey
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 DeleteKeySigningKey
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteKeySigningKey)))
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 -> DeleteKeySigningKeyResponse
DeleteKeySigningKeyResponse'
            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 DeleteKeySigningKey where
  hashWithSalt :: Int -> DeleteKeySigningKey -> Int
hashWithSalt Int
_salt DeleteKeySigningKey' {Text
ResourceId
name :: Text
hostedZoneId :: ResourceId
$sel:name:DeleteKeySigningKey' :: DeleteKeySigningKey -> Text
$sel:hostedZoneId:DeleteKeySigningKey' :: DeleteKeySigningKey -> ResourceId
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ResourceId
hostedZoneId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData DeleteKeySigningKey where
  rnf :: DeleteKeySigningKey -> ()
rnf DeleteKeySigningKey' {Text
ResourceId
name :: Text
hostedZoneId :: ResourceId
$sel:name:DeleteKeySigningKey' :: DeleteKeySigningKey -> Text
$sel:hostedZoneId:DeleteKeySigningKey' :: DeleteKeySigningKey -> ResourceId
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ResourceId
hostedZoneId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

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

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

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

-- | /See:/ 'newDeleteKeySigningKeyResponse' smart constructor.
data DeleteKeySigningKeyResponse = DeleteKeySigningKeyResponse'
  { -- | The response's http status code.
    DeleteKeySigningKeyResponse -> Int
httpStatus :: Prelude.Int,
    DeleteKeySigningKeyResponse -> ChangeInfo
changeInfo :: ChangeInfo
  }
  deriving (DeleteKeySigningKeyResponse -> DeleteKeySigningKeyResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteKeySigningKeyResponse -> DeleteKeySigningKeyResponse -> Bool
$c/= :: DeleteKeySigningKeyResponse -> DeleteKeySigningKeyResponse -> Bool
== :: DeleteKeySigningKeyResponse -> DeleteKeySigningKeyResponse -> Bool
$c== :: DeleteKeySigningKeyResponse -> DeleteKeySigningKeyResponse -> Bool
Prelude.Eq, ReadPrec [DeleteKeySigningKeyResponse]
ReadPrec DeleteKeySigningKeyResponse
Int -> ReadS DeleteKeySigningKeyResponse
ReadS [DeleteKeySigningKeyResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteKeySigningKeyResponse]
$creadListPrec :: ReadPrec [DeleteKeySigningKeyResponse]
readPrec :: ReadPrec DeleteKeySigningKeyResponse
$creadPrec :: ReadPrec DeleteKeySigningKeyResponse
readList :: ReadS [DeleteKeySigningKeyResponse]
$creadList :: ReadS [DeleteKeySigningKeyResponse]
readsPrec :: Int -> ReadS DeleteKeySigningKeyResponse
$creadsPrec :: Int -> ReadS DeleteKeySigningKeyResponse
Prelude.Read, Int -> DeleteKeySigningKeyResponse -> ShowS
[DeleteKeySigningKeyResponse] -> ShowS
DeleteKeySigningKeyResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteKeySigningKeyResponse] -> ShowS
$cshowList :: [DeleteKeySigningKeyResponse] -> ShowS
show :: DeleteKeySigningKeyResponse -> String
$cshow :: DeleteKeySigningKeyResponse -> String
showsPrec :: Int -> DeleteKeySigningKeyResponse -> ShowS
$cshowsPrec :: Int -> DeleteKeySigningKeyResponse -> ShowS
Prelude.Show, forall x.
Rep DeleteKeySigningKeyResponse x -> DeleteKeySigningKeyResponse
forall x.
DeleteKeySigningKeyResponse -> Rep DeleteKeySigningKeyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteKeySigningKeyResponse x -> DeleteKeySigningKeyResponse
$cfrom :: forall x.
DeleteKeySigningKeyResponse -> Rep DeleteKeySigningKeyResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteKeySigningKeyResponse' 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', 'deleteKeySigningKeyResponse_httpStatus' - The response's http status code.
--
-- 'changeInfo', 'deleteKeySigningKeyResponse_changeInfo' - Undocumented member.
newDeleteKeySigningKeyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'changeInfo'
  ChangeInfo ->
  DeleteKeySigningKeyResponse
newDeleteKeySigningKeyResponse :: Int -> ChangeInfo -> DeleteKeySigningKeyResponse
newDeleteKeySigningKeyResponse
  Int
pHttpStatus_
  ChangeInfo
pChangeInfo_ =
    DeleteKeySigningKeyResponse'
      { $sel:httpStatus:DeleteKeySigningKeyResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:changeInfo:DeleteKeySigningKeyResponse' :: ChangeInfo
changeInfo = ChangeInfo
pChangeInfo_
      }

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

-- | Undocumented member.
deleteKeySigningKeyResponse_changeInfo :: Lens.Lens' DeleteKeySigningKeyResponse ChangeInfo
deleteKeySigningKeyResponse_changeInfo :: Lens' DeleteKeySigningKeyResponse ChangeInfo
deleteKeySigningKeyResponse_changeInfo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteKeySigningKeyResponse' {ChangeInfo
changeInfo :: ChangeInfo
$sel:changeInfo:DeleteKeySigningKeyResponse' :: DeleteKeySigningKeyResponse -> ChangeInfo
changeInfo} -> ChangeInfo
changeInfo) (\s :: DeleteKeySigningKeyResponse
s@DeleteKeySigningKeyResponse' {} ChangeInfo
a -> DeleteKeySigningKeyResponse
s {$sel:changeInfo:DeleteKeySigningKeyResponse' :: ChangeInfo
changeInfo = ChangeInfo
a} :: DeleteKeySigningKeyResponse)

instance Prelude.NFData DeleteKeySigningKeyResponse where
  rnf :: DeleteKeySigningKeyResponse -> ()
rnf DeleteKeySigningKeyResponse' {Int
ChangeInfo
changeInfo :: ChangeInfo
httpStatus :: Int
$sel:changeInfo:DeleteKeySigningKeyResponse' :: DeleteKeySigningKeyResponse -> ChangeInfo
$sel:httpStatus:DeleteKeySigningKeyResponse' :: DeleteKeySigningKeyResponse -> 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