{-# 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.CertificateManager.ListTagsForCertificate
-- 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 that have been applied to the ACM certificate. Use the
-- certificate\'s Amazon Resource Name (ARN) to specify the certificate. To
-- add a tag to an ACM certificate, use the AddTagsToCertificate action. To
-- delete a tag, use the RemoveTagsFromCertificate action.
module Amazonka.CertificateManager.ListTagsForCertificate
  ( -- * Creating a Request
    ListTagsForCertificate (..),
    newListTagsForCertificate,

    -- * Request Lenses
    listTagsForCertificate_certificateArn,

    -- * Destructuring the Response
    ListTagsForCertificateResponse (..),
    newListTagsForCertificateResponse,

    -- * Response Lenses
    listTagsForCertificateResponse_tags,
    listTagsForCertificateResponse_httpStatus,
  )
where

import Amazonka.CertificateManager.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:/ 'newListTagsForCertificate' smart constructor.
data ListTagsForCertificate = ListTagsForCertificate'
  { -- | String that contains the ARN of the ACM certificate for which you want
    -- to list the tags. This must have the following form:
    --
    -- @arn:aws:acm:region:123456789012:certificate\/12345678-1234-1234-1234-123456789012@
    --
    -- For more information about ARNs, see
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>.
    ListTagsForCertificate -> Text
certificateArn :: Prelude.Text
  }
  deriving (ListTagsForCertificate -> ListTagsForCertificate -> Bool
(ListTagsForCertificate -> ListTagsForCertificate -> Bool)
-> (ListTagsForCertificate -> ListTagsForCertificate -> Bool)
-> Eq ListTagsForCertificate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTagsForCertificate -> ListTagsForCertificate -> Bool
$c/= :: ListTagsForCertificate -> ListTagsForCertificate -> Bool
== :: ListTagsForCertificate -> ListTagsForCertificate -> Bool
$c== :: ListTagsForCertificate -> ListTagsForCertificate -> Bool
Prelude.Eq, ReadPrec [ListTagsForCertificate]
ReadPrec ListTagsForCertificate
Int -> ReadS ListTagsForCertificate
ReadS [ListTagsForCertificate]
(Int -> ReadS ListTagsForCertificate)
-> ReadS [ListTagsForCertificate]
-> ReadPrec ListTagsForCertificate
-> ReadPrec [ListTagsForCertificate]
-> Read ListTagsForCertificate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTagsForCertificate]
$creadListPrec :: ReadPrec [ListTagsForCertificate]
readPrec :: ReadPrec ListTagsForCertificate
$creadPrec :: ReadPrec ListTagsForCertificate
readList :: ReadS [ListTagsForCertificate]
$creadList :: ReadS [ListTagsForCertificate]
readsPrec :: Int -> ReadS ListTagsForCertificate
$creadsPrec :: Int -> ReadS ListTagsForCertificate
Prelude.Read, Int -> ListTagsForCertificate -> ShowS
[ListTagsForCertificate] -> ShowS
ListTagsForCertificate -> String
(Int -> ListTagsForCertificate -> ShowS)
-> (ListTagsForCertificate -> String)
-> ([ListTagsForCertificate] -> ShowS)
-> Show ListTagsForCertificate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTagsForCertificate] -> ShowS
$cshowList :: [ListTagsForCertificate] -> ShowS
show :: ListTagsForCertificate -> String
$cshow :: ListTagsForCertificate -> String
showsPrec :: Int -> ListTagsForCertificate -> ShowS
$cshowsPrec :: Int -> ListTagsForCertificate -> ShowS
Prelude.Show, (forall x. ListTagsForCertificate -> Rep ListTagsForCertificate x)
-> (forall x.
    Rep ListTagsForCertificate x -> ListTagsForCertificate)
-> Generic ListTagsForCertificate
forall x. Rep ListTagsForCertificate x -> ListTagsForCertificate
forall x. ListTagsForCertificate -> Rep ListTagsForCertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTagsForCertificate x -> ListTagsForCertificate
$cfrom :: forall x. ListTagsForCertificate -> Rep ListTagsForCertificate x
Prelude.Generic)

-- |
-- Create a value of 'ListTagsForCertificate' 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:
--
-- 'certificateArn', 'listTagsForCertificate_certificateArn' - String that contains the ARN of the ACM certificate for which you want
-- to list the tags. This must have the following form:
--
-- @arn:aws:acm:region:123456789012:certificate\/12345678-1234-1234-1234-123456789012@
--
-- For more information about ARNs, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>.
newListTagsForCertificate ::
  -- | 'certificateArn'
  Prelude.Text ->
  ListTagsForCertificate
newListTagsForCertificate :: Text -> ListTagsForCertificate
newListTagsForCertificate Text
pCertificateArn_ =
  ListTagsForCertificate' :: Text -> ListTagsForCertificate
ListTagsForCertificate'
    { $sel:certificateArn:ListTagsForCertificate' :: Text
certificateArn =
        Text
pCertificateArn_
    }

-- | String that contains the ARN of the ACM certificate for which you want
-- to list the tags. This must have the following form:
--
-- @arn:aws:acm:region:123456789012:certificate\/12345678-1234-1234-1234-123456789012@
--
-- For more information about ARNs, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>.
listTagsForCertificate_certificateArn :: Lens.Lens' ListTagsForCertificate Prelude.Text
listTagsForCertificate_certificateArn :: (Text -> f Text)
-> ListTagsForCertificate -> f ListTagsForCertificate
listTagsForCertificate_certificateArn = (ListTagsForCertificate -> Text)
-> (ListTagsForCertificate -> Text -> ListTagsForCertificate)
-> Lens ListTagsForCertificate ListTagsForCertificate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTagsForCertificate' {Text
certificateArn :: Text
$sel:certificateArn:ListTagsForCertificate' :: ListTagsForCertificate -> Text
certificateArn} -> Text
certificateArn) (\s :: ListTagsForCertificate
s@ListTagsForCertificate' {} Text
a -> ListTagsForCertificate
s {$sel:certificateArn:ListTagsForCertificate' :: Text
certificateArn = Text
a} :: ListTagsForCertificate)

instance Core.AWSRequest ListTagsForCertificate where
  type
    AWSResponse ListTagsForCertificate =
      ListTagsForCertificateResponse
  request :: ListTagsForCertificate -> Request ListTagsForCertificate
request = Service -> ListTagsForCertificate -> Request ListTagsForCertificate
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListTagsForCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListTagsForCertificate)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListTagsForCertificate))
-> Logger
-> Service
-> Proxy ListTagsForCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListTagsForCertificate)))
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 -> ListTagsForCertificateResponse
ListTagsForCertificateResponse'
            (Maybe (NonEmpty Tag) -> Int -> ListTagsForCertificateResponse)
-> Either String (Maybe (NonEmpty Tag))
-> Either String (Int -> ListTagsForCertificateResponse)
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 -> ListTagsForCertificateResponse)
-> Either String Int
-> Either String ListTagsForCertificateResponse
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 ListTagsForCertificate

instance Prelude.NFData ListTagsForCertificate

instance Core.ToHeaders ListTagsForCertificate where
  toHeaders :: ListTagsForCertificate -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListTagsForCertificate -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"CertificateManager.ListTagsForCertificate" ::
                          Prelude.ByteString
                      ),
            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.ToJSON ListTagsForCertificate where
  toJSON :: ListTagsForCertificate -> Value
toJSON ListTagsForCertificate' {Text
certificateArn :: Text
$sel:certificateArn:ListTagsForCertificate' :: ListTagsForCertificate -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"CertificateArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
certificateArn)
          ]
      )

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

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

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

-- |
-- Create a value of 'ListTagsForCertificateResponse' 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', 'listTagsForCertificateResponse_tags' - The key-value pairs that define the applied tags.
--
-- 'httpStatus', 'listTagsForCertificateResponse_httpStatus' - The response's http status code.
newListTagsForCertificateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListTagsForCertificateResponse
newListTagsForCertificateResponse :: Int -> ListTagsForCertificateResponse
newListTagsForCertificateResponse Int
pHttpStatus_ =
  ListTagsForCertificateResponse' :: Maybe (NonEmpty Tag) -> Int -> ListTagsForCertificateResponse
ListTagsForCertificateResponse'
    { $sel:tags:ListTagsForCertificateResponse' :: Maybe (NonEmpty Tag)
tags =
        Maybe (NonEmpty Tag)
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListTagsForCertificateResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The key-value pairs that define the applied tags.
listTagsForCertificateResponse_tags :: Lens.Lens' ListTagsForCertificateResponse (Prelude.Maybe (Prelude.NonEmpty Tag))
listTagsForCertificateResponse_tags :: (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> ListTagsForCertificateResponse
-> f ListTagsForCertificateResponse
listTagsForCertificateResponse_tags = (ListTagsForCertificateResponse -> Maybe (NonEmpty Tag))
-> (ListTagsForCertificateResponse
    -> Maybe (NonEmpty Tag) -> ListTagsForCertificateResponse)
-> Lens
     ListTagsForCertificateResponse
     ListTagsForCertificateResponse
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTagsForCertificateResponse' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:ListTagsForCertificateResponse' :: ListTagsForCertificateResponse -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: ListTagsForCertificateResponse
s@ListTagsForCertificateResponse' {} Maybe (NonEmpty Tag)
a -> ListTagsForCertificateResponse
s {$sel:tags:ListTagsForCertificateResponse' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: ListTagsForCertificateResponse) ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
 -> ListTagsForCertificateResponse
 -> f ListTagsForCertificateResponse)
-> ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
    -> Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> ListTagsForCertificateResponse
-> f ListTagsForCertificateResponse
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.
listTagsForCertificateResponse_httpStatus :: Lens.Lens' ListTagsForCertificateResponse Prelude.Int
listTagsForCertificateResponse_httpStatus :: (Int -> f Int)
-> ListTagsForCertificateResponse
-> f ListTagsForCertificateResponse
listTagsForCertificateResponse_httpStatus = (ListTagsForCertificateResponse -> Int)
-> (ListTagsForCertificateResponse
    -> Int -> ListTagsForCertificateResponse)
-> Lens
     ListTagsForCertificateResponse
     ListTagsForCertificateResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTagsForCertificateResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListTagsForCertificateResponse' :: ListTagsForCertificateResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListTagsForCertificateResponse
s@ListTagsForCertificateResponse' {} Int
a -> ListTagsForCertificateResponse
s {$sel:httpStatus:ListTagsForCertificateResponse' :: Int
httpStatus = Int
a} :: ListTagsForCertificateResponse)

instance
  Prelude.NFData
    ListTagsForCertificateResponse