{-# 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.WAFV2.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)
--
-- Retrieves an array of the Amazon Resource Names (ARNs) for the regional
-- resources that are associated with the specified web ACL. If you want
-- the list of Amazon CloudFront resources, use the CloudFront call
-- @ListDistributionsByWebACLId@.
module Amazonka.WAFV2.ListResourcesForWebACL
  ( -- * Creating a Request
    ListResourcesForWebACL (..),
    newListResourcesForWebACL,

    -- * Request Lenses
    listResourcesForWebACL_resourceType,
    listResourcesForWebACL_webACLArn,

    -- * 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.WAFV2.Types

-- | /See:/ 'newListResourcesForWebACL' smart constructor.
data ListResourcesForWebACL = ListResourcesForWebACL'
  { -- | Used for web ACLs that are scoped for regional applications. A regional
    -- application can be an Application Load Balancer (ALB), an Amazon API
    -- Gateway REST API, an AppSync GraphQL API, or an Amazon Cognito user
    -- pool.
    --
    -- If you don\'t provide a resource type, the call uses the resource type
    -- @APPLICATION_LOAD_BALANCER@.
    --
    -- Default: @APPLICATION_LOAD_BALANCER@
    ListResourcesForWebACL -> Maybe ResourceType
resourceType :: Prelude.Maybe ResourceType,
    -- | The Amazon Resource Name (ARN) of the web ACL.
    ListResourcesForWebACL -> Text
webACLArn :: 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' - Used for web ACLs that are scoped for regional applications. A regional
-- application can be an Application Load Balancer (ALB), an Amazon API
-- Gateway REST API, an AppSync GraphQL API, or an Amazon Cognito user
-- pool.
--
-- If you don\'t provide a resource type, the call uses the resource type
-- @APPLICATION_LOAD_BALANCER@.
--
-- Default: @APPLICATION_LOAD_BALANCER@
--
-- 'webACLArn', 'listResourcesForWebACL_webACLArn' - The Amazon Resource Name (ARN) of the web ACL.
newListResourcesForWebACL ::
  -- | 'webACLArn'
  Prelude.Text ->
  ListResourcesForWebACL
newListResourcesForWebACL :: Text -> ListResourcesForWebACL
newListResourcesForWebACL Text
pWebACLArn_ =
  ListResourcesForWebACL'
    { $sel:resourceType:ListResourcesForWebACL' :: Maybe ResourceType
resourceType =
        forall a. Maybe a
Prelude.Nothing,
      $sel:webACLArn:ListResourcesForWebACL' :: Text
webACLArn = Text
pWebACLArn_
    }

-- | Used for web ACLs that are scoped for regional applications. A regional
-- application can be an Application Load Balancer (ALB), an Amazon API
-- Gateway REST API, an AppSync GraphQL API, or an Amazon Cognito user
-- pool.
--
-- If you don\'t provide a resource type, the call uses the resource type
-- @APPLICATION_LOAD_BALANCER@.
--
-- Default: @APPLICATION_LOAD_BALANCER@
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 Amazon Resource Name (ARN) of the web ACL.
listResourcesForWebACL_webACLArn :: Lens.Lens' ListResourcesForWebACL Prelude.Text
listResourcesForWebACL_webACLArn :: Lens' ListResourcesForWebACL Text
listResourcesForWebACL_webACLArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResourcesForWebACL' {Text
webACLArn :: Text
$sel:webACLArn:ListResourcesForWebACL' :: ListResourcesForWebACL -> Text
webACLArn} -> Text
webACLArn) (\s :: ListResourcesForWebACL
s@ListResourcesForWebACL' {} Text
a -> ListResourcesForWebACL
s {$sel:webACLArn:ListResourcesForWebACL' :: Text
webACLArn = 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
webACLArn :: Text
resourceType :: Maybe ResourceType
$sel:webACLArn: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
webACLArn

instance Prelude.NFData ListResourcesForWebACL where
  rnf :: ListResourcesForWebACL -> ()
rnf ListResourcesForWebACL' {Maybe ResourceType
Text
webACLArn :: Text
resourceType :: Maybe ResourceType
$sel:webACLArn: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
webACLArn

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_20190729.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
webACLArn :: Text
resourceType :: Maybe ResourceType
$sel:webACLArn: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
"WebACLArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
webACLArn)
          ]
      )

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'
  { -- | The array of Amazon Resource Names (ARNs) of the associated resources.
    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' - The array of Amazon Resource Names (ARNs) of the associated resources.
--
-- '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_
    }

-- | The array of Amazon Resource Names (ARNs) of the associated resources.
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