{-# 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-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)
--
-- 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 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:/ 'newStopCrawler' smart constructor.
data StopCrawler = StopCrawler'
  { -- | Name of the crawler to stop.
    StopCrawler -> Text
name :: Prelude.Text
  }
  deriving (StopCrawler -> StopCrawler -> Bool
(StopCrawler -> StopCrawler -> Bool)
-> (StopCrawler -> StopCrawler -> Bool) -> Eq StopCrawler
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]
(Int -> ReadS StopCrawler)
-> ReadS [StopCrawler]
-> ReadPrec StopCrawler
-> ReadPrec [StopCrawler]
-> Read 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
(Int -> StopCrawler -> ShowS)
-> (StopCrawler -> String)
-> ([StopCrawler] -> ShowS)
-> Show StopCrawler
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. StopCrawler -> Rep StopCrawler x)
-> (forall x. Rep StopCrawler x -> StopCrawler)
-> Generic StopCrawler
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' :: Text -> StopCrawler
StopCrawler' {$sel:name:StopCrawler' :: Text
name = Text
pName_}

-- | Name of the crawler to stop.
stopCrawler_name :: Lens.Lens' StopCrawler Prelude.Text
stopCrawler_name :: (Text -> f Text) -> StopCrawler -> f StopCrawler
stopCrawler_name = (StopCrawler -> Text)
-> (StopCrawler -> Text -> StopCrawler)
-> Lens StopCrawler StopCrawler Text Text
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 :: StopCrawler -> Request StopCrawler
request = Service -> StopCrawler -> Request StopCrawler
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopCrawler
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopCrawler)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse StopCrawler))
-> Logger
-> Service
-> Proxy StopCrawler
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopCrawler)))
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 -> StopCrawlerResponse
StopCrawlerResponse'
            (Int -> StopCrawlerResponse)
-> Either String Int -> Either String StopCrawlerResponse
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 StopCrawler

instance Prelude.NFData StopCrawler

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

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

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