{-# 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.ListTagsForResource
-- 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.
--
-- Retrieves the tags associated with the specified AWS resource. Tags are
-- key:value pairs that you can use to categorize and manage your
-- resources, for purposes like billing. For example, you might set the tag
-- key to \"customer\" and the value to the customer name or ID. You can
-- specify one or more tags to add to each AWS resource, up to 50 tags for
-- a resource.
--
-- Tagging is only available through the API, SDKs, and CLI. You can\'t
-- manage or view tags through the AWS WAF Classic console. You can tag the
-- AWS resources that you manage through AWS WAF Classic: web ACLs, rule
-- groups, and rules.
module Amazonka.WAF.ListTagsForResource
  ( -- * Creating a Request
    ListTagsForResource (..),
    newListTagsForResource,

    -- * Request Lenses
    listTagsForResource_limit,
    listTagsForResource_nextMarker,
    listTagsForResource_resourceARN,

    -- * Destructuring the Response
    ListTagsForResourceResponse (..),
    newListTagsForResourceResponse,

    -- * Response Lenses
    listTagsForResourceResponse_nextMarker,
    listTagsForResourceResponse_tagInfoForResource,
    listTagsForResourceResponse_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.WAF.Types

-- | /See:/ 'newListTagsForResource' smart constructor.
data ListTagsForResource = ListTagsForResource'
  { ListTagsForResource -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    ListTagsForResource -> Maybe Text
nextMarker :: Prelude.Maybe Prelude.Text,
    ListTagsForResource -> Text
resourceARN :: Prelude.Text
  }
  deriving (ListTagsForResource -> ListTagsForResource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTagsForResource -> ListTagsForResource -> Bool
$c/= :: ListTagsForResource -> ListTagsForResource -> Bool
== :: ListTagsForResource -> ListTagsForResource -> Bool
$c== :: ListTagsForResource -> ListTagsForResource -> Bool
Prelude.Eq, ReadPrec [ListTagsForResource]
ReadPrec ListTagsForResource
Int -> ReadS ListTagsForResource
ReadS [ListTagsForResource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTagsForResource]
$creadListPrec :: ReadPrec [ListTagsForResource]
readPrec :: ReadPrec ListTagsForResource
$creadPrec :: ReadPrec ListTagsForResource
readList :: ReadS [ListTagsForResource]
$creadList :: ReadS [ListTagsForResource]
readsPrec :: Int -> ReadS ListTagsForResource
$creadsPrec :: Int -> ReadS ListTagsForResource
Prelude.Read, Int -> ListTagsForResource -> ShowS
[ListTagsForResource] -> ShowS
ListTagsForResource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTagsForResource] -> ShowS
$cshowList :: [ListTagsForResource] -> ShowS
show :: ListTagsForResource -> String
$cshow :: ListTagsForResource -> String
showsPrec :: Int -> ListTagsForResource -> ShowS
$cshowsPrec :: Int -> ListTagsForResource -> ShowS
Prelude.Show, forall x. Rep ListTagsForResource x -> ListTagsForResource
forall x. ListTagsForResource -> Rep ListTagsForResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTagsForResource x -> ListTagsForResource
$cfrom :: forall x. ListTagsForResource -> Rep ListTagsForResource x
Prelude.Generic)

-- |
-- Create a value of 'ListTagsForResource' 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:
--
-- 'limit', 'listTagsForResource_limit' -
--
-- 'nextMarker', 'listTagsForResource_nextMarker' -
--
-- 'resourceARN', 'listTagsForResource_resourceARN' -
newListTagsForResource ::
  -- | 'resourceARN'
  Prelude.Text ->
  ListTagsForResource
newListTagsForResource :: Text -> ListTagsForResource
newListTagsForResource Text
pResourceARN_ =
  ListTagsForResource'
    { $sel:limit:ListTagsForResource' :: Maybe Natural
limit = forall a. Maybe a
Prelude.Nothing,
      $sel:nextMarker:ListTagsForResource' :: Maybe Text
nextMarker = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceARN:ListTagsForResource' :: Text
resourceARN = Text
pResourceARN_
    }

listTagsForResource_limit :: Lens.Lens' ListTagsForResource (Prelude.Maybe Prelude.Natural)
listTagsForResource_limit :: Lens' ListTagsForResource (Maybe Natural)
listTagsForResource_limit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTagsForResource' {Maybe Natural
limit :: Maybe Natural
$sel:limit:ListTagsForResource' :: ListTagsForResource -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: ListTagsForResource
s@ListTagsForResource' {} Maybe Natural
a -> ListTagsForResource
s {$sel:limit:ListTagsForResource' :: Maybe Natural
limit = Maybe Natural
a} :: ListTagsForResource)

listTagsForResource_nextMarker :: Lens.Lens' ListTagsForResource (Prelude.Maybe Prelude.Text)
listTagsForResource_nextMarker :: Lens' ListTagsForResource (Maybe Text)
listTagsForResource_nextMarker = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTagsForResource' {Maybe Text
nextMarker :: Maybe Text
$sel:nextMarker:ListTagsForResource' :: ListTagsForResource -> Maybe Text
nextMarker} -> Maybe Text
nextMarker) (\s :: ListTagsForResource
s@ListTagsForResource' {} Maybe Text
a -> ListTagsForResource
s {$sel:nextMarker:ListTagsForResource' :: Maybe Text
nextMarker = Maybe Text
a} :: ListTagsForResource)

listTagsForResource_resourceARN :: Lens.Lens' ListTagsForResource Prelude.Text
listTagsForResource_resourceARN :: Lens' ListTagsForResource Text
listTagsForResource_resourceARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTagsForResource' {Text
resourceARN :: Text
$sel:resourceARN:ListTagsForResource' :: ListTagsForResource -> Text
resourceARN} -> Text
resourceARN) (\s :: ListTagsForResource
s@ListTagsForResource' {} Text
a -> ListTagsForResource
s {$sel:resourceARN:ListTagsForResource' :: Text
resourceARN = Text
a} :: ListTagsForResource)

instance Core.AWSRequest ListTagsForResource where
  type
    AWSResponse ListTagsForResource =
      ListTagsForResourceResponse
  request :: (Service -> Service)
-> ListTagsForResource -> Request ListTagsForResource
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 ListTagsForResource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListTagsForResource)))
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
-> Maybe TagInfoForResource -> Int -> ListTagsForResourceResponse
ListTagsForResourceResponse'
            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
"NextMarker")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"TagInfoForResource")
            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 ListTagsForResource where
  hashWithSalt :: Int -> ListTagsForResource -> Int
hashWithSalt Int
_salt ListTagsForResource' {Maybe Natural
Maybe Text
Text
resourceARN :: Text
nextMarker :: Maybe Text
limit :: Maybe Natural
$sel:resourceARN:ListTagsForResource' :: ListTagsForResource -> Text
$sel:nextMarker:ListTagsForResource' :: ListTagsForResource -> Maybe Text
$sel:limit:ListTagsForResource' :: ListTagsForResource -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
limit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextMarker
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceARN

instance Prelude.NFData ListTagsForResource where
  rnf :: ListTagsForResource -> ()
rnf ListTagsForResource' {Maybe Natural
Maybe Text
Text
resourceARN :: Text
nextMarker :: Maybe Text
limit :: Maybe Natural
$sel:resourceARN:ListTagsForResource' :: ListTagsForResource -> Text
$sel:nextMarker:ListTagsForResource' :: ListTagsForResource -> Maybe Text
$sel:limit:ListTagsForResource' :: ListTagsForResource -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
limit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextMarker
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
resourceARN

instance Data.ToHeaders ListTagsForResource where
  toHeaders :: ListTagsForResource -> 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_20150824.ListTagsForResource" ::
                          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 ListTagsForResource where
  toJSON :: ListTagsForResource -> Value
toJSON ListTagsForResource' {Maybe Natural
Maybe Text
Text
resourceARN :: Text
nextMarker :: Maybe Text
limit :: Maybe Natural
$sel:resourceARN:ListTagsForResource' :: ListTagsForResource -> Text
$sel:nextMarker:ListTagsForResource' :: ListTagsForResource -> Maybe Text
$sel:limit:ListTagsForResource' :: ListTagsForResource -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Limit" 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 Natural
limit,
            (Key
"NextMarker" 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 Text
nextMarker,
            forall a. a -> Maybe a
Prelude.Just (Key
"ResourceARN" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
resourceARN)
          ]
      )

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

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

-- | /See:/ 'newListTagsForResourceResponse' smart constructor.
data ListTagsForResourceResponse = ListTagsForResourceResponse'
  { ListTagsForResourceResponse -> Maybe Text
nextMarker :: Prelude.Maybe Prelude.Text,
    ListTagsForResourceResponse -> Maybe TagInfoForResource
tagInfoForResource :: Prelude.Maybe TagInfoForResource,
    -- | The response's http status code.
    ListTagsForResourceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListTagsForResourceResponse -> ListTagsForResourceResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTagsForResourceResponse -> ListTagsForResourceResponse -> Bool
$c/= :: ListTagsForResourceResponse -> ListTagsForResourceResponse -> Bool
== :: ListTagsForResourceResponse -> ListTagsForResourceResponse -> Bool
$c== :: ListTagsForResourceResponse -> ListTagsForResourceResponse -> Bool
Prelude.Eq, ReadPrec [ListTagsForResourceResponse]
ReadPrec ListTagsForResourceResponse
Int -> ReadS ListTagsForResourceResponse
ReadS [ListTagsForResourceResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTagsForResourceResponse]
$creadListPrec :: ReadPrec [ListTagsForResourceResponse]
readPrec :: ReadPrec ListTagsForResourceResponse
$creadPrec :: ReadPrec ListTagsForResourceResponse
readList :: ReadS [ListTagsForResourceResponse]
$creadList :: ReadS [ListTagsForResourceResponse]
readsPrec :: Int -> ReadS ListTagsForResourceResponse
$creadsPrec :: Int -> ReadS ListTagsForResourceResponse
Prelude.Read, Int -> ListTagsForResourceResponse -> ShowS
[ListTagsForResourceResponse] -> ShowS
ListTagsForResourceResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTagsForResourceResponse] -> ShowS
$cshowList :: [ListTagsForResourceResponse] -> ShowS
show :: ListTagsForResourceResponse -> String
$cshow :: ListTagsForResourceResponse -> String
showsPrec :: Int -> ListTagsForResourceResponse -> ShowS
$cshowsPrec :: Int -> ListTagsForResourceResponse -> ShowS
Prelude.Show, forall x.
Rep ListTagsForResourceResponse x -> ListTagsForResourceResponse
forall x.
ListTagsForResourceResponse -> Rep ListTagsForResourceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListTagsForResourceResponse x -> ListTagsForResourceResponse
$cfrom :: forall x.
ListTagsForResourceResponse -> Rep ListTagsForResourceResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListTagsForResourceResponse' 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:
--
-- 'nextMarker', 'listTagsForResourceResponse_nextMarker' -
--
-- 'tagInfoForResource', 'listTagsForResourceResponse_tagInfoForResource' -
--
-- 'httpStatus', 'listTagsForResourceResponse_httpStatus' - The response's http status code.
newListTagsForResourceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListTagsForResourceResponse
newListTagsForResourceResponse :: Int -> ListTagsForResourceResponse
newListTagsForResourceResponse Int
pHttpStatus_ =
  ListTagsForResourceResponse'
    { $sel:nextMarker:ListTagsForResourceResponse' :: Maybe Text
nextMarker =
        forall a. Maybe a
Prelude.Nothing,
      $sel:tagInfoForResource:ListTagsForResourceResponse' :: Maybe TagInfoForResource
tagInfoForResource = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListTagsForResourceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

listTagsForResourceResponse_nextMarker :: Lens.Lens' ListTagsForResourceResponse (Prelude.Maybe Prelude.Text)
listTagsForResourceResponse_nextMarker :: Lens' ListTagsForResourceResponse (Maybe Text)
listTagsForResourceResponse_nextMarker = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTagsForResourceResponse' {Maybe Text
nextMarker :: Maybe Text
$sel:nextMarker:ListTagsForResourceResponse' :: ListTagsForResourceResponse -> Maybe Text
nextMarker} -> Maybe Text
nextMarker) (\s :: ListTagsForResourceResponse
s@ListTagsForResourceResponse' {} Maybe Text
a -> ListTagsForResourceResponse
s {$sel:nextMarker:ListTagsForResourceResponse' :: Maybe Text
nextMarker = Maybe Text
a} :: ListTagsForResourceResponse)

listTagsForResourceResponse_tagInfoForResource :: Lens.Lens' ListTagsForResourceResponse (Prelude.Maybe TagInfoForResource)
listTagsForResourceResponse_tagInfoForResource :: Lens' ListTagsForResourceResponse (Maybe TagInfoForResource)
listTagsForResourceResponse_tagInfoForResource = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTagsForResourceResponse' {Maybe TagInfoForResource
tagInfoForResource :: Maybe TagInfoForResource
$sel:tagInfoForResource:ListTagsForResourceResponse' :: ListTagsForResourceResponse -> Maybe TagInfoForResource
tagInfoForResource} -> Maybe TagInfoForResource
tagInfoForResource) (\s :: ListTagsForResourceResponse
s@ListTagsForResourceResponse' {} Maybe TagInfoForResource
a -> ListTagsForResourceResponse
s {$sel:tagInfoForResource:ListTagsForResourceResponse' :: Maybe TagInfoForResource
tagInfoForResource = Maybe TagInfoForResource
a} :: ListTagsForResourceResponse)

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

instance Prelude.NFData ListTagsForResourceResponse where
  rnf :: ListTagsForResourceResponse -> ()
rnf ListTagsForResourceResponse' {Int
Maybe Text
Maybe TagInfoForResource
httpStatus :: Int
tagInfoForResource :: Maybe TagInfoForResource
nextMarker :: Maybe Text
$sel:httpStatus:ListTagsForResourceResponse' :: ListTagsForResourceResponse -> Int
$sel:tagInfoForResource:ListTagsForResourceResponse' :: ListTagsForResourceResponse -> Maybe TagInfoForResource
$sel:nextMarker:ListTagsForResourceResponse' :: ListTagsForResourceResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextMarker
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TagInfoForResource
tagInfoForResource
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus