{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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' {$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 :: Lens' GetRuleGroup Text
getRuleGroup_ruleGroupId = 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 :: (Service -> Service) -> GetRuleGroup -> Request GetRuleGroup
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetRuleGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetRuleGroup)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe RuleGroup -> Int -> GetRuleGroupResponse
GetRuleGroupResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"RuleGroup")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetRuleGroup where
  hashWithSalt :: Int -> GetRuleGroup -> Int
hashWithSalt Int
_salt GetRuleGroup' {Text
ruleGroupId :: Text
$sel:ruleGroupId:GetRuleGroup' :: GetRuleGroup -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
ruleGroupId

instance Prelude.NFData GetRuleGroup where
  rnf :: GetRuleGroup -> ()
rnf GetRuleGroup' {Text
ruleGroupId :: Text
$sel:ruleGroupId:GetRuleGroup' :: GetRuleGroup -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
ruleGroupId

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

instance Data.ToJSON GetRuleGroup where
  toJSON :: GetRuleGroup -> Value
toJSON GetRuleGroup' {Text
ruleGroupId :: Text
$sel:ruleGroupId:GetRuleGroup' :: GetRuleGroup -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"RuleGroupId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
ruleGroupId)]
      )

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

instance Data.ToQuery GetRuleGroup where
  toQuery :: GetRuleGroup -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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'
    { $sel:ruleGroup:GetRuleGroupResponse' :: Maybe RuleGroup
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 :: Lens' GetRuleGroupResponse (Maybe RuleGroup)
getRuleGroupResponse_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 :: Lens' GetRuleGroupResponse Int
getRuleGroupResponse_httpStatus = 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 where
  rnf :: GetRuleGroupResponse -> ()
rnf GetRuleGroupResponse' {Int
Maybe RuleGroup
httpStatus :: Int
ruleGroup :: Maybe RuleGroup
$sel:httpStatus:GetRuleGroupResponse' :: GetRuleGroupResponse -> Int
$sel:ruleGroup:GetRuleGroupResponse' :: GetRuleGroupResponse -> Maybe RuleGroup
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe RuleGroup
ruleGroup
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus