{-# 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.CertificateManagerPCA.TagCertificateAuthority
-- 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)
--
-- Adds one or more tags to your private CA. Tags are labels that you can
-- use to identify and organize your AWS resources. Each tag consists of a
-- key and an optional value. You specify the private CA on input by its
-- Amazon Resource Name (ARN). You specify the tag by using a key-value
-- pair. You can apply a tag to just one private CA if you want to identify
-- a specific characteristic of that CA, or you can apply the same tag to
-- multiple private CAs if you want to filter for a common relationship
-- among those CAs. To remove one or more tags, use the
-- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_UntagCertificateAuthority.html UntagCertificateAuthority>
-- action. Call the
-- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_ListTags.html ListTags>
-- action to see what tags are associated with your CA.
module Amazonka.CertificateManagerPCA.TagCertificateAuthority
  ( -- * Creating a Request
    TagCertificateAuthority (..),
    newTagCertificateAuthority,

    -- * Request Lenses
    tagCertificateAuthority_certificateAuthorityArn,
    tagCertificateAuthority_tags,

    -- * Destructuring the Response
    TagCertificateAuthorityResponse (..),
    newTagCertificateAuthorityResponse,
  )
where

import Amazonka.CertificateManagerPCA.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:/ 'newTagCertificateAuthority' smart constructor.
data TagCertificateAuthority = TagCertificateAuthority'
  { -- | The Amazon Resource Name (ARN) that was returned when you called
    -- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_CreateCertificateAuthority.html CreateCertificateAuthority>.
    -- This must be of the form:
    --
    -- @arn:aws:acm-pca:region:account:certificate-authority\/12345678-1234-1234-1234-123456789012 @
    TagCertificateAuthority -> Text
certificateAuthorityArn :: Prelude.Text,
    -- | List of tags to be associated with the CA.
    TagCertificateAuthority -> NonEmpty Tag
tags :: Prelude.NonEmpty Tag
  }
  deriving (TagCertificateAuthority -> TagCertificateAuthority -> Bool
(TagCertificateAuthority -> TagCertificateAuthority -> Bool)
-> (TagCertificateAuthority -> TagCertificateAuthority -> Bool)
-> Eq TagCertificateAuthority
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TagCertificateAuthority -> TagCertificateAuthority -> Bool
$c/= :: TagCertificateAuthority -> TagCertificateAuthority -> Bool
== :: TagCertificateAuthority -> TagCertificateAuthority -> Bool
$c== :: TagCertificateAuthority -> TagCertificateAuthority -> Bool
Prelude.Eq, ReadPrec [TagCertificateAuthority]
ReadPrec TagCertificateAuthority
Int -> ReadS TagCertificateAuthority
ReadS [TagCertificateAuthority]
(Int -> ReadS TagCertificateAuthority)
-> ReadS [TagCertificateAuthority]
-> ReadPrec TagCertificateAuthority
-> ReadPrec [TagCertificateAuthority]
-> Read TagCertificateAuthority
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TagCertificateAuthority]
$creadListPrec :: ReadPrec [TagCertificateAuthority]
readPrec :: ReadPrec TagCertificateAuthority
$creadPrec :: ReadPrec TagCertificateAuthority
readList :: ReadS [TagCertificateAuthority]
$creadList :: ReadS [TagCertificateAuthority]
readsPrec :: Int -> ReadS TagCertificateAuthority
$creadsPrec :: Int -> ReadS TagCertificateAuthority
Prelude.Read, Int -> TagCertificateAuthority -> ShowS
[TagCertificateAuthority] -> ShowS
TagCertificateAuthority -> String
(Int -> TagCertificateAuthority -> ShowS)
-> (TagCertificateAuthority -> String)
-> ([TagCertificateAuthority] -> ShowS)
-> Show TagCertificateAuthority
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TagCertificateAuthority] -> ShowS
$cshowList :: [TagCertificateAuthority] -> ShowS
show :: TagCertificateAuthority -> String
$cshow :: TagCertificateAuthority -> String
showsPrec :: Int -> TagCertificateAuthority -> ShowS
$cshowsPrec :: Int -> TagCertificateAuthority -> ShowS
Prelude.Show, (forall x.
 TagCertificateAuthority -> Rep TagCertificateAuthority x)
-> (forall x.
    Rep TagCertificateAuthority x -> TagCertificateAuthority)
-> Generic TagCertificateAuthority
forall x. Rep TagCertificateAuthority x -> TagCertificateAuthority
forall x. TagCertificateAuthority -> Rep TagCertificateAuthority x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TagCertificateAuthority x -> TagCertificateAuthority
$cfrom :: forall x. TagCertificateAuthority -> Rep TagCertificateAuthority x
Prelude.Generic)

-- |
-- Create a value of 'TagCertificateAuthority' 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:
--
-- 'certificateAuthorityArn', 'tagCertificateAuthority_certificateAuthorityArn' - The Amazon Resource Name (ARN) that was returned when you called
-- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_CreateCertificateAuthority.html CreateCertificateAuthority>.
-- This must be of the form:
--
-- @arn:aws:acm-pca:region:account:certificate-authority\/12345678-1234-1234-1234-123456789012 @
--
-- 'tags', 'tagCertificateAuthority_tags' - List of tags to be associated with the CA.
newTagCertificateAuthority ::
  -- | 'certificateAuthorityArn'
  Prelude.Text ->
  -- | 'tags'
  Prelude.NonEmpty Tag ->
  TagCertificateAuthority
newTagCertificateAuthority :: Text -> NonEmpty Tag -> TagCertificateAuthority
newTagCertificateAuthority
  Text
pCertificateAuthorityArn_
  NonEmpty Tag
pTags_ =
    TagCertificateAuthority' :: Text -> NonEmpty Tag -> TagCertificateAuthority
TagCertificateAuthority'
      { $sel:certificateAuthorityArn:TagCertificateAuthority' :: Text
certificateAuthorityArn =
          Text
pCertificateAuthorityArn_,
        $sel:tags:TagCertificateAuthority' :: NonEmpty Tag
tags = Tagged (NonEmpty Tag) (Identity (NonEmpty Tag))
-> Tagged (NonEmpty Tag) (Identity (NonEmpty Tag))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Tag) (Identity (NonEmpty Tag))
 -> Tagged (NonEmpty Tag) (Identity (NonEmpty Tag)))
-> NonEmpty Tag -> NonEmpty Tag
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Tag
pTags_
      }

-- | The Amazon Resource Name (ARN) that was returned when you called
-- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_CreateCertificateAuthority.html CreateCertificateAuthority>.
-- This must be of the form:
--
-- @arn:aws:acm-pca:region:account:certificate-authority\/12345678-1234-1234-1234-123456789012 @
tagCertificateAuthority_certificateAuthorityArn :: Lens.Lens' TagCertificateAuthority Prelude.Text
tagCertificateAuthority_certificateAuthorityArn :: (Text -> f Text)
-> TagCertificateAuthority -> f TagCertificateAuthority
tagCertificateAuthority_certificateAuthorityArn = (TagCertificateAuthority -> Text)
-> (TagCertificateAuthority -> Text -> TagCertificateAuthority)
-> Lens TagCertificateAuthority TagCertificateAuthority Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagCertificateAuthority' {Text
certificateAuthorityArn :: Text
$sel:certificateAuthorityArn:TagCertificateAuthority' :: TagCertificateAuthority -> Text
certificateAuthorityArn} -> Text
certificateAuthorityArn) (\s :: TagCertificateAuthority
s@TagCertificateAuthority' {} Text
a -> TagCertificateAuthority
s {$sel:certificateAuthorityArn:TagCertificateAuthority' :: Text
certificateAuthorityArn = Text
a} :: TagCertificateAuthority)

-- | List of tags to be associated with the CA.
tagCertificateAuthority_tags :: Lens.Lens' TagCertificateAuthority (Prelude.NonEmpty Tag)
tagCertificateAuthority_tags :: (NonEmpty Tag -> f (NonEmpty Tag))
-> TagCertificateAuthority -> f TagCertificateAuthority
tagCertificateAuthority_tags = (TagCertificateAuthority -> NonEmpty Tag)
-> (TagCertificateAuthority
    -> NonEmpty Tag -> TagCertificateAuthority)
-> Lens
     TagCertificateAuthority
     TagCertificateAuthority
     (NonEmpty Tag)
     (NonEmpty Tag)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagCertificateAuthority' {NonEmpty Tag
tags :: NonEmpty Tag
$sel:tags:TagCertificateAuthority' :: TagCertificateAuthority -> NonEmpty Tag
tags} -> NonEmpty Tag
tags) (\s :: TagCertificateAuthority
s@TagCertificateAuthority' {} NonEmpty Tag
a -> TagCertificateAuthority
s {$sel:tags:TagCertificateAuthority' :: NonEmpty Tag
tags = NonEmpty Tag
a} :: TagCertificateAuthority) ((NonEmpty Tag -> f (NonEmpty Tag))
 -> TagCertificateAuthority -> f TagCertificateAuthority)
-> ((NonEmpty Tag -> f (NonEmpty Tag))
    -> NonEmpty Tag -> f (NonEmpty Tag))
-> (NonEmpty Tag -> f (NonEmpty Tag))
-> TagCertificateAuthority
-> f TagCertificateAuthority
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Tag -> f (NonEmpty Tag))
-> NonEmpty Tag -> f (NonEmpty Tag)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest TagCertificateAuthority where
  type
    AWSResponse TagCertificateAuthority =
      TagCertificateAuthorityResponse
  request :: TagCertificateAuthority -> Request TagCertificateAuthority
request = Service
-> TagCertificateAuthority -> Request TagCertificateAuthority
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy TagCertificateAuthority
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse TagCertificateAuthority)))
response =
    AWSResponse TagCertificateAuthority
-> Logger
-> Service
-> Proxy TagCertificateAuthority
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse TagCertificateAuthority)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse TagCertificateAuthority
TagCertificateAuthorityResponse
TagCertificateAuthorityResponse'

instance Prelude.Hashable TagCertificateAuthority

instance Prelude.NFData TagCertificateAuthority

instance Core.ToHeaders TagCertificateAuthority where
  toHeaders :: TagCertificateAuthority -> [Header]
toHeaders =
    [Header] -> TagCertificateAuthority -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"ACMPrivateCA.TagCertificateAuthority" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON TagCertificateAuthority where
  toJSON :: TagCertificateAuthority -> Value
toJSON TagCertificateAuthority' {NonEmpty Tag
Text
tags :: NonEmpty Tag
certificateAuthorityArn :: Text
$sel:tags:TagCertificateAuthority' :: TagCertificateAuthority -> NonEmpty Tag
$sel:certificateAuthorityArn:TagCertificateAuthority' :: TagCertificateAuthority -> 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
"CertificateAuthorityArn"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
certificateAuthorityArn
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Tags" Text -> NonEmpty Tag -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Tag
tags)
          ]
      )

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

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

-- | /See:/ 'newTagCertificateAuthorityResponse' smart constructor.
data TagCertificateAuthorityResponse = TagCertificateAuthorityResponse'
  {
  }
  deriving (TagCertificateAuthorityResponse
-> TagCertificateAuthorityResponse -> Bool
(TagCertificateAuthorityResponse
 -> TagCertificateAuthorityResponse -> Bool)
-> (TagCertificateAuthorityResponse
    -> TagCertificateAuthorityResponse -> Bool)
-> Eq TagCertificateAuthorityResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TagCertificateAuthorityResponse
-> TagCertificateAuthorityResponse -> Bool
$c/= :: TagCertificateAuthorityResponse
-> TagCertificateAuthorityResponse -> Bool
== :: TagCertificateAuthorityResponse
-> TagCertificateAuthorityResponse -> Bool
$c== :: TagCertificateAuthorityResponse
-> TagCertificateAuthorityResponse -> Bool
Prelude.Eq, ReadPrec [TagCertificateAuthorityResponse]
ReadPrec TagCertificateAuthorityResponse
Int -> ReadS TagCertificateAuthorityResponse
ReadS [TagCertificateAuthorityResponse]
(Int -> ReadS TagCertificateAuthorityResponse)
-> ReadS [TagCertificateAuthorityResponse]
-> ReadPrec TagCertificateAuthorityResponse
-> ReadPrec [TagCertificateAuthorityResponse]
-> Read TagCertificateAuthorityResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TagCertificateAuthorityResponse]
$creadListPrec :: ReadPrec [TagCertificateAuthorityResponse]
readPrec :: ReadPrec TagCertificateAuthorityResponse
$creadPrec :: ReadPrec TagCertificateAuthorityResponse
readList :: ReadS [TagCertificateAuthorityResponse]
$creadList :: ReadS [TagCertificateAuthorityResponse]
readsPrec :: Int -> ReadS TagCertificateAuthorityResponse
$creadsPrec :: Int -> ReadS TagCertificateAuthorityResponse
Prelude.Read, Int -> TagCertificateAuthorityResponse -> ShowS
[TagCertificateAuthorityResponse] -> ShowS
TagCertificateAuthorityResponse -> String
(Int -> TagCertificateAuthorityResponse -> ShowS)
-> (TagCertificateAuthorityResponse -> String)
-> ([TagCertificateAuthorityResponse] -> ShowS)
-> Show TagCertificateAuthorityResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TagCertificateAuthorityResponse] -> ShowS
$cshowList :: [TagCertificateAuthorityResponse] -> ShowS
show :: TagCertificateAuthorityResponse -> String
$cshow :: TagCertificateAuthorityResponse -> String
showsPrec :: Int -> TagCertificateAuthorityResponse -> ShowS
$cshowsPrec :: Int -> TagCertificateAuthorityResponse -> ShowS
Prelude.Show, (forall x.
 TagCertificateAuthorityResponse
 -> Rep TagCertificateAuthorityResponse x)
-> (forall x.
    Rep TagCertificateAuthorityResponse x
    -> TagCertificateAuthorityResponse)
-> Generic TagCertificateAuthorityResponse
forall x.
Rep TagCertificateAuthorityResponse x
-> TagCertificateAuthorityResponse
forall x.
TagCertificateAuthorityResponse
-> Rep TagCertificateAuthorityResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TagCertificateAuthorityResponse x
-> TagCertificateAuthorityResponse
$cfrom :: forall x.
TagCertificateAuthorityResponse
-> Rep TagCertificateAuthorityResponse x
Prelude.Generic)

-- |
-- Create a value of 'TagCertificateAuthorityResponse' 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.
newTagCertificateAuthorityResponse ::
  TagCertificateAuthorityResponse
newTagCertificateAuthorityResponse :: TagCertificateAuthorityResponse
newTagCertificateAuthorityResponse =
  TagCertificateAuthorityResponse
TagCertificateAuthorityResponse'

instance
  Prelude.NFData
    TagCertificateAuthorityResponse