{-# 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.ElastiCache.RemoveTagsFromResource
-- 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 the tags identified by the @TagKeys@ list from the named
-- resource. A tag is a key-value pair where the key and value are
-- case-sensitive. You can use tags to categorize and track all your
-- ElastiCache resources, with the exception of global replication group.
-- When you add or remove tags on replication groups, those actions will be
-- replicated to all nodes in the replication group. For more information,
-- see
-- <http://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/IAM.ResourceLevelPermissions.html Resource-level permissions>.
module Amazonka.ElastiCache.RemoveTagsFromResource
  ( -- * Creating a Request
    RemoveTagsFromResource (..),
    newRemoveTagsFromResource,

    -- * Request Lenses
    removeTagsFromResource_resourceName,
    removeTagsFromResource_tagKeys,

    -- * Destructuring the Response
    TagListMessage (..),
    newTagListMessage,

    -- * Response Lenses
    tagListMessage_tagList,
  )
where

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

-- | Represents the input of a @RemoveTagsFromResource@ operation.
--
-- /See:/ 'newRemoveTagsFromResource' smart constructor.
data RemoveTagsFromResource = RemoveTagsFromResource'
  { -- | The Amazon Resource Name (ARN) of the resource from which you want the
    -- tags removed, for example
    -- @arn:aws:elasticache:us-west-2:0123456789:cluster:myCluster@ or
    -- @arn:aws:elasticache:us-west-2:0123456789:snapshot:mySnapshot@.
    --
    -- For more information about ARNs, see
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs) and Amazon Service Namespaces>.
    RemoveTagsFromResource -> Text
resourceName :: Prelude.Text,
    -- | A list of @TagKeys@ identifying the tags you want removed from the named
    -- resource.
    RemoveTagsFromResource -> [Text]
tagKeys :: [Prelude.Text]
  }
  deriving (RemoveTagsFromResource -> RemoveTagsFromResource -> Bool
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]
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
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. 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:
--
-- 'resourceName', 'removeTagsFromResource_resourceName' - The Amazon Resource Name (ARN) of the resource from which you want the
-- tags removed, for example
-- @arn:aws:elasticache:us-west-2:0123456789:cluster:myCluster@ or
-- @arn:aws:elasticache:us-west-2:0123456789:snapshot:mySnapshot@.
--
-- For more information about ARNs, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs) and Amazon Service Namespaces>.
--
-- 'tagKeys', 'removeTagsFromResource_tagKeys' - A list of @TagKeys@ identifying the tags you want removed from the named
-- resource.
newRemoveTagsFromResource ::
  -- | 'resourceName'
  Prelude.Text ->
  RemoveTagsFromResource
newRemoveTagsFromResource :: Text -> RemoveTagsFromResource
newRemoveTagsFromResource Text
pResourceName_ =
  RemoveTagsFromResource'
    { $sel:resourceName:RemoveTagsFromResource' :: Text
resourceName =
        Text
pResourceName_,
      $sel:tagKeys:RemoveTagsFromResource' :: [Text]
tagKeys = forall a. Monoid a => a
Prelude.mempty
    }

-- | The Amazon Resource Name (ARN) of the resource from which you want the
-- tags removed, for example
-- @arn:aws:elasticache:us-west-2:0123456789:cluster:myCluster@ or
-- @arn:aws:elasticache:us-west-2:0123456789:snapshot:mySnapshot@.
--
-- For more information about ARNs, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs) and Amazon Service Namespaces>.
removeTagsFromResource_resourceName :: Lens.Lens' RemoveTagsFromResource Prelude.Text
removeTagsFromResource_resourceName :: Lens' RemoveTagsFromResource Text
removeTagsFromResource_resourceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveTagsFromResource' {Text
resourceName :: Text
$sel:resourceName:RemoveTagsFromResource' :: RemoveTagsFromResource -> Text
resourceName} -> Text
resourceName) (\s :: RemoveTagsFromResource
s@RemoveTagsFromResource' {} Text
a -> RemoveTagsFromResource
s {$sel:resourceName:RemoveTagsFromResource' :: Text
resourceName = Text
a} :: RemoveTagsFromResource)

-- | A list of @TagKeys@ identifying the tags you want removed from the named
-- resource.
removeTagsFromResource_tagKeys :: Lens.Lens' RemoveTagsFromResource [Prelude.Text]
removeTagsFromResource_tagKeys :: Lens' RemoveTagsFromResource [Text]
removeTagsFromResource_tagKeys = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveTagsFromResource' {[Text]
tagKeys :: [Text]
$sel:tagKeys:RemoveTagsFromResource' :: RemoveTagsFromResource -> [Text]
tagKeys} -> [Text]
tagKeys) (\s :: RemoveTagsFromResource
s@RemoveTagsFromResource' {} [Text]
a -> RemoveTagsFromResource
s {$sel:tagKeys:RemoveTagsFromResource' :: [Text]
tagKeys = [Text]
a} :: RemoveTagsFromResource) 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 RemoveTagsFromResource where
  type
    AWSResponse RemoveTagsFromResource =
      TagListMessage
  request :: (Service -> Service)
-> RemoveTagsFromResource -> Request RemoveTagsFromResource
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy RemoveTagsFromResource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RemoveTagsFromResource)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"RemoveTagsFromResourceResult"
      (\Int
s ResponseHeaders
h [Node]
x -> forall a. FromXML a => [Node] -> Either String a
Data.parseXML [Node]
x)

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

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

instance Data.ToHeaders RemoveTagsFromResource where
  toHeaders :: RemoveTagsFromResource -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery RemoveTagsFromResource where
  toQuery :: RemoveTagsFromResource -> QueryString
toQuery RemoveTagsFromResource' {[Text]
Text
tagKeys :: [Text]
resourceName :: Text
$sel:tagKeys:RemoveTagsFromResource' :: RemoveTagsFromResource -> [Text]
$sel:resourceName:RemoveTagsFromResource' :: RemoveTagsFromResource -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"RemoveTagsFromResource" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2015-02-02" :: Prelude.ByteString),
        ByteString
"ResourceName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
resourceName,
        ByteString
"TagKeys" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" [Text]
tagKeys
      ]