{-# 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.CloudHSM.RemoveTagsFromResource
-- 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)
--
-- This is documentation for __AWS CloudHSM Classic__. For more
-- information, see
-- <http://aws.amazon.com/cloudhsm/faqs-classic/ AWS CloudHSM Classic FAQs>,
-- the
-- <https://docs.aws.amazon.com/cloudhsm/classic/userguide/ AWS CloudHSM Classic User Guide>,
-- and the
-- <https://docs.aws.amazon.com/cloudhsm/classic/APIReference/ AWS CloudHSM Classic API Reference>.
--
-- __For information about the current version of AWS CloudHSM__, see
-- <http://aws.amazon.com/cloudhsm/ AWS CloudHSM>, the
-- <https://docs.aws.amazon.com/cloudhsm/latest/userguide/ AWS CloudHSM User Guide>,
-- and the
-- <https://docs.aws.amazon.com/cloudhsm/latest/APIReference/ AWS CloudHSM API Reference>.
--
-- Removes one or more tags from the specified AWS CloudHSM resource.
--
-- To remove a tag, specify only the tag key to remove (not the value). To
-- overwrite the value for an existing tag, use AddTagsToResource.
module Amazonka.CloudHSM.RemoveTagsFromResource
  ( -- * Creating a Request
    RemoveTagsFromResource (..),
    newRemoveTagsFromResource,

    -- * Request Lenses
    removeTagsFromResource_resourceArn,
    removeTagsFromResource_tagKeyList,

    -- * Destructuring the Response
    RemoveTagsFromResourceResponse (..),
    newRemoveTagsFromResourceResponse,

    -- * Response Lenses
    removeTagsFromResourceResponse_httpStatus,
    removeTagsFromResourceResponse_status,
  )
where

import Amazonka.CloudHSM.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:/ 'newRemoveTagsFromResource' smart constructor.
data RemoveTagsFromResource = RemoveTagsFromResource'
  { -- | The Amazon Resource Name (ARN) of the AWS CloudHSM resource.
    RemoveTagsFromResource -> Text
resourceArn :: Prelude.Text,
    -- | The tag key or keys to remove.
    --
    -- Specify only the tag key to remove (not the value). To overwrite the
    -- value for an existing tag, use AddTagsToResource.
    RemoveTagsFromResource -> [Text]
tagKeyList :: [Prelude.Text]
  }
  deriving (RemoveTagsFromResource -> RemoveTagsFromResource -> Bool
(RemoveTagsFromResource -> RemoveTagsFromResource -> Bool)
-> (RemoveTagsFromResource -> RemoveTagsFromResource -> Bool)
-> Eq RemoveTagsFromResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemoveTagsFromResource -> RemoveTagsFromResource -> Bool
$c/= :: RemoveTagsFromResource -> RemoveTagsFromResource -> Bool
== :: RemoveTagsFromResource -> RemoveTagsFromResource -> Bool
$c== :: RemoveTagsFromResource -> RemoveTagsFromResource -> Bool
Prelude.Eq, ReadPrec [RemoveTagsFromResource]
ReadPrec RemoveTagsFromResource
Int -> ReadS RemoveTagsFromResource
ReadS [RemoveTagsFromResource]
(Int -> ReadS RemoveTagsFromResource)
-> ReadS [RemoveTagsFromResource]
-> ReadPrec RemoveTagsFromResource
-> ReadPrec [RemoveTagsFromResource]
-> Read RemoveTagsFromResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemoveTagsFromResource]
$creadListPrec :: ReadPrec [RemoveTagsFromResource]
readPrec :: ReadPrec RemoveTagsFromResource
$creadPrec :: ReadPrec RemoveTagsFromResource
readList :: ReadS [RemoveTagsFromResource]
$creadList :: ReadS [RemoveTagsFromResource]
readsPrec :: Int -> ReadS RemoveTagsFromResource
$creadsPrec :: Int -> ReadS RemoveTagsFromResource
Prelude.Read, Int -> RemoveTagsFromResource -> ShowS
[RemoveTagsFromResource] -> ShowS
RemoveTagsFromResource -> String
(Int -> RemoveTagsFromResource -> ShowS)
-> (RemoveTagsFromResource -> String)
-> ([RemoveTagsFromResource] -> ShowS)
-> Show RemoveTagsFromResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemoveTagsFromResource] -> ShowS
$cshowList :: [RemoveTagsFromResource] -> ShowS
show :: RemoveTagsFromResource -> String
$cshow :: RemoveTagsFromResource -> String
showsPrec :: Int -> RemoveTagsFromResource -> ShowS
$cshowsPrec :: Int -> RemoveTagsFromResource -> ShowS
Prelude.Show, (forall x. RemoveTagsFromResource -> Rep RemoveTagsFromResource x)
-> (forall x.
    Rep RemoveTagsFromResource x -> RemoveTagsFromResource)
-> Generic RemoveTagsFromResource
forall x. Rep RemoveTagsFromResource x -> RemoveTagsFromResource
forall x. RemoveTagsFromResource -> Rep RemoveTagsFromResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RemoveTagsFromResource x -> RemoveTagsFromResource
$cfrom :: forall x. RemoveTagsFromResource -> Rep RemoveTagsFromResource x
Prelude.Generic)

-- |
-- Create a value of 'RemoveTagsFromResource' 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', 'removeTagsFromResource_resourceArn' - The Amazon Resource Name (ARN) of the AWS CloudHSM resource.
--
-- 'tagKeyList', 'removeTagsFromResource_tagKeyList' - The tag key or keys to remove.
--
-- Specify only the tag key to remove (not the value). To overwrite the
-- value for an existing tag, use AddTagsToResource.
newRemoveTagsFromResource ::
  -- | 'resourceArn'
  Prelude.Text ->
  RemoveTagsFromResource
newRemoveTagsFromResource :: Text -> RemoveTagsFromResource
newRemoveTagsFromResource Text
pResourceArn_ =
  RemoveTagsFromResource' :: Text -> [Text] -> RemoveTagsFromResource
RemoveTagsFromResource'
    { $sel:resourceArn:RemoveTagsFromResource' :: Text
resourceArn =
        Text
pResourceArn_,
      $sel:tagKeyList:RemoveTagsFromResource' :: [Text]
tagKeyList = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The Amazon Resource Name (ARN) of the AWS CloudHSM resource.
removeTagsFromResource_resourceArn :: Lens.Lens' RemoveTagsFromResource Prelude.Text
removeTagsFromResource_resourceArn :: (Text -> f Text)
-> RemoveTagsFromResource -> f RemoveTagsFromResource
removeTagsFromResource_resourceArn = (RemoveTagsFromResource -> Text)
-> (RemoveTagsFromResource -> Text -> RemoveTagsFromResource)
-> Lens RemoveTagsFromResource RemoveTagsFromResource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveTagsFromResource' {Text
resourceArn :: Text
$sel:resourceArn:RemoveTagsFromResource' :: RemoveTagsFromResource -> Text
resourceArn} -> Text
resourceArn) (\s :: RemoveTagsFromResource
s@RemoveTagsFromResource' {} Text
a -> RemoveTagsFromResource
s {$sel:resourceArn:RemoveTagsFromResource' :: Text
resourceArn = Text
a} :: RemoveTagsFromResource)

-- | The tag key or keys to remove.
--
-- Specify only the tag key to remove (not the value). To overwrite the
-- value for an existing tag, use AddTagsToResource.
removeTagsFromResource_tagKeyList :: Lens.Lens' RemoveTagsFromResource [Prelude.Text]
removeTagsFromResource_tagKeyList :: ([Text] -> f [Text])
-> RemoveTagsFromResource -> f RemoveTagsFromResource
removeTagsFromResource_tagKeyList = (RemoveTagsFromResource -> [Text])
-> (RemoveTagsFromResource -> [Text] -> RemoveTagsFromResource)
-> Lens RemoveTagsFromResource RemoveTagsFromResource [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveTagsFromResource' {[Text]
tagKeyList :: [Text]
$sel:tagKeyList:RemoveTagsFromResource' :: RemoveTagsFromResource -> [Text]
tagKeyList} -> [Text]
tagKeyList) (\s :: RemoveTagsFromResource
s@RemoveTagsFromResource' {} [Text]
a -> RemoveTagsFromResource
s {$sel:tagKeyList:RemoveTagsFromResource' :: [Text]
tagKeyList = [Text]
a} :: RemoveTagsFromResource) (([Text] -> f [Text])
 -> RemoveTagsFromResource -> f RemoveTagsFromResource)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> RemoveTagsFromResource
-> f RemoveTagsFromResource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest RemoveTagsFromResource where
  type
    AWSResponse RemoveTagsFromResource =
      RemoveTagsFromResourceResponse
  request :: RemoveTagsFromResource -> Request RemoveTagsFromResource
request = Service -> RemoveTagsFromResource -> Request RemoveTagsFromResource
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RemoveTagsFromResource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RemoveTagsFromResource)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse RemoveTagsFromResource))
-> Logger
-> Service
-> Proxy RemoveTagsFromResource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RemoveTagsFromResource)))
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 ->
          Int -> Text -> RemoveTagsFromResourceResponse
RemoveTagsFromResourceResponse'
            (Int -> Text -> RemoveTagsFromResourceResponse)
-> Either String Int
-> Either String (Text -> RemoveTagsFromResourceResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (Text -> RemoveTagsFromResourceResponse)
-> Either String Text
-> Either String RemoveTagsFromResourceResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"Status")
      )

instance Prelude.Hashable RemoveTagsFromResource

instance Prelude.NFData RemoveTagsFromResource

instance Core.ToHeaders RemoveTagsFromResource where
  toHeaders :: RemoveTagsFromResource -> ResponseHeaders
toHeaders =
    ResponseHeaders -> RemoveTagsFromResource -> 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
"CloudHsmFrontendService.RemoveTagsFromResource" ::
                          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 RemoveTagsFromResource where
  toJSON :: RemoveTagsFromResource -> Value
toJSON RemoveTagsFromResource' {[Text]
Text
tagKeyList :: [Text]
resourceArn :: Text
$sel:tagKeyList:RemoveTagsFromResource' :: RemoveTagsFromResource -> [Text]
$sel:resourceArn:RemoveTagsFromResource' :: RemoveTagsFromResource -> 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
"ResourceArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resourceArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TagKeyList" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
tagKeyList)
          ]
      )

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

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

-- | /See:/ 'newRemoveTagsFromResourceResponse' smart constructor.
data RemoveTagsFromResourceResponse = RemoveTagsFromResourceResponse'
  { -- | The response's http status code.
    RemoveTagsFromResourceResponse -> Int
httpStatus :: Prelude.Int,
    -- | The status of the operation.
    RemoveTagsFromResourceResponse -> Text
status :: Prelude.Text
  }
  deriving (RemoveTagsFromResourceResponse
-> RemoveTagsFromResourceResponse -> Bool
(RemoveTagsFromResourceResponse
 -> RemoveTagsFromResourceResponse -> Bool)
-> (RemoveTagsFromResourceResponse
    -> RemoveTagsFromResourceResponse -> Bool)
-> Eq RemoveTagsFromResourceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemoveTagsFromResourceResponse
-> RemoveTagsFromResourceResponse -> Bool
$c/= :: RemoveTagsFromResourceResponse
-> RemoveTagsFromResourceResponse -> Bool
== :: RemoveTagsFromResourceResponse
-> RemoveTagsFromResourceResponse -> Bool
$c== :: RemoveTagsFromResourceResponse
-> RemoveTagsFromResourceResponse -> Bool
Prelude.Eq, ReadPrec [RemoveTagsFromResourceResponse]
ReadPrec RemoveTagsFromResourceResponse
Int -> ReadS RemoveTagsFromResourceResponse
ReadS [RemoveTagsFromResourceResponse]
(Int -> ReadS RemoveTagsFromResourceResponse)
-> ReadS [RemoveTagsFromResourceResponse]
-> ReadPrec RemoveTagsFromResourceResponse
-> ReadPrec [RemoveTagsFromResourceResponse]
-> Read RemoveTagsFromResourceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemoveTagsFromResourceResponse]
$creadListPrec :: ReadPrec [RemoveTagsFromResourceResponse]
readPrec :: ReadPrec RemoveTagsFromResourceResponse
$creadPrec :: ReadPrec RemoveTagsFromResourceResponse
readList :: ReadS [RemoveTagsFromResourceResponse]
$creadList :: ReadS [RemoveTagsFromResourceResponse]
readsPrec :: Int -> ReadS RemoveTagsFromResourceResponse
$creadsPrec :: Int -> ReadS RemoveTagsFromResourceResponse
Prelude.Read, Int -> RemoveTagsFromResourceResponse -> ShowS
[RemoveTagsFromResourceResponse] -> ShowS
RemoveTagsFromResourceResponse -> String
(Int -> RemoveTagsFromResourceResponse -> ShowS)
-> (RemoveTagsFromResourceResponse -> String)
-> ([RemoveTagsFromResourceResponse] -> ShowS)
-> Show RemoveTagsFromResourceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemoveTagsFromResourceResponse] -> ShowS
$cshowList :: [RemoveTagsFromResourceResponse] -> ShowS
show :: RemoveTagsFromResourceResponse -> String
$cshow :: RemoveTagsFromResourceResponse -> String
showsPrec :: Int -> RemoveTagsFromResourceResponse -> ShowS
$cshowsPrec :: Int -> RemoveTagsFromResourceResponse -> ShowS
Prelude.Show, (forall x.
 RemoveTagsFromResourceResponse
 -> Rep RemoveTagsFromResourceResponse x)
-> (forall x.
    Rep RemoveTagsFromResourceResponse x
    -> RemoveTagsFromResourceResponse)
-> Generic RemoveTagsFromResourceResponse
forall x.
Rep RemoveTagsFromResourceResponse x
-> RemoveTagsFromResourceResponse
forall x.
RemoveTagsFromResourceResponse
-> Rep RemoveTagsFromResourceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RemoveTagsFromResourceResponse x
-> RemoveTagsFromResourceResponse
$cfrom :: forall x.
RemoveTagsFromResourceResponse
-> Rep RemoveTagsFromResourceResponse x
Prelude.Generic)

-- |
-- Create a value of 'RemoveTagsFromResourceResponse' 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:
--
-- 'httpStatus', 'removeTagsFromResourceResponse_httpStatus' - The response's http status code.
--
-- 'status', 'removeTagsFromResourceResponse_status' - The status of the operation.
newRemoveTagsFromResourceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'status'
  Prelude.Text ->
  RemoveTagsFromResourceResponse
newRemoveTagsFromResourceResponse :: Int -> Text -> RemoveTagsFromResourceResponse
newRemoveTagsFromResourceResponse
  Int
pHttpStatus_
  Text
pStatus_ =
    RemoveTagsFromResourceResponse' :: Int -> Text -> RemoveTagsFromResourceResponse
RemoveTagsFromResourceResponse'
      { $sel:httpStatus:RemoveTagsFromResourceResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:status:RemoveTagsFromResourceResponse' :: Text
status = Text
pStatus_
      }

-- | The response's http status code.
removeTagsFromResourceResponse_httpStatus :: Lens.Lens' RemoveTagsFromResourceResponse Prelude.Int
removeTagsFromResourceResponse_httpStatus :: (Int -> f Int)
-> RemoveTagsFromResourceResponse
-> f RemoveTagsFromResourceResponse
removeTagsFromResourceResponse_httpStatus = (RemoveTagsFromResourceResponse -> Int)
-> (RemoveTagsFromResourceResponse
    -> Int -> RemoveTagsFromResourceResponse)
-> Lens
     RemoveTagsFromResourceResponse
     RemoveTagsFromResourceResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveTagsFromResourceResponse' {Int
httpStatus :: Int
$sel:httpStatus:RemoveTagsFromResourceResponse' :: RemoveTagsFromResourceResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: RemoveTagsFromResourceResponse
s@RemoveTagsFromResourceResponse' {} Int
a -> RemoveTagsFromResourceResponse
s {$sel:httpStatus:RemoveTagsFromResourceResponse' :: Int
httpStatus = Int
a} :: RemoveTagsFromResourceResponse)

-- | The status of the operation.
removeTagsFromResourceResponse_status :: Lens.Lens' RemoveTagsFromResourceResponse Prelude.Text
removeTagsFromResourceResponse_status :: (Text -> f Text)
-> RemoveTagsFromResourceResponse
-> f RemoveTagsFromResourceResponse
removeTagsFromResourceResponse_status = (RemoveTagsFromResourceResponse -> Text)
-> (RemoveTagsFromResourceResponse
    -> Text -> RemoveTagsFromResourceResponse)
-> Lens
     RemoveTagsFromResourceResponse
     RemoveTagsFromResourceResponse
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveTagsFromResourceResponse' {Text
status :: Text
$sel:status:RemoveTagsFromResourceResponse' :: RemoveTagsFromResourceResponse -> Text
status} -> Text
status) (\s :: RemoveTagsFromResourceResponse
s@RemoveTagsFromResourceResponse' {} Text
a -> RemoveTagsFromResourceResponse
s {$sel:status:RemoveTagsFromResourceResponse' :: Text
status = Text
a} :: RemoveTagsFromResourceResponse)

instance
  Prelude.NFData
    RemoveTagsFromResourceResponse