{-# 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.TestDNSAnswer
-- 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)
--
-- Gets the value that Amazon Route 53 returns in response to a DNS request
-- for a specified record name and type. You can optionally specify the IP
-- address of a DNS resolver, an EDNS0 client subnet IP address, and a
-- subnet mask.
--
-- This call only supports querying public hosted zones.
module Amazonka.Route53.TestDNSAnswer
  ( -- * Creating a Request
    TestDNSAnswer (..),
    newTestDNSAnswer,

    -- * Request Lenses
    testDNSAnswer_resolverIP,
    testDNSAnswer_eDNS0ClientSubnetIP,
    testDNSAnswer_eDNS0ClientSubnetMask,
    testDNSAnswer_hostedZoneId,
    testDNSAnswer_recordName,
    testDNSAnswer_recordType,

    -- * Destructuring the Response
    TestDNSAnswerResponse (..),
    newTestDNSAnswerResponse,

    -- * Response Lenses
    testDNSAnswerResponse_httpStatus,
    testDNSAnswerResponse_nameserver,
    testDNSAnswerResponse_recordName,
    testDNSAnswerResponse_recordType,
    testDNSAnswerResponse_recordData,
    testDNSAnswerResponse_responseCode,
    testDNSAnswerResponse_protocol,
  )
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

-- | Gets the value that Amazon Route 53 returns in response to a DNS request
-- for a specified record name and type. You can optionally specify the IP
-- address of a DNS resolver, an EDNS0 client subnet IP address, and a
-- subnet mask.
--
-- /See:/ 'newTestDNSAnswer' smart constructor.
data TestDNSAnswer = TestDNSAnswer'
  { -- | If you want to simulate a request from a specific DNS resolver, specify
    -- the IP address for that resolver. If you omit this value,
    -- @TestDnsAnswer@ uses the IP address of a DNS resolver in the Amazon Web
    -- Services US East (N. Virginia) Region (@us-east-1@).
    TestDNSAnswer -> Maybe Text
resolverIP :: Prelude.Maybe Prelude.Text,
    -- | If the resolver that you specified for resolverip supports EDNS0,
    -- specify the IPv4 or IPv6 address of a client in the applicable location,
    -- for example, @192.0.2.44@ or @2001:db8:85a3::8a2e:370:7334@.
    TestDNSAnswer -> Maybe Text
eDNS0ClientSubnetIP :: Prelude.Maybe Prelude.Text,
    -- | If you specify an IP address for @edns0clientsubnetip@, you can
    -- optionally specify the number of bits of the IP address that you want
    -- the checking tool to include in the DNS query. For example, if you
    -- specify @192.0.2.44@ for @edns0clientsubnetip@ and @24@ for
    -- @edns0clientsubnetmask@, the checking tool will simulate a request from
    -- 192.0.2.0\/24. The default value is 24 bits for IPv4 addresses and 64
    -- bits for IPv6 addresses.
    --
    -- The range of valid values depends on whether @edns0clientsubnetip@ is an
    -- IPv4 or an IPv6 address:
    --
    -- -   __IPv4__: Specify a value between 0 and 32
    --
    -- -   __IPv6__: Specify a value between 0 and 128
    TestDNSAnswer -> Maybe Text
eDNS0ClientSubnetMask :: Prelude.Maybe Prelude.Text,
    -- | The ID of the hosted zone that you want Amazon Route 53 to simulate a
    -- query for.
    TestDNSAnswer -> ResourceId
hostedZoneId :: ResourceId,
    -- | The name of the resource record set that you want Amazon Route 53 to
    -- simulate a query for.
    TestDNSAnswer -> Text
recordName :: Prelude.Text,
    -- | The type of the resource record set.
    TestDNSAnswer -> RRType
recordType :: RRType
  }
  deriving (TestDNSAnswer -> TestDNSAnswer -> Bool
(TestDNSAnswer -> TestDNSAnswer -> Bool)
-> (TestDNSAnswer -> TestDNSAnswer -> Bool) -> Eq TestDNSAnswer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestDNSAnswer -> TestDNSAnswer -> Bool
$c/= :: TestDNSAnswer -> TestDNSAnswer -> Bool
== :: TestDNSAnswer -> TestDNSAnswer -> Bool
$c== :: TestDNSAnswer -> TestDNSAnswer -> Bool
Prelude.Eq, ReadPrec [TestDNSAnswer]
ReadPrec TestDNSAnswer
Int -> ReadS TestDNSAnswer
ReadS [TestDNSAnswer]
(Int -> ReadS TestDNSAnswer)
-> ReadS [TestDNSAnswer]
-> ReadPrec TestDNSAnswer
-> ReadPrec [TestDNSAnswer]
-> Read TestDNSAnswer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TestDNSAnswer]
$creadListPrec :: ReadPrec [TestDNSAnswer]
readPrec :: ReadPrec TestDNSAnswer
$creadPrec :: ReadPrec TestDNSAnswer
readList :: ReadS [TestDNSAnswer]
$creadList :: ReadS [TestDNSAnswer]
readsPrec :: Int -> ReadS TestDNSAnswer
$creadsPrec :: Int -> ReadS TestDNSAnswer
Prelude.Read, Int -> TestDNSAnswer -> ShowS
[TestDNSAnswer] -> ShowS
TestDNSAnswer -> String
(Int -> TestDNSAnswer -> ShowS)
-> (TestDNSAnswer -> String)
-> ([TestDNSAnswer] -> ShowS)
-> Show TestDNSAnswer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestDNSAnswer] -> ShowS
$cshowList :: [TestDNSAnswer] -> ShowS
show :: TestDNSAnswer -> String
$cshow :: TestDNSAnswer -> String
showsPrec :: Int -> TestDNSAnswer -> ShowS
$cshowsPrec :: Int -> TestDNSAnswer -> ShowS
Prelude.Show, (forall x. TestDNSAnswer -> Rep TestDNSAnswer x)
-> (forall x. Rep TestDNSAnswer x -> TestDNSAnswer)
-> Generic TestDNSAnswer
forall x. Rep TestDNSAnswer x -> TestDNSAnswer
forall x. TestDNSAnswer -> Rep TestDNSAnswer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TestDNSAnswer x -> TestDNSAnswer
$cfrom :: forall x. TestDNSAnswer -> Rep TestDNSAnswer x
Prelude.Generic)

-- |
-- Create a value of 'TestDNSAnswer' 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:
--
-- 'resolverIP', 'testDNSAnswer_resolverIP' - If you want to simulate a request from a specific DNS resolver, specify
-- the IP address for that resolver. If you omit this value,
-- @TestDnsAnswer@ uses the IP address of a DNS resolver in the Amazon Web
-- Services US East (N. Virginia) Region (@us-east-1@).
--
-- 'eDNS0ClientSubnetIP', 'testDNSAnswer_eDNS0ClientSubnetIP' - If the resolver that you specified for resolverip supports EDNS0,
-- specify the IPv4 or IPv6 address of a client in the applicable location,
-- for example, @192.0.2.44@ or @2001:db8:85a3::8a2e:370:7334@.
--
-- 'eDNS0ClientSubnetMask', 'testDNSAnswer_eDNS0ClientSubnetMask' - If you specify an IP address for @edns0clientsubnetip@, you can
-- optionally specify the number of bits of the IP address that you want
-- the checking tool to include in the DNS query. For example, if you
-- specify @192.0.2.44@ for @edns0clientsubnetip@ and @24@ for
-- @edns0clientsubnetmask@, the checking tool will simulate a request from
-- 192.0.2.0\/24. The default value is 24 bits for IPv4 addresses and 64
-- bits for IPv6 addresses.
--
-- The range of valid values depends on whether @edns0clientsubnetip@ is an
-- IPv4 or an IPv6 address:
--
-- -   __IPv4__: Specify a value between 0 and 32
--
-- -   __IPv6__: Specify a value between 0 and 128
--
-- 'hostedZoneId', 'testDNSAnswer_hostedZoneId' - The ID of the hosted zone that you want Amazon Route 53 to simulate a
-- query for.
--
-- 'recordName', 'testDNSAnswer_recordName' - The name of the resource record set that you want Amazon Route 53 to
-- simulate a query for.
--
-- 'recordType', 'testDNSAnswer_recordType' - The type of the resource record set.
newTestDNSAnswer ::
  -- | 'hostedZoneId'
  ResourceId ->
  -- | 'recordName'
  Prelude.Text ->
  -- | 'recordType'
  RRType ->
  TestDNSAnswer
newTestDNSAnswer :: ResourceId -> Text -> RRType -> TestDNSAnswer
newTestDNSAnswer
  ResourceId
pHostedZoneId_
  Text
pRecordName_
  RRType
pRecordType_ =
    TestDNSAnswer' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> ResourceId
-> Text
-> RRType
-> TestDNSAnswer
TestDNSAnswer'
      { $sel:resolverIP:TestDNSAnswer' :: Maybe Text
resolverIP = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:eDNS0ClientSubnetIP:TestDNSAnswer' :: Maybe Text
eDNS0ClientSubnetIP = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:eDNS0ClientSubnetMask:TestDNSAnswer' :: Maybe Text
eDNS0ClientSubnetMask = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:hostedZoneId:TestDNSAnswer' :: ResourceId
hostedZoneId = ResourceId
pHostedZoneId_,
        $sel:recordName:TestDNSAnswer' :: Text
recordName = Text
pRecordName_,
        $sel:recordType:TestDNSAnswer' :: RRType
recordType = RRType
pRecordType_
      }

-- | If you want to simulate a request from a specific DNS resolver, specify
-- the IP address for that resolver. If you omit this value,
-- @TestDnsAnswer@ uses the IP address of a DNS resolver in the Amazon Web
-- Services US East (N. Virginia) Region (@us-east-1@).
testDNSAnswer_resolverIP :: Lens.Lens' TestDNSAnswer (Prelude.Maybe Prelude.Text)
testDNSAnswer_resolverIP :: (Maybe Text -> f (Maybe Text)) -> TestDNSAnswer -> f TestDNSAnswer
testDNSAnswer_resolverIP = (TestDNSAnswer -> Maybe Text)
-> (TestDNSAnswer -> Maybe Text -> TestDNSAnswer)
-> Lens TestDNSAnswer TestDNSAnswer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestDNSAnswer' {Maybe Text
resolverIP :: Maybe Text
$sel:resolverIP:TestDNSAnswer' :: TestDNSAnswer -> Maybe Text
resolverIP} -> Maybe Text
resolverIP) (\s :: TestDNSAnswer
s@TestDNSAnswer' {} Maybe Text
a -> TestDNSAnswer
s {$sel:resolverIP:TestDNSAnswer' :: Maybe Text
resolverIP = Maybe Text
a} :: TestDNSAnswer)

-- | If the resolver that you specified for resolverip supports EDNS0,
-- specify the IPv4 or IPv6 address of a client in the applicable location,
-- for example, @192.0.2.44@ or @2001:db8:85a3::8a2e:370:7334@.
testDNSAnswer_eDNS0ClientSubnetIP :: Lens.Lens' TestDNSAnswer (Prelude.Maybe Prelude.Text)
testDNSAnswer_eDNS0ClientSubnetIP :: (Maybe Text -> f (Maybe Text)) -> TestDNSAnswer -> f TestDNSAnswer
testDNSAnswer_eDNS0ClientSubnetIP = (TestDNSAnswer -> Maybe Text)
-> (TestDNSAnswer -> Maybe Text -> TestDNSAnswer)
-> Lens TestDNSAnswer TestDNSAnswer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestDNSAnswer' {Maybe Text
eDNS0ClientSubnetIP :: Maybe Text
$sel:eDNS0ClientSubnetIP:TestDNSAnswer' :: TestDNSAnswer -> Maybe Text
eDNS0ClientSubnetIP} -> Maybe Text
eDNS0ClientSubnetIP) (\s :: TestDNSAnswer
s@TestDNSAnswer' {} Maybe Text
a -> TestDNSAnswer
s {$sel:eDNS0ClientSubnetIP:TestDNSAnswer' :: Maybe Text
eDNS0ClientSubnetIP = Maybe Text
a} :: TestDNSAnswer)

-- | If you specify an IP address for @edns0clientsubnetip@, you can
-- optionally specify the number of bits of the IP address that you want
-- the checking tool to include in the DNS query. For example, if you
-- specify @192.0.2.44@ for @edns0clientsubnetip@ and @24@ for
-- @edns0clientsubnetmask@, the checking tool will simulate a request from
-- 192.0.2.0\/24. The default value is 24 bits for IPv4 addresses and 64
-- bits for IPv6 addresses.
--
-- The range of valid values depends on whether @edns0clientsubnetip@ is an
-- IPv4 or an IPv6 address:
--
-- -   __IPv4__: Specify a value between 0 and 32
--
-- -   __IPv6__: Specify a value between 0 and 128
testDNSAnswer_eDNS0ClientSubnetMask :: Lens.Lens' TestDNSAnswer (Prelude.Maybe Prelude.Text)
testDNSAnswer_eDNS0ClientSubnetMask :: (Maybe Text -> f (Maybe Text)) -> TestDNSAnswer -> f TestDNSAnswer
testDNSAnswer_eDNS0ClientSubnetMask = (TestDNSAnswer -> Maybe Text)
-> (TestDNSAnswer -> Maybe Text -> TestDNSAnswer)
-> Lens TestDNSAnswer TestDNSAnswer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestDNSAnswer' {Maybe Text
eDNS0ClientSubnetMask :: Maybe Text
$sel:eDNS0ClientSubnetMask:TestDNSAnswer' :: TestDNSAnswer -> Maybe Text
eDNS0ClientSubnetMask} -> Maybe Text
eDNS0ClientSubnetMask) (\s :: TestDNSAnswer
s@TestDNSAnswer' {} Maybe Text
a -> TestDNSAnswer
s {$sel:eDNS0ClientSubnetMask:TestDNSAnswer' :: Maybe Text
eDNS0ClientSubnetMask = Maybe Text
a} :: TestDNSAnswer)

-- | The ID of the hosted zone that you want Amazon Route 53 to simulate a
-- query for.
testDNSAnswer_hostedZoneId :: Lens.Lens' TestDNSAnswer ResourceId
testDNSAnswer_hostedZoneId :: (ResourceId -> f ResourceId) -> TestDNSAnswer -> f TestDNSAnswer
testDNSAnswer_hostedZoneId = (TestDNSAnswer -> ResourceId)
-> (TestDNSAnswer -> ResourceId -> TestDNSAnswer)
-> Lens TestDNSAnswer TestDNSAnswer ResourceId ResourceId
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestDNSAnswer' {ResourceId
hostedZoneId :: ResourceId
$sel:hostedZoneId:TestDNSAnswer' :: TestDNSAnswer -> ResourceId
hostedZoneId} -> ResourceId
hostedZoneId) (\s :: TestDNSAnswer
s@TestDNSAnswer' {} ResourceId
a -> TestDNSAnswer
s {$sel:hostedZoneId:TestDNSAnswer' :: ResourceId
hostedZoneId = ResourceId
a} :: TestDNSAnswer)

-- | The name of the resource record set that you want Amazon Route 53 to
-- simulate a query for.
testDNSAnswer_recordName :: Lens.Lens' TestDNSAnswer Prelude.Text
testDNSAnswer_recordName :: (Text -> f Text) -> TestDNSAnswer -> f TestDNSAnswer
testDNSAnswer_recordName = (TestDNSAnswer -> Text)
-> (TestDNSAnswer -> Text -> TestDNSAnswer)
-> Lens TestDNSAnswer TestDNSAnswer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestDNSAnswer' {Text
recordName :: Text
$sel:recordName:TestDNSAnswer' :: TestDNSAnswer -> Text
recordName} -> Text
recordName) (\s :: TestDNSAnswer
s@TestDNSAnswer' {} Text
a -> TestDNSAnswer
s {$sel:recordName:TestDNSAnswer' :: Text
recordName = Text
a} :: TestDNSAnswer)

-- | The type of the resource record set.
testDNSAnswer_recordType :: Lens.Lens' TestDNSAnswer RRType
testDNSAnswer_recordType :: (RRType -> f RRType) -> TestDNSAnswer -> f TestDNSAnswer
testDNSAnswer_recordType = (TestDNSAnswer -> RRType)
-> (TestDNSAnswer -> RRType -> TestDNSAnswer)
-> Lens TestDNSAnswer TestDNSAnswer RRType RRType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestDNSAnswer' {RRType
recordType :: RRType
$sel:recordType:TestDNSAnswer' :: TestDNSAnswer -> RRType
recordType} -> RRType
recordType) (\s :: TestDNSAnswer
s@TestDNSAnswer' {} RRType
a -> TestDNSAnswer
s {$sel:recordType:TestDNSAnswer' :: RRType
recordType = RRType
a} :: TestDNSAnswer)

instance Core.AWSRequest TestDNSAnswer where
  type
    AWSResponse TestDNSAnswer =
      TestDNSAnswerResponse
  request :: TestDNSAnswer -> Request TestDNSAnswer
request = Service -> TestDNSAnswer -> Request TestDNSAnswer
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy TestDNSAnswer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse TestDNSAnswer)))
response =
    (Int
 -> ResponseHeaders
 -> [Node]
 -> Either String (AWSResponse TestDNSAnswer))
-> Logger
-> Service
-> Proxy TestDNSAnswer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse TestDNSAnswer)))
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
-> Text
-> Text
-> RRType
-> [Text]
-> Text
-> Text
-> TestDNSAnswerResponse
TestDNSAnswerResponse'
            (Int
 -> Text
 -> Text
 -> RRType
 -> [Text]
 -> Text
 -> Text
 -> TestDNSAnswerResponse)
-> Either String Int
-> Either
     String
     (Text
      -> Text
      -> RRType
      -> [Text]
      -> Text
      -> Text
      -> TestDNSAnswerResponse)
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
  (Text
   -> Text
   -> RRType
   -> [Text]
   -> Text
   -> Text
   -> TestDNSAnswerResponse)
-> Either String Text
-> Either
     String
     (Text -> RRType -> [Text] -> Text -> Text -> TestDNSAnswerResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Nameserver")
            Either
  String
  (Text -> RRType -> [Text] -> Text -> Text -> TestDNSAnswerResponse)
-> Either String Text
-> Either
     String (RRType -> [Text] -> Text -> Text -> TestDNSAnswerResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"RecordName")
            Either
  String (RRType -> [Text] -> Text -> Text -> TestDNSAnswerResponse)
-> Either String RRType
-> Either String ([Text] -> Text -> Text -> TestDNSAnswerResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String RRType
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"RecordType")
            Either String ([Text] -> Text -> Text -> TestDNSAnswerResponse)
-> Either String [Text]
-> Either String (Text -> Text -> TestDNSAnswerResponse)
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
"RecordData" 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 [Text]) -> Either String [Text]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= Text -> [Node] -> Either String [Text]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"RecordDataEntry"
                        )
            Either String (Text -> Text -> TestDNSAnswerResponse)
-> Either String Text
-> Either String (Text -> TestDNSAnswerResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"ResponseCode")
            Either String (Text -> TestDNSAnswerResponse)
-> Either String Text -> Either String TestDNSAnswerResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Protocol")
      )

instance Prelude.Hashable TestDNSAnswer

instance Prelude.NFData TestDNSAnswer

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

instance Core.ToPath TestDNSAnswer where
  toPath :: TestDNSAnswer -> ByteString
toPath = ByteString -> TestDNSAnswer -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/2013-04-01/testdnsanswer"

instance Core.ToQuery TestDNSAnswer where
  toQuery :: TestDNSAnswer -> QueryString
toQuery TestDNSAnswer' {Maybe Text
Text
ResourceId
RRType
recordType :: RRType
recordName :: Text
hostedZoneId :: ResourceId
eDNS0ClientSubnetMask :: Maybe Text
eDNS0ClientSubnetIP :: Maybe Text
resolverIP :: Maybe Text
$sel:recordType:TestDNSAnswer' :: TestDNSAnswer -> RRType
$sel:recordName:TestDNSAnswer' :: TestDNSAnswer -> Text
$sel:hostedZoneId:TestDNSAnswer' :: TestDNSAnswer -> ResourceId
$sel:eDNS0ClientSubnetMask:TestDNSAnswer' :: TestDNSAnswer -> Maybe Text
$sel:eDNS0ClientSubnetIP:TestDNSAnswer' :: TestDNSAnswer -> Maybe Text
$sel:resolverIP:TestDNSAnswer' :: TestDNSAnswer -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"resolverip" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
resolverIP,
        ByteString
"edns0clientsubnetip" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
eDNS0ClientSubnetIP,
        ByteString
"edns0clientsubnetmask"
          ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
eDNS0ClientSubnetMask,
        ByteString
"hostedzoneid" ByteString -> ResourceId -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ResourceId
hostedZoneId,
        ByteString
"recordname" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
recordName,
        ByteString
"recordtype" ByteString -> RRType -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: RRType
recordType
      ]

-- | A complex type that contains the response to a @TestDNSAnswer@ request.
--
-- /See:/ 'newTestDNSAnswerResponse' smart constructor.
data TestDNSAnswerResponse = TestDNSAnswerResponse'
  { -- | The response's http status code.
    TestDNSAnswerResponse -> Int
httpStatus :: Prelude.Int,
    -- | The Amazon Route 53 name server used to respond to the request.
    TestDNSAnswerResponse -> Text
nameserver :: Prelude.Text,
    -- | The name of the resource record set that you submitted a request for.
    TestDNSAnswerResponse -> Text
recordName :: Prelude.Text,
    -- | The type of the resource record set that you submitted a request for.
    TestDNSAnswerResponse -> RRType
recordType :: RRType,
    -- | A list that contains values that Amazon Route 53 returned for this
    -- resource record set.
    TestDNSAnswerResponse -> [Text]
recordData :: [Prelude.Text],
    -- | A code that indicates whether the request is valid or not. The most
    -- common response code is @NOERROR@, meaning that the request is valid. If
    -- the response is not valid, Amazon Route 53 returns a response code that
    -- describes the error. For a list of possible response codes, see
    -- <http://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-6 DNS RCODES>
    -- on the IANA website.
    TestDNSAnswerResponse -> Text
responseCode :: Prelude.Text,
    -- | The protocol that Amazon Route 53 used to respond to the request, either
    -- @UDP@ or @TCP@.
    TestDNSAnswerResponse -> Text
protocol :: Prelude.Text
  }
  deriving (TestDNSAnswerResponse -> TestDNSAnswerResponse -> Bool
(TestDNSAnswerResponse -> TestDNSAnswerResponse -> Bool)
-> (TestDNSAnswerResponse -> TestDNSAnswerResponse -> Bool)
-> Eq TestDNSAnswerResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestDNSAnswerResponse -> TestDNSAnswerResponse -> Bool
$c/= :: TestDNSAnswerResponse -> TestDNSAnswerResponse -> Bool
== :: TestDNSAnswerResponse -> TestDNSAnswerResponse -> Bool
$c== :: TestDNSAnswerResponse -> TestDNSAnswerResponse -> Bool
Prelude.Eq, ReadPrec [TestDNSAnswerResponse]
ReadPrec TestDNSAnswerResponse
Int -> ReadS TestDNSAnswerResponse
ReadS [TestDNSAnswerResponse]
(Int -> ReadS TestDNSAnswerResponse)
-> ReadS [TestDNSAnswerResponse]
-> ReadPrec TestDNSAnswerResponse
-> ReadPrec [TestDNSAnswerResponse]
-> Read TestDNSAnswerResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TestDNSAnswerResponse]
$creadListPrec :: ReadPrec [TestDNSAnswerResponse]
readPrec :: ReadPrec TestDNSAnswerResponse
$creadPrec :: ReadPrec TestDNSAnswerResponse
readList :: ReadS [TestDNSAnswerResponse]
$creadList :: ReadS [TestDNSAnswerResponse]
readsPrec :: Int -> ReadS TestDNSAnswerResponse
$creadsPrec :: Int -> ReadS TestDNSAnswerResponse
Prelude.Read, Int -> TestDNSAnswerResponse -> ShowS
[TestDNSAnswerResponse] -> ShowS
TestDNSAnswerResponse -> String
(Int -> TestDNSAnswerResponse -> ShowS)
-> (TestDNSAnswerResponse -> String)
-> ([TestDNSAnswerResponse] -> ShowS)
-> Show TestDNSAnswerResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestDNSAnswerResponse] -> ShowS
$cshowList :: [TestDNSAnswerResponse] -> ShowS
show :: TestDNSAnswerResponse -> String
$cshow :: TestDNSAnswerResponse -> String
showsPrec :: Int -> TestDNSAnswerResponse -> ShowS
$cshowsPrec :: Int -> TestDNSAnswerResponse -> ShowS
Prelude.Show, (forall x. TestDNSAnswerResponse -> Rep TestDNSAnswerResponse x)
-> (forall x. Rep TestDNSAnswerResponse x -> TestDNSAnswerResponse)
-> Generic TestDNSAnswerResponse
forall x. Rep TestDNSAnswerResponse x -> TestDNSAnswerResponse
forall x. TestDNSAnswerResponse -> Rep TestDNSAnswerResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TestDNSAnswerResponse x -> TestDNSAnswerResponse
$cfrom :: forall x. TestDNSAnswerResponse -> Rep TestDNSAnswerResponse x
Prelude.Generic)

-- |
-- Create a value of 'TestDNSAnswerResponse' 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', 'testDNSAnswerResponse_httpStatus' - The response's http status code.
--
-- 'nameserver', 'testDNSAnswerResponse_nameserver' - The Amazon Route 53 name server used to respond to the request.
--
-- 'recordName', 'testDNSAnswerResponse_recordName' - The name of the resource record set that you submitted a request for.
--
-- 'recordType', 'testDNSAnswerResponse_recordType' - The type of the resource record set that you submitted a request for.
--
-- 'recordData', 'testDNSAnswerResponse_recordData' - A list that contains values that Amazon Route 53 returned for this
-- resource record set.
--
-- 'responseCode', 'testDNSAnswerResponse_responseCode' - A code that indicates whether the request is valid or not. The most
-- common response code is @NOERROR@, meaning that the request is valid. If
-- the response is not valid, Amazon Route 53 returns a response code that
-- describes the error. For a list of possible response codes, see
-- <http://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-6 DNS RCODES>
-- on the IANA website.
--
-- 'protocol', 'testDNSAnswerResponse_protocol' - The protocol that Amazon Route 53 used to respond to the request, either
-- @UDP@ or @TCP@.
newTestDNSAnswerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'nameserver'
  Prelude.Text ->
  -- | 'recordName'
  Prelude.Text ->
  -- | 'recordType'
  RRType ->
  -- | 'responseCode'
  Prelude.Text ->
  -- | 'protocol'
  Prelude.Text ->
  TestDNSAnswerResponse
newTestDNSAnswerResponse :: Int
-> Text -> Text -> RRType -> Text -> Text -> TestDNSAnswerResponse
newTestDNSAnswerResponse
  Int
pHttpStatus_
  Text
pNameserver_
  Text
pRecordName_
  RRType
pRecordType_
  Text
pResponseCode_
  Text
pProtocol_ =
    TestDNSAnswerResponse' :: Int
-> Text
-> Text
-> RRType
-> [Text]
-> Text
-> Text
-> TestDNSAnswerResponse
TestDNSAnswerResponse'
      { $sel:httpStatus:TestDNSAnswerResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:nameserver:TestDNSAnswerResponse' :: Text
nameserver = Text
pNameserver_,
        $sel:recordName:TestDNSAnswerResponse' :: Text
recordName = Text
pRecordName_,
        $sel:recordType:TestDNSAnswerResponse' :: RRType
recordType = RRType
pRecordType_,
        $sel:recordData:TestDNSAnswerResponse' :: [Text]
recordData = [Text]
forall a. Monoid a => a
Prelude.mempty,
        $sel:responseCode:TestDNSAnswerResponse' :: Text
responseCode = Text
pResponseCode_,
        $sel:protocol:TestDNSAnswerResponse' :: Text
protocol = Text
pProtocol_
      }

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

-- | The Amazon Route 53 name server used to respond to the request.
testDNSAnswerResponse_nameserver :: Lens.Lens' TestDNSAnswerResponse Prelude.Text
testDNSAnswerResponse_nameserver :: (Text -> f Text)
-> TestDNSAnswerResponse -> f TestDNSAnswerResponse
testDNSAnswerResponse_nameserver = (TestDNSAnswerResponse -> Text)
-> (TestDNSAnswerResponse -> Text -> TestDNSAnswerResponse)
-> Lens TestDNSAnswerResponse TestDNSAnswerResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestDNSAnswerResponse' {Text
nameserver :: Text
$sel:nameserver:TestDNSAnswerResponse' :: TestDNSAnswerResponse -> Text
nameserver} -> Text
nameserver) (\s :: TestDNSAnswerResponse
s@TestDNSAnswerResponse' {} Text
a -> TestDNSAnswerResponse
s {$sel:nameserver:TestDNSAnswerResponse' :: Text
nameserver = Text
a} :: TestDNSAnswerResponse)

-- | The name of the resource record set that you submitted a request for.
testDNSAnswerResponse_recordName :: Lens.Lens' TestDNSAnswerResponse Prelude.Text
testDNSAnswerResponse_recordName :: (Text -> f Text)
-> TestDNSAnswerResponse -> f TestDNSAnswerResponse
testDNSAnswerResponse_recordName = (TestDNSAnswerResponse -> Text)
-> (TestDNSAnswerResponse -> Text -> TestDNSAnswerResponse)
-> Lens TestDNSAnswerResponse TestDNSAnswerResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestDNSAnswerResponse' {Text
recordName :: Text
$sel:recordName:TestDNSAnswerResponse' :: TestDNSAnswerResponse -> Text
recordName} -> Text
recordName) (\s :: TestDNSAnswerResponse
s@TestDNSAnswerResponse' {} Text
a -> TestDNSAnswerResponse
s {$sel:recordName:TestDNSAnswerResponse' :: Text
recordName = Text
a} :: TestDNSAnswerResponse)

-- | The type of the resource record set that you submitted a request for.
testDNSAnswerResponse_recordType :: Lens.Lens' TestDNSAnswerResponse RRType
testDNSAnswerResponse_recordType :: (RRType -> f RRType)
-> TestDNSAnswerResponse -> f TestDNSAnswerResponse
testDNSAnswerResponse_recordType = (TestDNSAnswerResponse -> RRType)
-> (TestDNSAnswerResponse -> RRType -> TestDNSAnswerResponse)
-> Lens TestDNSAnswerResponse TestDNSAnswerResponse RRType RRType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestDNSAnswerResponse' {RRType
recordType :: RRType
$sel:recordType:TestDNSAnswerResponse' :: TestDNSAnswerResponse -> RRType
recordType} -> RRType
recordType) (\s :: TestDNSAnswerResponse
s@TestDNSAnswerResponse' {} RRType
a -> TestDNSAnswerResponse
s {$sel:recordType:TestDNSAnswerResponse' :: RRType
recordType = RRType
a} :: TestDNSAnswerResponse)

-- | A list that contains values that Amazon Route 53 returned for this
-- resource record set.
testDNSAnswerResponse_recordData :: Lens.Lens' TestDNSAnswerResponse [Prelude.Text]
testDNSAnswerResponse_recordData :: ([Text] -> f [Text])
-> TestDNSAnswerResponse -> f TestDNSAnswerResponse
testDNSAnswerResponse_recordData = (TestDNSAnswerResponse -> [Text])
-> (TestDNSAnswerResponse -> [Text] -> TestDNSAnswerResponse)
-> Lens TestDNSAnswerResponse TestDNSAnswerResponse [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestDNSAnswerResponse' {[Text]
recordData :: [Text]
$sel:recordData:TestDNSAnswerResponse' :: TestDNSAnswerResponse -> [Text]
recordData} -> [Text]
recordData) (\s :: TestDNSAnswerResponse
s@TestDNSAnswerResponse' {} [Text]
a -> TestDNSAnswerResponse
s {$sel:recordData:TestDNSAnswerResponse' :: [Text]
recordData = [Text]
a} :: TestDNSAnswerResponse) (([Text] -> f [Text])
 -> TestDNSAnswerResponse -> f TestDNSAnswerResponse)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> TestDNSAnswerResponse
-> f TestDNSAnswerResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A code that indicates whether the request is valid or not. The most
-- common response code is @NOERROR@, meaning that the request is valid. If
-- the response is not valid, Amazon Route 53 returns a response code that
-- describes the error. For a list of possible response codes, see
-- <http://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-6 DNS RCODES>
-- on the IANA website.
testDNSAnswerResponse_responseCode :: Lens.Lens' TestDNSAnswerResponse Prelude.Text
testDNSAnswerResponse_responseCode :: (Text -> f Text)
-> TestDNSAnswerResponse -> f TestDNSAnswerResponse
testDNSAnswerResponse_responseCode = (TestDNSAnswerResponse -> Text)
-> (TestDNSAnswerResponse -> Text -> TestDNSAnswerResponse)
-> Lens TestDNSAnswerResponse TestDNSAnswerResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestDNSAnswerResponse' {Text
responseCode :: Text
$sel:responseCode:TestDNSAnswerResponse' :: TestDNSAnswerResponse -> Text
responseCode} -> Text
responseCode) (\s :: TestDNSAnswerResponse
s@TestDNSAnswerResponse' {} Text
a -> TestDNSAnswerResponse
s {$sel:responseCode:TestDNSAnswerResponse' :: Text
responseCode = Text
a} :: TestDNSAnswerResponse)

-- | The protocol that Amazon Route 53 used to respond to the request, either
-- @UDP@ or @TCP@.
testDNSAnswerResponse_protocol :: Lens.Lens' TestDNSAnswerResponse Prelude.Text
testDNSAnswerResponse_protocol :: (Text -> f Text)
-> TestDNSAnswerResponse -> f TestDNSAnswerResponse
testDNSAnswerResponse_protocol = (TestDNSAnswerResponse -> Text)
-> (TestDNSAnswerResponse -> Text -> TestDNSAnswerResponse)
-> Lens TestDNSAnswerResponse TestDNSAnswerResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestDNSAnswerResponse' {Text
protocol :: Text
$sel:protocol:TestDNSAnswerResponse' :: TestDNSAnswerResponse -> Text
protocol} -> Text
protocol) (\s :: TestDNSAnswerResponse
s@TestDNSAnswerResponse' {} Text
a -> TestDNSAnswerResponse
s {$sel:protocol:TestDNSAnswerResponse' :: Text
protocol = Text
a} :: TestDNSAnswerResponse)

instance Prelude.NFData TestDNSAnswerResponse