{-# 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.Route53.ListTagsForResource
-- 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)
--
-- Lists tags for one health check or hosted zone.
--
-- For information about using tags for cost allocation, see
-- <https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/cost-alloc-tags.html Using Cost Allocation Tags>
-- in the /Billing and Cost Management User Guide/.
module Amazonka.Route53.ListTagsForResource
  ( -- * Creating a Request
    ListTagsForResource (..),
    newListTagsForResource,

    -- * Request Lenses
    listTagsForResource_resourceType,
    listTagsForResource_resourceId,

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

    -- * Response Lenses
    listTagsForResourceResponse_httpStatus,
    listTagsForResourceResponse_resourceTagSet,
  )
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.Route53.Types

-- | A complex type containing information about a request for a list of the
-- tags that are associated with an individual resource.
--
-- /See:/ 'newListTagsForResource' smart constructor.
data ListTagsForResource = ListTagsForResource'
  { -- | The type of the resource.
    --
    -- -   The resource type for health checks is @healthcheck@.
    --
    -- -   The resource type for hosted zones is @hostedzone@.
    ListTagsForResource -> TagResourceType
resourceType :: TagResourceType,
    -- | The ID of the resource for which you want to retrieve tags.
    ListTagsForResource -> Text
resourceId :: Prelude.Text
  }
  deriving (ListTagsForResource -> ListTagsForResource -> Bool
(ListTagsForResource -> ListTagsForResource -> Bool)
-> (ListTagsForResource -> ListTagsForResource -> Bool)
-> Eq ListTagsForResource
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]
(Int -> ReadS ListTagsForResource)
-> ReadS [ListTagsForResource]
-> ReadPrec ListTagsForResource
-> ReadPrec [ListTagsForResource]
-> Read 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
(Int -> ListTagsForResource -> ShowS)
-> (ListTagsForResource -> String)
-> ([ListTagsForResource] -> ShowS)
-> Show ListTagsForResource
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. ListTagsForResource -> Rep ListTagsForResource x)
-> (forall x. Rep ListTagsForResource x -> ListTagsForResource)
-> Generic ListTagsForResource
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:
--
-- 'resourceType', 'listTagsForResource_resourceType' - The type of the resource.
--
-- -   The resource type for health checks is @healthcheck@.
--
-- -   The resource type for hosted zones is @hostedzone@.
--
-- 'resourceId', 'listTagsForResource_resourceId' - The ID of the resource for which you want to retrieve tags.
newListTagsForResource ::
  -- | 'resourceType'
  TagResourceType ->
  -- | 'resourceId'
  Prelude.Text ->
  ListTagsForResource
newListTagsForResource :: TagResourceType -> Text -> ListTagsForResource
newListTagsForResource TagResourceType
pResourceType_ Text
pResourceId_ =
  ListTagsForResource' :: TagResourceType -> Text -> ListTagsForResource
ListTagsForResource'
    { $sel:resourceType:ListTagsForResource' :: TagResourceType
resourceType = TagResourceType
pResourceType_,
      $sel:resourceId:ListTagsForResource' :: Text
resourceId = Text
pResourceId_
    }

-- | The type of the resource.
--
-- -   The resource type for health checks is @healthcheck@.
--
-- -   The resource type for hosted zones is @hostedzone@.
listTagsForResource_resourceType :: Lens.Lens' ListTagsForResource TagResourceType
listTagsForResource_resourceType :: (TagResourceType -> f TagResourceType)
-> ListTagsForResource -> f ListTagsForResource
listTagsForResource_resourceType = (ListTagsForResource -> TagResourceType)
-> (ListTagsForResource -> TagResourceType -> ListTagsForResource)
-> Lens
     ListTagsForResource
     ListTagsForResource
     TagResourceType
     TagResourceType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTagsForResource' {TagResourceType
resourceType :: TagResourceType
$sel:resourceType:ListTagsForResource' :: ListTagsForResource -> TagResourceType
resourceType} -> TagResourceType
resourceType) (\s :: ListTagsForResource
s@ListTagsForResource' {} TagResourceType
a -> ListTagsForResource
s {$sel:resourceType:ListTagsForResource' :: TagResourceType
resourceType = TagResourceType
a} :: ListTagsForResource)

-- | The ID of the resource for which you want to retrieve tags.
listTagsForResource_resourceId :: Lens.Lens' ListTagsForResource Prelude.Text
listTagsForResource_resourceId :: (Text -> f Text) -> ListTagsForResource -> f ListTagsForResource
listTagsForResource_resourceId = (ListTagsForResource -> Text)
-> (ListTagsForResource -> Text -> ListTagsForResource)
-> Lens ListTagsForResource ListTagsForResource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTagsForResource' {Text
resourceId :: Text
$sel:resourceId:ListTagsForResource' :: ListTagsForResource -> Text
resourceId} -> Text
resourceId) (\s :: ListTagsForResource
s@ListTagsForResource' {} Text
a -> ListTagsForResource
s {$sel:resourceId:ListTagsForResource' :: Text
resourceId = Text
a} :: ListTagsForResource)

instance Core.AWSRequest ListTagsForResource where
  type
    AWSResponse ListTagsForResource =
      ListTagsForResourceResponse
  request :: ListTagsForResource -> Request ListTagsForResource
request = Service -> ListTagsForResource -> Request ListTagsForResource
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListTagsForResource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListTagsForResource)))
response =
    (Int
 -> ResponseHeaders
 -> [Node]
 -> Either String (AWSResponse ListTagsForResource))
-> Logger
-> Service
-> Proxy ListTagsForResource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListTagsForResource)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> ResourceTagSet -> ListTagsForResourceResponse
ListTagsForResourceResponse'
            (Int -> ResourceTagSet -> ListTagsForResourceResponse)
-> Either String Int
-> Either String (ResourceTagSet -> ListTagsForResourceResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (ResourceTagSet -> ListTagsForResourceResponse)
-> Either String ResourceTagSet
-> Either String ListTagsForResourceResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String ResourceTagSet
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"ResourceTagSet")
      )

instance Prelude.Hashable ListTagsForResource

instance Prelude.NFData ListTagsForResource

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

instance Core.ToPath ListTagsForResource where
  toPath :: ListTagsForResource -> ByteString
toPath ListTagsForResource' {Text
TagResourceType
resourceId :: Text
resourceType :: TagResourceType
$sel:resourceId:ListTagsForResource' :: ListTagsForResource -> Text
$sel:resourceType:ListTagsForResource' :: ListTagsForResource -> TagResourceType
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2013-04-01/tags/",
        TagResourceType -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS TagResourceType
resourceType,
        ByteString
"/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
resourceId
      ]

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

-- | A complex type that contains information about the health checks or
-- hosted zones for which you want to list tags.
--
-- /See:/ 'newListTagsForResourceResponse' smart constructor.
data ListTagsForResourceResponse = ListTagsForResourceResponse'
  { -- | The response's http status code.
    ListTagsForResourceResponse -> Int
httpStatus :: Prelude.Int,
    -- | A @ResourceTagSet@ containing tags associated with the specified
    -- resource.
    ListTagsForResourceResponse -> ResourceTagSet
resourceTagSet :: ResourceTagSet
  }
  deriving (ListTagsForResourceResponse -> ListTagsForResourceResponse -> Bool
(ListTagsForResourceResponse
 -> ListTagsForResourceResponse -> Bool)
-> (ListTagsForResourceResponse
    -> ListTagsForResourceResponse -> Bool)
-> Eq ListTagsForResourceResponse
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]
(Int -> ReadS ListTagsForResourceResponse)
-> ReadS [ListTagsForResourceResponse]
-> ReadPrec ListTagsForResourceResponse
-> ReadPrec [ListTagsForResourceResponse]
-> Read 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
(Int -> ListTagsForResourceResponse -> ShowS)
-> (ListTagsForResourceResponse -> String)
-> ([ListTagsForResourceResponse] -> ShowS)
-> Show ListTagsForResourceResponse
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.
 ListTagsForResourceResponse -> Rep ListTagsForResourceResponse x)
-> (forall x.
    Rep ListTagsForResourceResponse x -> ListTagsForResourceResponse)
-> Generic ListTagsForResourceResponse
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:
--
-- 'httpStatus', 'listTagsForResourceResponse_httpStatus' - The response's http status code.
--
-- 'resourceTagSet', 'listTagsForResourceResponse_resourceTagSet' - A @ResourceTagSet@ containing tags associated with the specified
-- resource.
newListTagsForResourceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'resourceTagSet'
  ResourceTagSet ->
  ListTagsForResourceResponse
newListTagsForResourceResponse :: Int -> ResourceTagSet -> ListTagsForResourceResponse
newListTagsForResourceResponse
  Int
pHttpStatus_
  ResourceTagSet
pResourceTagSet_ =
    ListTagsForResourceResponse' :: Int -> ResourceTagSet -> ListTagsForResourceResponse
ListTagsForResourceResponse'
      { $sel:httpStatus:ListTagsForResourceResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:resourceTagSet:ListTagsForResourceResponse' :: ResourceTagSet
resourceTagSet = ResourceTagSet
pResourceTagSet_
      }

-- | The response's http status code.
listTagsForResourceResponse_httpStatus :: Lens.Lens' ListTagsForResourceResponse Prelude.Int
listTagsForResourceResponse_httpStatus :: (Int -> f Int)
-> ListTagsForResourceResponse -> f ListTagsForResourceResponse
listTagsForResourceResponse_httpStatus = (ListTagsForResourceResponse -> Int)
-> (ListTagsForResourceResponse
    -> Int -> ListTagsForResourceResponse)
-> Lens
     ListTagsForResourceResponse ListTagsForResourceResponse Int Int
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)

-- | A @ResourceTagSet@ containing tags associated with the specified
-- resource.
listTagsForResourceResponse_resourceTagSet :: Lens.Lens' ListTagsForResourceResponse ResourceTagSet
listTagsForResourceResponse_resourceTagSet :: (ResourceTagSet -> f ResourceTagSet)
-> ListTagsForResourceResponse -> f ListTagsForResourceResponse
listTagsForResourceResponse_resourceTagSet = (ListTagsForResourceResponse -> ResourceTagSet)
-> (ListTagsForResourceResponse
    -> ResourceTagSet -> ListTagsForResourceResponse)
-> Lens
     ListTagsForResourceResponse
     ListTagsForResourceResponse
     ResourceTagSet
     ResourceTagSet
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTagsForResourceResponse' {ResourceTagSet
resourceTagSet :: ResourceTagSet
$sel:resourceTagSet:ListTagsForResourceResponse' :: ListTagsForResourceResponse -> ResourceTagSet
resourceTagSet} -> ResourceTagSet
resourceTagSet) (\s :: ListTagsForResourceResponse
s@ListTagsForResourceResponse' {} ResourceTagSet
a -> ListTagsForResourceResponse
s {$sel:resourceTagSet:ListTagsForResourceResponse' :: ResourceTagSet
resourceTagSet = ResourceTagSet
a} :: ListTagsForResourceResponse)

instance Prelude.NFData ListTagsForResourceResponse