{-# 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.UpdateCrawlerSchedule
-- 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)
--
-- Updates the schedule of a crawler using a @cron@ expression.
module Amazonka.Glue.UpdateCrawlerSchedule
  ( -- * Creating a Request
    UpdateCrawlerSchedule (..),
    newUpdateCrawlerSchedule,

    -- * Request Lenses
    updateCrawlerSchedule_schedule,
    updateCrawlerSchedule_crawlerName,

    -- * Destructuring the Response
    UpdateCrawlerScheduleResponse (..),
    newUpdateCrawlerScheduleResponse,

    -- * Response Lenses
    updateCrawlerScheduleResponse_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:/ 'newUpdateCrawlerSchedule' smart constructor.
data UpdateCrawlerSchedule = UpdateCrawlerSchedule'
  { -- | The updated @cron@ expression used to specify the schedule (see
    -- <https://docs.aws.amazon.com/glue/latest/dg/monitor-data-warehouse-schedule.html Time-Based Schedules for Jobs and Crawlers>.
    -- For example, to run something every day at 12:15 UTC, you would specify:
    -- @cron(15 12 * * ? *)@.
    UpdateCrawlerSchedule -> Maybe Text
schedule :: Prelude.Maybe Prelude.Text,
    -- | The name of the crawler whose schedule to update.
    UpdateCrawlerSchedule -> Text
crawlerName :: Prelude.Text
  }
  deriving (UpdateCrawlerSchedule -> UpdateCrawlerSchedule -> Bool
(UpdateCrawlerSchedule -> UpdateCrawlerSchedule -> Bool)
-> (UpdateCrawlerSchedule -> UpdateCrawlerSchedule -> Bool)
-> Eq UpdateCrawlerSchedule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateCrawlerSchedule -> UpdateCrawlerSchedule -> Bool
$c/= :: UpdateCrawlerSchedule -> UpdateCrawlerSchedule -> Bool
== :: UpdateCrawlerSchedule -> UpdateCrawlerSchedule -> Bool
$c== :: UpdateCrawlerSchedule -> UpdateCrawlerSchedule -> Bool
Prelude.Eq, ReadPrec [UpdateCrawlerSchedule]
ReadPrec UpdateCrawlerSchedule
Int -> ReadS UpdateCrawlerSchedule
ReadS [UpdateCrawlerSchedule]
(Int -> ReadS UpdateCrawlerSchedule)
-> ReadS [UpdateCrawlerSchedule]
-> ReadPrec UpdateCrawlerSchedule
-> ReadPrec [UpdateCrawlerSchedule]
-> Read UpdateCrawlerSchedule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateCrawlerSchedule]
$creadListPrec :: ReadPrec [UpdateCrawlerSchedule]
readPrec :: ReadPrec UpdateCrawlerSchedule
$creadPrec :: ReadPrec UpdateCrawlerSchedule
readList :: ReadS [UpdateCrawlerSchedule]
$creadList :: ReadS [UpdateCrawlerSchedule]
readsPrec :: Int -> ReadS UpdateCrawlerSchedule
$creadsPrec :: Int -> ReadS UpdateCrawlerSchedule
Prelude.Read, Int -> UpdateCrawlerSchedule -> ShowS
[UpdateCrawlerSchedule] -> ShowS
UpdateCrawlerSchedule -> String
(Int -> UpdateCrawlerSchedule -> ShowS)
-> (UpdateCrawlerSchedule -> String)
-> ([UpdateCrawlerSchedule] -> ShowS)
-> Show UpdateCrawlerSchedule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateCrawlerSchedule] -> ShowS
$cshowList :: [UpdateCrawlerSchedule] -> ShowS
show :: UpdateCrawlerSchedule -> String
$cshow :: UpdateCrawlerSchedule -> String
showsPrec :: Int -> UpdateCrawlerSchedule -> ShowS
$cshowsPrec :: Int -> UpdateCrawlerSchedule -> ShowS
Prelude.Show, (forall x. UpdateCrawlerSchedule -> Rep UpdateCrawlerSchedule x)
-> (forall x. Rep UpdateCrawlerSchedule x -> UpdateCrawlerSchedule)
-> Generic UpdateCrawlerSchedule
forall x. Rep UpdateCrawlerSchedule x -> UpdateCrawlerSchedule
forall x. UpdateCrawlerSchedule -> Rep UpdateCrawlerSchedule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateCrawlerSchedule x -> UpdateCrawlerSchedule
$cfrom :: forall x. UpdateCrawlerSchedule -> Rep UpdateCrawlerSchedule x
Prelude.Generic)

-- |
-- Create a value of 'UpdateCrawlerSchedule' 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:
--
-- 'schedule', 'updateCrawlerSchedule_schedule' - The updated @cron@ expression used to specify the schedule (see
-- <https://docs.aws.amazon.com/glue/latest/dg/monitor-data-warehouse-schedule.html Time-Based Schedules for Jobs and Crawlers>.
-- For example, to run something every day at 12:15 UTC, you would specify:
-- @cron(15 12 * * ? *)@.
--
-- 'crawlerName', 'updateCrawlerSchedule_crawlerName' - The name of the crawler whose schedule to update.
newUpdateCrawlerSchedule ::
  -- | 'crawlerName'
  Prelude.Text ->
  UpdateCrawlerSchedule
newUpdateCrawlerSchedule :: Text -> UpdateCrawlerSchedule
newUpdateCrawlerSchedule Text
pCrawlerName_ =
  UpdateCrawlerSchedule' :: Maybe Text -> Text -> UpdateCrawlerSchedule
UpdateCrawlerSchedule'
    { $sel:schedule:UpdateCrawlerSchedule' :: Maybe Text
schedule = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:crawlerName:UpdateCrawlerSchedule' :: Text
crawlerName = Text
pCrawlerName_
    }

-- | The updated @cron@ expression used to specify the schedule (see
-- <https://docs.aws.amazon.com/glue/latest/dg/monitor-data-warehouse-schedule.html Time-Based Schedules for Jobs and Crawlers>.
-- For example, to run something every day at 12:15 UTC, you would specify:
-- @cron(15 12 * * ? *)@.
updateCrawlerSchedule_schedule :: Lens.Lens' UpdateCrawlerSchedule (Prelude.Maybe Prelude.Text)
updateCrawlerSchedule_schedule :: (Maybe Text -> f (Maybe Text))
-> UpdateCrawlerSchedule -> f UpdateCrawlerSchedule
updateCrawlerSchedule_schedule = (UpdateCrawlerSchedule -> Maybe Text)
-> (UpdateCrawlerSchedule -> Maybe Text -> UpdateCrawlerSchedule)
-> Lens
     UpdateCrawlerSchedule
     UpdateCrawlerSchedule
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCrawlerSchedule' {Maybe Text
schedule :: Maybe Text
$sel:schedule:UpdateCrawlerSchedule' :: UpdateCrawlerSchedule -> Maybe Text
schedule} -> Maybe Text
schedule) (\s :: UpdateCrawlerSchedule
s@UpdateCrawlerSchedule' {} Maybe Text
a -> UpdateCrawlerSchedule
s {$sel:schedule:UpdateCrawlerSchedule' :: Maybe Text
schedule = Maybe Text
a} :: UpdateCrawlerSchedule)

-- | The name of the crawler whose schedule to update.
updateCrawlerSchedule_crawlerName :: Lens.Lens' UpdateCrawlerSchedule Prelude.Text
updateCrawlerSchedule_crawlerName :: (Text -> f Text)
-> UpdateCrawlerSchedule -> f UpdateCrawlerSchedule
updateCrawlerSchedule_crawlerName = (UpdateCrawlerSchedule -> Text)
-> (UpdateCrawlerSchedule -> Text -> UpdateCrawlerSchedule)
-> Lens UpdateCrawlerSchedule UpdateCrawlerSchedule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCrawlerSchedule' {Text
crawlerName :: Text
$sel:crawlerName:UpdateCrawlerSchedule' :: UpdateCrawlerSchedule -> Text
crawlerName} -> Text
crawlerName) (\s :: UpdateCrawlerSchedule
s@UpdateCrawlerSchedule' {} Text
a -> UpdateCrawlerSchedule
s {$sel:crawlerName:UpdateCrawlerSchedule' :: Text
crawlerName = Text
a} :: UpdateCrawlerSchedule)

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

instance Prelude.NFData UpdateCrawlerSchedule

instance Core.ToHeaders UpdateCrawlerSchedule where
  toHeaders :: UpdateCrawlerSchedule -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateCrawlerSchedule -> 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.UpdateCrawlerSchedule" ::
                          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 UpdateCrawlerSchedule where
  toJSON :: UpdateCrawlerSchedule -> Value
toJSON UpdateCrawlerSchedule' {Maybe Text
Text
crawlerName :: Text
schedule :: Maybe Text
$sel:crawlerName:UpdateCrawlerSchedule' :: UpdateCrawlerSchedule -> Text
$sel:schedule:UpdateCrawlerSchedule' :: UpdateCrawlerSchedule -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Schedule" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
schedule,
            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 UpdateCrawlerSchedule where
  toPath :: UpdateCrawlerSchedule -> ByteString
toPath = ByteString -> UpdateCrawlerSchedule -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

instance Prelude.NFData UpdateCrawlerScheduleResponse