{-# 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.ActivateKeySigningKey
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Activates a key-signing key (KSK) so that it can be used for signing by
-- DNSSEC. This operation changes the KSK status to @ACTIVE@.
module Amazonka.Route53.ActivateKeySigningKey
  ( -- * Creating a Request
    ActivateKeySigningKey (..),
    newActivateKeySigningKey,

    -- * Request Lenses
    activateKeySigningKey_hostedZoneId,
    activateKeySigningKey_name,

    -- * Destructuring the Response
    ActivateKeySigningKeyResponse (..),
    newActivateKeySigningKeyResponse,

    -- * Response Lenses
    activateKeySigningKeyResponse_httpStatus,
    activateKeySigningKeyResponse_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:/ 'newActivateKeySigningKey' smart constructor.
data ActivateKeySigningKey = ActivateKeySigningKey'
  { -- | A unique string used to identify a hosted zone.
    ActivateKeySigningKey -> ResourceId
hostedZoneId :: ResourceId,
    -- | A string used to identify a key-signing key (KSK). @Name@ can include
    -- numbers, letters, and underscores (_). @Name@ must be unique for each
    -- key-signing key in the same hosted zone.
    ActivateKeySigningKey -> Text
name :: Prelude.Text
  }
  deriving (ActivateKeySigningKey -> ActivateKeySigningKey -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActivateKeySigningKey -> ActivateKeySigningKey -> Bool
$c/= :: ActivateKeySigningKey -> ActivateKeySigningKey -> Bool
== :: ActivateKeySigningKey -> ActivateKeySigningKey -> Bool
$c== :: ActivateKeySigningKey -> ActivateKeySigningKey -> Bool
Prelude.Eq, ReadPrec [ActivateKeySigningKey]
ReadPrec ActivateKeySigningKey
Int -> ReadS ActivateKeySigningKey
ReadS [ActivateKeySigningKey]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ActivateKeySigningKey]
$creadListPrec :: ReadPrec [ActivateKeySigningKey]
readPrec :: ReadPrec ActivateKeySigningKey
$creadPrec :: ReadPrec ActivateKeySigningKey
readList :: ReadS [ActivateKeySigningKey]
$creadList :: ReadS [ActivateKeySigningKey]
readsPrec :: Int -> ReadS ActivateKeySigningKey
$creadsPrec :: Int -> ReadS ActivateKeySigningKey
Prelude.Read, Int -> ActivateKeySigningKey -> ShowS
[ActivateKeySigningKey] -> ShowS
ActivateKeySigningKey -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActivateKeySigningKey] -> ShowS
$cshowList :: [ActivateKeySigningKey] -> ShowS
show :: ActivateKeySigningKey -> String
$cshow :: ActivateKeySigningKey -> String
showsPrec :: Int -> ActivateKeySigningKey -> ShowS
$cshowsPrec :: Int -> ActivateKeySigningKey -> ShowS
Prelude.Show, forall x. Rep ActivateKeySigningKey x -> ActivateKeySigningKey
forall x. ActivateKeySigningKey -> Rep ActivateKeySigningKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ActivateKeySigningKey x -> ActivateKeySigningKey
$cfrom :: forall x. ActivateKeySigningKey -> Rep ActivateKeySigningKey x
Prelude.Generic)

-- |
-- Create a value of 'ActivateKeySigningKey' 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', 'activateKeySigningKey_hostedZoneId' - A unique string used to identify a hosted zone.
--
-- 'name', 'activateKeySigningKey_name' - A string used to identify a key-signing key (KSK). @Name@ can include
-- numbers, letters, and underscores (_). @Name@ must be unique for each
-- key-signing key in the same hosted zone.
newActivateKeySigningKey ::
  -- | 'hostedZoneId'
  ResourceId ->
  -- | 'name'
  Prelude.Text ->
  ActivateKeySigningKey
newActivateKeySigningKey :: ResourceId -> Text -> ActivateKeySigningKey
newActivateKeySigningKey ResourceId
pHostedZoneId_ Text
pName_ =
  ActivateKeySigningKey'
    { $sel:hostedZoneId:ActivateKeySigningKey' :: ResourceId
hostedZoneId =
        ResourceId
pHostedZoneId_,
      $sel:name:ActivateKeySigningKey' :: Text
name = Text
pName_
    }

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

-- | A string used to identify a key-signing key (KSK). @Name@ can include
-- numbers, letters, and underscores (_). @Name@ must be unique for each
-- key-signing key in the same hosted zone.
activateKeySigningKey_name :: Lens.Lens' ActivateKeySigningKey Prelude.Text
activateKeySigningKey_name :: Lens' ActivateKeySigningKey Text
activateKeySigningKey_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActivateKeySigningKey' {Text
name :: Text
$sel:name:ActivateKeySigningKey' :: ActivateKeySigningKey -> Text
name} -> Text
name) (\s :: ActivateKeySigningKey
s@ActivateKeySigningKey' {} Text
a -> ActivateKeySigningKey
s {$sel:name:ActivateKeySigningKey' :: Text
name = Text
a} :: ActivateKeySigningKey)

instance Core.AWSRequest ActivateKeySigningKey where
  type
    AWSResponse ActivateKeySigningKey =
      ActivateKeySigningKeyResponse
  request :: (Service -> Service)
-> ActivateKeySigningKey -> Request ActivateKeySigningKey
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.post (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ActivateKeySigningKey
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ActivateKeySigningKey)))
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 -> ActivateKeySigningKeyResponse
ActivateKeySigningKeyResponse'
            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 ActivateKeySigningKey where
  hashWithSalt :: Int -> ActivateKeySigningKey -> Int
hashWithSalt Int
_salt ActivateKeySigningKey' {Text
ResourceId
name :: Text
hostedZoneId :: ResourceId
$sel:name:ActivateKeySigningKey' :: ActivateKeySigningKey -> Text
$sel:hostedZoneId:ActivateKeySigningKey' :: ActivateKeySigningKey -> 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 ActivateKeySigningKey where
  rnf :: ActivateKeySigningKey -> ()
rnf ActivateKeySigningKey' {Text
ResourceId
name :: Text
hostedZoneId :: ResourceId
$sel:name:ActivateKeySigningKey' :: ActivateKeySigningKey -> Text
$sel:hostedZoneId:ActivateKeySigningKey' :: ActivateKeySigningKey -> 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 ActivateKeySigningKey where
  toHeaders :: ActivateKeySigningKey -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath ActivateKeySigningKey where
  toPath :: ActivateKeySigningKey -> ByteString
toPath ActivateKeySigningKey' {Text
ResourceId
name :: Text
hostedZoneId :: ResourceId
$sel:name:ActivateKeySigningKey' :: ActivateKeySigningKey -> Text
$sel:hostedZoneId:ActivateKeySigningKey' :: ActivateKeySigningKey -> 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,
        ByteString
"/activate"
      ]

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

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

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

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

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

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