{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DataSync.Types.TaskSchedule where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $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 :: Lens' TaskSchedule Text
taskSchedule_scheduleExpression = 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 Data.FromJSON TaskSchedule where
  parseJSON :: Value -> Parser TaskSchedule
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TaskSchedule"
      ( \Object
x ->
          Text -> TaskSchedule
TaskSchedule'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ScheduleExpression")
      )

instance Prelude.Hashable TaskSchedule where
  hashWithSalt :: Int -> TaskSchedule -> Int
hashWithSalt Int
_salt TaskSchedule' {Text
scheduleExpression :: Text
$sel:scheduleExpression:TaskSchedule' :: TaskSchedule -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
scheduleExpression

instance Prelude.NFData TaskSchedule where
  rnf :: TaskSchedule -> ()
rnf TaskSchedule' {Text
scheduleExpression :: Text
$sel:scheduleExpression:TaskSchedule' :: TaskSchedule -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
scheduleExpression

instance Data.ToJSON TaskSchedule where
  toJSON :: TaskSchedule -> Value
toJSON TaskSchedule' {Text
scheduleExpression :: Text
$sel:scheduleExpression:TaskSchedule' :: TaskSchedule -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"ScheduleExpression" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
scheduleExpression)
          ]
      )