{-# 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.SecretsManager.UntagResource
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Removes specific tags from a secret.
--
-- This operation is idempotent. If a requested tag is not attached to the
-- secret, no error is returned and the secret metadata is unchanged.
--
-- If you use tags as part of your security strategy, then removing a tag
-- can change permissions. If successfully completing this operation would
-- result in you losing your permissions for this secret, then the
-- operation is blocked and returns an Access Denied error.
--
-- Secrets Manager generates a CloudTrail log entry when you call this
-- action. Do not include sensitive information in request parameters
-- because it might be logged. For more information, see
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/retrieve-ct-entries.html Logging Secrets Manager events with CloudTrail>.
--
-- __Required permissions:__ @secretsmanager:UntagResource@. For more
-- information, see
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/reference_iam-permissions.html#reference_iam-permissions_actions IAM policy actions for Secrets Manager>
-- and
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access.html Authentication and access control in Secrets Manager>.
module Amazonka.SecretsManager.UntagResource
  ( -- * Creating a Request
    UntagResource (..),
    newUntagResource,

    -- * Request Lenses
    untagResource_secretId,
    untagResource_tagKeys,

    -- * Destructuring the Response
    UntagResourceResponse (..),
    newUntagResourceResponse,
  )
where

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
import Amazonka.SecretsManager.Types

-- | /See:/ 'newUntagResource' smart constructor.
data UntagResource = UntagResource'
  { -- | The ARN or name of the secret.
    --
    -- For an ARN, we recommend that you specify a complete ARN rather than a
    -- partial ARN. See
    -- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/troubleshoot.html#ARN_secretnamehyphen Finding a secret from a partial ARN>.
    UntagResource -> Text
secretId :: Prelude.Text,
    -- | A list of tag key names to remove from the secret. You don\'t specify
    -- the value. Both the key and its associated value are removed.
    --
    -- This parameter requires a JSON text string argument.
    --
    -- For storing multiple values, we recommend that you use a JSON text
    -- string argument and specify key\/value pairs. For more information, see
    -- <https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-parameters.html Specifying parameter values for the Amazon Web Services CLI>
    -- in the Amazon Web Services CLI User Guide.
    UntagResource -> [Text]
tagKeys :: [Prelude.Text]
  }
  deriving (UntagResource -> UntagResource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UntagResource -> UntagResource -> Bool
$c/= :: UntagResource -> UntagResource -> Bool
== :: UntagResource -> UntagResource -> Bool
$c== :: UntagResource -> UntagResource -> Bool
Prelude.Eq, ReadPrec [UntagResource]
ReadPrec UntagResource
Int -> ReadS UntagResource
ReadS [UntagResource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UntagResource]
$creadListPrec :: ReadPrec [UntagResource]
readPrec :: ReadPrec UntagResource
$creadPrec :: ReadPrec UntagResource
readList :: ReadS [UntagResource]
$creadList :: ReadS [UntagResource]
readsPrec :: Int -> ReadS UntagResource
$creadsPrec :: Int -> ReadS UntagResource
Prelude.Read, Int -> UntagResource -> ShowS
[UntagResource] -> ShowS
UntagResource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UntagResource] -> ShowS
$cshowList :: [UntagResource] -> ShowS
show :: UntagResource -> String
$cshow :: UntagResource -> String
showsPrec :: Int -> UntagResource -> ShowS
$cshowsPrec :: Int -> UntagResource -> ShowS
Prelude.Show, forall x. Rep UntagResource x -> UntagResource
forall x. UntagResource -> Rep UntagResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UntagResource x -> UntagResource
$cfrom :: forall x. UntagResource -> Rep UntagResource x
Prelude.Generic)

-- |
-- Create a value of 'UntagResource' 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:
--
-- 'secretId', 'untagResource_secretId' - The ARN or name of the secret.
--
-- For an ARN, we recommend that you specify a complete ARN rather than a
-- partial ARN. See
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/troubleshoot.html#ARN_secretnamehyphen Finding a secret from a partial ARN>.
--
-- 'tagKeys', 'untagResource_tagKeys' - A list of tag key names to remove from the secret. You don\'t specify
-- the value. Both the key and its associated value are removed.
--
-- This parameter requires a JSON text string argument.
--
-- For storing multiple values, we recommend that you use a JSON text
-- string argument and specify key\/value pairs. For more information, see
-- <https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-parameters.html Specifying parameter values for the Amazon Web Services CLI>
-- in the Amazon Web Services CLI User Guide.
newUntagResource ::
  -- | 'secretId'
  Prelude.Text ->
  UntagResource
newUntagResource :: Text -> UntagResource
newUntagResource Text
pSecretId_ =
  UntagResource'
    { $sel:secretId:UntagResource' :: Text
secretId = Text
pSecretId_,
      $sel:tagKeys:UntagResource' :: [Text]
tagKeys = forall a. Monoid a => a
Prelude.mempty
    }

-- | The ARN or name of the secret.
--
-- For an ARN, we recommend that you specify a complete ARN rather than a
-- partial ARN. See
-- <https://docs.aws.amazon.com/secretsmanager/latest/userguide/troubleshoot.html#ARN_secretnamehyphen Finding a secret from a partial ARN>.
untagResource_secretId :: Lens.Lens' UntagResource Prelude.Text
untagResource_secretId :: Lens' UntagResource Text
untagResource_secretId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UntagResource' {Text
secretId :: Text
$sel:secretId:UntagResource' :: UntagResource -> Text
secretId} -> Text
secretId) (\s :: UntagResource
s@UntagResource' {} Text
a -> UntagResource
s {$sel:secretId:UntagResource' :: Text
secretId = Text
a} :: UntagResource)

-- | A list of tag key names to remove from the secret. You don\'t specify
-- the value. Both the key and its associated value are removed.
--
-- This parameter requires a JSON text string argument.
--
-- For storing multiple values, we recommend that you use a JSON text
-- string argument and specify key\/value pairs. For more information, see
-- <https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-parameters.html Specifying parameter values for the Amazon Web Services CLI>
-- in the Amazon Web Services CLI User Guide.
untagResource_tagKeys :: Lens.Lens' UntagResource [Prelude.Text]
untagResource_tagKeys :: Lens' UntagResource [Text]
untagResource_tagKeys = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UntagResource' {[Text]
tagKeys :: [Text]
$sel:tagKeys:UntagResource' :: UntagResource -> [Text]
tagKeys} -> [Text]
tagKeys) (\s :: UntagResource
s@UntagResource' {} [Text]
a -> UntagResource
s {$sel:tagKeys:UntagResource' :: [Text]
tagKeys = [Text]
a} :: UntagResource) 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 UntagResource where
  type
    AWSResponse UntagResource =
      UntagResourceResponse
  request :: (Service -> Service) -> UntagResource -> Request UntagResource
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 UntagResource
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UntagResource)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull UntagResourceResponse
UntagResourceResponse'

instance Prelude.Hashable UntagResource where
  hashWithSalt :: Int -> UntagResource -> Int
hashWithSalt Int
_salt UntagResource' {[Text]
Text
tagKeys :: [Text]
secretId :: Text
$sel:tagKeys:UntagResource' :: UntagResource -> [Text]
$sel:secretId:UntagResource' :: UntagResource -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
secretId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
tagKeys

instance Prelude.NFData UntagResource where
  rnf :: UntagResource -> ()
rnf UntagResource' {[Text]
Text
tagKeys :: [Text]
secretId :: Text
$sel:tagKeys:UntagResource' :: UntagResource -> [Text]
$sel:secretId:UntagResource' :: UntagResource -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
secretId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
tagKeys

instance Data.ToHeaders UntagResource where
  toHeaders :: UntagResource -> [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
"secretsmanager.UntagResource" ::
                          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 UntagResource where
  toJSON :: UntagResource -> Value
toJSON UntagResource' {[Text]
Text
tagKeys :: [Text]
secretId :: Text
$sel:tagKeys:UntagResource' :: UntagResource -> [Text]
$sel:secretId:UntagResource' :: UntagResource -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"SecretId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
secretId),
            forall a. a -> Maybe a
Prelude.Just (Key
"TagKeys" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
tagKeys)
          ]
      )

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

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

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

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

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