{-# 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.SQS.ListQueueTags
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- List all cost allocation tags added to the specified Amazon SQS queue.
-- For an overview, see
-- <https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-queue-tags.html Tagging Your Amazon SQS Queues>
-- in the /Amazon SQS Developer Guide/.
--
-- Cross-account permissions don\'t apply to this action. For more
-- information, see
-- <https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-customer-managed-policy-examples.html#grant-cross-account-permissions-to-role-and-user-name Grant cross-account permissions to a role and a user name>
-- in the /Amazon SQS Developer Guide/.
module Amazonka.SQS.ListQueueTags
  ( -- * Creating a Request
    ListQueueTags (..),
    newListQueueTags,

    -- * Request Lenses
    listQueueTags_queueUrl,

    -- * Destructuring the Response
    ListQueueTagsResponse (..),
    newListQueueTagsResponse,

    -- * Response Lenses
    listQueueTagsResponse_tags,
    listQueueTagsResponse_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.SQS.Types

-- | /See:/ 'newListQueueTags' smart constructor.
data ListQueueTags = ListQueueTags'
  { -- | The URL of the queue.
    ListQueueTags -> Text
queueUrl :: Prelude.Text
  }
  deriving (ListQueueTags -> ListQueueTags -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListQueueTags -> ListQueueTags -> Bool
$c/= :: ListQueueTags -> ListQueueTags -> Bool
== :: ListQueueTags -> ListQueueTags -> Bool
$c== :: ListQueueTags -> ListQueueTags -> Bool
Prelude.Eq, ReadPrec [ListQueueTags]
ReadPrec ListQueueTags
Int -> ReadS ListQueueTags
ReadS [ListQueueTags]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListQueueTags]
$creadListPrec :: ReadPrec [ListQueueTags]
readPrec :: ReadPrec ListQueueTags
$creadPrec :: ReadPrec ListQueueTags
readList :: ReadS [ListQueueTags]
$creadList :: ReadS [ListQueueTags]
readsPrec :: Int -> ReadS ListQueueTags
$creadsPrec :: Int -> ReadS ListQueueTags
Prelude.Read, Int -> ListQueueTags -> ShowS
[ListQueueTags] -> ShowS
ListQueueTags -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListQueueTags] -> ShowS
$cshowList :: [ListQueueTags] -> ShowS
show :: ListQueueTags -> String
$cshow :: ListQueueTags -> String
showsPrec :: Int -> ListQueueTags -> ShowS
$cshowsPrec :: Int -> ListQueueTags -> ShowS
Prelude.Show, forall x. Rep ListQueueTags x -> ListQueueTags
forall x. ListQueueTags -> Rep ListQueueTags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListQueueTags x -> ListQueueTags
$cfrom :: forall x. ListQueueTags -> Rep ListQueueTags x
Prelude.Generic)

-- |
-- Create a value of 'ListQueueTags' 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:
--
-- 'queueUrl', 'listQueueTags_queueUrl' - The URL of the queue.
newListQueueTags ::
  -- | 'queueUrl'
  Prelude.Text ->
  ListQueueTags
newListQueueTags :: Text -> ListQueueTags
newListQueueTags Text
pQueueUrl_ =
  ListQueueTags' {$sel:queueUrl:ListQueueTags' :: Text
queueUrl = Text
pQueueUrl_}

-- | The URL of the queue.
listQueueTags_queueUrl :: Lens.Lens' ListQueueTags Prelude.Text
listQueueTags_queueUrl :: Lens' ListQueueTags Text
listQueueTags_queueUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListQueueTags' {Text
queueUrl :: Text
$sel:queueUrl:ListQueueTags' :: ListQueueTags -> Text
queueUrl} -> Text
queueUrl) (\s :: ListQueueTags
s@ListQueueTags' {} Text
a -> ListQueueTags
s {$sel:queueUrl:ListQueueTags' :: Text
queueUrl = Text
a} :: ListQueueTags)

instance Core.AWSRequest ListQueueTags where
  type
    AWSResponse ListQueueTags =
      ListQueueTagsResponse
  request :: (Service -> Service) -> ListQueueTags -> Request ListQueueTags
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListQueueTags
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListQueueTags)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"ListQueueTagsResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe (HashMap Text Text) -> Int -> ListQueueTagsResponse
ListQueueTagsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall k v.
(Eq k, Hashable k, FromText k, FromXML v) =>
Text -> Text -> Text -> [Node] -> Either String (HashMap k v)
Data.parseXMLMap Text
"Tag" Text
"Key" Text
"Value") [Node]
x)
            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 ListQueueTags where
  hashWithSalt :: Int -> ListQueueTags -> Int
hashWithSalt Int
_salt ListQueueTags' {Text
queueUrl :: Text
$sel:queueUrl:ListQueueTags' :: ListQueueTags -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
queueUrl

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

instance Data.ToHeaders ListQueueTags where
  toHeaders :: ListQueueTags -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery ListQueueTags where
  toQuery :: ListQueueTags -> QueryString
toQuery ListQueueTags' {Text
queueUrl :: Text
$sel:queueUrl:ListQueueTags' :: ListQueueTags -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"ListQueueTags" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2012-11-05" :: Prelude.ByteString),
        ByteString
"QueueUrl" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
queueUrl
      ]

-- | /See:/ 'newListQueueTagsResponse' smart constructor.
data ListQueueTagsResponse = ListQueueTagsResponse'
  { -- | The list of all tags added to the specified queue.
    ListQueueTagsResponse -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The response's http status code.
    ListQueueTagsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListQueueTagsResponse -> ListQueueTagsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListQueueTagsResponse -> ListQueueTagsResponse -> Bool
$c/= :: ListQueueTagsResponse -> ListQueueTagsResponse -> Bool
== :: ListQueueTagsResponse -> ListQueueTagsResponse -> Bool
$c== :: ListQueueTagsResponse -> ListQueueTagsResponse -> Bool
Prelude.Eq, ReadPrec [ListQueueTagsResponse]
ReadPrec ListQueueTagsResponse
Int -> ReadS ListQueueTagsResponse
ReadS [ListQueueTagsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListQueueTagsResponse]
$creadListPrec :: ReadPrec [ListQueueTagsResponse]
readPrec :: ReadPrec ListQueueTagsResponse
$creadPrec :: ReadPrec ListQueueTagsResponse
readList :: ReadS [ListQueueTagsResponse]
$creadList :: ReadS [ListQueueTagsResponse]
readsPrec :: Int -> ReadS ListQueueTagsResponse
$creadsPrec :: Int -> ReadS ListQueueTagsResponse
Prelude.Read, Int -> ListQueueTagsResponse -> ShowS
[ListQueueTagsResponse] -> ShowS
ListQueueTagsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListQueueTagsResponse] -> ShowS
$cshowList :: [ListQueueTagsResponse] -> ShowS
show :: ListQueueTagsResponse -> String
$cshow :: ListQueueTagsResponse -> String
showsPrec :: Int -> ListQueueTagsResponse -> ShowS
$cshowsPrec :: Int -> ListQueueTagsResponse -> ShowS
Prelude.Show, forall x. Rep ListQueueTagsResponse x -> ListQueueTagsResponse
forall x. ListQueueTagsResponse -> Rep ListQueueTagsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListQueueTagsResponse x -> ListQueueTagsResponse
$cfrom :: forall x. ListQueueTagsResponse -> Rep ListQueueTagsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListQueueTagsResponse' 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:
--
-- 'tags', 'listQueueTagsResponse_tags' - The list of all tags added to the specified queue.
--
-- 'httpStatus', 'listQueueTagsResponse_httpStatus' - The response's http status code.
newListQueueTagsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListQueueTagsResponse
newListQueueTagsResponse :: Int -> ListQueueTagsResponse
newListQueueTagsResponse Int
pHttpStatus_ =
  ListQueueTagsResponse'
    { $sel:tags:ListQueueTagsResponse' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListQueueTagsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The list of all tags added to the specified queue.
listQueueTagsResponse_tags :: Lens.Lens' ListQueueTagsResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
listQueueTagsResponse_tags :: Lens' ListQueueTagsResponse (Maybe (HashMap Text Text))
listQueueTagsResponse_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListQueueTagsResponse' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:ListQueueTagsResponse' :: ListQueueTagsResponse -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: ListQueueTagsResponse
s@ListQueueTagsResponse' {} Maybe (HashMap Text Text)
a -> ListQueueTagsResponse
s {$sel:tags:ListQueueTagsResponse' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: ListQueueTagsResponse) 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.
listQueueTagsResponse_httpStatus :: Lens.Lens' ListQueueTagsResponse Prelude.Int
listQueueTagsResponse_httpStatus :: Lens' ListQueueTagsResponse Int
listQueueTagsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListQueueTagsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListQueueTagsResponse' :: ListQueueTagsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListQueueTagsResponse
s@ListQueueTagsResponse' {} Int
a -> ListQueueTagsResponse
s {$sel:httpStatus:ListQueueTagsResponse' :: Int
httpStatus = Int
a} :: ListQueueTagsResponse)

instance Prelude.NFData ListQueueTagsResponse where
  rnf :: ListQueueTagsResponse -> ()
rnf ListQueueTagsResponse' {Int
Maybe (HashMap Text Text)
httpStatus :: Int
tags :: Maybe (HashMap Text Text)
$sel:httpStatus:ListQueueTagsResponse' :: ListQueueTagsResponse -> Int
$sel:tags:ListQueueTagsResponse' :: ListQueueTagsResponse -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus