{-# 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.ListResourcesForWebACL
-- 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 Regional__ 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 an array of resources associated with the specified web ACL.
module Amazonka.WAFRegional.ListResourcesForWebACL
  ( -- * Creating a Request
    ListResourcesForWebACL (..),
    newListResourcesForWebACL,

    -- * Request Lenses
    listResourcesForWebACL_resourceType,
    listResourcesForWebACL_webACLId,

    -- * Destructuring the Response
    ListResourcesForWebACLResponse (..),
    newListResourcesForWebACLResponse,

    -- * Response Lenses
    listResourcesForWebACLResponse_resourceArns,
    listResourcesForWebACLResponse_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:/ 'newListResourcesForWebACL' smart constructor.
data ListResourcesForWebACL = ListResourcesForWebACL'
  { -- | The type of resource to list, either an application load balancer or
    -- Amazon API Gateway.
    ListResourcesForWebACL -> Maybe ResourceType
resourceType :: Prelude.Maybe ResourceType,
    -- | The unique identifier (ID) of the web ACL for which to list the
    -- associated resources.
    ListResourcesForWebACL -> Text
webACLId :: Prelude.Text
  }
  deriving (ListResourcesForWebACL -> ListResourcesForWebACL -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListResourcesForWebACL -> ListResourcesForWebACL -> Bool
$c/= :: ListResourcesForWebACL -> ListResourcesForWebACL -> Bool
== :: ListResourcesForWebACL -> ListResourcesForWebACL -> Bool
$c== :: ListResourcesForWebACL -> ListResourcesForWebACL -> Bool
Prelude.Eq, ReadPrec [ListResourcesForWebACL]
ReadPrec ListResourcesForWebACL
Int -> ReadS ListResourcesForWebACL
ReadS [ListResourcesForWebACL]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListResourcesForWebACL]
$creadListPrec :: ReadPrec [ListResourcesForWebACL]
readPrec :: ReadPrec ListResourcesForWebACL
$creadPrec :: ReadPrec ListResourcesForWebACL
readList :: ReadS [ListResourcesForWebACL]
$creadList :: ReadS [ListResourcesForWebACL]
readsPrec :: Int -> ReadS ListResourcesForWebACL
$creadsPrec :: Int -> ReadS ListResourcesForWebACL
Prelude.Read, Int -> ListResourcesForWebACL -> ShowS
[ListResourcesForWebACL] -> ShowS
ListResourcesForWebACL -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListResourcesForWebACL] -> ShowS
$cshowList :: [ListResourcesForWebACL] -> ShowS
show :: ListResourcesForWebACL -> String
$cshow :: ListResourcesForWebACL -> String
showsPrec :: Int -> ListResourcesForWebACL -> ShowS
$cshowsPrec :: Int -> ListResourcesForWebACL -> ShowS
Prelude.Show, forall x. Rep ListResourcesForWebACL x -> ListResourcesForWebACL
forall x. ListResourcesForWebACL -> Rep ListResourcesForWebACL x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListResourcesForWebACL x -> ListResourcesForWebACL
$cfrom :: forall x. ListResourcesForWebACL -> Rep ListResourcesForWebACL x
Prelude.Generic)

-- |
-- Create a value of 'ListResourcesForWebACL' 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:
--
-- 'resourceType', 'listResourcesForWebACL_resourceType' - The type of resource to list, either an application load balancer or
-- Amazon API Gateway.
--
-- 'webACLId', 'listResourcesForWebACL_webACLId' - The unique identifier (ID) of the web ACL for which to list the
-- associated resources.
newListResourcesForWebACL ::
  -- | 'webACLId'
  Prelude.Text ->
  ListResourcesForWebACL
newListResourcesForWebACL :: Text -> ListResourcesForWebACL
newListResourcesForWebACL Text
pWebACLId_ =
  ListResourcesForWebACL'
    { $sel:resourceType:ListResourcesForWebACL' :: Maybe ResourceType
resourceType =
        forall a. Maybe a
Prelude.Nothing,
      $sel:webACLId:ListResourcesForWebACL' :: Text
webACLId = Text
pWebACLId_
    }

-- | The type of resource to list, either an application load balancer or
-- Amazon API Gateway.
listResourcesForWebACL_resourceType :: Lens.Lens' ListResourcesForWebACL (Prelude.Maybe ResourceType)
listResourcesForWebACL_resourceType :: Lens' ListResourcesForWebACL (Maybe ResourceType)
listResourcesForWebACL_resourceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResourcesForWebACL' {Maybe ResourceType
resourceType :: Maybe ResourceType
$sel:resourceType:ListResourcesForWebACL' :: ListResourcesForWebACL -> Maybe ResourceType
resourceType} -> Maybe ResourceType
resourceType) (\s :: ListResourcesForWebACL
s@ListResourcesForWebACL' {} Maybe ResourceType
a -> ListResourcesForWebACL
s {$sel:resourceType:ListResourcesForWebACL' :: Maybe ResourceType
resourceType = Maybe ResourceType
a} :: ListResourcesForWebACL)

-- | The unique identifier (ID) of the web ACL for which to list the
-- associated resources.
listResourcesForWebACL_webACLId :: Lens.Lens' ListResourcesForWebACL Prelude.Text
listResourcesForWebACL_webACLId :: Lens' ListResourcesForWebACL Text
listResourcesForWebACL_webACLId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResourcesForWebACL' {Text
webACLId :: Text
$sel:webACLId:ListResourcesForWebACL' :: ListResourcesForWebACL -> Text
webACLId} -> Text
webACLId) (\s :: ListResourcesForWebACL
s@ListResourcesForWebACL' {} Text
a -> ListResourcesForWebACL
s {$sel:webACLId:ListResourcesForWebACL' :: Text
webACLId = Text
a} :: ListResourcesForWebACL)

instance Core.AWSRequest ListResourcesForWebACL where
  type
    AWSResponse ListResourcesForWebACL =
      ListResourcesForWebACLResponse
  request :: (Service -> Service)
-> ListResourcesForWebACL -> Request ListResourcesForWebACL
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 ListResourcesForWebACL
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListResourcesForWebACL)))
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 [Text] -> Int -> ListResourcesForWebACLResponse
ListResourcesForWebACLResponse'
            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
"ResourceArns" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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 ListResourcesForWebACL where
  hashWithSalt :: Int -> ListResourcesForWebACL -> Int
hashWithSalt Int
_salt ListResourcesForWebACL' {Maybe ResourceType
Text
webACLId :: Text
resourceType :: Maybe ResourceType
$sel:webACLId:ListResourcesForWebACL' :: ListResourcesForWebACL -> Text
$sel:resourceType:ListResourcesForWebACL' :: ListResourcesForWebACL -> Maybe ResourceType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResourceType
resourceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
webACLId

instance Prelude.NFData ListResourcesForWebACL where
  rnf :: ListResourcesForWebACL -> ()
rnf ListResourcesForWebACL' {Maybe ResourceType
Text
webACLId :: Text
resourceType :: Maybe ResourceType
$sel:webACLId:ListResourcesForWebACL' :: ListResourcesForWebACL -> Text
$sel:resourceType:ListResourcesForWebACL' :: ListResourcesForWebACL -> Maybe ResourceType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ResourceType
resourceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
webACLId

instance Data.ToHeaders ListResourcesForWebACL where
  toHeaders :: ListResourcesForWebACL -> 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.ListResourcesForWebACL" ::
                          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 ListResourcesForWebACL where
  toJSON :: ListResourcesForWebACL -> Value
toJSON ListResourcesForWebACL' {Maybe ResourceType
Text
webACLId :: Text
resourceType :: Maybe ResourceType
$sel:webACLId:ListResourcesForWebACL' :: ListResourcesForWebACL -> Text
$sel:resourceType:ListResourcesForWebACL' :: ListResourcesForWebACL -> Maybe ResourceType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ResourceType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ResourceType
resourceType,
            forall a. a -> Maybe a
Prelude.Just (Key
"WebACLId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
webACLId)
          ]
      )

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

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

-- | /See:/ 'newListResourcesForWebACLResponse' smart constructor.
data ListResourcesForWebACLResponse = ListResourcesForWebACLResponse'
  { -- | An array of ARNs (Amazon Resource Names) of the resources associated
    -- with the specified web ACL. An array with zero elements is returned if
    -- there are no resources associated with the web ACL.
    ListResourcesForWebACLResponse -> Maybe [Text]
resourceArns :: Prelude.Maybe [Prelude.Text],
    -- | The response's http status code.
    ListResourcesForWebACLResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListResourcesForWebACLResponse
-> ListResourcesForWebACLResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListResourcesForWebACLResponse
-> ListResourcesForWebACLResponse -> Bool
$c/= :: ListResourcesForWebACLResponse
-> ListResourcesForWebACLResponse -> Bool
== :: ListResourcesForWebACLResponse
-> ListResourcesForWebACLResponse -> Bool
$c== :: ListResourcesForWebACLResponse
-> ListResourcesForWebACLResponse -> Bool
Prelude.Eq, ReadPrec [ListResourcesForWebACLResponse]
ReadPrec ListResourcesForWebACLResponse
Int -> ReadS ListResourcesForWebACLResponse
ReadS [ListResourcesForWebACLResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListResourcesForWebACLResponse]
$creadListPrec :: ReadPrec [ListResourcesForWebACLResponse]
readPrec :: ReadPrec ListResourcesForWebACLResponse
$creadPrec :: ReadPrec ListResourcesForWebACLResponse
readList :: ReadS [ListResourcesForWebACLResponse]
$creadList :: ReadS [ListResourcesForWebACLResponse]
readsPrec :: Int -> ReadS ListResourcesForWebACLResponse
$creadsPrec :: Int -> ReadS ListResourcesForWebACLResponse
Prelude.Read, Int -> ListResourcesForWebACLResponse -> ShowS
[ListResourcesForWebACLResponse] -> ShowS
ListResourcesForWebACLResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListResourcesForWebACLResponse] -> ShowS
$cshowList :: [ListResourcesForWebACLResponse] -> ShowS
show :: ListResourcesForWebACLResponse -> String
$cshow :: ListResourcesForWebACLResponse -> String
showsPrec :: Int -> ListResourcesForWebACLResponse -> ShowS
$cshowsPrec :: Int -> ListResourcesForWebACLResponse -> ShowS
Prelude.Show, forall x.
Rep ListResourcesForWebACLResponse x
-> ListResourcesForWebACLResponse
forall x.
ListResourcesForWebACLResponse
-> Rep ListResourcesForWebACLResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListResourcesForWebACLResponse x
-> ListResourcesForWebACLResponse
$cfrom :: forall x.
ListResourcesForWebACLResponse
-> Rep ListResourcesForWebACLResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListResourcesForWebACLResponse' 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:
--
-- 'resourceArns', 'listResourcesForWebACLResponse_resourceArns' - An array of ARNs (Amazon Resource Names) of the resources associated
-- with the specified web ACL. An array with zero elements is returned if
-- there are no resources associated with the web ACL.
--
-- 'httpStatus', 'listResourcesForWebACLResponse_httpStatus' - The response's http status code.
newListResourcesForWebACLResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListResourcesForWebACLResponse
newListResourcesForWebACLResponse :: Int -> ListResourcesForWebACLResponse
newListResourcesForWebACLResponse Int
pHttpStatus_ =
  ListResourcesForWebACLResponse'
    { $sel:resourceArns:ListResourcesForWebACLResponse' :: Maybe [Text]
resourceArns =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListResourcesForWebACLResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of ARNs (Amazon Resource Names) of the resources associated
-- with the specified web ACL. An array with zero elements is returned if
-- there are no resources associated with the web ACL.
listResourcesForWebACLResponse_resourceArns :: Lens.Lens' ListResourcesForWebACLResponse (Prelude.Maybe [Prelude.Text])
listResourcesForWebACLResponse_resourceArns :: Lens' ListResourcesForWebACLResponse (Maybe [Text])
listResourcesForWebACLResponse_resourceArns = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResourcesForWebACLResponse' {Maybe [Text]
resourceArns :: Maybe [Text]
$sel:resourceArns:ListResourcesForWebACLResponse' :: ListResourcesForWebACLResponse -> Maybe [Text]
resourceArns} -> Maybe [Text]
resourceArns) (\s :: ListResourcesForWebACLResponse
s@ListResourcesForWebACLResponse' {} Maybe [Text]
a -> ListResourcesForWebACLResponse
s {$sel:resourceArns:ListResourcesForWebACLResponse' :: Maybe [Text]
resourceArns = Maybe [Text]
a} :: ListResourcesForWebACLResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    ListResourcesForWebACLResponse
  where
  rnf :: ListResourcesForWebACLResponse -> ()
rnf ListResourcesForWebACLResponse' {Int
Maybe [Text]
httpStatus :: Int
resourceArns :: Maybe [Text]
$sel:httpStatus:ListResourcesForWebACLResponse' :: ListResourcesForWebACLResponse -> Int
$sel:resourceArns:ListResourcesForWebACLResponse' :: ListResourcesForWebACLResponse -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
resourceArns
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus