amazonka-kms-2.0: gen/Amazonka/KMS/UntagResource.hs
{-# 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.KMS.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)
--
-- Deletes tags from a
-- <https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#customer-cmk customer managed key>.
-- To delete a tag, specify the tag key and the KMS key.
--
-- Tagging or untagging a KMS key can allow or deny permission to the KMS
-- key. For details, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/abac.html ABAC for KMS>
-- in the /Key Management Service Developer Guide/.
--
-- When it succeeds, the @UntagResource@ operation doesn\'t return any
-- output. Also, if the specified tag key isn\'t found on the KMS key, it
-- doesn\'t throw an exception or return a response. To confirm that the
-- operation worked, use the ListResourceTags operation.
--
-- For information about using tags in KMS, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/tagging-keys.html Tagging keys>.
-- For general information about tags, including the format and syntax, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html Tagging Amazon Web Services resources>
-- in the /Amazon Web Services General Reference/.
--
-- The KMS key that you use for this operation must be in a compatible key
-- state. For details, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/key-state.html Key states of KMS keys>
-- in the /Key Management Service Developer Guide/.
--
-- __Cross-account use__: No. You cannot perform this operation on a KMS
-- key in a different Amazon Web Services account.
--
-- __Required permissions__:
-- <https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html kms:UntagResource>
-- (key policy)
--
-- __Related operations__
--
-- - CreateKey
--
-- - ListResourceTags
--
-- - ReplicateKey
--
-- - TagResource
module Amazonka.KMS.UntagResource
( -- * Creating a Request
UntagResource (..),
newUntagResource,
-- * Request Lenses
untagResource_keyId,
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 Amazonka.KMS.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
-- | /See:/ 'newUntagResource' smart constructor.
data UntagResource = UntagResource'
{ -- | Identifies the KMS key from which you are removing tags.
--
-- Specify the key ID or key ARN of the KMS key.
--
-- For example:
--
-- - Key ID: @1234abcd-12ab-34cd-56ef-1234567890ab@
--
-- - Key ARN:
-- @arn:aws:kms:us-east-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab@
--
-- To get the key ID and key ARN for a KMS key, use ListKeys or
-- DescribeKey.
keyId :: Prelude.Text,
-- | One or more tag keys. Specify only the tag keys, not the tag values.
tagKeys :: [Prelude.Text]
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, 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:
--
-- 'keyId', 'untagResource_keyId' - Identifies the KMS key from which you are removing tags.
--
-- Specify the key ID or key ARN of the KMS key.
--
-- For example:
--
-- - Key ID: @1234abcd-12ab-34cd-56ef-1234567890ab@
--
-- - Key ARN:
-- @arn:aws:kms:us-east-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab@
--
-- To get the key ID and key ARN for a KMS key, use ListKeys or
-- DescribeKey.
--
-- 'tagKeys', 'untagResource_tagKeys' - One or more tag keys. Specify only the tag keys, not the tag values.
newUntagResource ::
-- | 'keyId'
Prelude.Text ->
UntagResource
newUntagResource pKeyId_ =
UntagResource'
{ keyId = pKeyId_,
tagKeys = Prelude.mempty
}
-- | Identifies the KMS key from which you are removing tags.
--
-- Specify the key ID or key ARN of the KMS key.
--
-- For example:
--
-- - Key ID: @1234abcd-12ab-34cd-56ef-1234567890ab@
--
-- - Key ARN:
-- @arn:aws:kms:us-east-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab@
--
-- To get the key ID and key ARN for a KMS key, use ListKeys or
-- DescribeKey.
untagResource_keyId :: Lens.Lens' UntagResource Prelude.Text
untagResource_keyId = Lens.lens (\UntagResource' {keyId} -> keyId) (\s@UntagResource' {} a -> s {keyId = a} :: UntagResource)
-- | One or more tag keys. Specify only the tag keys, not the tag values.
untagResource_tagKeys :: Lens.Lens' UntagResource [Prelude.Text]
untagResource_tagKeys = Lens.lens (\UntagResource' {tagKeys} -> tagKeys) (\s@UntagResource' {} a -> s {tagKeys = a} :: UntagResource) Prelude.. Lens.coerced
instance Core.AWSRequest UntagResource where
type
AWSResponse UntagResource =
UntagResourceResponse
request overrides =
Request.postJSON (overrides defaultService)
response =
Response.receiveNull UntagResourceResponse'
instance Prelude.Hashable UntagResource where
hashWithSalt _salt UntagResource' {..} =
_salt
`Prelude.hashWithSalt` keyId
`Prelude.hashWithSalt` tagKeys
instance Prelude.NFData UntagResource where
rnf UntagResource' {..} =
Prelude.rnf keyId `Prelude.seq` Prelude.rnf tagKeys
instance Data.ToHeaders UntagResource where
toHeaders =
Prelude.const
( Prelude.mconcat
[ "X-Amz-Target"
Data.=# ("TrentService.UntagResource" :: Prelude.ByteString),
"Content-Type"
Data.=# ( "application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON UntagResource where
toJSON UntagResource' {..} =
Data.object
( Prelude.catMaybes
[ Prelude.Just ("KeyId" Data..= keyId),
Prelude.Just ("TagKeys" Data..= tagKeys)
]
)
instance Data.ToPath UntagResource where
toPath = Prelude.const "/"
instance Data.ToQuery UntagResource where
toQuery = Prelude.const Prelude.mempty
-- | /See:/ 'newUntagResourceResponse' smart constructor.
data UntagResourceResponse = UntagResourceResponse'
{
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, 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'
instance Prelude.NFData UntagResourceResponse where
rnf _ = ()