{-# 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.GetDNSSEC
-- 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)
--
-- Returns information about DNSSEC for a specific hosted zone, including
-- the key-signing keys (KSKs) in the hosted zone.
module Amazonka.Route53.GetDNSSEC
  ( -- * Creating a Request
    GetDNSSEC (..),
    newGetDNSSEC,

    -- * Request Lenses
    getDNSSEC_hostedZoneId,

    -- * Destructuring the Response
    GetDNSSECResponse (..),
    newGetDNSSECResponse,

    -- * Response Lenses
    getDNSSECResponse_httpStatus,
    getDNSSECResponse_status,
    getDNSSECResponse_keySigningKeys,
  )
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:/ 'newGetDNSSEC' smart constructor.
data GetDNSSEC = GetDNSSEC'
  { -- | A unique string used to identify a hosted zone.
    GetDNSSEC -> ResourceId
hostedZoneId :: ResourceId
  }
  deriving (GetDNSSEC -> GetDNSSEC -> Bool
(GetDNSSEC -> GetDNSSEC -> Bool)
-> (GetDNSSEC -> GetDNSSEC -> Bool) -> Eq GetDNSSEC
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDNSSEC -> GetDNSSEC -> Bool
$c/= :: GetDNSSEC -> GetDNSSEC -> Bool
== :: GetDNSSEC -> GetDNSSEC -> Bool
$c== :: GetDNSSEC -> GetDNSSEC -> Bool
Prelude.Eq, ReadPrec [GetDNSSEC]
ReadPrec GetDNSSEC
Int -> ReadS GetDNSSEC
ReadS [GetDNSSEC]
(Int -> ReadS GetDNSSEC)
-> ReadS [GetDNSSEC]
-> ReadPrec GetDNSSEC
-> ReadPrec [GetDNSSEC]
-> Read GetDNSSEC
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDNSSEC]
$creadListPrec :: ReadPrec [GetDNSSEC]
readPrec :: ReadPrec GetDNSSEC
$creadPrec :: ReadPrec GetDNSSEC
readList :: ReadS [GetDNSSEC]
$creadList :: ReadS [GetDNSSEC]
readsPrec :: Int -> ReadS GetDNSSEC
$creadsPrec :: Int -> ReadS GetDNSSEC
Prelude.Read, Int -> GetDNSSEC -> ShowS
[GetDNSSEC] -> ShowS
GetDNSSEC -> String
(Int -> GetDNSSEC -> ShowS)
-> (GetDNSSEC -> String)
-> ([GetDNSSEC] -> ShowS)
-> Show GetDNSSEC
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDNSSEC] -> ShowS
$cshowList :: [GetDNSSEC] -> ShowS
show :: GetDNSSEC -> String
$cshow :: GetDNSSEC -> String
showsPrec :: Int -> GetDNSSEC -> ShowS
$cshowsPrec :: Int -> GetDNSSEC -> ShowS
Prelude.Show, (forall x. GetDNSSEC -> Rep GetDNSSEC x)
-> (forall x. Rep GetDNSSEC x -> GetDNSSEC) -> Generic GetDNSSEC
forall x. Rep GetDNSSEC x -> GetDNSSEC
forall x. GetDNSSEC -> Rep GetDNSSEC x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDNSSEC x -> GetDNSSEC
$cfrom :: forall x. GetDNSSEC -> Rep GetDNSSEC x
Prelude.Generic)

-- |
-- Create a value of 'GetDNSSEC' 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', 'getDNSSEC_hostedZoneId' - A unique string used to identify a hosted zone.
newGetDNSSEC ::
  -- | 'hostedZoneId'
  ResourceId ->
  GetDNSSEC
newGetDNSSEC :: ResourceId -> GetDNSSEC
newGetDNSSEC ResourceId
pHostedZoneId_ =
  GetDNSSEC' :: ResourceId -> GetDNSSEC
GetDNSSEC' {$sel:hostedZoneId:GetDNSSEC' :: ResourceId
hostedZoneId = ResourceId
pHostedZoneId_}

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

instance Core.AWSRequest GetDNSSEC where
  type AWSResponse GetDNSSEC = GetDNSSECResponse
  request :: GetDNSSEC -> Request GetDNSSEC
request = Service -> GetDNSSEC -> Request GetDNSSEC
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetDNSSEC
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDNSSEC)))
response =
    (Int
 -> ResponseHeaders
 -> [Node]
 -> Either String (AWSResponse GetDNSSEC))
-> Logger
-> Service
-> Proxy GetDNSSEC
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDNSSEC)))
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 -> DNSSECStatus -> [KeySigningKey] -> GetDNSSECResponse
GetDNSSECResponse'
            (Int -> DNSSECStatus -> [KeySigningKey] -> GetDNSSECResponse)
-> Either String Int
-> Either
     String (DNSSECStatus -> [KeySigningKey] -> GetDNSSECResponse)
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 (DNSSECStatus -> [KeySigningKey] -> GetDNSSECResponse)
-> Either String DNSSECStatus
-> Either String ([KeySigningKey] -> GetDNSSECResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String DNSSECStatus
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Status")
            Either String ([KeySigningKey] -> GetDNSSECResponse)
-> Either String [KeySigningKey] -> Either String GetDNSSECResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"KeySigningKeys" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                            Either String [Node]
-> ([Node] -> Either String [KeySigningKey])
-> Either String [KeySigningKey]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= Text -> [Node] -> Either String [KeySigningKey]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member"
                        )
      )

instance Prelude.Hashable GetDNSSEC

instance Prelude.NFData GetDNSSEC

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

instance Core.ToPath GetDNSSEC where
  toPath :: GetDNSSEC -> ByteString
toPath GetDNSSEC' {ResourceId
hostedZoneId :: ResourceId
$sel:hostedZoneId:GetDNSSEC' :: GetDNSSEC -> 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
hostedZoneId,
        ByteString
"/dnssec"
      ]

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

-- | /See:/ 'newGetDNSSECResponse' smart constructor.
data GetDNSSECResponse = GetDNSSECResponse'
  { -- | The response's http status code.
    GetDNSSECResponse -> Int
httpStatus :: Prelude.Int,
    -- | A string repesenting the status of DNSSEC.
    GetDNSSECResponse -> DNSSECStatus
status :: DNSSECStatus,
    -- | The key-signing keys (KSKs) in your account.
    GetDNSSECResponse -> [KeySigningKey]
keySigningKeys :: [KeySigningKey]
  }
  deriving (GetDNSSECResponse -> GetDNSSECResponse -> Bool
(GetDNSSECResponse -> GetDNSSECResponse -> Bool)
-> (GetDNSSECResponse -> GetDNSSECResponse -> Bool)
-> Eq GetDNSSECResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDNSSECResponse -> GetDNSSECResponse -> Bool
$c/= :: GetDNSSECResponse -> GetDNSSECResponse -> Bool
== :: GetDNSSECResponse -> GetDNSSECResponse -> Bool
$c== :: GetDNSSECResponse -> GetDNSSECResponse -> Bool
Prelude.Eq, ReadPrec [GetDNSSECResponse]
ReadPrec GetDNSSECResponse
Int -> ReadS GetDNSSECResponse
ReadS [GetDNSSECResponse]
(Int -> ReadS GetDNSSECResponse)
-> ReadS [GetDNSSECResponse]
-> ReadPrec GetDNSSECResponse
-> ReadPrec [GetDNSSECResponse]
-> Read GetDNSSECResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDNSSECResponse]
$creadListPrec :: ReadPrec [GetDNSSECResponse]
readPrec :: ReadPrec GetDNSSECResponse
$creadPrec :: ReadPrec GetDNSSECResponse
readList :: ReadS [GetDNSSECResponse]
$creadList :: ReadS [GetDNSSECResponse]
readsPrec :: Int -> ReadS GetDNSSECResponse
$creadsPrec :: Int -> ReadS GetDNSSECResponse
Prelude.Read, Int -> GetDNSSECResponse -> ShowS
[GetDNSSECResponse] -> ShowS
GetDNSSECResponse -> String
(Int -> GetDNSSECResponse -> ShowS)
-> (GetDNSSECResponse -> String)
-> ([GetDNSSECResponse] -> ShowS)
-> Show GetDNSSECResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDNSSECResponse] -> ShowS
$cshowList :: [GetDNSSECResponse] -> ShowS
show :: GetDNSSECResponse -> String
$cshow :: GetDNSSECResponse -> String
showsPrec :: Int -> GetDNSSECResponse -> ShowS
$cshowsPrec :: Int -> GetDNSSECResponse -> ShowS
Prelude.Show, (forall x. GetDNSSECResponse -> Rep GetDNSSECResponse x)
-> (forall x. Rep GetDNSSECResponse x -> GetDNSSECResponse)
-> Generic GetDNSSECResponse
forall x. Rep GetDNSSECResponse x -> GetDNSSECResponse
forall x. GetDNSSECResponse -> Rep GetDNSSECResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDNSSECResponse x -> GetDNSSECResponse
$cfrom :: forall x. GetDNSSECResponse -> Rep GetDNSSECResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDNSSECResponse' 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', 'getDNSSECResponse_httpStatus' - The response's http status code.
--
-- 'status', 'getDNSSECResponse_status' - A string repesenting the status of DNSSEC.
--
-- 'keySigningKeys', 'getDNSSECResponse_keySigningKeys' - The key-signing keys (KSKs) in your account.
newGetDNSSECResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'status'
  DNSSECStatus ->
  GetDNSSECResponse
newGetDNSSECResponse :: Int -> DNSSECStatus -> GetDNSSECResponse
newGetDNSSECResponse Int
pHttpStatus_ DNSSECStatus
pStatus_ =
  GetDNSSECResponse' :: Int -> DNSSECStatus -> [KeySigningKey] -> GetDNSSECResponse
GetDNSSECResponse'
    { $sel:httpStatus:GetDNSSECResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:status:GetDNSSECResponse' :: DNSSECStatus
status = DNSSECStatus
pStatus_,
      $sel:keySigningKeys:GetDNSSECResponse' :: [KeySigningKey]
keySigningKeys = [KeySigningKey]
forall a. Monoid a => a
Prelude.mempty
    }

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

-- | A string repesenting the status of DNSSEC.
getDNSSECResponse_status :: Lens.Lens' GetDNSSECResponse DNSSECStatus
getDNSSECResponse_status :: (DNSSECStatus -> f DNSSECStatus)
-> GetDNSSECResponse -> f GetDNSSECResponse
getDNSSECResponse_status = (GetDNSSECResponse -> DNSSECStatus)
-> (GetDNSSECResponse -> DNSSECStatus -> GetDNSSECResponse)
-> Lens
     GetDNSSECResponse GetDNSSECResponse DNSSECStatus DNSSECStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDNSSECResponse' {DNSSECStatus
status :: DNSSECStatus
$sel:status:GetDNSSECResponse' :: GetDNSSECResponse -> DNSSECStatus
status} -> DNSSECStatus
status) (\s :: GetDNSSECResponse
s@GetDNSSECResponse' {} DNSSECStatus
a -> GetDNSSECResponse
s {$sel:status:GetDNSSECResponse' :: DNSSECStatus
status = DNSSECStatus
a} :: GetDNSSECResponse)

-- | The key-signing keys (KSKs) in your account.
getDNSSECResponse_keySigningKeys :: Lens.Lens' GetDNSSECResponse [KeySigningKey]
getDNSSECResponse_keySigningKeys :: ([KeySigningKey] -> f [KeySigningKey])
-> GetDNSSECResponse -> f GetDNSSECResponse
getDNSSECResponse_keySigningKeys = (GetDNSSECResponse -> [KeySigningKey])
-> (GetDNSSECResponse -> [KeySigningKey] -> GetDNSSECResponse)
-> Lens
     GetDNSSECResponse GetDNSSECResponse [KeySigningKey] [KeySigningKey]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDNSSECResponse' {[KeySigningKey]
keySigningKeys :: [KeySigningKey]
$sel:keySigningKeys:GetDNSSECResponse' :: GetDNSSECResponse -> [KeySigningKey]
keySigningKeys} -> [KeySigningKey]
keySigningKeys) (\s :: GetDNSSECResponse
s@GetDNSSECResponse' {} [KeySigningKey]
a -> GetDNSSECResponse
s {$sel:keySigningKeys:GetDNSSECResponse' :: [KeySigningKey]
keySigningKeys = [KeySigningKey]
a} :: GetDNSSECResponse) (([KeySigningKey] -> f [KeySigningKey])
 -> GetDNSSECResponse -> f GetDNSSECResponse)
-> (([KeySigningKey] -> f [KeySigningKey])
    -> [KeySigningKey] -> f [KeySigningKey])
-> ([KeySigningKey] -> f [KeySigningKey])
-> GetDNSSECResponse
-> f GetDNSSECResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([KeySigningKey] -> f [KeySigningKey])
-> [KeySigningKey] -> f [KeySigningKey]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData GetDNSSECResponse