{-# 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.Chime.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 the tags applied to an Amazon Chime SDK meeting resource.
module Amazonka.Chime.ListTagsForResource
  ( -- * Creating a Request
    ListTagsForResource (..),
    newListTagsForResource,

    -- * Request Lenses
    listTagsForResource_resourceARN,

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

    -- * Response Lenses
    listTagsForResourceResponse_tags,
    listTagsForResourceResponse_httpStatus,
  )
where

import Amazonka.Chime.Types
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

-- | /See:/ 'newListTagsForResource' smart constructor.
data ListTagsForResource = ListTagsForResource'
  { -- | The resource ARN.
    ListTagsForResource -> Sensitive Text
resourceARN :: Core.Sensitive 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, 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:
--
-- 'resourceARN', 'listTagsForResource_resourceARN' - The resource ARN.
newListTagsForResource ::
  -- | 'resourceARN'
  Prelude.Text ->
  ListTagsForResource
newListTagsForResource :: Text -> ListTagsForResource
newListTagsForResource Text
pResourceARN_ =
  ListTagsForResource' :: Sensitive Text -> ListTagsForResource
ListTagsForResource'
    { $sel:resourceARN:ListTagsForResource' :: Sensitive Text
resourceARN =
        Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pResourceARN_
    }

-- | The resource ARN.
listTagsForResource_resourceARN :: Lens.Lens' ListTagsForResource Prelude.Text
listTagsForResource_resourceARN :: (Text -> f Text) -> ListTagsForResource -> f ListTagsForResource
listTagsForResource_resourceARN = (ListTagsForResource -> Sensitive Text)
-> (ListTagsForResource -> Sensitive Text -> ListTagsForResource)
-> Lens
     ListTagsForResource
     ListTagsForResource
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTagsForResource' {Sensitive Text
resourceARN :: Sensitive Text
$sel:resourceARN:ListTagsForResource' :: ListTagsForResource -> Sensitive Text
resourceARN} -> Sensitive Text
resourceARN) (\s :: ListTagsForResource
s@ListTagsForResource' {} Sensitive Text
a -> ListTagsForResource
s {$sel:resourceARN:ListTagsForResource' :: Sensitive Text
resourceARN = Sensitive Text
a} :: ListTagsForResource) ((Sensitive Text -> f (Sensitive Text))
 -> ListTagsForResource -> f ListTagsForResource)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> ListTagsForResource
-> f ListTagsForResource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

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
 -> Object
 -> Either String (AWSResponse ListTagsForResource))
-> Logger
-> Service
-> Proxy ListTagsForResource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListTagsForResource)))
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 (NonEmpty Tag) -> Int -> ListTagsForResourceResponse
ListTagsForResourceResponse'
            (Maybe (NonEmpty Tag) -> Int -> ListTagsForResourceResponse)
-> Either String (Maybe (NonEmpty Tag))
-> Either String (Int -> ListTagsForResourceResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (NonEmpty Tag))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Tags")
            Either String (Int -> ListTagsForResourceResponse)
-> Either String Int -> Either String ListTagsForResourceResponse
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 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 = ByteString -> ListTagsForResource -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/tags"

instance Core.ToQuery ListTagsForResource where
  toQuery :: ListTagsForResource -> QueryString
toQuery ListTagsForResource' {Sensitive Text
resourceARN :: Sensitive Text
$sel:resourceARN:ListTagsForResource' :: ListTagsForResource -> Sensitive Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"arn" ByteString -> Sensitive Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Sensitive Text
resourceARN]

-- | /See:/ 'newListTagsForResourceResponse' smart constructor.
data ListTagsForResourceResponse = ListTagsForResourceResponse'
  { -- | A list of tag-key value pairs.
    ListTagsForResourceResponse -> Maybe (NonEmpty Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty Tag),
    -- | The response's http status code.
    ListTagsForResourceResponse -> Int
httpStatus :: Prelude.Int
  }
  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, 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:
--
-- 'tags', 'listTagsForResourceResponse_tags' - A list of tag-key value pairs.
--
-- 'httpStatus', 'listTagsForResourceResponse_httpStatus' - The response's http status code.
newListTagsForResourceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListTagsForResourceResponse
newListTagsForResourceResponse :: Int -> ListTagsForResourceResponse
newListTagsForResourceResponse Int
pHttpStatus_ =
  ListTagsForResourceResponse' :: Maybe (NonEmpty Tag) -> Int -> ListTagsForResourceResponse
ListTagsForResourceResponse'
    { $sel:tags:ListTagsForResourceResponse' :: Maybe (NonEmpty Tag)
tags =
        Maybe (NonEmpty Tag)
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListTagsForResourceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of tag-key value pairs.
listTagsForResourceResponse_tags :: Lens.Lens' ListTagsForResourceResponse (Prelude.Maybe (Prelude.NonEmpty Tag))
listTagsForResourceResponse_tags :: (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> ListTagsForResourceResponse -> f ListTagsForResourceResponse
listTagsForResourceResponse_tags = (ListTagsForResourceResponse -> Maybe (NonEmpty Tag))
-> (ListTagsForResourceResponse
    -> Maybe (NonEmpty Tag) -> ListTagsForResourceResponse)
-> Lens
     ListTagsForResourceResponse
     ListTagsForResourceResponse
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTagsForResourceResponse' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:ListTagsForResourceResponse' :: ListTagsForResourceResponse -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: ListTagsForResourceResponse
s@ListTagsForResourceResponse' {} Maybe (NonEmpty Tag)
a -> ListTagsForResourceResponse
s {$sel:tags:ListTagsForResourceResponse' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: ListTagsForResourceResponse) ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
 -> ListTagsForResourceResponse -> f ListTagsForResourceResponse)
-> ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
    -> Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> ListTagsForResourceResponse
-> f ListTagsForResourceResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
-> Iso
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
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 (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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)

instance Prelude.NFData ListTagsForResourceResponse