{-# 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.SageMaker.Types.ScheduleConfig
-- 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.SageMaker.Types.ScheduleConfig 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

-- | Configuration details about the monitoring schedule.
--
-- /See:/ 'newScheduleConfig' smart constructor.
data ScheduleConfig = ScheduleConfig'
  { -- | A cron expression that describes details about the monitoring schedule.
    --
    -- Currently the only supported cron expressions are:
    --
    -- -   If you want to set the job to start every hour, please use the
    --     following:
    --
    --     @Hourly: cron(0 * ? * * *)@
    --
    -- -   If you want to start the job daily:
    --
    --     @cron(0 [00-23] ? * * *)@
    --
    -- For example, the following are valid cron expressions:
    --
    -- -   Daily at noon UTC: @cron(0 12 ? * * *)@
    --
    -- -   Daily at midnight UTC: @cron(0 0 ? * * *)@
    --
    -- To support running every 6, 12 hours, the following are also supported:
    --
    -- @cron(0 [00-23]\/[01-24] ? * * *)@
    --
    -- For example, the following are valid cron expressions:
    --
    -- -   Every 12 hours, starting at 5pm UTC: @cron(0 17\/12 ? * * *)@
    --
    -- -   Every two hours starting at midnight: @cron(0 0\/2 ? * * *)@
    --
    -- -   Even though the cron expression is set to start at 5PM UTC, note
    --     that there could be a delay of 0-20 minutes from the actual
    --     requested time to run the execution.
    --
    -- -   We recommend that if you would like a daily schedule, you do not
    --     provide this parameter. Amazon SageMaker will pick a time for
    --     running every day.
    ScheduleConfig -> Text
scheduleExpression :: Prelude.Text
  }
  deriving (ScheduleConfig -> ScheduleConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScheduleConfig -> ScheduleConfig -> Bool
$c/= :: ScheduleConfig -> ScheduleConfig -> Bool
== :: ScheduleConfig -> ScheduleConfig -> Bool
$c== :: ScheduleConfig -> ScheduleConfig -> Bool
Prelude.Eq, ReadPrec [ScheduleConfig]
ReadPrec ScheduleConfig
Int -> ReadS ScheduleConfig
ReadS [ScheduleConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScheduleConfig]
$creadListPrec :: ReadPrec [ScheduleConfig]
readPrec :: ReadPrec ScheduleConfig
$creadPrec :: ReadPrec ScheduleConfig
readList :: ReadS [ScheduleConfig]
$creadList :: ReadS [ScheduleConfig]
readsPrec :: Int -> ReadS ScheduleConfig
$creadsPrec :: Int -> ReadS ScheduleConfig
Prelude.Read, Int -> ScheduleConfig -> ShowS
[ScheduleConfig] -> ShowS
ScheduleConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScheduleConfig] -> ShowS
$cshowList :: [ScheduleConfig] -> ShowS
show :: ScheduleConfig -> String
$cshow :: ScheduleConfig -> String
showsPrec :: Int -> ScheduleConfig -> ShowS
$cshowsPrec :: Int -> ScheduleConfig -> ShowS
Prelude.Show, forall x. Rep ScheduleConfig x -> ScheduleConfig
forall x. ScheduleConfig -> Rep ScheduleConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ScheduleConfig x -> ScheduleConfig
$cfrom :: forall x. ScheduleConfig -> Rep ScheduleConfig x
Prelude.Generic)

-- |
-- Create a value of 'ScheduleConfig' 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', 'scheduleConfig_scheduleExpression' - A cron expression that describes details about the monitoring schedule.
--
-- Currently the only supported cron expressions are:
--
-- -   If you want to set the job to start every hour, please use the
--     following:
--
--     @Hourly: cron(0 * ? * * *)@
--
-- -   If you want to start the job daily:
--
--     @cron(0 [00-23] ? * * *)@
--
-- For example, the following are valid cron expressions:
--
-- -   Daily at noon UTC: @cron(0 12 ? * * *)@
--
-- -   Daily at midnight UTC: @cron(0 0 ? * * *)@
--
-- To support running every 6, 12 hours, the following are also supported:
--
-- @cron(0 [00-23]\/[01-24] ? * * *)@
--
-- For example, the following are valid cron expressions:
--
-- -   Every 12 hours, starting at 5pm UTC: @cron(0 17\/12 ? * * *)@
--
-- -   Every two hours starting at midnight: @cron(0 0\/2 ? * * *)@
--
-- -   Even though the cron expression is set to start at 5PM UTC, note
--     that there could be a delay of 0-20 minutes from the actual
--     requested time to run the execution.
--
-- -   We recommend that if you would like a daily schedule, you do not
--     provide this parameter. Amazon SageMaker will pick a time for
--     running every day.
newScheduleConfig ::
  -- | 'scheduleExpression'
  Prelude.Text ->
  ScheduleConfig
newScheduleConfig :: Text -> ScheduleConfig
newScheduleConfig Text
pScheduleExpression_ =
  ScheduleConfig'
    { $sel:scheduleExpression:ScheduleConfig' :: Text
scheduleExpression =
        Text
pScheduleExpression_
    }

-- | A cron expression that describes details about the monitoring schedule.
--
-- Currently the only supported cron expressions are:
--
-- -   If you want to set the job to start every hour, please use the
--     following:
--
--     @Hourly: cron(0 * ? * * *)@
--
-- -   If you want to start the job daily:
--
--     @cron(0 [00-23] ? * * *)@
--
-- For example, the following are valid cron expressions:
--
-- -   Daily at noon UTC: @cron(0 12 ? * * *)@
--
-- -   Daily at midnight UTC: @cron(0 0 ? * * *)@
--
-- To support running every 6, 12 hours, the following are also supported:
--
-- @cron(0 [00-23]\/[01-24] ? * * *)@
--
-- For example, the following are valid cron expressions:
--
-- -   Every 12 hours, starting at 5pm UTC: @cron(0 17\/12 ? * * *)@
--
-- -   Every two hours starting at midnight: @cron(0 0\/2 ? * * *)@
--
-- -   Even though the cron expression is set to start at 5PM UTC, note
--     that there could be a delay of 0-20 minutes from the actual
--     requested time to run the execution.
--
-- -   We recommend that if you would like a daily schedule, you do not
--     provide this parameter. Amazon SageMaker will pick a time for
--     running every day.
scheduleConfig_scheduleExpression :: Lens.Lens' ScheduleConfig Prelude.Text
scheduleConfig_scheduleExpression :: Lens' ScheduleConfig Text
scheduleConfig_scheduleExpression = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduleConfig' {Text
scheduleExpression :: Text
$sel:scheduleExpression:ScheduleConfig' :: ScheduleConfig -> Text
scheduleExpression} -> Text
scheduleExpression) (\s :: ScheduleConfig
s@ScheduleConfig' {} Text
a -> ScheduleConfig
s {$sel:scheduleExpression:ScheduleConfig' :: Text
scheduleExpression = Text
a} :: ScheduleConfig)

instance Data.FromJSON ScheduleConfig where
  parseJSON :: Value -> Parser ScheduleConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ScheduleConfig"
      ( \Object
x ->
          Text -> ScheduleConfig
ScheduleConfig'
            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 ScheduleConfig where
  hashWithSalt :: Int -> ScheduleConfig -> Int
hashWithSalt Int
_salt ScheduleConfig' {Text
scheduleExpression :: Text
$sel:scheduleExpression:ScheduleConfig' :: ScheduleConfig -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
scheduleExpression

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

instance Data.ToJSON ScheduleConfig where
  toJSON :: ScheduleConfig -> Value
toJSON ScheduleConfig' {Text
scheduleExpression :: Text
$sel:scheduleExpression:ScheduleConfig' :: ScheduleConfig -> 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)
          ]
      )