{-# 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-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)
--
-- 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.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

-- | /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
(ActivateKeySigningKey -> ActivateKeySigningKey -> Bool)
-> (ActivateKeySigningKey -> ActivateKeySigningKey -> Bool)
-> Eq ActivateKeySigningKey
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]
(Int -> ReadS ActivateKeySigningKey)
-> ReadS [ActivateKeySigningKey]
-> ReadPrec ActivateKeySigningKey
-> ReadPrec [ActivateKeySigningKey]
-> Read 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
(Int -> ActivateKeySigningKey -> ShowS)
-> (ActivateKeySigningKey -> String)
-> ([ActivateKeySigningKey] -> ShowS)
-> Show ActivateKeySigningKey
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. ActivateKeySigningKey -> Rep ActivateKeySigningKey x)
-> (forall x. Rep ActivateKeySigningKey x -> ActivateKeySigningKey)
-> Generic ActivateKeySigningKey
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' :: ResourceId -> Text -> ActivateKeySigningKey
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 :: (ResourceId -> f ResourceId)
-> ActivateKeySigningKey -> f ActivateKeySigningKey
activateKeySigningKey_hostedZoneId = (ActivateKeySigningKey -> ResourceId)
-> (ActivateKeySigningKey -> ResourceId -> ActivateKeySigningKey)
-> Lens
     ActivateKeySigningKey ActivateKeySigningKey ResourceId ResourceId
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 :: (Text -> f Text)
-> ActivateKeySigningKey -> f ActivateKeySigningKey
activateKeySigningKey_name = (ActivateKeySigningKey -> Text)
-> (ActivateKeySigningKey -> Text -> ActivateKeySigningKey)
-> Lens ActivateKeySigningKey ActivateKeySigningKey Text Text
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 :: ActivateKeySigningKey -> Request ActivateKeySigningKey
request = Service -> ActivateKeySigningKey -> Request ActivateKeySigningKey
forall a. ToRequest a => Service -> a -> Request a
Request.post Service
defaultService
  response :: Logger
-> Service
-> Proxy ActivateKeySigningKey
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ActivateKeySigningKey)))
response =
    (Int
 -> ResponseHeaders
 -> [Node]
 -> Either String (AWSResponse ActivateKeySigningKey))
-> Logger
-> Service
-> Proxy ActivateKeySigningKey
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ActivateKeySigningKey)))
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 -> ActivateKeySigningKeyResponse
ActivateKeySigningKeyResponse'
            (Int -> ChangeInfo -> ActivateKeySigningKeyResponse)
-> Either String Int
-> Either String (ChangeInfo -> ActivateKeySigningKeyResponse)
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 -> ActivateKeySigningKeyResponse)
-> Either String ChangeInfo
-> Either String ActivateKeySigningKeyResponse
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 ActivateKeySigningKey

instance Prelude.NFData ActivateKeySigningKey

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

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

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