{-# 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.CloudWatchEvents.DeleteApiDestination
-- 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 the specified API destination.
module Amazonka.CloudWatchEvents.DeleteApiDestination
  ( -- * Creating a Request
    DeleteApiDestination (..),
    newDeleteApiDestination,

    -- * Request Lenses
    deleteApiDestination_name,

    -- * Destructuring the Response
    DeleteApiDestinationResponse (..),
    newDeleteApiDestinationResponse,

    -- * Response Lenses
    deleteApiDestinationResponse_httpStatus,
  )
where

import Amazonka.CloudWatchEvents.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

-- | /See:/ 'newDeleteApiDestination' smart constructor.
data DeleteApiDestination = DeleteApiDestination'
  { -- | The name of the destination to delete.
    DeleteApiDestination -> Text
name :: Prelude.Text
  }
  deriving (DeleteApiDestination -> DeleteApiDestination -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteApiDestination -> DeleteApiDestination -> Bool
$c/= :: DeleteApiDestination -> DeleteApiDestination -> Bool
== :: DeleteApiDestination -> DeleteApiDestination -> Bool
$c== :: DeleteApiDestination -> DeleteApiDestination -> Bool
Prelude.Eq, ReadPrec [DeleteApiDestination]
ReadPrec DeleteApiDestination
Int -> ReadS DeleteApiDestination
ReadS [DeleteApiDestination]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteApiDestination]
$creadListPrec :: ReadPrec [DeleteApiDestination]
readPrec :: ReadPrec DeleteApiDestination
$creadPrec :: ReadPrec DeleteApiDestination
readList :: ReadS [DeleteApiDestination]
$creadList :: ReadS [DeleteApiDestination]
readsPrec :: Int -> ReadS DeleteApiDestination
$creadsPrec :: Int -> ReadS DeleteApiDestination
Prelude.Read, Int -> DeleteApiDestination -> ShowS
[DeleteApiDestination] -> ShowS
DeleteApiDestination -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteApiDestination] -> ShowS
$cshowList :: [DeleteApiDestination] -> ShowS
show :: DeleteApiDestination -> String
$cshow :: DeleteApiDestination -> String
showsPrec :: Int -> DeleteApiDestination -> ShowS
$cshowsPrec :: Int -> DeleteApiDestination -> ShowS
Prelude.Show, forall x. Rep DeleteApiDestination x -> DeleteApiDestination
forall x. DeleteApiDestination -> Rep DeleteApiDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteApiDestination x -> DeleteApiDestination
$cfrom :: forall x. DeleteApiDestination -> Rep DeleteApiDestination x
Prelude.Generic)

-- |
-- Create a value of 'DeleteApiDestination' 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', 'deleteApiDestination_name' - The name of the destination to delete.
newDeleteApiDestination ::
  -- | 'name'
  Prelude.Text ->
  DeleteApiDestination
newDeleteApiDestination :: Text -> DeleteApiDestination
newDeleteApiDestination Text
pName_ =
  DeleteApiDestination' {$sel:name:DeleteApiDestination' :: Text
name = Text
pName_}

-- | The name of the destination to delete.
deleteApiDestination_name :: Lens.Lens' DeleteApiDestination Prelude.Text
deleteApiDestination_name :: Lens' DeleteApiDestination Text
deleteApiDestination_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteApiDestination' {Text
name :: Text
$sel:name:DeleteApiDestination' :: DeleteApiDestination -> Text
name} -> Text
name) (\s :: DeleteApiDestination
s@DeleteApiDestination' {} Text
a -> DeleteApiDestination
s {$sel:name:DeleteApiDestination' :: Text
name = Text
a} :: DeleteApiDestination)

instance Core.AWSRequest DeleteApiDestination where
  type
    AWSResponse DeleteApiDestination =
      DeleteApiDestinationResponse
  request :: (Service -> Service)
-> DeleteApiDestination -> Request DeleteApiDestination
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 DeleteApiDestination
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteApiDestination)))
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 -> DeleteApiDestinationResponse
DeleteApiDestinationResponse'
            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 DeleteApiDestination where
  hashWithSalt :: Int -> DeleteApiDestination -> Int
hashWithSalt Int
_salt DeleteApiDestination' {Text
name :: Text
$sel:name:DeleteApiDestination' :: DeleteApiDestination -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData DeleteApiDestination where
  rnf :: DeleteApiDestination -> ()
rnf DeleteApiDestination' {Text
name :: Text
$sel:name:DeleteApiDestination' :: DeleteApiDestination -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToHeaders DeleteApiDestination where
  toHeaders :: DeleteApiDestination -> 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
"AWSEvents.DeleteApiDestination" ::
                          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 DeleteApiDestination where
  toJSON :: DeleteApiDestination -> Value
toJSON DeleteApiDestination' {Text
name :: Text
$sel:name:DeleteApiDestination' :: DeleteApiDestination -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)]
      )

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

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

-- | /See:/ 'newDeleteApiDestinationResponse' smart constructor.
data DeleteApiDestinationResponse = DeleteApiDestinationResponse'
  { -- | The response's http status code.
    DeleteApiDestinationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteApiDestinationResponse
-> DeleteApiDestinationResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteApiDestinationResponse
-> DeleteApiDestinationResponse -> Bool
$c/= :: DeleteApiDestinationResponse
-> DeleteApiDestinationResponse -> Bool
== :: DeleteApiDestinationResponse
-> DeleteApiDestinationResponse -> Bool
$c== :: DeleteApiDestinationResponse
-> DeleteApiDestinationResponse -> Bool
Prelude.Eq, ReadPrec [DeleteApiDestinationResponse]
ReadPrec DeleteApiDestinationResponse
Int -> ReadS DeleteApiDestinationResponse
ReadS [DeleteApiDestinationResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteApiDestinationResponse]
$creadListPrec :: ReadPrec [DeleteApiDestinationResponse]
readPrec :: ReadPrec DeleteApiDestinationResponse
$creadPrec :: ReadPrec DeleteApiDestinationResponse
readList :: ReadS [DeleteApiDestinationResponse]
$creadList :: ReadS [DeleteApiDestinationResponse]
readsPrec :: Int -> ReadS DeleteApiDestinationResponse
$creadsPrec :: Int -> ReadS DeleteApiDestinationResponse
Prelude.Read, Int -> DeleteApiDestinationResponse -> ShowS
[DeleteApiDestinationResponse] -> ShowS
DeleteApiDestinationResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteApiDestinationResponse] -> ShowS
$cshowList :: [DeleteApiDestinationResponse] -> ShowS
show :: DeleteApiDestinationResponse -> String
$cshow :: DeleteApiDestinationResponse -> String
showsPrec :: Int -> DeleteApiDestinationResponse -> ShowS
$cshowsPrec :: Int -> DeleteApiDestinationResponse -> ShowS
Prelude.Show, forall x.
Rep DeleteApiDestinationResponse x -> DeleteApiDestinationResponse
forall x.
DeleteApiDestinationResponse -> Rep DeleteApiDestinationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteApiDestinationResponse x -> DeleteApiDestinationResponse
$cfrom :: forall x.
DeleteApiDestinationResponse -> Rep DeleteApiDestinationResponse x
Prelude.Generic)

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

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

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