{-# 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.UntagCertificateAuthority
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Remove one or more tags from your private CA. A tag consists of a
-- key-value pair. If you do not specify the value portion of the tag when
-- calling this action, the tag will be removed regardless of value. If you
-- specify a value, the tag is removed only if it is associated with the
-- specified value. To add tags to a private CA, use the
-- <https://docs.aws.amazon.com/privateca/latest/APIReference/API_TagCertificateAuthority.html TagCertificateAuthority>.
-- Call the
-- <https://docs.aws.amazon.com/privateca/latest/APIReference/API_ListTags.html ListTags>
-- action to see what tags are associated with your CA.
module Amazonka.CertificateManagerPCA.UntagCertificateAuthority
  ( -- * Creating a Request
    UntagCertificateAuthority (..),
    newUntagCertificateAuthority,

    -- * Request Lenses
    untagCertificateAuthority_certificateAuthorityArn,
    untagCertificateAuthority_tags,

    -- * Destructuring the Response
    UntagCertificateAuthorityResponse (..),
    newUntagCertificateAuthorityResponse,
  )
where

import Amazonka.CertificateManagerPCA.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUntagCertificateAuthority' smart constructor.
data UntagCertificateAuthority = UntagCertificateAuthority'
  { -- | The Amazon Resource Name (ARN) that was returned when you called
    -- <https://docs.aws.amazon.com/privateca/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@/@ @
    UntagCertificateAuthority -> Text
certificateAuthorityArn :: Prelude.Text,
    -- | List of tags to be removed from the CA.
    UntagCertificateAuthority -> NonEmpty Tag
tags :: Prelude.NonEmpty Tag
  }
  deriving (UntagCertificateAuthority -> UntagCertificateAuthority -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UntagCertificateAuthority -> UntagCertificateAuthority -> Bool
$c/= :: UntagCertificateAuthority -> UntagCertificateAuthority -> Bool
== :: UntagCertificateAuthority -> UntagCertificateAuthority -> Bool
$c== :: UntagCertificateAuthority -> UntagCertificateAuthority -> Bool
Prelude.Eq, ReadPrec [UntagCertificateAuthority]
ReadPrec UntagCertificateAuthority
Int -> ReadS UntagCertificateAuthority
ReadS [UntagCertificateAuthority]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UntagCertificateAuthority]
$creadListPrec :: ReadPrec [UntagCertificateAuthority]
readPrec :: ReadPrec UntagCertificateAuthority
$creadPrec :: ReadPrec UntagCertificateAuthority
readList :: ReadS [UntagCertificateAuthority]
$creadList :: ReadS [UntagCertificateAuthority]
readsPrec :: Int -> ReadS UntagCertificateAuthority
$creadsPrec :: Int -> ReadS UntagCertificateAuthority
Prelude.Read, Int -> UntagCertificateAuthority -> ShowS
[UntagCertificateAuthority] -> ShowS
UntagCertificateAuthority -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UntagCertificateAuthority] -> ShowS
$cshowList :: [UntagCertificateAuthority] -> ShowS
show :: UntagCertificateAuthority -> String
$cshow :: UntagCertificateAuthority -> String
showsPrec :: Int -> UntagCertificateAuthority -> ShowS
$cshowsPrec :: Int -> UntagCertificateAuthority -> ShowS
Prelude.Show, forall x.
Rep UntagCertificateAuthority x -> UntagCertificateAuthority
forall x.
UntagCertificateAuthority -> Rep UntagCertificateAuthority x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UntagCertificateAuthority x -> UntagCertificateAuthority
$cfrom :: forall x.
UntagCertificateAuthority -> Rep UntagCertificateAuthority x
Prelude.Generic)

-- |
-- Create a value of 'UntagCertificateAuthority' 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', 'untagCertificateAuthority_certificateAuthorityArn' - The Amazon Resource Name (ARN) that was returned when you called
-- <https://docs.aws.amazon.com/privateca/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', 'untagCertificateAuthority_tags' - List of tags to be removed from the CA.
newUntagCertificateAuthority ::
  -- | 'certificateAuthorityArn'
  Prelude.Text ->
  -- | 'tags'
  Prelude.NonEmpty Tag ->
  UntagCertificateAuthority
newUntagCertificateAuthority :: Text -> NonEmpty Tag -> UntagCertificateAuthority
newUntagCertificateAuthority
  Text
pCertificateAuthorityArn_
  NonEmpty Tag
pTags_ =
    UntagCertificateAuthority'
      { $sel:certificateAuthorityArn:UntagCertificateAuthority' :: Text
certificateAuthorityArn =
          Text
pCertificateAuthorityArn_,
        $sel:tags:UntagCertificateAuthority' :: NonEmpty Tag
tags = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced 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/privateca/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@/@ @
untagCertificateAuthority_certificateAuthorityArn :: Lens.Lens' UntagCertificateAuthority Prelude.Text
untagCertificateAuthority_certificateAuthorityArn :: Lens' UntagCertificateAuthority Text
untagCertificateAuthority_certificateAuthorityArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UntagCertificateAuthority' {Text
certificateAuthorityArn :: Text
$sel:certificateAuthorityArn:UntagCertificateAuthority' :: UntagCertificateAuthority -> Text
certificateAuthorityArn} -> Text
certificateAuthorityArn) (\s :: UntagCertificateAuthority
s@UntagCertificateAuthority' {} Text
a -> UntagCertificateAuthority
s {$sel:certificateAuthorityArn:UntagCertificateAuthority' :: Text
certificateAuthorityArn = Text
a} :: UntagCertificateAuthority)

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

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

instance Prelude.Hashable UntagCertificateAuthority where
  hashWithSalt :: Int -> UntagCertificateAuthority -> Int
hashWithSalt Int
_salt UntagCertificateAuthority' {NonEmpty Tag
Text
tags :: NonEmpty Tag
certificateAuthorityArn :: Text
$sel:tags:UntagCertificateAuthority' :: UntagCertificateAuthority -> NonEmpty Tag
$sel:certificateAuthorityArn:UntagCertificateAuthority' :: UntagCertificateAuthority -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
certificateAuthorityArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Tag
tags

instance Prelude.NFData UntagCertificateAuthority where
  rnf :: UntagCertificateAuthority -> ()
rnf UntagCertificateAuthority' {NonEmpty Tag
Text
tags :: NonEmpty Tag
certificateAuthorityArn :: Text
$sel:tags:UntagCertificateAuthority' :: UntagCertificateAuthority -> NonEmpty Tag
$sel:certificateAuthorityArn:UntagCertificateAuthority' :: UntagCertificateAuthority -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
certificateAuthorityArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Tag
tags

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

instance Data.ToJSON UntagCertificateAuthority where
  toJSON :: UntagCertificateAuthority -> Value
toJSON UntagCertificateAuthority' {NonEmpty Tag
Text
tags :: NonEmpty Tag
certificateAuthorityArn :: Text
$sel:tags:UntagCertificateAuthority' :: UntagCertificateAuthority -> NonEmpty Tag
$sel:certificateAuthorityArn:UntagCertificateAuthority' :: UntagCertificateAuthority -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"CertificateAuthorityArn"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
certificateAuthorityArn
              ),
            forall a. a -> Maybe a
Prelude.Just (Key
"Tags" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Tag
tags)
          ]
      )

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

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

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

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

instance
  Prelude.NFData
    UntagCertificateAuthorityResponse
  where
  rnf :: UntagCertificateAuthorityResponse -> ()
rnf UntagCertificateAuthorityResponse
_ = ()