{-# 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.RemoveTagsFromCertificate
-- 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)
--
-- Remove one or more tags from an ACM certificate. A tag consists of a
-- key-value pair. If you do not specify the value portion of the tag when
-- calling this function, 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 certificate, use the AddTagsToCertificate action. To
-- view all of the tags that have been applied to a specific ACM
-- certificate, use the ListTagsForCertificate action.
module Amazonka.CertificateManager.RemoveTagsFromCertificate
  ( -- * Creating a Request
    RemoveTagsFromCertificate (..),
    newRemoveTagsFromCertificate,

    -- * Request Lenses
    removeTagsFromCertificate_certificateArn,
    removeTagsFromCertificate_tags,

    -- * Destructuring the Response
    RemoveTagsFromCertificateResponse (..),
    newRemoveTagsFromCertificateResponse,
  )
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:/ 'newRemoveTagsFromCertificate' smart constructor.
data RemoveTagsFromCertificate = RemoveTagsFromCertificate'
  { -- | String that contains the ARN of the ACM Certificate with one or more
    -- tags that you want to remove. This must be of the 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)>.
    RemoveTagsFromCertificate -> Text
certificateArn :: Prelude.Text,
    -- | The key-value pair that defines the tag to remove.
    RemoveTagsFromCertificate -> NonEmpty Tag
tags :: Prelude.NonEmpty Tag
  }
  deriving (RemoveTagsFromCertificate -> RemoveTagsFromCertificate -> Bool
(RemoveTagsFromCertificate -> RemoveTagsFromCertificate -> Bool)
-> (RemoveTagsFromCertificate -> RemoveTagsFromCertificate -> Bool)
-> Eq RemoveTagsFromCertificate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemoveTagsFromCertificate -> RemoveTagsFromCertificate -> Bool
$c/= :: RemoveTagsFromCertificate -> RemoveTagsFromCertificate -> Bool
== :: RemoveTagsFromCertificate -> RemoveTagsFromCertificate -> Bool
$c== :: RemoveTagsFromCertificate -> RemoveTagsFromCertificate -> Bool
Prelude.Eq, ReadPrec [RemoveTagsFromCertificate]
ReadPrec RemoveTagsFromCertificate
Int -> ReadS RemoveTagsFromCertificate
ReadS [RemoveTagsFromCertificate]
(Int -> ReadS RemoveTagsFromCertificate)
-> ReadS [RemoveTagsFromCertificate]
-> ReadPrec RemoveTagsFromCertificate
-> ReadPrec [RemoveTagsFromCertificate]
-> Read RemoveTagsFromCertificate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemoveTagsFromCertificate]
$creadListPrec :: ReadPrec [RemoveTagsFromCertificate]
readPrec :: ReadPrec RemoveTagsFromCertificate
$creadPrec :: ReadPrec RemoveTagsFromCertificate
readList :: ReadS [RemoveTagsFromCertificate]
$creadList :: ReadS [RemoveTagsFromCertificate]
readsPrec :: Int -> ReadS RemoveTagsFromCertificate
$creadsPrec :: Int -> ReadS RemoveTagsFromCertificate
Prelude.Read, Int -> RemoveTagsFromCertificate -> ShowS
[RemoveTagsFromCertificate] -> ShowS
RemoveTagsFromCertificate -> String
(Int -> RemoveTagsFromCertificate -> ShowS)
-> (RemoveTagsFromCertificate -> String)
-> ([RemoveTagsFromCertificate] -> ShowS)
-> Show RemoveTagsFromCertificate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemoveTagsFromCertificate] -> ShowS
$cshowList :: [RemoveTagsFromCertificate] -> ShowS
show :: RemoveTagsFromCertificate -> String
$cshow :: RemoveTagsFromCertificate -> String
showsPrec :: Int -> RemoveTagsFromCertificate -> ShowS
$cshowsPrec :: Int -> RemoveTagsFromCertificate -> ShowS
Prelude.Show, (forall x.
 RemoveTagsFromCertificate -> Rep RemoveTagsFromCertificate x)
-> (forall x.
    Rep RemoveTagsFromCertificate x -> RemoveTagsFromCertificate)
-> Generic RemoveTagsFromCertificate
forall x.
Rep RemoveTagsFromCertificate x -> RemoveTagsFromCertificate
forall x.
RemoveTagsFromCertificate -> Rep RemoveTagsFromCertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RemoveTagsFromCertificate x -> RemoveTagsFromCertificate
$cfrom :: forall x.
RemoveTagsFromCertificate -> Rep RemoveTagsFromCertificate x
Prelude.Generic)

-- |
-- Create a value of 'RemoveTagsFromCertificate' 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', 'removeTagsFromCertificate_certificateArn' - String that contains the ARN of the ACM Certificate with one or more
-- tags that you want to remove. This must be of the 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)>.
--
-- 'tags', 'removeTagsFromCertificate_tags' - The key-value pair that defines the tag to remove.
newRemoveTagsFromCertificate ::
  -- | 'certificateArn'
  Prelude.Text ->
  -- | 'tags'
  Prelude.NonEmpty Tag ->
  RemoveTagsFromCertificate
newRemoveTagsFromCertificate :: Text -> NonEmpty Tag -> RemoveTagsFromCertificate
newRemoveTagsFromCertificate Text
pCertificateArn_ NonEmpty Tag
pTags_ =
  RemoveTagsFromCertificate' :: Text -> NonEmpty Tag -> RemoveTagsFromCertificate
RemoveTagsFromCertificate'
    { $sel:certificateArn:RemoveTagsFromCertificate' :: Text
certificateArn =
        Text
pCertificateArn_,
      $sel:tags:RemoveTagsFromCertificate' :: 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_
    }

-- | String that contains the ARN of the ACM Certificate with one or more
-- tags that you want to remove. This must be of the 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)>.
removeTagsFromCertificate_certificateArn :: Lens.Lens' RemoveTagsFromCertificate Prelude.Text
removeTagsFromCertificate_certificateArn :: (Text -> f Text)
-> RemoveTagsFromCertificate -> f RemoveTagsFromCertificate
removeTagsFromCertificate_certificateArn = (RemoveTagsFromCertificate -> Text)
-> (RemoveTagsFromCertificate -> Text -> RemoveTagsFromCertificate)
-> Lens
     RemoveTagsFromCertificate RemoveTagsFromCertificate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveTagsFromCertificate' {Text
certificateArn :: Text
$sel:certificateArn:RemoveTagsFromCertificate' :: RemoveTagsFromCertificate -> Text
certificateArn} -> Text
certificateArn) (\s :: RemoveTagsFromCertificate
s@RemoveTagsFromCertificate' {} Text
a -> RemoveTagsFromCertificate
s {$sel:certificateArn:RemoveTagsFromCertificate' :: Text
certificateArn = Text
a} :: RemoveTagsFromCertificate)

-- | The key-value pair that defines the tag to remove.
removeTagsFromCertificate_tags :: Lens.Lens' RemoveTagsFromCertificate (Prelude.NonEmpty Tag)
removeTagsFromCertificate_tags :: (NonEmpty Tag -> f (NonEmpty Tag))
-> RemoveTagsFromCertificate -> f RemoveTagsFromCertificate
removeTagsFromCertificate_tags = (RemoveTagsFromCertificate -> NonEmpty Tag)
-> (RemoveTagsFromCertificate
    -> NonEmpty Tag -> RemoveTagsFromCertificate)
-> Lens
     RemoveTagsFromCertificate
     RemoveTagsFromCertificate
     (NonEmpty Tag)
     (NonEmpty Tag)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveTagsFromCertificate' {NonEmpty Tag
tags :: NonEmpty Tag
$sel:tags:RemoveTagsFromCertificate' :: RemoveTagsFromCertificate -> NonEmpty Tag
tags} -> NonEmpty Tag
tags) (\s :: RemoveTagsFromCertificate
s@RemoveTagsFromCertificate' {} NonEmpty Tag
a -> RemoveTagsFromCertificate
s {$sel:tags:RemoveTagsFromCertificate' :: NonEmpty Tag
tags = NonEmpty Tag
a} :: RemoveTagsFromCertificate) ((NonEmpty Tag -> f (NonEmpty Tag))
 -> RemoveTagsFromCertificate -> f RemoveTagsFromCertificate)
-> ((NonEmpty Tag -> f (NonEmpty Tag))
    -> NonEmpty Tag -> f (NonEmpty Tag))
-> (NonEmpty Tag -> f (NonEmpty Tag))
-> RemoveTagsFromCertificate
-> f RemoveTagsFromCertificate
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 RemoveTagsFromCertificate where
  type
    AWSResponse RemoveTagsFromCertificate =
      RemoveTagsFromCertificateResponse
  request :: RemoveTagsFromCertificate -> Request RemoveTagsFromCertificate
request = Service
-> RemoveTagsFromCertificate -> Request RemoveTagsFromCertificate
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RemoveTagsFromCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RemoveTagsFromCertificate)))
response =
    AWSResponse RemoveTagsFromCertificate
-> Logger
-> Service
-> Proxy RemoveTagsFromCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RemoveTagsFromCertificate)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse RemoveTagsFromCertificate
RemoveTagsFromCertificateResponse
RemoveTagsFromCertificateResponse'

instance Prelude.Hashable RemoveTagsFromCertificate

instance Prelude.NFData RemoveTagsFromCertificate

instance Core.ToHeaders RemoveTagsFromCertificate where
  toHeaders :: RemoveTagsFromCertificate -> [Header]
toHeaders =
    [Header] -> RemoveTagsFromCertificate -> [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
"CertificateManager.RemoveTagsFromCertificate" ::
                          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 RemoveTagsFromCertificate where
  toJSON :: RemoveTagsFromCertificate -> Value
toJSON RemoveTagsFromCertificate' {NonEmpty Tag
Text
tags :: NonEmpty Tag
certificateArn :: Text
$sel:tags:RemoveTagsFromCertificate' :: RemoveTagsFromCertificate -> NonEmpty Tag
$sel:certificateArn:RemoveTagsFromCertificate' :: RemoveTagsFromCertificate -> 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),
            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 RemoveTagsFromCertificate where
  toPath :: RemoveTagsFromCertificate -> ByteString
toPath = ByteString -> RemoveTagsFromCertificate -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

instance
  Prelude.NFData
    RemoveTagsFromCertificateResponse