{-# 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.DataBrew.UpdateSchedule
-- 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)
--
-- Modifies the definition of an existing DataBrew schedule.
module Amazonka.DataBrew.UpdateSchedule
  ( -- * Creating a Request
    UpdateSchedule (..),
    newUpdateSchedule,

    -- * Request Lenses
    updateSchedule_jobNames,
    updateSchedule_cronExpression,
    updateSchedule_name,

    -- * Destructuring the Response
    UpdateScheduleResponse (..),
    newUpdateScheduleResponse,

    -- * Response Lenses
    updateScheduleResponse_httpStatus,
    updateScheduleResponse_name,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DataBrew.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:/ 'newUpdateSchedule' smart constructor.
data UpdateSchedule = UpdateSchedule'
  { -- | The name or names of one or more jobs to be run for this schedule.
    UpdateSchedule -> Maybe [Text]
jobNames :: Prelude.Maybe [Prelude.Text],
    -- | The date or dates and time or times when the jobs are to be run. For
    -- more information, see
    -- <https://docs.aws.amazon.com/databrew/latest/dg/jobs.cron.html Cron expressions>
    -- in the /Glue DataBrew Developer Guide/.
    UpdateSchedule -> Text
cronExpression :: Prelude.Text,
    -- | The name of the schedule to update.
    UpdateSchedule -> Text
name :: Prelude.Text
  }
  deriving (UpdateSchedule -> UpdateSchedule -> Bool
(UpdateSchedule -> UpdateSchedule -> Bool)
-> (UpdateSchedule -> UpdateSchedule -> Bool) -> Eq UpdateSchedule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateSchedule -> UpdateSchedule -> Bool
$c/= :: UpdateSchedule -> UpdateSchedule -> Bool
== :: UpdateSchedule -> UpdateSchedule -> Bool
$c== :: UpdateSchedule -> UpdateSchedule -> Bool
Prelude.Eq, ReadPrec [UpdateSchedule]
ReadPrec UpdateSchedule
Int -> ReadS UpdateSchedule
ReadS [UpdateSchedule]
(Int -> ReadS UpdateSchedule)
-> ReadS [UpdateSchedule]
-> ReadPrec UpdateSchedule
-> ReadPrec [UpdateSchedule]
-> Read UpdateSchedule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateSchedule]
$creadListPrec :: ReadPrec [UpdateSchedule]
readPrec :: ReadPrec UpdateSchedule
$creadPrec :: ReadPrec UpdateSchedule
readList :: ReadS [UpdateSchedule]
$creadList :: ReadS [UpdateSchedule]
readsPrec :: Int -> ReadS UpdateSchedule
$creadsPrec :: Int -> ReadS UpdateSchedule
Prelude.Read, Int -> UpdateSchedule -> ShowS
[UpdateSchedule] -> ShowS
UpdateSchedule -> String
(Int -> UpdateSchedule -> ShowS)
-> (UpdateSchedule -> String)
-> ([UpdateSchedule] -> ShowS)
-> Show UpdateSchedule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateSchedule] -> ShowS
$cshowList :: [UpdateSchedule] -> ShowS
show :: UpdateSchedule -> String
$cshow :: UpdateSchedule -> String
showsPrec :: Int -> UpdateSchedule -> ShowS
$cshowsPrec :: Int -> UpdateSchedule -> ShowS
Prelude.Show, (forall x. UpdateSchedule -> Rep UpdateSchedule x)
-> (forall x. Rep UpdateSchedule x -> UpdateSchedule)
-> Generic UpdateSchedule
forall x. Rep UpdateSchedule x -> UpdateSchedule
forall x. UpdateSchedule -> Rep UpdateSchedule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateSchedule x -> UpdateSchedule
$cfrom :: forall x. UpdateSchedule -> Rep UpdateSchedule x
Prelude.Generic)

-- |
-- Create a value of 'UpdateSchedule' 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:
--
-- 'jobNames', 'updateSchedule_jobNames' - The name or names of one or more jobs to be run for this schedule.
--
-- 'cronExpression', 'updateSchedule_cronExpression' - The date or dates and time or times when the jobs are to be run. For
-- more information, see
-- <https://docs.aws.amazon.com/databrew/latest/dg/jobs.cron.html Cron expressions>
-- in the /Glue DataBrew Developer Guide/.
--
-- 'name', 'updateSchedule_name' - The name of the schedule to update.
newUpdateSchedule ::
  -- | 'cronExpression'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  UpdateSchedule
newUpdateSchedule :: Text -> Text -> UpdateSchedule
newUpdateSchedule Text
pCronExpression_ Text
pName_ =
  UpdateSchedule' :: Maybe [Text] -> Text -> Text -> UpdateSchedule
UpdateSchedule'
    { $sel:jobNames:UpdateSchedule' :: Maybe [Text]
jobNames = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:cronExpression:UpdateSchedule' :: Text
cronExpression = Text
pCronExpression_,
      $sel:name:UpdateSchedule' :: Text
name = Text
pName_
    }

-- | The name or names of one or more jobs to be run for this schedule.
updateSchedule_jobNames :: Lens.Lens' UpdateSchedule (Prelude.Maybe [Prelude.Text])
updateSchedule_jobNames :: (Maybe [Text] -> f (Maybe [Text]))
-> UpdateSchedule -> f UpdateSchedule
updateSchedule_jobNames = (UpdateSchedule -> Maybe [Text])
-> (UpdateSchedule -> Maybe [Text] -> UpdateSchedule)
-> Lens UpdateSchedule UpdateSchedule (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSchedule' {Maybe [Text]
jobNames :: Maybe [Text]
$sel:jobNames:UpdateSchedule' :: UpdateSchedule -> Maybe [Text]
jobNames} -> Maybe [Text]
jobNames) (\s :: UpdateSchedule
s@UpdateSchedule' {} Maybe [Text]
a -> UpdateSchedule
s {$sel:jobNames:UpdateSchedule' :: Maybe [Text]
jobNames = Maybe [Text]
a} :: UpdateSchedule) ((Maybe [Text] -> f (Maybe [Text]))
 -> UpdateSchedule -> f UpdateSchedule)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> UpdateSchedule
-> f UpdateSchedule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The date or dates and time or times when the jobs are to be run. For
-- more information, see
-- <https://docs.aws.amazon.com/databrew/latest/dg/jobs.cron.html Cron expressions>
-- in the /Glue DataBrew Developer Guide/.
updateSchedule_cronExpression :: Lens.Lens' UpdateSchedule Prelude.Text
updateSchedule_cronExpression :: (Text -> f Text) -> UpdateSchedule -> f UpdateSchedule
updateSchedule_cronExpression = (UpdateSchedule -> Text)
-> (UpdateSchedule -> Text -> UpdateSchedule)
-> Lens UpdateSchedule UpdateSchedule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSchedule' {Text
cronExpression :: Text
$sel:cronExpression:UpdateSchedule' :: UpdateSchedule -> Text
cronExpression} -> Text
cronExpression) (\s :: UpdateSchedule
s@UpdateSchedule' {} Text
a -> UpdateSchedule
s {$sel:cronExpression:UpdateSchedule' :: Text
cronExpression = Text
a} :: UpdateSchedule)

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

instance Core.AWSRequest UpdateSchedule where
  type
    AWSResponse UpdateSchedule =
      UpdateScheduleResponse
  request :: UpdateSchedule -> Request UpdateSchedule
request = Service -> UpdateSchedule -> Request UpdateSchedule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateSchedule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateSchedule)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateSchedule))
-> Logger
-> Service
-> Proxy UpdateSchedule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateSchedule)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> Text -> UpdateScheduleResponse
UpdateScheduleResponse'
            (Int -> Text -> UpdateScheduleResponse)
-> Either String Int
-> Either String (Text -> UpdateScheduleResponse)
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))
            Either String (Text -> UpdateScheduleResponse)
-> Either String Text -> Either String UpdateScheduleResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"Name")
      )

instance Prelude.Hashable UpdateSchedule

instance Prelude.NFData UpdateSchedule

instance Core.ToHeaders UpdateSchedule where
  toHeaders :: UpdateSchedule -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateSchedule -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 UpdateSchedule where
  toJSON :: UpdateSchedule -> Value
toJSON UpdateSchedule' {Maybe [Text]
Text
name :: Text
cronExpression :: Text
jobNames :: Maybe [Text]
$sel:name:UpdateSchedule' :: UpdateSchedule -> Text
$sel:cronExpression:UpdateSchedule' :: UpdateSchedule -> Text
$sel:jobNames:UpdateSchedule' :: UpdateSchedule -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"JobNames" 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]
jobNames,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"CronExpression" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
cronExpression)
          ]
      )

instance Core.ToPath UpdateSchedule where
  toPath :: UpdateSchedule -> ByteString
toPath UpdateSchedule' {Maybe [Text]
Text
name :: Text
cronExpression :: Text
jobNames :: Maybe [Text]
$sel:name:UpdateSchedule' :: UpdateSchedule -> Text
$sel:cronExpression:UpdateSchedule' :: UpdateSchedule -> Text
$sel:jobNames:UpdateSchedule' :: UpdateSchedule -> Maybe [Text]
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/schedules/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
name]

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

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

-- |
-- Create a value of 'UpdateScheduleResponse' 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', 'updateScheduleResponse_httpStatus' - The response's http status code.
--
-- 'name', 'updateScheduleResponse_name' - The name of the schedule that was updated.
newUpdateScheduleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'name'
  Prelude.Text ->
  UpdateScheduleResponse
newUpdateScheduleResponse :: Int -> Text -> UpdateScheduleResponse
newUpdateScheduleResponse Int
pHttpStatus_ Text
pName_ =
  UpdateScheduleResponse' :: Int -> Text -> UpdateScheduleResponse
UpdateScheduleResponse'
    { $sel:httpStatus:UpdateScheduleResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:name:UpdateScheduleResponse' :: Text
name = Text
pName_
    }

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

-- | The name of the schedule that was updated.
updateScheduleResponse_name :: Lens.Lens' UpdateScheduleResponse Prelude.Text
updateScheduleResponse_name :: (Text -> f Text)
-> UpdateScheduleResponse -> f UpdateScheduleResponse
updateScheduleResponse_name = (UpdateScheduleResponse -> Text)
-> (UpdateScheduleResponse -> Text -> UpdateScheduleResponse)
-> Lens UpdateScheduleResponse UpdateScheduleResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateScheduleResponse' {Text
name :: Text
$sel:name:UpdateScheduleResponse' :: UpdateScheduleResponse -> Text
name} -> Text
name) (\s :: UpdateScheduleResponse
s@UpdateScheduleResponse' {} Text
a -> UpdateScheduleResponse
s {$sel:name:UpdateScheduleResponse' :: Text
name = Text
a} :: UpdateScheduleResponse)

instance Prelude.NFData UpdateScheduleResponse