{-# 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.SSM.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 tag keys from the specified resource.
module Amazonka.SSM.RemoveTagsFromResource
  ( -- * Creating a Request
    RemoveTagsFromResource (..),
    newRemoveTagsFromResource,

    -- * Request Lenses
    removeTagsFromResource_resourceType,
    removeTagsFromResource_resourceId,
    removeTagsFromResource_tagKeys,

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

    -- * Response Lenses
    removeTagsFromResourceResponse_httpStatus,
  )
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.SSM.Types

-- | /See:/ 'newRemoveTagsFromResource' smart constructor.
data RemoveTagsFromResource = RemoveTagsFromResource'
  { -- | The type of resource from which you want to remove a tag.
    --
    -- The @ManagedInstance@ type for this API operation is only for
    -- on-premises managed nodes. Specify the name of the managed node in the
    -- following format: @mi-@/@ID_number@/@ @. For example, @mi-1a2b3c4d5e6f@.
    RemoveTagsFromResource -> ResourceTypeForTagging
resourceType :: ResourceTypeForTagging,
    -- | The ID of the resource from which you want to remove tags. For example:
    --
    -- ManagedInstance: mi-012345abcde
    --
    -- MaintenanceWindow: mw-012345abcde
    --
    -- @Automation@: @example-c160-4567-8519-012345abcde@
    --
    -- PatchBaseline: pb-012345abcde
    --
    -- OpsMetadata object: @ResourceID@ for tagging is created from the Amazon
    -- Resource Name (ARN) for the object. Specifically, @ResourceID@ is
    -- created from the strings that come after the word @opsmetadata@ in the
    -- ARN. For example, an OpsMetadata object with an ARN of
    -- @arn:aws:ssm:us-east-2:1234567890:opsmetadata\/aws\/ssm\/MyGroup\/appmanager@
    -- has a @ResourceID@ of either @aws\/ssm\/MyGroup\/appmanager@ or
    -- @\/aws\/ssm\/MyGroup\/appmanager@.
    --
    -- For the Document and Parameter values, use the name of the resource.
    --
    -- The @ManagedInstance@ type for this API operation is only for
    -- on-premises managed nodes. Specify the name of the managed node in the
    -- following format: mi-ID_number. For example, mi-1a2b3c4d5e6f.
    RemoveTagsFromResource -> Text
resourceId :: Prelude.Text,
    -- | Tag keys that you want to remove from the specified 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:
--
-- 'resourceType', 'removeTagsFromResource_resourceType' - The type of resource from which you want to remove a tag.
--
-- The @ManagedInstance@ type for this API operation is only for
-- on-premises managed nodes. Specify the name of the managed node in the
-- following format: @mi-@/@ID_number@/@ @. For example, @mi-1a2b3c4d5e6f@.
--
-- 'resourceId', 'removeTagsFromResource_resourceId' - The ID of the resource from which you want to remove tags. For example:
--
-- ManagedInstance: mi-012345abcde
--
-- MaintenanceWindow: mw-012345abcde
--
-- @Automation@: @example-c160-4567-8519-012345abcde@
--
-- PatchBaseline: pb-012345abcde
--
-- OpsMetadata object: @ResourceID@ for tagging is created from the Amazon
-- Resource Name (ARN) for the object. Specifically, @ResourceID@ is
-- created from the strings that come after the word @opsmetadata@ in the
-- ARN. For example, an OpsMetadata object with an ARN of
-- @arn:aws:ssm:us-east-2:1234567890:opsmetadata\/aws\/ssm\/MyGroup\/appmanager@
-- has a @ResourceID@ of either @aws\/ssm\/MyGroup\/appmanager@ or
-- @\/aws\/ssm\/MyGroup\/appmanager@.
--
-- For the Document and Parameter values, use the name of the resource.
--
-- The @ManagedInstance@ type for this API operation is only for
-- on-premises managed nodes. Specify the name of the managed node in the
-- following format: mi-ID_number. For example, mi-1a2b3c4d5e6f.
--
-- 'tagKeys', 'removeTagsFromResource_tagKeys' - Tag keys that you want to remove from the specified resource.
newRemoveTagsFromResource ::
  -- | 'resourceType'
  ResourceTypeForTagging ->
  -- | 'resourceId'
  Prelude.Text ->
  RemoveTagsFromResource
newRemoveTagsFromResource :: ResourceTypeForTagging -> Text -> RemoveTagsFromResource
newRemoveTagsFromResource ResourceTypeForTagging
pResourceType_ Text
pResourceId_ =
  RemoveTagsFromResource'
    { $sel:resourceType:RemoveTagsFromResource' :: ResourceTypeForTagging
resourceType =
        ResourceTypeForTagging
pResourceType_,
      $sel:resourceId:RemoveTagsFromResource' :: Text
resourceId = Text
pResourceId_,
      $sel:tagKeys:RemoveTagsFromResource' :: [Text]
tagKeys = forall a. Monoid a => a
Prelude.mempty
    }

-- | The type of resource from which you want to remove a tag.
--
-- The @ManagedInstance@ type for this API operation is only for
-- on-premises managed nodes. Specify the name of the managed node in the
-- following format: @mi-@/@ID_number@/@ @. For example, @mi-1a2b3c4d5e6f@.
removeTagsFromResource_resourceType :: Lens.Lens' RemoveTagsFromResource ResourceTypeForTagging
removeTagsFromResource_resourceType :: Lens' RemoveTagsFromResource ResourceTypeForTagging
removeTagsFromResource_resourceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveTagsFromResource' {ResourceTypeForTagging
resourceType :: ResourceTypeForTagging
$sel:resourceType:RemoveTagsFromResource' :: RemoveTagsFromResource -> ResourceTypeForTagging
resourceType} -> ResourceTypeForTagging
resourceType) (\s :: RemoveTagsFromResource
s@RemoveTagsFromResource' {} ResourceTypeForTagging
a -> RemoveTagsFromResource
s {$sel:resourceType:RemoveTagsFromResource' :: ResourceTypeForTagging
resourceType = ResourceTypeForTagging
a} :: RemoveTagsFromResource)

-- | The ID of the resource from which you want to remove tags. For example:
--
-- ManagedInstance: mi-012345abcde
--
-- MaintenanceWindow: mw-012345abcde
--
-- @Automation@: @example-c160-4567-8519-012345abcde@
--
-- PatchBaseline: pb-012345abcde
--
-- OpsMetadata object: @ResourceID@ for tagging is created from the Amazon
-- Resource Name (ARN) for the object. Specifically, @ResourceID@ is
-- created from the strings that come after the word @opsmetadata@ in the
-- ARN. For example, an OpsMetadata object with an ARN of
-- @arn:aws:ssm:us-east-2:1234567890:opsmetadata\/aws\/ssm\/MyGroup\/appmanager@
-- has a @ResourceID@ of either @aws\/ssm\/MyGroup\/appmanager@ or
-- @\/aws\/ssm\/MyGroup\/appmanager@.
--
-- For the Document and Parameter values, use the name of the resource.
--
-- The @ManagedInstance@ type for this API operation is only for
-- on-premises managed nodes. Specify the name of the managed node in the
-- following format: mi-ID_number. For example, mi-1a2b3c4d5e6f.
removeTagsFromResource_resourceId :: Lens.Lens' RemoveTagsFromResource Prelude.Text
removeTagsFromResource_resourceId :: Lens' RemoveTagsFromResource Text
removeTagsFromResource_resourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveTagsFromResource' {Text
resourceId :: Text
$sel:resourceId:RemoveTagsFromResource' :: RemoveTagsFromResource -> Text
resourceId} -> Text
resourceId) (\s :: RemoveTagsFromResource
s@RemoveTagsFromResource' {} Text
a -> RemoveTagsFromResource
s {$sel:resourceId:RemoveTagsFromResource' :: Text
resourceId = Text
a} :: RemoveTagsFromResource)

-- | Tag keys that you want to remove from the specified 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 =
      RemoveTagsFromResourceResponse
  request :: (Service -> Service)
-> RemoveTagsFromResource -> Request RemoveTagsFromResource
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 RemoveTagsFromResource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RemoveTagsFromResource)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> RemoveTagsFromResourceResponse
RemoveTagsFromResourceResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

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

instance Prelude.NFData RemoveTagsFromResource where
  rnf :: RemoveTagsFromResource -> ()
rnf RemoveTagsFromResource' {[Text]
Text
ResourceTypeForTagging
tagKeys :: [Text]
resourceId :: Text
resourceType :: ResourceTypeForTagging
$sel:tagKeys:RemoveTagsFromResource' :: RemoveTagsFromResource -> [Text]
$sel:resourceId:RemoveTagsFromResource' :: RemoveTagsFromResource -> Text
$sel:resourceType:RemoveTagsFromResource' :: RemoveTagsFromResource -> ResourceTypeForTagging
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ResourceTypeForTagging
resourceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
resourceId
      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] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AmazonSSM.RemoveTagsFromResource" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON RemoveTagsFromResource where
  toJSON :: RemoveTagsFromResource -> Value
toJSON RemoveTagsFromResource' {[Text]
Text
ResourceTypeForTagging
tagKeys :: [Text]
resourceId :: Text
resourceType :: ResourceTypeForTagging
$sel:tagKeys:RemoveTagsFromResource' :: RemoveTagsFromResource -> [Text]
$sel:resourceId:RemoveTagsFromResource' :: RemoveTagsFromResource -> Text
$sel:resourceType:RemoveTagsFromResource' :: RemoveTagsFromResource -> ResourceTypeForTagging
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"ResourceType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ResourceTypeForTagging
resourceType),
            forall a. a -> Maybe a
Prelude.Just (Key
"ResourceId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
resourceId),
            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 RemoveTagsFromResource where
  toPath :: RemoveTagsFromResource -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery RemoveTagsFromResource where
  toQuery :: RemoveTagsFromResource -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
  }
  deriving (RemoveTagsFromResourceResponse
-> RemoveTagsFromResourceResponse -> Bool
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]
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
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.
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.
newRemoveTagsFromResourceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RemoveTagsFromResourceResponse
newRemoveTagsFromResourceResponse :: Int -> RemoveTagsFromResourceResponse
newRemoveTagsFromResourceResponse Int
pHttpStatus_ =
  RemoveTagsFromResourceResponse'
    { $sel:httpStatus:RemoveTagsFromResourceResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
removeTagsFromResourceResponse_httpStatus :: Lens.Lens' RemoveTagsFromResourceResponse Prelude.Int
removeTagsFromResourceResponse_httpStatus :: Lens' RemoveTagsFromResourceResponse Int
removeTagsFromResourceResponse_httpStatus = 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)

instance
  Prelude.NFData
    RemoveTagsFromResourceResponse
  where
  rnf :: RemoveTagsFromResourceResponse -> ()
rnf RemoveTagsFromResourceResponse' {Int
httpStatus :: Int
$sel:httpStatus:RemoveTagsFromResourceResponse' :: RemoveTagsFromResourceResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus