{-# 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-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 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.Lens as Lens
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
(DeleteApiDestination -> DeleteApiDestination -> Bool)
-> (DeleteApiDestination -> DeleteApiDestination -> Bool)
-> Eq DeleteApiDestination
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]
(Int -> ReadS DeleteApiDestination)
-> ReadS [DeleteApiDestination]
-> ReadPrec DeleteApiDestination
-> ReadPrec [DeleteApiDestination]
-> Read 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
(Int -> DeleteApiDestination -> ShowS)
-> (DeleteApiDestination -> String)
-> ([DeleteApiDestination] -> ShowS)
-> Show DeleteApiDestination
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. DeleteApiDestination -> Rep DeleteApiDestination x)
-> (forall x. Rep DeleteApiDestination x -> DeleteApiDestination)
-> Generic DeleteApiDestination
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' :: Text -> DeleteApiDestination
DeleteApiDestination' {$sel:name:DeleteApiDestination' :: Text
name = Text
pName_}

-- | The name of the destination to delete.
deleteApiDestination_name :: Lens.Lens' DeleteApiDestination Prelude.Text
deleteApiDestination_name :: (Text -> f Text) -> DeleteApiDestination -> f DeleteApiDestination
deleteApiDestination_name = (DeleteApiDestination -> Text)
-> (DeleteApiDestination -> Text -> DeleteApiDestination)
-> Lens DeleteApiDestination DeleteApiDestination Text Text
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 :: DeleteApiDestination -> Request DeleteApiDestination
request = Service -> DeleteApiDestination -> Request DeleteApiDestination
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteApiDestination
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteApiDestination)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteApiDestination))
-> Logger
-> Service
-> Proxy DeleteApiDestination
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteApiDestination)))
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 -> DeleteApiDestinationResponse
DeleteApiDestinationResponse'
            (Int -> DeleteApiDestinationResponse)
-> Either String Int -> Either String DeleteApiDestinationResponse
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 DeleteApiDestination

instance Prelude.NFData DeleteApiDestination

instance Core.ToHeaders DeleteApiDestination where
  toHeaders :: DeleteApiDestination -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteApiDestination -> 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
"AWSEvents.DeleteApiDestination" ::
                          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 DeleteApiDestination where
  toJSON :: DeleteApiDestination -> Value
toJSON DeleteApiDestination' {Text
name :: Text
$sel:name:DeleteApiDestination' :: DeleteApiDestination -> 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 DeleteApiDestination where
  toPath :: DeleteApiDestination -> ByteString
toPath = ByteString -> DeleteApiDestination -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery DeleteApiDestination where
  toQuery :: DeleteApiDestination -> QueryString
toQuery = QueryString -> DeleteApiDestination -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteApiDestinationResponse
 -> DeleteApiDestinationResponse -> Bool)
-> (DeleteApiDestinationResponse
    -> DeleteApiDestinationResponse -> Bool)
-> Eq DeleteApiDestinationResponse
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]
(Int -> ReadS DeleteApiDestinationResponse)
-> ReadS [DeleteApiDestinationResponse]
-> ReadPrec DeleteApiDestinationResponse
-> ReadPrec [DeleteApiDestinationResponse]
-> Read 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
(Int -> DeleteApiDestinationResponse -> ShowS)
-> (DeleteApiDestinationResponse -> String)
-> ([DeleteApiDestinationResponse] -> ShowS)
-> Show DeleteApiDestinationResponse
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.
 DeleteApiDestinationResponse -> Rep DeleteApiDestinationResponse x)
-> (forall x.
    Rep DeleteApiDestinationResponse x -> DeleteApiDestinationResponse)
-> Generic DeleteApiDestinationResponse
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' :: Int -> DeleteApiDestinationResponse
DeleteApiDestinationResponse'
    { $sel:httpStatus:DeleteApiDestinationResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
deleteApiDestinationResponse_httpStatus :: Lens.Lens' DeleteApiDestinationResponse Prelude.Int
deleteApiDestinationResponse_httpStatus :: (Int -> f Int)
-> DeleteApiDestinationResponse -> f DeleteApiDestinationResponse
deleteApiDestinationResponse_httpStatus = (DeleteApiDestinationResponse -> Int)
-> (DeleteApiDestinationResponse
    -> Int -> DeleteApiDestinationResponse)
-> Lens
     DeleteApiDestinationResponse DeleteApiDestinationResponse Int Int
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