{-# 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.StopCrawlerSchedule
-- 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)
--
-- Sets the schedule state of the specified crawler to @NOT_SCHEDULED@, but
-- does not stop the crawler if it is already running.
module Amazonka.Glue.StopCrawlerSchedule
  ( -- * Creating a Request
    StopCrawlerSchedule (..),
    newStopCrawlerSchedule,

    -- * Request Lenses
    stopCrawlerSchedule_crawlerName,

    -- * Destructuring the Response
    StopCrawlerScheduleResponse (..),
    newStopCrawlerScheduleResponse,

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

-- |
-- Create a value of 'StopCrawlerSchedule' 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:
--
-- 'crawlerName', 'stopCrawlerSchedule_crawlerName' - Name of the crawler whose schedule state to set.
newStopCrawlerSchedule ::
  -- | 'crawlerName'
  Prelude.Text ->
  StopCrawlerSchedule
newStopCrawlerSchedule :: Text -> StopCrawlerSchedule
newStopCrawlerSchedule Text
pCrawlerName_ =
  StopCrawlerSchedule' :: Text -> StopCrawlerSchedule
StopCrawlerSchedule' {$sel:crawlerName:StopCrawlerSchedule' :: Text
crawlerName = Text
pCrawlerName_}

-- | Name of the crawler whose schedule state to set.
stopCrawlerSchedule_crawlerName :: Lens.Lens' StopCrawlerSchedule Prelude.Text
stopCrawlerSchedule_crawlerName :: (Text -> f Text) -> StopCrawlerSchedule -> f StopCrawlerSchedule
stopCrawlerSchedule_crawlerName = (StopCrawlerSchedule -> Text)
-> (StopCrawlerSchedule -> Text -> StopCrawlerSchedule)
-> Lens StopCrawlerSchedule StopCrawlerSchedule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopCrawlerSchedule' {Text
crawlerName :: Text
$sel:crawlerName:StopCrawlerSchedule' :: StopCrawlerSchedule -> Text
crawlerName} -> Text
crawlerName) (\s :: StopCrawlerSchedule
s@StopCrawlerSchedule' {} Text
a -> StopCrawlerSchedule
s {$sel:crawlerName:StopCrawlerSchedule' :: Text
crawlerName = Text
a} :: StopCrawlerSchedule)

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

instance Prelude.NFData StopCrawlerSchedule

instance Core.ToHeaders StopCrawlerSchedule where
  toHeaders :: StopCrawlerSchedule -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StopCrawlerSchedule -> 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.StopCrawlerSchedule" ::
                          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 StopCrawlerSchedule where
  toJSON :: StopCrawlerSchedule -> Value
toJSON StopCrawlerSchedule' {Text
crawlerName :: Text
$sel:crawlerName:StopCrawlerSchedule' :: StopCrawlerSchedule -> 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
"CrawlerName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
crawlerName)]
      )

instance Core.ToPath StopCrawlerSchedule where
  toPath :: StopCrawlerSchedule -> ByteString
toPath = ByteString -> StopCrawlerSchedule -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

instance Prelude.NFData StopCrawlerScheduleResponse