{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 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:/ '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
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]
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
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. 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'
    { $sel:schedule:UpdateCrawlerSchedule' :: Maybe Text
schedule = 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 :: Lens' UpdateCrawlerSchedule (Maybe Text)
updateCrawlerSchedule_schedule = 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 :: Lens' UpdateCrawlerSchedule Text
updateCrawlerSchedule_crawlerName = 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 :: (Service -> Service)
-> UpdateCrawlerSchedule -> Request UpdateCrawlerSchedule
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 UpdateCrawlerSchedule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateCrawlerSchedule)))
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 -> UpdateCrawlerScheduleResponse
UpdateCrawlerScheduleResponse'
            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 UpdateCrawlerSchedule where
  hashWithSalt :: Int -> UpdateCrawlerSchedule -> Int
hashWithSalt Int
_salt UpdateCrawlerSchedule' {Maybe Text
Text
crawlerName :: Text
schedule :: Maybe Text
$sel:crawlerName:UpdateCrawlerSchedule' :: UpdateCrawlerSchedule -> Text
$sel:schedule:UpdateCrawlerSchedule' :: UpdateCrawlerSchedule -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
schedule
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
crawlerName

instance Prelude.NFData UpdateCrawlerSchedule where
  rnf :: UpdateCrawlerSchedule -> ()
rnf UpdateCrawlerSchedule' {Maybe Text
Text
crawlerName :: Text
schedule :: Maybe Text
$sel:crawlerName:UpdateCrawlerSchedule' :: UpdateCrawlerSchedule -> Text
$sel:schedule:UpdateCrawlerSchedule' :: UpdateCrawlerSchedule -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
schedule
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
crawlerName

instance Data.ToHeaders UpdateCrawlerSchedule where
  toHeaders :: UpdateCrawlerSchedule -> 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.UpdateCrawlerSchedule" ::
                          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 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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Schedule" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
schedule,
            forall a. a -> Maybe a
Prelude.Just (Key
"CrawlerName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
crawlerName)
          ]
      )

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

instance Data.ToQuery UpdateCrawlerSchedule where
  toQuery :: UpdateCrawlerSchedule -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:httpStatus:UpdateCrawlerScheduleResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
updateCrawlerScheduleResponse_httpStatus :: Lens.Lens' UpdateCrawlerScheduleResponse Prelude.Int
updateCrawlerScheduleResponse_httpStatus :: Lens' UpdateCrawlerScheduleResponse Int
updateCrawlerScheduleResponse_httpStatus = 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 where
  rnf :: UpdateCrawlerScheduleResponse -> ()
rnf UpdateCrawlerScheduleResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateCrawlerScheduleResponse' :: UpdateCrawlerScheduleResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus