{-# 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.StopCrawler
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- If the specified crawler is running, stops the crawl.
module Amazonka.Glue.StopCrawler
  ( -- * Creating a Request
    StopCrawler (..),
    newStopCrawler,

    -- * Request Lenses
    stopCrawler_name,

    -- * Destructuring the Response
    StopCrawlerResponse (..),
    newStopCrawlerResponse,

    -- * Response Lenses
    stopCrawlerResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glue.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

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

-- |
-- Create a value of 'StopCrawler' 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', 'stopCrawler_name' - Name of the crawler to stop.
newStopCrawler ::
  -- | 'name'
  Prelude.Text ->
  StopCrawler
newStopCrawler :: Text -> StopCrawler
newStopCrawler Text
pName_ = StopCrawler' {$sel:name:StopCrawler' :: Text
name = Text
pName_}

-- | Name of the crawler to stop.
stopCrawler_name :: Lens.Lens' StopCrawler Prelude.Text
stopCrawler_name :: Lens' StopCrawler Text
stopCrawler_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopCrawler' {Text
name :: Text
$sel:name:StopCrawler' :: StopCrawler -> Text
name} -> Text
name) (\s :: StopCrawler
s@StopCrawler' {} Text
a -> StopCrawler
s {$sel:name:StopCrawler' :: Text
name = Text
a} :: StopCrawler)

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

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

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

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

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

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

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

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