{-# 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.Route53Resolver.GetResolverRule
-- 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 information about a specified Resolver rule, such as the domain
-- name that the rule forwards DNS queries for and the ID of the outbound
-- Resolver endpoint that the rule is associated with.
module Amazonka.Route53Resolver.GetResolverRule
  ( -- * Creating a Request
    GetResolverRule (..),
    newGetResolverRule,

    -- * Request Lenses
    getResolverRule_resolverRuleId,

    -- * Destructuring the Response
    GetResolverRuleResponse (..),
    newGetResolverRuleResponse,

    -- * Response Lenses
    getResolverRuleResponse_resolverRule,
    getResolverRuleResponse_httpStatus,
  )
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.Route53Resolver.Types

-- | /See:/ 'newGetResolverRule' smart constructor.
data GetResolverRule = GetResolverRule'
  { -- | The ID of the Resolver rule that you want to get information about.
    GetResolverRule -> Text
resolverRuleId :: Prelude.Text
  }
  deriving (GetResolverRule -> GetResolverRule -> Bool
(GetResolverRule -> GetResolverRule -> Bool)
-> (GetResolverRule -> GetResolverRule -> Bool)
-> Eq GetResolverRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetResolverRule -> GetResolverRule -> Bool
$c/= :: GetResolverRule -> GetResolverRule -> Bool
== :: GetResolverRule -> GetResolverRule -> Bool
$c== :: GetResolverRule -> GetResolverRule -> Bool
Prelude.Eq, ReadPrec [GetResolverRule]
ReadPrec GetResolverRule
Int -> ReadS GetResolverRule
ReadS [GetResolverRule]
(Int -> ReadS GetResolverRule)
-> ReadS [GetResolverRule]
-> ReadPrec GetResolverRule
-> ReadPrec [GetResolverRule]
-> Read GetResolverRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetResolverRule]
$creadListPrec :: ReadPrec [GetResolverRule]
readPrec :: ReadPrec GetResolverRule
$creadPrec :: ReadPrec GetResolverRule
readList :: ReadS [GetResolverRule]
$creadList :: ReadS [GetResolverRule]
readsPrec :: Int -> ReadS GetResolverRule
$creadsPrec :: Int -> ReadS GetResolverRule
Prelude.Read, Int -> GetResolverRule -> ShowS
[GetResolverRule] -> ShowS
GetResolverRule -> String
(Int -> GetResolverRule -> ShowS)
-> (GetResolverRule -> String)
-> ([GetResolverRule] -> ShowS)
-> Show GetResolverRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetResolverRule] -> ShowS
$cshowList :: [GetResolverRule] -> ShowS
show :: GetResolverRule -> String
$cshow :: GetResolverRule -> String
showsPrec :: Int -> GetResolverRule -> ShowS
$cshowsPrec :: Int -> GetResolverRule -> ShowS
Prelude.Show, (forall x. GetResolverRule -> Rep GetResolverRule x)
-> (forall x. Rep GetResolverRule x -> GetResolverRule)
-> Generic GetResolverRule
forall x. Rep GetResolverRule x -> GetResolverRule
forall x. GetResolverRule -> Rep GetResolverRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetResolverRule x -> GetResolverRule
$cfrom :: forall x. GetResolverRule -> Rep GetResolverRule x
Prelude.Generic)

-- |
-- Create a value of 'GetResolverRule' 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:
--
-- 'resolverRuleId', 'getResolverRule_resolverRuleId' - The ID of the Resolver rule that you want to get information about.
newGetResolverRule ::
  -- | 'resolverRuleId'
  Prelude.Text ->
  GetResolverRule
newGetResolverRule :: Text -> GetResolverRule
newGetResolverRule Text
pResolverRuleId_ =
  GetResolverRule' :: Text -> GetResolverRule
GetResolverRule' {$sel:resolverRuleId:GetResolverRule' :: Text
resolverRuleId = Text
pResolverRuleId_}

-- | The ID of the Resolver rule that you want to get information about.
getResolverRule_resolverRuleId :: Lens.Lens' GetResolverRule Prelude.Text
getResolverRule_resolverRuleId :: (Text -> f Text) -> GetResolverRule -> f GetResolverRule
getResolverRule_resolverRuleId = (GetResolverRule -> Text)
-> (GetResolverRule -> Text -> GetResolverRule)
-> Lens GetResolverRule GetResolverRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResolverRule' {Text
resolverRuleId :: Text
$sel:resolverRuleId:GetResolverRule' :: GetResolverRule -> Text
resolverRuleId} -> Text
resolverRuleId) (\s :: GetResolverRule
s@GetResolverRule' {} Text
a -> GetResolverRule
s {$sel:resolverRuleId:GetResolverRule' :: Text
resolverRuleId = Text
a} :: GetResolverRule)

instance Core.AWSRequest GetResolverRule where
  type
    AWSResponse GetResolverRule =
      GetResolverRuleResponse
  request :: GetResolverRule -> Request GetResolverRule
request = Service -> GetResolverRule -> Request GetResolverRule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetResolverRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetResolverRule)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetResolverRule))
-> Logger
-> Service
-> Proxy GetResolverRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetResolverRule)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe ResolverRule -> Int -> GetResolverRuleResponse
GetResolverRuleResponse'
            (Maybe ResolverRule -> Int -> GetResolverRuleResponse)
-> Either String (Maybe ResolverRule)
-> Either String (Int -> GetResolverRuleResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ResolverRule)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ResolverRule")
            Either String (Int -> GetResolverRuleResponse)
-> Either String Int -> Either String GetResolverRuleResponse
forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable GetResolverRule

instance Prelude.NFData GetResolverRule

instance Core.ToHeaders GetResolverRule where
  toHeaders :: GetResolverRule -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetResolverRule -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Route53Resolver.GetResolverRule" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON GetResolverRule where
  toJSON :: GetResolverRule -> Value
toJSON GetResolverRule' {Text
resolverRuleId :: Text
$sel:resolverRuleId:GetResolverRule' :: GetResolverRule -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ResolverRuleId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resolverRuleId)
          ]
      )

instance Core.ToPath GetResolverRule where
  toPath :: GetResolverRule -> ByteString
toPath = ByteString -> GetResolverRule -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newGetResolverRuleResponse' smart constructor.
data GetResolverRuleResponse = GetResolverRuleResponse'
  { -- | Information about the Resolver rule that you specified in a
    -- @GetResolverRule@ request.
    GetResolverRuleResponse -> Maybe ResolverRule
resolverRule :: Prelude.Maybe ResolverRule,
    -- | The response's http status code.
    GetResolverRuleResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetResolverRuleResponse -> GetResolverRuleResponse -> Bool
(GetResolverRuleResponse -> GetResolverRuleResponse -> Bool)
-> (GetResolverRuleResponse -> GetResolverRuleResponse -> Bool)
-> Eq GetResolverRuleResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetResolverRuleResponse -> GetResolverRuleResponse -> Bool
$c/= :: GetResolverRuleResponse -> GetResolverRuleResponse -> Bool
== :: GetResolverRuleResponse -> GetResolverRuleResponse -> Bool
$c== :: GetResolverRuleResponse -> GetResolverRuleResponse -> Bool
Prelude.Eq, ReadPrec [GetResolverRuleResponse]
ReadPrec GetResolverRuleResponse
Int -> ReadS GetResolverRuleResponse
ReadS [GetResolverRuleResponse]
(Int -> ReadS GetResolverRuleResponse)
-> ReadS [GetResolverRuleResponse]
-> ReadPrec GetResolverRuleResponse
-> ReadPrec [GetResolverRuleResponse]
-> Read GetResolverRuleResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetResolverRuleResponse]
$creadListPrec :: ReadPrec [GetResolverRuleResponse]
readPrec :: ReadPrec GetResolverRuleResponse
$creadPrec :: ReadPrec GetResolverRuleResponse
readList :: ReadS [GetResolverRuleResponse]
$creadList :: ReadS [GetResolverRuleResponse]
readsPrec :: Int -> ReadS GetResolverRuleResponse
$creadsPrec :: Int -> ReadS GetResolverRuleResponse
Prelude.Read, Int -> GetResolverRuleResponse -> ShowS
[GetResolverRuleResponse] -> ShowS
GetResolverRuleResponse -> String
(Int -> GetResolverRuleResponse -> ShowS)
-> (GetResolverRuleResponse -> String)
-> ([GetResolverRuleResponse] -> ShowS)
-> Show GetResolverRuleResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetResolverRuleResponse] -> ShowS
$cshowList :: [GetResolverRuleResponse] -> ShowS
show :: GetResolverRuleResponse -> String
$cshow :: GetResolverRuleResponse -> String
showsPrec :: Int -> GetResolverRuleResponse -> ShowS
$cshowsPrec :: Int -> GetResolverRuleResponse -> ShowS
Prelude.Show, (forall x.
 GetResolverRuleResponse -> Rep GetResolverRuleResponse x)
-> (forall x.
    Rep GetResolverRuleResponse x -> GetResolverRuleResponse)
-> Generic GetResolverRuleResponse
forall x. Rep GetResolverRuleResponse x -> GetResolverRuleResponse
forall x. GetResolverRuleResponse -> Rep GetResolverRuleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetResolverRuleResponse x -> GetResolverRuleResponse
$cfrom :: forall x. GetResolverRuleResponse -> Rep GetResolverRuleResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetResolverRuleResponse' 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:
--
-- 'resolverRule', 'getResolverRuleResponse_resolverRule' - Information about the Resolver rule that you specified in a
-- @GetResolverRule@ request.
--
-- 'httpStatus', 'getResolverRuleResponse_httpStatus' - The response's http status code.
newGetResolverRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetResolverRuleResponse
newGetResolverRuleResponse :: Int -> GetResolverRuleResponse
newGetResolverRuleResponse Int
pHttpStatus_ =
  GetResolverRuleResponse' :: Maybe ResolverRule -> Int -> GetResolverRuleResponse
GetResolverRuleResponse'
    { $sel:resolverRule:GetResolverRuleResponse' :: Maybe ResolverRule
resolverRule =
        Maybe ResolverRule
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetResolverRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the Resolver rule that you specified in a
-- @GetResolverRule@ request.
getResolverRuleResponse_resolverRule :: Lens.Lens' GetResolverRuleResponse (Prelude.Maybe ResolverRule)
getResolverRuleResponse_resolverRule :: (Maybe ResolverRule -> f (Maybe ResolverRule))
-> GetResolverRuleResponse -> f GetResolverRuleResponse
getResolverRuleResponse_resolverRule = (GetResolverRuleResponse -> Maybe ResolverRule)
-> (GetResolverRuleResponse
    -> Maybe ResolverRule -> GetResolverRuleResponse)
-> Lens
     GetResolverRuleResponse
     GetResolverRuleResponse
     (Maybe ResolverRule)
     (Maybe ResolverRule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResolverRuleResponse' {Maybe ResolverRule
resolverRule :: Maybe ResolverRule
$sel:resolverRule:GetResolverRuleResponse' :: GetResolverRuleResponse -> Maybe ResolverRule
resolverRule} -> Maybe ResolverRule
resolverRule) (\s :: GetResolverRuleResponse
s@GetResolverRuleResponse' {} Maybe ResolverRule
a -> GetResolverRuleResponse
s {$sel:resolverRule:GetResolverRuleResponse' :: Maybe ResolverRule
resolverRule = Maybe ResolverRule
a} :: GetResolverRuleResponse)

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

instance Prelude.NFData GetResolverRuleResponse