{-# 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.DeleteTrail
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes a trail. This operation must be called from the region in which
-- the trail was created. @DeleteTrail@ cannot be called on the shadow
-- trails (replicated trails in other regions) of a trail that is enabled
-- in all regions.
module Amazonka.CloudTrail.DeleteTrail
  ( -- * Creating a Request
    DeleteTrail (..),
    newDeleteTrail,

    -- * Request Lenses
    deleteTrail_name,

    -- * Destructuring the Response
    DeleteTrailResponse (..),
    newDeleteTrailResponse,

    -- * Response Lenses
    deleteTrailResponse_httpStatus,
  )
where

import Amazonka.CloudTrail.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | The request that specifies the name of a trail to delete.
--
-- /See:/ 'newDeleteTrail' smart constructor.
data DeleteTrail = DeleteTrail'
  { -- | Specifies the name or the CloudTrail ARN of the trail to be deleted. The
    -- following is the format of a trail ARN.
    -- @arn:aws:cloudtrail:us-east-2:123456789012:trail\/MyTrail@
    DeleteTrail -> Text
name :: Prelude.Text
  }
  deriving (DeleteTrail -> DeleteTrail -> Bool
(DeleteTrail -> DeleteTrail -> Bool)
-> (DeleteTrail -> DeleteTrail -> Bool) -> Eq DeleteTrail
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteTrail -> DeleteTrail -> Bool
$c/= :: DeleteTrail -> DeleteTrail -> Bool
== :: DeleteTrail -> DeleteTrail -> Bool
$c== :: DeleteTrail -> DeleteTrail -> Bool
Prelude.Eq, ReadPrec [DeleteTrail]
ReadPrec DeleteTrail
Int -> ReadS DeleteTrail
ReadS [DeleteTrail]
(Int -> ReadS DeleteTrail)
-> ReadS [DeleteTrail]
-> ReadPrec DeleteTrail
-> ReadPrec [DeleteTrail]
-> Read DeleteTrail
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteTrail]
$creadListPrec :: ReadPrec [DeleteTrail]
readPrec :: ReadPrec DeleteTrail
$creadPrec :: ReadPrec DeleteTrail
readList :: ReadS [DeleteTrail]
$creadList :: ReadS [DeleteTrail]
readsPrec :: Int -> ReadS DeleteTrail
$creadsPrec :: Int -> ReadS DeleteTrail
Prelude.Read, Int -> DeleteTrail -> ShowS
[DeleteTrail] -> ShowS
DeleteTrail -> String
(Int -> DeleteTrail -> ShowS)
-> (DeleteTrail -> String)
-> ([DeleteTrail] -> ShowS)
-> Show DeleteTrail
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteTrail] -> ShowS
$cshowList :: [DeleteTrail] -> ShowS
show :: DeleteTrail -> String
$cshow :: DeleteTrail -> String
showsPrec :: Int -> DeleteTrail -> ShowS
$cshowsPrec :: Int -> DeleteTrail -> ShowS
Prelude.Show, (forall x. DeleteTrail -> Rep DeleteTrail x)
-> (forall x. Rep DeleteTrail x -> DeleteTrail)
-> Generic DeleteTrail
forall x. Rep DeleteTrail x -> DeleteTrail
forall x. DeleteTrail -> Rep DeleteTrail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteTrail x -> DeleteTrail
$cfrom :: forall x. DeleteTrail -> Rep DeleteTrail x
Prelude.Generic)

-- |
-- Create a value of 'DeleteTrail' 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:
--
-- 'name', 'deleteTrail_name' - Specifies the name or the CloudTrail ARN of the trail to be deleted. The
-- following is the format of a trail ARN.
-- @arn:aws:cloudtrail:us-east-2:123456789012:trail\/MyTrail@
newDeleteTrail ::
  -- | 'name'
  Prelude.Text ->
  DeleteTrail
newDeleteTrail :: Text -> DeleteTrail
newDeleteTrail Text
pName_ = DeleteTrail' :: Text -> DeleteTrail
DeleteTrail' {$sel:name:DeleteTrail' :: Text
name = Text
pName_}

-- | Specifies the name or the CloudTrail ARN of the trail to be deleted. The
-- following is the format of a trail ARN.
-- @arn:aws:cloudtrail:us-east-2:123456789012:trail\/MyTrail@
deleteTrail_name :: Lens.Lens' DeleteTrail Prelude.Text
deleteTrail_name :: (Text -> f Text) -> DeleteTrail -> f DeleteTrail
deleteTrail_name = (DeleteTrail -> Text)
-> (DeleteTrail -> Text -> DeleteTrail)
-> Lens DeleteTrail DeleteTrail Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteTrail' {Text
name :: Text
$sel:name:DeleteTrail' :: DeleteTrail -> Text
name} -> Text
name) (\s :: DeleteTrail
s@DeleteTrail' {} Text
a -> DeleteTrail
s {$sel:name:DeleteTrail' :: Text
name = Text
a} :: DeleteTrail)

instance Core.AWSRequest DeleteTrail where
  type AWSResponse DeleteTrail = DeleteTrailResponse
  request :: DeleteTrail -> Request DeleteTrail
request = Service -> DeleteTrail -> Request DeleteTrail
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteTrail
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteTrail)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteTrail))
-> Logger
-> Service
-> Proxy DeleteTrail
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteTrail)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteTrailResponse
DeleteTrailResponse'
            (Int -> DeleteTrailResponse)
-> Either String Int -> Either String DeleteTrailResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteTrail

instance Prelude.NFData DeleteTrail

instance Core.ToHeaders DeleteTrail where
  toHeaders :: DeleteTrail -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteTrail -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101.DeleteTrail" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DeleteTrail where
  toJSON :: DeleteTrail -> Value
toJSON DeleteTrail' {Text
name :: Text
$sel:name:DeleteTrail' :: DeleteTrail -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)]
      )

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

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

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

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

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

instance Prelude.NFData DeleteTrailResponse