{-# 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.Glue.DeleteTrigger
-- 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 specified trigger. If the trigger is not found, no exception
-- is thrown.
module Amazonka.Glue.DeleteTrigger
  ( -- * Creating a Request
    DeleteTrigger (..),
    newDeleteTrigger,

    -- * Request Lenses
    deleteTrigger_name,

    -- * Destructuring the Response
    DeleteTriggerResponse (..),
    newDeleteTriggerResponse,

    -- * Response Lenses
    deleteTriggerResponse_name,
    deleteTriggerResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types
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:/ 'newDeleteTrigger' smart constructor.
data DeleteTrigger = DeleteTrigger'
  { -- | The name of the trigger to delete.
    DeleteTrigger -> Text
name :: Prelude.Text
  }
  deriving (DeleteTrigger -> DeleteTrigger -> Bool
(DeleteTrigger -> DeleteTrigger -> Bool)
-> (DeleteTrigger -> DeleteTrigger -> Bool) -> Eq DeleteTrigger
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteTrigger -> DeleteTrigger -> Bool
$c/= :: DeleteTrigger -> DeleteTrigger -> Bool
== :: DeleteTrigger -> DeleteTrigger -> Bool
$c== :: DeleteTrigger -> DeleteTrigger -> Bool
Prelude.Eq, ReadPrec [DeleteTrigger]
ReadPrec DeleteTrigger
Int -> ReadS DeleteTrigger
ReadS [DeleteTrigger]
(Int -> ReadS DeleteTrigger)
-> ReadS [DeleteTrigger]
-> ReadPrec DeleteTrigger
-> ReadPrec [DeleteTrigger]
-> Read DeleteTrigger
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteTrigger]
$creadListPrec :: ReadPrec [DeleteTrigger]
readPrec :: ReadPrec DeleteTrigger
$creadPrec :: ReadPrec DeleteTrigger
readList :: ReadS [DeleteTrigger]
$creadList :: ReadS [DeleteTrigger]
readsPrec :: Int -> ReadS DeleteTrigger
$creadsPrec :: Int -> ReadS DeleteTrigger
Prelude.Read, Int -> DeleteTrigger -> ShowS
[DeleteTrigger] -> ShowS
DeleteTrigger -> String
(Int -> DeleteTrigger -> ShowS)
-> (DeleteTrigger -> String)
-> ([DeleteTrigger] -> ShowS)
-> Show DeleteTrigger
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteTrigger] -> ShowS
$cshowList :: [DeleteTrigger] -> ShowS
show :: DeleteTrigger -> String
$cshow :: DeleteTrigger -> String
showsPrec :: Int -> DeleteTrigger -> ShowS
$cshowsPrec :: Int -> DeleteTrigger -> ShowS
Prelude.Show, (forall x. DeleteTrigger -> Rep DeleteTrigger x)
-> (forall x. Rep DeleteTrigger x -> DeleteTrigger)
-> Generic DeleteTrigger
forall x. Rep DeleteTrigger x -> DeleteTrigger
forall x. DeleteTrigger -> Rep DeleteTrigger x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteTrigger x -> DeleteTrigger
$cfrom :: forall x. DeleteTrigger -> Rep DeleteTrigger x
Prelude.Generic)

-- |
-- Create a value of 'DeleteTrigger' 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', 'deleteTrigger_name' - The name of the trigger to delete.
newDeleteTrigger ::
  -- | 'name'
  Prelude.Text ->
  DeleteTrigger
newDeleteTrigger :: Text -> DeleteTrigger
newDeleteTrigger Text
pName_ =
  DeleteTrigger' :: Text -> DeleteTrigger
DeleteTrigger' {$sel:name:DeleteTrigger' :: Text
name = Text
pName_}

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

instance Core.AWSRequest DeleteTrigger where
  type
    AWSResponse DeleteTrigger =
      DeleteTriggerResponse
  request :: DeleteTrigger -> Request DeleteTrigger
request = Service -> DeleteTrigger -> Request DeleteTrigger
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteTrigger
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteTrigger)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteTrigger))
-> Logger
-> Service
-> Proxy DeleteTrigger
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteTrigger)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> DeleteTriggerResponse
DeleteTriggerResponse'
            (Maybe Text -> Int -> DeleteTriggerResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DeleteTriggerResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Name")
            Either String (Int -> DeleteTriggerResponse)
-> Either String Int -> Either String DeleteTriggerResponse
forall (f :: * -> *) a b. Applicative f => 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 DeleteTrigger

instance Prelude.NFData DeleteTrigger

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

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

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

-- |
-- Create a value of 'DeleteTriggerResponse' 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', 'deleteTriggerResponse_name' - The name of the trigger that was deleted.
--
-- 'httpStatus', 'deleteTriggerResponse_httpStatus' - The response's http status code.
newDeleteTriggerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteTriggerResponse
newDeleteTriggerResponse :: Int -> DeleteTriggerResponse
newDeleteTriggerResponse Int
pHttpStatus_ =
  DeleteTriggerResponse' :: Maybe Text -> Int -> DeleteTriggerResponse
DeleteTriggerResponse'
    { $sel:name:DeleteTriggerResponse' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteTriggerResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The name of the trigger that was deleted.
deleteTriggerResponse_name :: Lens.Lens' DeleteTriggerResponse (Prelude.Maybe Prelude.Text)
deleteTriggerResponse_name :: (Maybe Text -> f (Maybe Text))
-> DeleteTriggerResponse -> f DeleteTriggerResponse
deleteTriggerResponse_name = (DeleteTriggerResponse -> Maybe Text)
-> (DeleteTriggerResponse -> Maybe Text -> DeleteTriggerResponse)
-> Lens
     DeleteTriggerResponse
     DeleteTriggerResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteTriggerResponse' {Maybe Text
name :: Maybe Text
$sel:name:DeleteTriggerResponse' :: DeleteTriggerResponse -> Maybe Text
name} -> Maybe Text
name) (\s :: DeleteTriggerResponse
s@DeleteTriggerResponse' {} Maybe Text
a -> DeleteTriggerResponse
s {$sel:name:DeleteTriggerResponse' :: Maybe Text
name = Maybe Text
a} :: DeleteTriggerResponse)

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

instance Prelude.NFData DeleteTriggerResponse