{-# 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.CloudTrail.RemoveTags
-- 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 specified tags from a trail or event data store.
module Amazonka.CloudTrail.RemoveTags
  ( -- * Creating a Request
    RemoveTags (..),
    newRemoveTags,

    -- * Request Lenses
    removeTags_resourceId,
    removeTags_tagsList,

    -- * Destructuring the Response
    RemoveTagsResponse (..),
    newRemoveTagsResponse,

    -- * Response Lenses
    removeTagsResponse_httpStatus,
  )
where

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

-- | Specifies the tags to remove from a trail or event data store.
--
-- /See:/ 'newRemoveTags' smart constructor.
data RemoveTags = RemoveTags'
  { -- | Specifies the ARN of the trail or event data store from which tags
    -- should be removed.
    --
    -- Example trail ARN format:
    -- @arn:aws:cloudtrail:us-east-2:123456789012:trail\/MyTrail@
    --
    -- Example event data store ARN format:
    -- @arn:aws:cloudtrail:us-east-2:12345678910:eventdatastore\/EXAMPLE-f852-4e8f-8bd1-bcf6cEXAMPLE@
    RemoveTags -> Text
resourceId :: Prelude.Text,
    -- | Specifies a list of tags to be removed.
    RemoveTags -> [Tag]
tagsList :: [Tag]
  }
  deriving (RemoveTags -> RemoveTags -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemoveTags -> RemoveTags -> Bool
$c/= :: RemoveTags -> RemoveTags -> Bool
== :: RemoveTags -> RemoveTags -> Bool
$c== :: RemoveTags -> RemoveTags -> Bool
Prelude.Eq, ReadPrec [RemoveTags]
ReadPrec RemoveTags
Int -> ReadS RemoveTags
ReadS [RemoveTags]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemoveTags]
$creadListPrec :: ReadPrec [RemoveTags]
readPrec :: ReadPrec RemoveTags
$creadPrec :: ReadPrec RemoveTags
readList :: ReadS [RemoveTags]
$creadList :: ReadS [RemoveTags]
readsPrec :: Int -> ReadS RemoveTags
$creadsPrec :: Int -> ReadS RemoveTags
Prelude.Read, Int -> RemoveTags -> ShowS
[RemoveTags] -> ShowS
RemoveTags -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemoveTags] -> ShowS
$cshowList :: [RemoveTags] -> ShowS
show :: RemoveTags -> String
$cshow :: RemoveTags -> String
showsPrec :: Int -> RemoveTags -> ShowS
$cshowsPrec :: Int -> RemoveTags -> ShowS
Prelude.Show, forall x. Rep RemoveTags x -> RemoveTags
forall x. RemoveTags -> Rep RemoveTags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RemoveTags x -> RemoveTags
$cfrom :: forall x. RemoveTags -> Rep RemoveTags x
Prelude.Generic)

-- |
-- Create a value of 'RemoveTags' 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:
--
-- 'resourceId', 'removeTags_resourceId' - Specifies the ARN of the trail or event data store from which tags
-- should be removed.
--
-- Example trail ARN format:
-- @arn:aws:cloudtrail:us-east-2:123456789012:trail\/MyTrail@
--
-- Example event data store ARN format:
-- @arn:aws:cloudtrail:us-east-2:12345678910:eventdatastore\/EXAMPLE-f852-4e8f-8bd1-bcf6cEXAMPLE@
--
-- 'tagsList', 'removeTags_tagsList' - Specifies a list of tags to be removed.
newRemoveTags ::
  -- | 'resourceId'
  Prelude.Text ->
  RemoveTags
newRemoveTags :: Text -> RemoveTags
newRemoveTags Text
pResourceId_ =
  RemoveTags'
    { $sel:resourceId:RemoveTags' :: Text
resourceId = Text
pResourceId_,
      $sel:tagsList:RemoveTags' :: [Tag]
tagsList = forall a. Monoid a => a
Prelude.mempty
    }

-- | Specifies the ARN of the trail or event data store from which tags
-- should be removed.
--
-- Example trail ARN format:
-- @arn:aws:cloudtrail:us-east-2:123456789012:trail\/MyTrail@
--
-- Example event data store ARN format:
-- @arn:aws:cloudtrail:us-east-2:12345678910:eventdatastore\/EXAMPLE-f852-4e8f-8bd1-bcf6cEXAMPLE@
removeTags_resourceId :: Lens.Lens' RemoveTags Prelude.Text
removeTags_resourceId :: Lens' RemoveTags Text
removeTags_resourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveTags' {Text
resourceId :: Text
$sel:resourceId:RemoveTags' :: RemoveTags -> Text
resourceId} -> Text
resourceId) (\s :: RemoveTags
s@RemoveTags' {} Text
a -> RemoveTags
s {$sel:resourceId:RemoveTags' :: Text
resourceId = Text
a} :: RemoveTags)

-- | Specifies a list of tags to be removed.
removeTags_tagsList :: Lens.Lens' RemoveTags [Tag]
removeTags_tagsList :: Lens' RemoveTags [Tag]
removeTags_tagsList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveTags' {[Tag]
tagsList :: [Tag]
$sel:tagsList:RemoveTags' :: RemoveTags -> [Tag]
tagsList} -> [Tag]
tagsList) (\s :: RemoveTags
s@RemoveTags' {} [Tag]
a -> RemoveTags
s {$sel:tagsList:RemoveTags' :: [Tag]
tagsList = [Tag]
a} :: RemoveTags) 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 RemoveTags where
  type AWSResponse RemoveTags = RemoveTagsResponse
  request :: (Service -> Service) -> RemoveTags -> Request RemoveTags
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 RemoveTags
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RemoveTags)))
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 -> RemoveTagsResponse
RemoveTagsResponse'
            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 RemoveTags where
  hashWithSalt :: Int -> RemoveTags -> Int
hashWithSalt Int
_salt RemoveTags' {[Tag]
Text
tagsList :: [Tag]
resourceId :: Text
$sel:tagsList:RemoveTags' :: RemoveTags -> [Tag]
$sel:resourceId:RemoveTags' :: RemoveTags -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Tag]
tagsList

instance Prelude.NFData RemoveTags where
  rnf :: RemoveTags -> ()
rnf RemoveTags' {[Tag]
Text
tagsList :: [Tag]
resourceId :: Text
$sel:tagsList:RemoveTags' :: RemoveTags -> [Tag]
$sel:resourceId:RemoveTags' :: RemoveTags -> Text
..} =
    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 [Tag]
tagsList

instance Data.ToHeaders RemoveTags where
  toHeaders :: RemoveTags -> 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
"com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101.RemoveTags" ::
                          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 RemoveTags where
  toJSON :: RemoveTags -> Value
toJSON RemoveTags' {[Tag]
Text
tagsList :: [Tag]
resourceId :: Text
$sel:tagsList:RemoveTags' :: RemoveTags -> [Tag]
$sel:resourceId:RemoveTags' :: RemoveTags -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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
"TagsList" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Tag]
tagsList)
          ]
      )

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

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

-- | Returns the objects or data listed below if successful. Otherwise,
-- returns an error.
--
-- /See:/ 'newRemoveTagsResponse' smart constructor.
data RemoveTagsResponse = RemoveTagsResponse'
  { -- | The response's http status code.
    RemoveTagsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (RemoveTagsResponse -> RemoveTagsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemoveTagsResponse -> RemoveTagsResponse -> Bool
$c/= :: RemoveTagsResponse -> RemoveTagsResponse -> Bool
== :: RemoveTagsResponse -> RemoveTagsResponse -> Bool
$c== :: RemoveTagsResponse -> RemoveTagsResponse -> Bool
Prelude.Eq, ReadPrec [RemoveTagsResponse]
ReadPrec RemoveTagsResponse
Int -> ReadS RemoveTagsResponse
ReadS [RemoveTagsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemoveTagsResponse]
$creadListPrec :: ReadPrec [RemoveTagsResponse]
readPrec :: ReadPrec RemoveTagsResponse
$creadPrec :: ReadPrec RemoveTagsResponse
readList :: ReadS [RemoveTagsResponse]
$creadList :: ReadS [RemoveTagsResponse]
readsPrec :: Int -> ReadS RemoveTagsResponse
$creadsPrec :: Int -> ReadS RemoveTagsResponse
Prelude.Read, Int -> RemoveTagsResponse -> ShowS
[RemoveTagsResponse] -> ShowS
RemoveTagsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemoveTagsResponse] -> ShowS
$cshowList :: [RemoveTagsResponse] -> ShowS
show :: RemoveTagsResponse -> String
$cshow :: RemoveTagsResponse -> String
showsPrec :: Int -> RemoveTagsResponse -> ShowS
$cshowsPrec :: Int -> RemoveTagsResponse -> ShowS
Prelude.Show, forall x. Rep RemoveTagsResponse x -> RemoveTagsResponse
forall x. RemoveTagsResponse -> Rep RemoveTagsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RemoveTagsResponse x -> RemoveTagsResponse
$cfrom :: forall x. RemoveTagsResponse -> Rep RemoveTagsResponse x
Prelude.Generic)

-- |
-- Create a value of 'RemoveTagsResponse' 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', 'removeTagsResponse_httpStatus' - The response's http status code.
newRemoveTagsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RemoveTagsResponse
newRemoveTagsResponse :: Int -> RemoveTagsResponse
newRemoveTagsResponse Int
pHttpStatus_ =
  RemoveTagsResponse' {$sel:httpStatus:RemoveTagsResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

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