{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.DataSync.Types.TaskSchedule
-- 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)
module Amazonka.DataSync.Types.TaskSchedule where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies the schedule you want your task to use for repeated
-- executions. For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html Schedule Expressions for Rules>.
--
-- /See:/ 'newTaskSchedule' smart constructor.
data TaskSchedule = TaskSchedule'
  { -- | A cron expression that specifies when DataSync initiates a scheduled
    -- transfer from a source to a destination location.
    TaskSchedule -> Text
scheduleExpression :: Prelude.Text
  }
  deriving (TaskSchedule -> TaskSchedule -> Bool
(TaskSchedule -> TaskSchedule -> Bool)
-> (TaskSchedule -> TaskSchedule -> Bool) -> Eq TaskSchedule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TaskSchedule -> TaskSchedule -> Bool
$c/= :: TaskSchedule -> TaskSchedule -> Bool
== :: TaskSchedule -> TaskSchedule -> Bool
$c== :: TaskSchedule -> TaskSchedule -> Bool
Prelude.Eq, ReadPrec [TaskSchedule]
ReadPrec TaskSchedule
Int -> ReadS TaskSchedule
ReadS [TaskSchedule]
(Int -> ReadS TaskSchedule)
-> ReadS [TaskSchedule]
-> ReadPrec TaskSchedule
-> ReadPrec [TaskSchedule]
-> Read TaskSchedule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TaskSchedule]
$creadListPrec :: ReadPrec [TaskSchedule]
readPrec :: ReadPrec TaskSchedule
$creadPrec :: ReadPrec TaskSchedule
readList :: ReadS [TaskSchedule]
$creadList :: ReadS [TaskSchedule]
readsPrec :: Int -> ReadS TaskSchedule
$creadsPrec :: Int -> ReadS TaskSchedule
Prelude.Read, Int -> TaskSchedule -> ShowS
[TaskSchedule] -> ShowS
TaskSchedule -> String
(Int -> TaskSchedule -> ShowS)
-> (TaskSchedule -> String)
-> ([TaskSchedule] -> ShowS)
-> Show TaskSchedule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TaskSchedule] -> ShowS
$cshowList :: [TaskSchedule] -> ShowS
show :: TaskSchedule -> String
$cshow :: TaskSchedule -> String
showsPrec :: Int -> TaskSchedule -> ShowS
$cshowsPrec :: Int -> TaskSchedule -> ShowS
Prelude.Show, (forall x. TaskSchedule -> Rep TaskSchedule x)
-> (forall x. Rep TaskSchedule x -> TaskSchedule)
-> Generic TaskSchedule
forall x. Rep TaskSchedule x -> TaskSchedule
forall x. TaskSchedule -> Rep TaskSchedule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TaskSchedule x -> TaskSchedule
$cfrom :: forall x. TaskSchedule -> Rep TaskSchedule x
Prelude.Generic)

-- |
-- Create a value of 'TaskSchedule' 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:
--
-- 'scheduleExpression', 'taskSchedule_scheduleExpression' - A cron expression that specifies when DataSync initiates a scheduled
-- transfer from a source to a destination location.
newTaskSchedule ::
  -- | 'scheduleExpression'
  Prelude.Text ->
  TaskSchedule
newTaskSchedule :: Text -> TaskSchedule
newTaskSchedule Text
pScheduleExpression_ =
  TaskSchedule' :: Text -> TaskSchedule
TaskSchedule'
    { $sel:scheduleExpression:TaskSchedule' :: Text
scheduleExpression =
        Text
pScheduleExpression_
    }

-- | A cron expression that specifies when DataSync initiates a scheduled
-- transfer from a source to a destination location.
taskSchedule_scheduleExpression :: Lens.Lens' TaskSchedule Prelude.Text
taskSchedule_scheduleExpression :: (Text -> f Text) -> TaskSchedule -> f TaskSchedule
taskSchedule_scheduleExpression = (TaskSchedule -> Text)
-> (TaskSchedule -> Text -> TaskSchedule)
-> Lens TaskSchedule TaskSchedule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TaskSchedule' {Text
scheduleExpression :: Text
$sel:scheduleExpression:TaskSchedule' :: TaskSchedule -> Text
scheduleExpression} -> Text
scheduleExpression) (\s :: TaskSchedule
s@TaskSchedule' {} Text
a -> TaskSchedule
s {$sel:scheduleExpression:TaskSchedule' :: Text
scheduleExpression = Text
a} :: TaskSchedule)

instance Core.FromJSON TaskSchedule where
  parseJSON :: Value -> Parser TaskSchedule
parseJSON =
    String
-> (Object -> Parser TaskSchedule) -> Value -> Parser TaskSchedule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TaskSchedule"
      ( \Object
x ->
          Text -> TaskSchedule
TaskSchedule'
            (Text -> TaskSchedule) -> Parser Text -> Parser TaskSchedule
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ScheduleExpression")
      )

instance Prelude.Hashable TaskSchedule

instance Prelude.NFData TaskSchedule

instance Core.ToJSON TaskSchedule where
  toJSON :: TaskSchedule -> Value
toJSON TaskSchedule' {Text
scheduleExpression :: Text
$sel:scheduleExpression:TaskSchedule' :: TaskSchedule -> 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
"ScheduleExpression" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
scheduleExpression)
          ]
      )