{-# 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.WAF.GetWebACL
-- 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 WebACL that is specified by @WebACLId@.
module Amazonka.WAF.GetWebACL
  ( -- * Creating a Request
    GetWebACL (..),
    newGetWebACL,

    -- * Request Lenses
    getWebACL_webACLId,

    -- * Destructuring the Response
    GetWebACLResponse (..),
    newGetWebACLResponse,

    -- * Response Lenses
    getWebACLResponse_webACL,
    getWebACLResponse_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.WAF.Types

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

-- |
-- Create a value of 'GetWebACL' 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:
--
-- 'webACLId', 'getWebACL_webACLId' - The @WebACLId@ of the WebACL that you want to get. @WebACLId@ is
-- returned by CreateWebACL and by ListWebACLs.
newGetWebACL ::
  -- | 'webACLId'
  Prelude.Text ->
  GetWebACL
newGetWebACL :: Text -> GetWebACL
newGetWebACL Text
pWebACLId_ =
  GetWebACL' :: Text -> GetWebACL
GetWebACL' {$sel:webACLId:GetWebACL' :: Text
webACLId = Text
pWebACLId_}

-- | The @WebACLId@ of the WebACL that you want to get. @WebACLId@ is
-- returned by CreateWebACL and by ListWebACLs.
getWebACL_webACLId :: Lens.Lens' GetWebACL Prelude.Text
getWebACL_webACLId :: (Text -> f Text) -> GetWebACL -> f GetWebACL
getWebACL_webACLId = (GetWebACL -> Text)
-> (GetWebACL -> Text -> GetWebACL)
-> Lens GetWebACL GetWebACL Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetWebACL' {Text
webACLId :: Text
$sel:webACLId:GetWebACL' :: GetWebACL -> Text
webACLId} -> Text
webACLId) (\s :: GetWebACL
s@GetWebACL' {} Text
a -> GetWebACL
s {$sel:webACLId:GetWebACL' :: Text
webACLId = Text
a} :: GetWebACL)

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

instance Prelude.NFData GetWebACL

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

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

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

-- | /See:/ 'newGetWebACLResponse' smart constructor.
data GetWebACLResponse = GetWebACLResponse'
  { -- | Information about the WebACL that you specified in the @GetWebACL@
    -- request. For more information, see the following topics:
    --
    -- -   WebACL: Contains @DefaultAction@, @MetricName@, @Name@, an array of
    --     @Rule@ objects, and @WebACLId@
    --
    -- -   @DefaultAction@ (Data type is WafAction): Contains @Type@
    --
    -- -   @Rules@: Contains an array of @ActivatedRule@ objects, which contain
    --     @Action@, @Priority@, and @RuleId@
    --
    -- -   @Action@: Contains @Type@
    GetWebACLResponse -> Maybe WebACL
webACL :: Prelude.Maybe WebACL,
    -- | The response's http status code.
    GetWebACLResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetWebACLResponse -> GetWebACLResponse -> Bool
(GetWebACLResponse -> GetWebACLResponse -> Bool)
-> (GetWebACLResponse -> GetWebACLResponse -> Bool)
-> Eq GetWebACLResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetWebACLResponse -> GetWebACLResponse -> Bool
$c/= :: GetWebACLResponse -> GetWebACLResponse -> Bool
== :: GetWebACLResponse -> GetWebACLResponse -> Bool
$c== :: GetWebACLResponse -> GetWebACLResponse -> Bool
Prelude.Eq, ReadPrec [GetWebACLResponse]
ReadPrec GetWebACLResponse
Int -> ReadS GetWebACLResponse
ReadS [GetWebACLResponse]
(Int -> ReadS GetWebACLResponse)
-> ReadS [GetWebACLResponse]
-> ReadPrec GetWebACLResponse
-> ReadPrec [GetWebACLResponse]
-> Read GetWebACLResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetWebACLResponse]
$creadListPrec :: ReadPrec [GetWebACLResponse]
readPrec :: ReadPrec GetWebACLResponse
$creadPrec :: ReadPrec GetWebACLResponse
readList :: ReadS [GetWebACLResponse]
$creadList :: ReadS [GetWebACLResponse]
readsPrec :: Int -> ReadS GetWebACLResponse
$creadsPrec :: Int -> ReadS GetWebACLResponse
Prelude.Read, Int -> GetWebACLResponse -> ShowS
[GetWebACLResponse] -> ShowS
GetWebACLResponse -> String
(Int -> GetWebACLResponse -> ShowS)
-> (GetWebACLResponse -> String)
-> ([GetWebACLResponse] -> ShowS)
-> Show GetWebACLResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetWebACLResponse] -> ShowS
$cshowList :: [GetWebACLResponse] -> ShowS
show :: GetWebACLResponse -> String
$cshow :: GetWebACLResponse -> String
showsPrec :: Int -> GetWebACLResponse -> ShowS
$cshowsPrec :: Int -> GetWebACLResponse -> ShowS
Prelude.Show, (forall x. GetWebACLResponse -> Rep GetWebACLResponse x)
-> (forall x. Rep GetWebACLResponse x -> GetWebACLResponse)
-> Generic GetWebACLResponse
forall x. Rep GetWebACLResponse x -> GetWebACLResponse
forall x. GetWebACLResponse -> Rep GetWebACLResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetWebACLResponse x -> GetWebACLResponse
$cfrom :: forall x. GetWebACLResponse -> Rep GetWebACLResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetWebACLResponse' 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:
--
-- 'webACL', 'getWebACLResponse_webACL' - Information about the WebACL that you specified in the @GetWebACL@
-- request. For more information, see the following topics:
--
-- -   WebACL: Contains @DefaultAction@, @MetricName@, @Name@, an array of
--     @Rule@ objects, and @WebACLId@
--
-- -   @DefaultAction@ (Data type is WafAction): Contains @Type@
--
-- -   @Rules@: Contains an array of @ActivatedRule@ objects, which contain
--     @Action@, @Priority@, and @RuleId@
--
-- -   @Action@: Contains @Type@
--
-- 'httpStatus', 'getWebACLResponse_httpStatus' - The response's http status code.
newGetWebACLResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetWebACLResponse
newGetWebACLResponse :: Int -> GetWebACLResponse
newGetWebACLResponse Int
pHttpStatus_ =
  GetWebACLResponse' :: Maybe WebACL -> Int -> GetWebACLResponse
GetWebACLResponse'
    { $sel:webACL:GetWebACLResponse' :: Maybe WebACL
webACL = Maybe WebACL
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetWebACLResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the WebACL that you specified in the @GetWebACL@
-- request. For more information, see the following topics:
--
-- -   WebACL: Contains @DefaultAction@, @MetricName@, @Name@, an array of
--     @Rule@ objects, and @WebACLId@
--
-- -   @DefaultAction@ (Data type is WafAction): Contains @Type@
--
-- -   @Rules@: Contains an array of @ActivatedRule@ objects, which contain
--     @Action@, @Priority@, and @RuleId@
--
-- -   @Action@: Contains @Type@
getWebACLResponse_webACL :: Lens.Lens' GetWebACLResponse (Prelude.Maybe WebACL)
getWebACLResponse_webACL :: (Maybe WebACL -> f (Maybe WebACL))
-> GetWebACLResponse -> f GetWebACLResponse
getWebACLResponse_webACL = (GetWebACLResponse -> Maybe WebACL)
-> (GetWebACLResponse -> Maybe WebACL -> GetWebACLResponse)
-> Lens
     GetWebACLResponse GetWebACLResponse (Maybe WebACL) (Maybe WebACL)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetWebACLResponse' {Maybe WebACL
webACL :: Maybe WebACL
$sel:webACL:GetWebACLResponse' :: GetWebACLResponse -> Maybe WebACL
webACL} -> Maybe WebACL
webACL) (\s :: GetWebACLResponse
s@GetWebACLResponse' {} Maybe WebACL
a -> GetWebACLResponse
s {$sel:webACL:GetWebACLResponse' :: Maybe WebACL
webACL = Maybe WebACL
a} :: GetWebACLResponse)

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

instance Prelude.NFData GetWebACLResponse