{-# 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.DeleteWorkflow
-- 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 workflow.
module Amazonka.Glue.DeleteWorkflow
  ( -- * Creating a Request
    DeleteWorkflow (..),
    newDeleteWorkflow,

    -- * Request Lenses
    deleteWorkflow_name,

    -- * Destructuring the Response
    DeleteWorkflowResponse (..),
    newDeleteWorkflowResponse,

    -- * Response Lenses
    deleteWorkflowResponse_name,
    deleteWorkflowResponse_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:/ 'newDeleteWorkflow' smart constructor.
data DeleteWorkflow = DeleteWorkflow'
  { -- | Name of the workflow to be deleted.
    DeleteWorkflow -> Text
name :: Prelude.Text
  }
  deriving (DeleteWorkflow -> DeleteWorkflow -> Bool
(DeleteWorkflow -> DeleteWorkflow -> Bool)
-> (DeleteWorkflow -> DeleteWorkflow -> Bool) -> Eq DeleteWorkflow
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteWorkflow -> DeleteWorkflow -> Bool
$c/= :: DeleteWorkflow -> DeleteWorkflow -> Bool
== :: DeleteWorkflow -> DeleteWorkflow -> Bool
$c== :: DeleteWorkflow -> DeleteWorkflow -> Bool
Prelude.Eq, ReadPrec [DeleteWorkflow]
ReadPrec DeleteWorkflow
Int -> ReadS DeleteWorkflow
ReadS [DeleteWorkflow]
(Int -> ReadS DeleteWorkflow)
-> ReadS [DeleteWorkflow]
-> ReadPrec DeleteWorkflow
-> ReadPrec [DeleteWorkflow]
-> Read DeleteWorkflow
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteWorkflow]
$creadListPrec :: ReadPrec [DeleteWorkflow]
readPrec :: ReadPrec DeleteWorkflow
$creadPrec :: ReadPrec DeleteWorkflow
readList :: ReadS [DeleteWorkflow]
$creadList :: ReadS [DeleteWorkflow]
readsPrec :: Int -> ReadS DeleteWorkflow
$creadsPrec :: Int -> ReadS DeleteWorkflow
Prelude.Read, Int -> DeleteWorkflow -> ShowS
[DeleteWorkflow] -> ShowS
DeleteWorkflow -> String
(Int -> DeleteWorkflow -> ShowS)
-> (DeleteWorkflow -> String)
-> ([DeleteWorkflow] -> ShowS)
-> Show DeleteWorkflow
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteWorkflow] -> ShowS
$cshowList :: [DeleteWorkflow] -> ShowS
show :: DeleteWorkflow -> String
$cshow :: DeleteWorkflow -> String
showsPrec :: Int -> DeleteWorkflow -> ShowS
$cshowsPrec :: Int -> DeleteWorkflow -> ShowS
Prelude.Show, (forall x. DeleteWorkflow -> Rep DeleteWorkflow x)
-> (forall x. Rep DeleteWorkflow x -> DeleteWorkflow)
-> Generic DeleteWorkflow
forall x. Rep DeleteWorkflow x -> DeleteWorkflow
forall x. DeleteWorkflow -> Rep DeleteWorkflow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteWorkflow x -> DeleteWorkflow
$cfrom :: forall x. DeleteWorkflow -> Rep DeleteWorkflow x
Prelude.Generic)

-- |
-- Create a value of 'DeleteWorkflow' 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', 'deleteWorkflow_name' - Name of the workflow to be deleted.
newDeleteWorkflow ::
  -- | 'name'
  Prelude.Text ->
  DeleteWorkflow
newDeleteWorkflow :: Text -> DeleteWorkflow
newDeleteWorkflow Text
pName_ =
  DeleteWorkflow' :: Text -> DeleteWorkflow
DeleteWorkflow' {$sel:name:DeleteWorkflow' :: Text
name = Text
pName_}

-- | Name of the workflow to be deleted.
deleteWorkflow_name :: Lens.Lens' DeleteWorkflow Prelude.Text
deleteWorkflow_name :: (Text -> f Text) -> DeleteWorkflow -> f DeleteWorkflow
deleteWorkflow_name = (DeleteWorkflow -> Text)
-> (DeleteWorkflow -> Text -> DeleteWorkflow)
-> Lens DeleteWorkflow DeleteWorkflow Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteWorkflow' {Text
name :: Text
$sel:name:DeleteWorkflow' :: DeleteWorkflow -> Text
name} -> Text
name) (\s :: DeleteWorkflow
s@DeleteWorkflow' {} Text
a -> DeleteWorkflow
s {$sel:name:DeleteWorkflow' :: Text
name = Text
a} :: DeleteWorkflow)

instance Core.AWSRequest DeleteWorkflow where
  type
    AWSResponse DeleteWorkflow =
      DeleteWorkflowResponse
  request :: DeleteWorkflow -> Request DeleteWorkflow
request = Service -> DeleteWorkflow -> Request DeleteWorkflow
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteWorkflow
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteWorkflow)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteWorkflow))
-> Logger
-> Service
-> Proxy DeleteWorkflow
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteWorkflow)))
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 -> DeleteWorkflowResponse
DeleteWorkflowResponse'
            (Maybe Text -> Int -> DeleteWorkflowResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DeleteWorkflowResponse)
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 -> DeleteWorkflowResponse)
-> Either String Int -> Either String DeleteWorkflowResponse
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 DeleteWorkflow

instance Prelude.NFData DeleteWorkflow

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

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

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

-- |
-- Create a value of 'DeleteWorkflowResponse' 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', 'deleteWorkflowResponse_name' - Name of the workflow specified in input.
--
-- 'httpStatus', 'deleteWorkflowResponse_httpStatus' - The response's http status code.
newDeleteWorkflowResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteWorkflowResponse
newDeleteWorkflowResponse :: Int -> DeleteWorkflowResponse
newDeleteWorkflowResponse Int
pHttpStatus_ =
  DeleteWorkflowResponse' :: Maybe Text -> Int -> DeleteWorkflowResponse
DeleteWorkflowResponse'
    { $sel:name:DeleteWorkflowResponse' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteWorkflowResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Name of the workflow specified in input.
deleteWorkflowResponse_name :: Lens.Lens' DeleteWorkflowResponse (Prelude.Maybe Prelude.Text)
deleteWorkflowResponse_name :: (Maybe Text -> f (Maybe Text))
-> DeleteWorkflowResponse -> f DeleteWorkflowResponse
deleteWorkflowResponse_name = (DeleteWorkflowResponse -> Maybe Text)
-> (DeleteWorkflowResponse -> Maybe Text -> DeleteWorkflowResponse)
-> Lens
     DeleteWorkflowResponse
     DeleteWorkflowResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteWorkflowResponse' {Maybe Text
name :: Maybe Text
$sel:name:DeleteWorkflowResponse' :: DeleteWorkflowResponse -> Maybe Text
name} -> Maybe Text
name) (\s :: DeleteWorkflowResponse
s@DeleteWorkflowResponse' {} Maybe Text
a -> DeleteWorkflowResponse
s {$sel:name:DeleteWorkflowResponse' :: Maybe Text
name = Maybe Text
a} :: DeleteWorkflowResponse)

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

instance Prelude.NFData DeleteWorkflowResponse