{-# 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.DeleteCrawler
-- 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)
--
-- Removes a specified crawler from the Glue Data Catalog, unless the
-- crawler state is @RUNNING@.
module Amazonka.Glue.DeleteCrawler
  ( -- * Creating a Request
    DeleteCrawler (..),
    newDeleteCrawler,

    -- * Request Lenses
    deleteCrawler_name,

    -- * Destructuring the Response
    DeleteCrawlerResponse (..),
    newDeleteCrawlerResponse,

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

-- |
-- Create a value of 'DeleteCrawler' 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', 'deleteCrawler_name' - The name of the crawler to remove.
newDeleteCrawler ::
  -- | 'name'
  Prelude.Text ->
  DeleteCrawler
newDeleteCrawler :: Text -> DeleteCrawler
newDeleteCrawler Text
pName_ =
  DeleteCrawler' :: Text -> DeleteCrawler
DeleteCrawler' {$sel:name:DeleteCrawler' :: Text
name = Text
pName_}

-- | The name of the crawler to remove.
deleteCrawler_name :: Lens.Lens' DeleteCrawler Prelude.Text
deleteCrawler_name :: (Text -> f Text) -> DeleteCrawler -> f DeleteCrawler
deleteCrawler_name = (DeleteCrawler -> Text)
-> (DeleteCrawler -> Text -> DeleteCrawler)
-> Lens DeleteCrawler DeleteCrawler Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCrawler' {Text
name :: Text
$sel:name:DeleteCrawler' :: DeleteCrawler -> Text
name} -> Text
name) (\s :: DeleteCrawler
s@DeleteCrawler' {} Text
a -> DeleteCrawler
s {$sel:name:DeleteCrawler' :: Text
name = Text
a} :: DeleteCrawler)

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

instance Prelude.NFData DeleteCrawler

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

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

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

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

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

instance Prelude.NFData DeleteCrawlerResponse