{-# 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.StartCrawlerSchedule
-- 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)
--
-- Changes the schedule state of the specified crawler to @SCHEDULED@,
-- unless the crawler is already running or the schedule state is already
-- @SCHEDULED@.
module Amazonka.Glue.StartCrawlerSchedule
  ( -- * Creating a Request
    StartCrawlerSchedule (..),
    newStartCrawlerSchedule,

    -- * Request Lenses
    startCrawlerSchedule_crawlerName,

    -- * Destructuring the Response
    StartCrawlerScheduleResponse (..),
    newStartCrawlerScheduleResponse,

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

-- |
-- Create a value of 'StartCrawlerSchedule' 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', 'startCrawlerSchedule_crawlerName' - Name of the crawler to schedule.
newStartCrawlerSchedule ::
  -- | 'crawlerName'
  Prelude.Text ->
  StartCrawlerSchedule
newStartCrawlerSchedule :: Text -> StartCrawlerSchedule
newStartCrawlerSchedule Text
pCrawlerName_ =
  StartCrawlerSchedule' :: Text -> StartCrawlerSchedule
StartCrawlerSchedule' {$sel:crawlerName:StartCrawlerSchedule' :: Text
crawlerName = Text
pCrawlerName_}

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

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

instance Prelude.NFData StartCrawlerSchedule

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

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

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

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

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

instance Prelude.NFData StartCrawlerScheduleResponse