{-# 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.GetResolverRulePolicy
-- 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 the Resolver rule policy for a specified rule. A
-- Resolver rule policy includes the rule that you want to share with
-- another account, the account that you want to share the rule with, and
-- the Resolver operations that you want to allow the account to use.
module Amazonka.Route53Resolver.GetResolverRulePolicy
  ( -- * Creating a Request
    GetResolverRulePolicy (..),
    newGetResolverRulePolicy,

    -- * Request Lenses
    getResolverRulePolicy_arn,

    -- * Destructuring the Response
    GetResolverRulePolicyResponse (..),
    newGetResolverRulePolicyResponse,

    -- * Response Lenses
    getResolverRulePolicyResponse_resolverRulePolicy,
    getResolverRulePolicyResponse_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:/ 'newGetResolverRulePolicy' smart constructor.
data GetResolverRulePolicy = GetResolverRulePolicy'
  { -- | The ID of the Resolver rule that you want to get the Resolver rule
    -- policy for.
    GetResolverRulePolicy -> Text
arn :: Prelude.Text
  }
  deriving (GetResolverRulePolicy -> GetResolverRulePolicy -> Bool
(GetResolverRulePolicy -> GetResolverRulePolicy -> Bool)
-> (GetResolverRulePolicy -> GetResolverRulePolicy -> Bool)
-> Eq GetResolverRulePolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetResolverRulePolicy -> GetResolverRulePolicy -> Bool
$c/= :: GetResolverRulePolicy -> GetResolverRulePolicy -> Bool
== :: GetResolverRulePolicy -> GetResolverRulePolicy -> Bool
$c== :: GetResolverRulePolicy -> GetResolverRulePolicy -> Bool
Prelude.Eq, ReadPrec [GetResolverRulePolicy]
ReadPrec GetResolverRulePolicy
Int -> ReadS GetResolverRulePolicy
ReadS [GetResolverRulePolicy]
(Int -> ReadS GetResolverRulePolicy)
-> ReadS [GetResolverRulePolicy]
-> ReadPrec GetResolverRulePolicy
-> ReadPrec [GetResolverRulePolicy]
-> Read GetResolverRulePolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetResolverRulePolicy]
$creadListPrec :: ReadPrec [GetResolverRulePolicy]
readPrec :: ReadPrec GetResolverRulePolicy
$creadPrec :: ReadPrec GetResolverRulePolicy
readList :: ReadS [GetResolverRulePolicy]
$creadList :: ReadS [GetResolverRulePolicy]
readsPrec :: Int -> ReadS GetResolverRulePolicy
$creadsPrec :: Int -> ReadS GetResolverRulePolicy
Prelude.Read, Int -> GetResolverRulePolicy -> ShowS
[GetResolverRulePolicy] -> ShowS
GetResolverRulePolicy -> String
(Int -> GetResolverRulePolicy -> ShowS)
-> (GetResolverRulePolicy -> String)
-> ([GetResolverRulePolicy] -> ShowS)
-> Show GetResolverRulePolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetResolverRulePolicy] -> ShowS
$cshowList :: [GetResolverRulePolicy] -> ShowS
show :: GetResolverRulePolicy -> String
$cshow :: GetResolverRulePolicy -> String
showsPrec :: Int -> GetResolverRulePolicy -> ShowS
$cshowsPrec :: Int -> GetResolverRulePolicy -> ShowS
Prelude.Show, (forall x. GetResolverRulePolicy -> Rep GetResolverRulePolicy x)
-> (forall x. Rep GetResolverRulePolicy x -> GetResolverRulePolicy)
-> Generic GetResolverRulePolicy
forall x. Rep GetResolverRulePolicy x -> GetResolverRulePolicy
forall x. GetResolverRulePolicy -> Rep GetResolverRulePolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetResolverRulePolicy x -> GetResolverRulePolicy
$cfrom :: forall x. GetResolverRulePolicy -> Rep GetResolverRulePolicy x
Prelude.Generic)

-- |
-- Create a value of 'GetResolverRulePolicy' 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:
--
-- 'arn', 'getResolverRulePolicy_arn' - The ID of the Resolver rule that you want to get the Resolver rule
-- policy for.
newGetResolverRulePolicy ::
  -- | 'arn'
  Prelude.Text ->
  GetResolverRulePolicy
newGetResolverRulePolicy :: Text -> GetResolverRulePolicy
newGetResolverRulePolicy Text
pArn_ =
  GetResolverRulePolicy' :: Text -> GetResolverRulePolicy
GetResolverRulePolicy' {$sel:arn:GetResolverRulePolicy' :: Text
arn = Text
pArn_}

-- | The ID of the Resolver rule that you want to get the Resolver rule
-- policy for.
getResolverRulePolicy_arn :: Lens.Lens' GetResolverRulePolicy Prelude.Text
getResolverRulePolicy_arn :: (Text -> f Text)
-> GetResolverRulePolicy -> f GetResolverRulePolicy
getResolverRulePolicy_arn = (GetResolverRulePolicy -> Text)
-> (GetResolverRulePolicy -> Text -> GetResolverRulePolicy)
-> Lens GetResolverRulePolicy GetResolverRulePolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResolverRulePolicy' {Text
arn :: Text
$sel:arn:GetResolverRulePolicy' :: GetResolverRulePolicy -> Text
arn} -> Text
arn) (\s :: GetResolverRulePolicy
s@GetResolverRulePolicy' {} Text
a -> GetResolverRulePolicy
s {$sel:arn:GetResolverRulePolicy' :: Text
arn = Text
a} :: GetResolverRulePolicy)

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

instance Prelude.NFData GetResolverRulePolicy

instance Core.ToHeaders GetResolverRulePolicy where
  toHeaders :: GetResolverRulePolicy -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetResolverRulePolicy -> 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.GetResolverRulePolicy" ::
                          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 GetResolverRulePolicy where
  toJSON :: GetResolverRulePolicy -> Value
toJSON GetResolverRulePolicy' {Text
arn :: Text
$sel:arn:GetResolverRulePolicy' :: GetResolverRulePolicy -> 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
"Arn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
arn)]
      )

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

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

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

-- |
-- Create a value of 'GetResolverRulePolicyResponse' 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:
--
-- 'resolverRulePolicy', 'getResolverRulePolicyResponse_resolverRulePolicy' - The Resolver rule policy for the rule that you specified in a
-- @GetResolverRulePolicy@ request.
--
-- 'httpStatus', 'getResolverRulePolicyResponse_httpStatus' - The response's http status code.
newGetResolverRulePolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetResolverRulePolicyResponse
newGetResolverRulePolicyResponse :: Int -> GetResolverRulePolicyResponse
newGetResolverRulePolicyResponse Int
pHttpStatus_ =
  GetResolverRulePolicyResponse' :: Maybe Text -> Int -> GetResolverRulePolicyResponse
GetResolverRulePolicyResponse'
    { $sel:resolverRulePolicy:GetResolverRulePolicyResponse' :: Maybe Text
resolverRulePolicy =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetResolverRulePolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Resolver rule policy for the rule that you specified in a
-- @GetResolverRulePolicy@ request.
getResolverRulePolicyResponse_resolverRulePolicy :: Lens.Lens' GetResolverRulePolicyResponse (Prelude.Maybe Prelude.Text)
getResolverRulePolicyResponse_resolverRulePolicy :: (Maybe Text -> f (Maybe Text))
-> GetResolverRulePolicyResponse -> f GetResolverRulePolicyResponse
getResolverRulePolicyResponse_resolverRulePolicy = (GetResolverRulePolicyResponse -> Maybe Text)
-> (GetResolverRulePolicyResponse
    -> Maybe Text -> GetResolverRulePolicyResponse)
-> Lens
     GetResolverRulePolicyResponse
     GetResolverRulePolicyResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResolverRulePolicyResponse' {Maybe Text
resolverRulePolicy :: Maybe Text
$sel:resolverRulePolicy:GetResolverRulePolicyResponse' :: GetResolverRulePolicyResponse -> Maybe Text
resolverRulePolicy} -> Maybe Text
resolverRulePolicy) (\s :: GetResolverRulePolicyResponse
s@GetResolverRulePolicyResponse' {} Maybe Text
a -> GetResolverRulePolicyResponse
s {$sel:resolverRulePolicy:GetResolverRulePolicyResponse' :: Maybe Text
resolverRulePolicy = Maybe Text
a} :: GetResolverRulePolicyResponse)

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

instance Prelude.NFData GetResolverRulePolicyResponse