{-# 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.WAFRegional.GetRuleGroup
-- 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)
--
-- This is __AWS WAF Classic__ documentation. For more information, see
-- <https://docs.aws.amazon.com/waf/latest/developerguide/classic-waf-chapter.html AWS WAF Classic>
-- in the developer guide.
--
-- __For the latest version of AWS WAF__, use the AWS WAFV2 API and see the
-- <https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html AWS WAF Developer Guide>.
-- With the latest version, AWS WAF has a single set of endpoints for
-- regional and global use.
--
-- Returns the RuleGroup that is specified by the @RuleGroupId@ that you
-- included in the @GetRuleGroup@ request.
--
-- To view the rules in a rule group, use ListActivatedRulesInRuleGroup.
module Amazonka.WAFRegional.GetRuleGroup
  ( -- * Creating a Request
    GetRuleGroup (..),
    newGetRuleGroup,

    -- * Request Lenses
    getRuleGroup_ruleGroupId,

    -- * Destructuring the Response
    GetRuleGroupResponse (..),
    newGetRuleGroupResponse,

    -- * Response Lenses
    getRuleGroupResponse_ruleGroup,
    getRuleGroupResponse_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.WAFRegional.Types

-- | /See:/ 'newGetRuleGroup' smart constructor.
data GetRuleGroup = GetRuleGroup'
  { -- | The @RuleGroupId@ of the RuleGroup that you want to get. @RuleGroupId@
    -- is returned by CreateRuleGroup and by ListRuleGroups.
    GetRuleGroup -> Text
ruleGroupId :: Prelude.Text
  }
  deriving (GetRuleGroup -> GetRuleGroup -> Bool
(GetRuleGroup -> GetRuleGroup -> Bool)
-> (GetRuleGroup -> GetRuleGroup -> Bool) -> Eq GetRuleGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRuleGroup -> GetRuleGroup -> Bool
$c/= :: GetRuleGroup -> GetRuleGroup -> Bool
== :: GetRuleGroup -> GetRuleGroup -> Bool
$c== :: GetRuleGroup -> GetRuleGroup -> Bool
Prelude.Eq, ReadPrec [GetRuleGroup]
ReadPrec GetRuleGroup
Int -> ReadS GetRuleGroup
ReadS [GetRuleGroup]
(Int -> ReadS GetRuleGroup)
-> ReadS [GetRuleGroup]
-> ReadPrec GetRuleGroup
-> ReadPrec [GetRuleGroup]
-> Read GetRuleGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRuleGroup]
$creadListPrec :: ReadPrec [GetRuleGroup]
readPrec :: ReadPrec GetRuleGroup
$creadPrec :: ReadPrec GetRuleGroup
readList :: ReadS [GetRuleGroup]
$creadList :: ReadS [GetRuleGroup]
readsPrec :: Int -> ReadS GetRuleGroup
$creadsPrec :: Int -> ReadS GetRuleGroup
Prelude.Read, Int -> GetRuleGroup -> ShowS
[GetRuleGroup] -> ShowS
GetRuleGroup -> String
(Int -> GetRuleGroup -> ShowS)
-> (GetRuleGroup -> String)
-> ([GetRuleGroup] -> ShowS)
-> Show GetRuleGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRuleGroup] -> ShowS
$cshowList :: [GetRuleGroup] -> ShowS
show :: GetRuleGroup -> String
$cshow :: GetRuleGroup -> String
showsPrec :: Int -> GetRuleGroup -> ShowS
$cshowsPrec :: Int -> GetRuleGroup -> ShowS
Prelude.Show, (forall x. GetRuleGroup -> Rep GetRuleGroup x)
-> (forall x. Rep GetRuleGroup x -> GetRuleGroup)
-> Generic GetRuleGroup
forall x. Rep GetRuleGroup x -> GetRuleGroup
forall x. GetRuleGroup -> Rep GetRuleGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRuleGroup x -> GetRuleGroup
$cfrom :: forall x. GetRuleGroup -> Rep GetRuleGroup x
Prelude.Generic)

-- |
-- Create a value of 'GetRuleGroup' 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:
--
-- 'ruleGroupId', 'getRuleGroup_ruleGroupId' - The @RuleGroupId@ of the RuleGroup that you want to get. @RuleGroupId@
-- is returned by CreateRuleGroup and by ListRuleGroups.
newGetRuleGroup ::
  -- | 'ruleGroupId'
  Prelude.Text ->
  GetRuleGroup
newGetRuleGroup :: Text -> GetRuleGroup
newGetRuleGroup Text
pRuleGroupId_ =
  GetRuleGroup' :: Text -> GetRuleGroup
GetRuleGroup' {$sel:ruleGroupId:GetRuleGroup' :: Text
ruleGroupId = Text
pRuleGroupId_}

-- | The @RuleGroupId@ of the RuleGroup that you want to get. @RuleGroupId@
-- is returned by CreateRuleGroup and by ListRuleGroups.
getRuleGroup_ruleGroupId :: Lens.Lens' GetRuleGroup Prelude.Text
getRuleGroup_ruleGroupId :: (Text -> f Text) -> GetRuleGroup -> f GetRuleGroup
getRuleGroup_ruleGroupId = (GetRuleGroup -> Text)
-> (GetRuleGroup -> Text -> GetRuleGroup)
-> Lens GetRuleGroup GetRuleGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRuleGroup' {Text
ruleGroupId :: Text
$sel:ruleGroupId:GetRuleGroup' :: GetRuleGroup -> Text
ruleGroupId} -> Text
ruleGroupId) (\s :: GetRuleGroup
s@GetRuleGroup' {} Text
a -> GetRuleGroup
s {$sel:ruleGroupId:GetRuleGroup' :: Text
ruleGroupId = Text
a} :: GetRuleGroup)

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

instance Prelude.NFData GetRuleGroup

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

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

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

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

-- |
-- Create a value of 'GetRuleGroupResponse' 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:
--
-- 'ruleGroup', 'getRuleGroupResponse_ruleGroup' - Information about the RuleGroup that you specified in the @GetRuleGroup@
-- request.
--
-- 'httpStatus', 'getRuleGroupResponse_httpStatus' - The response's http status code.
newGetRuleGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetRuleGroupResponse
newGetRuleGroupResponse :: Int -> GetRuleGroupResponse
newGetRuleGroupResponse Int
pHttpStatus_ =
  GetRuleGroupResponse' :: Maybe RuleGroup -> Int -> GetRuleGroupResponse
GetRuleGroupResponse'
    { $sel:ruleGroup:GetRuleGroupResponse' :: Maybe RuleGroup
ruleGroup = Maybe RuleGroup
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetRuleGroupResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the RuleGroup that you specified in the @GetRuleGroup@
-- request.
getRuleGroupResponse_ruleGroup :: Lens.Lens' GetRuleGroupResponse (Prelude.Maybe RuleGroup)
getRuleGroupResponse_ruleGroup :: (Maybe RuleGroup -> f (Maybe RuleGroup))
-> GetRuleGroupResponse -> f GetRuleGroupResponse
getRuleGroupResponse_ruleGroup = (GetRuleGroupResponse -> Maybe RuleGroup)
-> (GetRuleGroupResponse
    -> Maybe RuleGroup -> GetRuleGroupResponse)
-> Lens
     GetRuleGroupResponse
     GetRuleGroupResponse
     (Maybe RuleGroup)
     (Maybe RuleGroup)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRuleGroupResponse' {Maybe RuleGroup
ruleGroup :: Maybe RuleGroup
$sel:ruleGroup:GetRuleGroupResponse' :: GetRuleGroupResponse -> Maybe RuleGroup
ruleGroup} -> Maybe RuleGroup
ruleGroup) (\s :: GetRuleGroupResponse
s@GetRuleGroupResponse' {} Maybe RuleGroup
a -> GetRuleGroupResponse
s {$sel:ruleGroup:GetRuleGroupResponse' :: Maybe RuleGroup
ruleGroup = Maybe RuleGroup
a} :: GetRuleGroupResponse)

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

instance Prelude.NFData GetRuleGroupResponse