{-# 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-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)
--
-- 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.Lens as Lens
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
(ListQueueTags -> ListQueueTags -> Bool)
-> (ListQueueTags -> ListQueueTags -> Bool) -> Eq ListQueueTags
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]
(Int -> ReadS ListQueueTags)
-> ReadS [ListQueueTags]
-> ReadPrec ListQueueTags
-> ReadPrec [ListQueueTags]
-> Read 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
(Int -> ListQueueTags -> ShowS)
-> (ListQueueTags -> String)
-> ([ListQueueTags] -> ShowS)
-> Show ListQueueTags
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. ListQueueTags -> Rep ListQueueTags x)
-> (forall x. Rep ListQueueTags x -> ListQueueTags)
-> Generic ListQueueTags
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' :: Text -> ListQueueTags
ListQueueTags' {$sel:queueUrl:ListQueueTags' :: Text
queueUrl = Text
pQueueUrl_}

-- | The URL of the queue.
listQueueTags_queueUrl :: Lens.Lens' ListQueueTags Prelude.Text
listQueueTags_queueUrl :: (Text -> f Text) -> ListQueueTags -> f ListQueueTags
listQueueTags_queueUrl = (ListQueueTags -> Text)
-> (ListQueueTags -> Text -> ListQueueTags)
-> Lens ListQueueTags ListQueueTags Text Text
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 :: ListQueueTags -> Request ListQueueTags
request = Service -> ListQueueTags -> Request ListQueueTags
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy ListQueueTags
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListQueueTags)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse ListQueueTags))
-> Logger
-> Service
-> Proxy ListQueueTags
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListQueueTags)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> 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'
            (Maybe (HashMap Text Text) -> Int -> ListQueueTagsResponse)
-> Either String (Maybe (HashMap Text Text))
-> Either String (Int -> ListQueueTagsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (([Node] -> Either String (HashMap Text Text))
-> [Node] -> Either String (Maybe (HashMap Text Text))
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> Text -> Text -> [Node] -> Either String (HashMap Text Text)
forall k v.
(Eq k, Hashable k, FromText k, FromXML v) =>
Text -> Text -> Text -> [Node] -> Either String (HashMap k v)
Core.parseXMLMap Text
"Tag" Text
"Key" Text
"Value") [Node]
x)
            Either String (Int -> ListQueueTagsResponse)
-> Either String Int -> Either String ListQueueTagsResponse
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 ListQueueTags

instance Prelude.NFData ListQueueTags

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

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

instance Core.ToQuery ListQueueTags where
  toQuery :: ListQueueTags -> QueryString
toQuery ListQueueTags' {Text
queueUrl :: Text
$sel:queueUrl:ListQueueTags' :: ListQueueTags -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"ListQueueTags" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2012-11-05" :: Prelude.ByteString),
        ByteString
"QueueUrl" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: 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
(ListQueueTagsResponse -> ListQueueTagsResponse -> Bool)
-> (ListQueueTagsResponse -> ListQueueTagsResponse -> Bool)
-> Eq ListQueueTagsResponse
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]
(Int -> ReadS ListQueueTagsResponse)
-> ReadS [ListQueueTagsResponse]
-> ReadPrec ListQueueTagsResponse
-> ReadPrec [ListQueueTagsResponse]
-> Read 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
(Int -> ListQueueTagsResponse -> ShowS)
-> (ListQueueTagsResponse -> String)
-> ([ListQueueTagsResponse] -> ShowS)
-> Show ListQueueTagsResponse
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. ListQueueTagsResponse -> Rep ListQueueTagsResponse x)
-> (forall x. Rep ListQueueTagsResponse x -> ListQueueTagsResponse)
-> Generic ListQueueTagsResponse
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' :: Maybe (HashMap Text Text) -> Int -> ListQueueTagsResponse
ListQueueTagsResponse'
    { $sel:tags:ListQueueTagsResponse' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
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 :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ListQueueTagsResponse -> f ListQueueTagsResponse
listQueueTagsResponse_tags = (ListQueueTagsResponse -> Maybe (HashMap Text Text))
-> (ListQueueTagsResponse
    -> Maybe (HashMap Text Text) -> ListQueueTagsResponse)
-> Lens
     ListQueueTagsResponse
     ListQueueTagsResponse
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> ListQueueTagsResponse -> f ListQueueTagsResponse)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ListQueueTagsResponse
-> f ListQueueTagsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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 AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
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 :: (Int -> f Int) -> ListQueueTagsResponse -> f ListQueueTagsResponse
listQueueTagsResponse_httpStatus = (ListQueueTagsResponse -> Int)
-> (ListQueueTagsResponse -> Int -> ListQueueTagsResponse)
-> Lens ListQueueTagsResponse ListQueueTagsResponse Int Int
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