{-# 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.Route53RecoveryReadiness.ListTagsForResources
-- 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)
--
-- Returns a list of the tags assigned to the specified resource.
module Amazonka.Route53RecoveryReadiness.ListTagsForResources
  ( -- * Creating a Request
    ListTagsForResources (..),
    newListTagsForResources,

    -- * Request Lenses
    listTagsForResources_resourceArn,

    -- * Destructuring the Response
    ListTagsForResourcesResponse (..),
    newListTagsForResourcesResponse,

    -- * Response Lenses
    listTagsForResourcesResponse_tags,
    listTagsForResourcesResponse_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.Route53RecoveryReadiness.Types

-- | /See:/ 'newListTagsForResources' smart constructor.
data ListTagsForResources = ListTagsForResources'
  { -- | The Amazon Resource Name (ARN) for the resource. You can get this from
    -- the response to any request to the resource.
    ListTagsForResources -> Text
resourceArn :: Prelude.Text
  }
  deriving (ListTagsForResources -> ListTagsForResources -> Bool
(ListTagsForResources -> ListTagsForResources -> Bool)
-> (ListTagsForResources -> ListTagsForResources -> Bool)
-> Eq ListTagsForResources
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTagsForResources -> ListTagsForResources -> Bool
$c/= :: ListTagsForResources -> ListTagsForResources -> Bool
== :: ListTagsForResources -> ListTagsForResources -> Bool
$c== :: ListTagsForResources -> ListTagsForResources -> Bool
Prelude.Eq, ReadPrec [ListTagsForResources]
ReadPrec ListTagsForResources
Int -> ReadS ListTagsForResources
ReadS [ListTagsForResources]
(Int -> ReadS ListTagsForResources)
-> ReadS [ListTagsForResources]
-> ReadPrec ListTagsForResources
-> ReadPrec [ListTagsForResources]
-> Read ListTagsForResources
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTagsForResources]
$creadListPrec :: ReadPrec [ListTagsForResources]
readPrec :: ReadPrec ListTagsForResources
$creadPrec :: ReadPrec ListTagsForResources
readList :: ReadS [ListTagsForResources]
$creadList :: ReadS [ListTagsForResources]
readsPrec :: Int -> ReadS ListTagsForResources
$creadsPrec :: Int -> ReadS ListTagsForResources
Prelude.Read, Int -> ListTagsForResources -> ShowS
[ListTagsForResources] -> ShowS
ListTagsForResources -> String
(Int -> ListTagsForResources -> ShowS)
-> (ListTagsForResources -> String)
-> ([ListTagsForResources] -> ShowS)
-> Show ListTagsForResources
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTagsForResources] -> ShowS
$cshowList :: [ListTagsForResources] -> ShowS
show :: ListTagsForResources -> String
$cshow :: ListTagsForResources -> String
showsPrec :: Int -> ListTagsForResources -> ShowS
$cshowsPrec :: Int -> ListTagsForResources -> ShowS
Prelude.Show, (forall x. ListTagsForResources -> Rep ListTagsForResources x)
-> (forall x. Rep ListTagsForResources x -> ListTagsForResources)
-> Generic ListTagsForResources
forall x. Rep ListTagsForResources x -> ListTagsForResources
forall x. ListTagsForResources -> Rep ListTagsForResources x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTagsForResources x -> ListTagsForResources
$cfrom :: forall x. ListTagsForResources -> Rep ListTagsForResources x
Prelude.Generic)

-- |
-- Create a value of 'ListTagsForResources' 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:
--
-- 'resourceArn', 'listTagsForResources_resourceArn' - The Amazon Resource Name (ARN) for the resource. You can get this from
-- the response to any request to the resource.
newListTagsForResources ::
  -- | 'resourceArn'
  Prelude.Text ->
  ListTagsForResources
newListTagsForResources :: Text -> ListTagsForResources
newListTagsForResources Text
pResourceArn_ =
  ListTagsForResources' :: Text -> ListTagsForResources
ListTagsForResources' {$sel:resourceArn:ListTagsForResources' :: Text
resourceArn = Text
pResourceArn_}

-- | The Amazon Resource Name (ARN) for the resource. You can get this from
-- the response to any request to the resource.
listTagsForResources_resourceArn :: Lens.Lens' ListTagsForResources Prelude.Text
listTagsForResources_resourceArn :: (Text -> f Text) -> ListTagsForResources -> f ListTagsForResources
listTagsForResources_resourceArn = (ListTagsForResources -> Text)
-> (ListTagsForResources -> Text -> ListTagsForResources)
-> Lens ListTagsForResources ListTagsForResources Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTagsForResources' {Text
resourceArn :: Text
$sel:resourceArn:ListTagsForResources' :: ListTagsForResources -> Text
resourceArn} -> Text
resourceArn) (\s :: ListTagsForResources
s@ListTagsForResources' {} Text
a -> ListTagsForResources
s {$sel:resourceArn:ListTagsForResources' :: Text
resourceArn = Text
a} :: ListTagsForResources)

instance Core.AWSRequest ListTagsForResources where
  type
    AWSResponse ListTagsForResources =
      ListTagsForResourcesResponse
  request :: ListTagsForResources -> Request ListTagsForResources
request = Service -> ListTagsForResources -> Request ListTagsForResources
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListTagsForResources
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListTagsForResources)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListTagsForResources))
-> Logger
-> Service
-> Proxy ListTagsForResources
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListTagsForResources)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe (HashMap Text Text) -> Int -> ListTagsForResourcesResponse
ListTagsForResourcesResponse'
            (Maybe (HashMap Text Text) -> Int -> ListTagsForResourcesResponse)
-> Either String (Maybe (HashMap Text Text))
-> Either String (Int -> ListTagsForResourcesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"tags" Either String (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text)
-> Either String (Maybe (HashMap Text Text))
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> ListTagsForResourcesResponse)
-> Either String Int -> Either String ListTagsForResourcesResponse
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 ListTagsForResources

instance Prelude.NFData ListTagsForResources

instance Core.ToHeaders ListTagsForResources where
  toHeaders :: ListTagsForResources -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListTagsForResources -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToPath ListTagsForResources where
  toPath :: ListTagsForResources -> ByteString
toPath ListTagsForResources' {Text
resourceArn :: Text
$sel:resourceArn:ListTagsForResources' :: ListTagsForResources -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/tags/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
resourceArn]

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

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

-- |
-- Create a value of 'ListTagsForResourcesResponse' 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', 'listTagsForResourcesResponse_tags' - Undocumented member.
--
-- 'httpStatus', 'listTagsForResourcesResponse_httpStatus' - The response's http status code.
newListTagsForResourcesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListTagsForResourcesResponse
newListTagsForResourcesResponse :: Int -> ListTagsForResourcesResponse
newListTagsForResourcesResponse Int
pHttpStatus_ =
  ListTagsForResourcesResponse' :: Maybe (HashMap Text Text) -> Int -> ListTagsForResourcesResponse
ListTagsForResourcesResponse'
    { $sel:tags:ListTagsForResourcesResponse' :: Maybe (HashMap Text Text)
tags =
        Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListTagsForResourcesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
listTagsForResourcesResponse_tags :: Lens.Lens' ListTagsForResourcesResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
listTagsForResourcesResponse_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ListTagsForResourcesResponse -> f ListTagsForResourcesResponse
listTagsForResourcesResponse_tags = (ListTagsForResourcesResponse -> Maybe (HashMap Text Text))
-> (ListTagsForResourcesResponse
    -> Maybe (HashMap Text Text) -> ListTagsForResourcesResponse)
-> Lens
     ListTagsForResourcesResponse
     ListTagsForResourcesResponse
     (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 (\ListTagsForResourcesResponse' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:ListTagsForResourcesResponse' :: ListTagsForResourcesResponse -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: ListTagsForResourcesResponse
s@ListTagsForResourcesResponse' {} Maybe (HashMap Text Text)
a -> ListTagsForResourcesResponse
s {$sel:tags:ListTagsForResourcesResponse' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: ListTagsForResourcesResponse) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> ListTagsForResourcesResponse -> f ListTagsForResourcesResponse)
-> ((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)))
-> ListTagsForResourcesResponse
-> f ListTagsForResourcesResponse
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.
listTagsForResourcesResponse_httpStatus :: Lens.Lens' ListTagsForResourcesResponse Prelude.Int
listTagsForResourcesResponse_httpStatus :: (Int -> f Int)
-> ListTagsForResourcesResponse -> f ListTagsForResourcesResponse
listTagsForResourcesResponse_httpStatus = (ListTagsForResourcesResponse -> Int)
-> (ListTagsForResourcesResponse
    -> Int -> ListTagsForResourcesResponse)
-> Lens
     ListTagsForResourcesResponse ListTagsForResourcesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTagsForResourcesResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListTagsForResourcesResponse' :: ListTagsForResourcesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListTagsForResourcesResponse
s@ListTagsForResourcesResponse' {} Int
a -> ListTagsForResourcesResponse
s {$sel:httpStatus:ListTagsForResourcesResponse' :: Int
httpStatus = Int
a} :: ListTagsForResourcesResponse)

instance Prelude.NFData ListTagsForResourcesResponse