{-# 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.IoT.Types.SchedulingConfig
-- 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.IoT.Types.SchedulingConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT.Types.JobEndBehavior
import qualified Amazonka.Prelude as Prelude

-- | Specifies the date and time that a job will begin the rollout of the job
-- document to all devices in the target group. Additionally, you can
-- specify the end behavior for each job execution when it reaches the
-- scheduled end time.
--
-- /See:/ 'newSchedulingConfig' smart constructor.
data SchedulingConfig = SchedulingConfig'
  { -- | Specifies the end behavior for all job executions after a job reaches
    -- the selected @endTime@. If @endTime@ is not selected when creating the
    -- job, then @endBehavior@ does not apply.
    SchedulingConfig -> Maybe JobEndBehavior
endBehavior :: Prelude.Maybe JobEndBehavior,
    -- | The time a job will stop rollout of the job document to all devices in
    -- the target group for a job. The @endTime@ must take place no later than
    -- two years from the current time and be scheduled a minimum of thirty
    -- minutes from the current time. The minimum duration between @startTime@
    -- and @endTime@ is thirty minutes. The maximum duration between
    -- @startTime@ and @endTime@ is two years.
    SchedulingConfig -> Maybe Text
endTime :: Prelude.Maybe Prelude.Text,
    -- | The time a job will begin rollout of the job document to all devices in
    -- the target group for a job. The @startTime@ can be scheduled up to a
    -- year in advance and must be scheduled a minimum of thirty minutes from
    -- the current time.
    SchedulingConfig -> Maybe Text
startTime :: Prelude.Maybe Prelude.Text
  }
  deriving (SchedulingConfig -> SchedulingConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SchedulingConfig -> SchedulingConfig -> Bool
$c/= :: SchedulingConfig -> SchedulingConfig -> Bool
== :: SchedulingConfig -> SchedulingConfig -> Bool
$c== :: SchedulingConfig -> SchedulingConfig -> Bool
Prelude.Eq, ReadPrec [SchedulingConfig]
ReadPrec SchedulingConfig
Int -> ReadS SchedulingConfig
ReadS [SchedulingConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SchedulingConfig]
$creadListPrec :: ReadPrec [SchedulingConfig]
readPrec :: ReadPrec SchedulingConfig
$creadPrec :: ReadPrec SchedulingConfig
readList :: ReadS [SchedulingConfig]
$creadList :: ReadS [SchedulingConfig]
readsPrec :: Int -> ReadS SchedulingConfig
$creadsPrec :: Int -> ReadS SchedulingConfig
Prelude.Read, Int -> SchedulingConfig -> ShowS
[SchedulingConfig] -> ShowS
SchedulingConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SchedulingConfig] -> ShowS
$cshowList :: [SchedulingConfig] -> ShowS
show :: SchedulingConfig -> String
$cshow :: SchedulingConfig -> String
showsPrec :: Int -> SchedulingConfig -> ShowS
$cshowsPrec :: Int -> SchedulingConfig -> ShowS
Prelude.Show, forall x. Rep SchedulingConfig x -> SchedulingConfig
forall x. SchedulingConfig -> Rep SchedulingConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SchedulingConfig x -> SchedulingConfig
$cfrom :: forall x. SchedulingConfig -> Rep SchedulingConfig x
Prelude.Generic)

-- |
-- Create a value of 'SchedulingConfig' 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:
--
-- 'endBehavior', 'schedulingConfig_endBehavior' - Specifies the end behavior for all job executions after a job reaches
-- the selected @endTime@. If @endTime@ is not selected when creating the
-- job, then @endBehavior@ does not apply.
--
-- 'endTime', 'schedulingConfig_endTime' - The time a job will stop rollout of the job document to all devices in
-- the target group for a job. The @endTime@ must take place no later than
-- two years from the current time and be scheduled a minimum of thirty
-- minutes from the current time. The minimum duration between @startTime@
-- and @endTime@ is thirty minutes. The maximum duration between
-- @startTime@ and @endTime@ is two years.
--
-- 'startTime', 'schedulingConfig_startTime' - The time a job will begin rollout of the job document to all devices in
-- the target group for a job. The @startTime@ can be scheduled up to a
-- year in advance and must be scheduled a minimum of thirty minutes from
-- the current time.
newSchedulingConfig ::
  SchedulingConfig
newSchedulingConfig :: SchedulingConfig
newSchedulingConfig =
  SchedulingConfig'
    { $sel:endBehavior:SchedulingConfig' :: Maybe JobEndBehavior
endBehavior = forall a. Maybe a
Prelude.Nothing,
      $sel:endTime:SchedulingConfig' :: Maybe Text
endTime = forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:SchedulingConfig' :: Maybe Text
startTime = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the end behavior for all job executions after a job reaches
-- the selected @endTime@. If @endTime@ is not selected when creating the
-- job, then @endBehavior@ does not apply.
schedulingConfig_endBehavior :: Lens.Lens' SchedulingConfig (Prelude.Maybe JobEndBehavior)
schedulingConfig_endBehavior :: Lens' SchedulingConfig (Maybe JobEndBehavior)
schedulingConfig_endBehavior = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchedulingConfig' {Maybe JobEndBehavior
endBehavior :: Maybe JobEndBehavior
$sel:endBehavior:SchedulingConfig' :: SchedulingConfig -> Maybe JobEndBehavior
endBehavior} -> Maybe JobEndBehavior
endBehavior) (\s :: SchedulingConfig
s@SchedulingConfig' {} Maybe JobEndBehavior
a -> SchedulingConfig
s {$sel:endBehavior:SchedulingConfig' :: Maybe JobEndBehavior
endBehavior = Maybe JobEndBehavior
a} :: SchedulingConfig)

-- | The time a job will stop rollout of the job document to all devices in
-- the target group for a job. The @endTime@ must take place no later than
-- two years from the current time and be scheduled a minimum of thirty
-- minutes from the current time. The minimum duration between @startTime@
-- and @endTime@ is thirty minutes. The maximum duration between
-- @startTime@ and @endTime@ is two years.
schedulingConfig_endTime :: Lens.Lens' SchedulingConfig (Prelude.Maybe Prelude.Text)
schedulingConfig_endTime :: Lens' SchedulingConfig (Maybe Text)
schedulingConfig_endTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchedulingConfig' {Maybe Text
endTime :: Maybe Text
$sel:endTime:SchedulingConfig' :: SchedulingConfig -> Maybe Text
endTime} -> Maybe Text
endTime) (\s :: SchedulingConfig
s@SchedulingConfig' {} Maybe Text
a -> SchedulingConfig
s {$sel:endTime:SchedulingConfig' :: Maybe Text
endTime = Maybe Text
a} :: SchedulingConfig)

-- | The time a job will begin rollout of the job document to all devices in
-- the target group for a job. The @startTime@ can be scheduled up to a
-- year in advance and must be scheduled a minimum of thirty minutes from
-- the current time.
schedulingConfig_startTime :: Lens.Lens' SchedulingConfig (Prelude.Maybe Prelude.Text)
schedulingConfig_startTime :: Lens' SchedulingConfig (Maybe Text)
schedulingConfig_startTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchedulingConfig' {Maybe Text
startTime :: Maybe Text
$sel:startTime:SchedulingConfig' :: SchedulingConfig -> Maybe Text
startTime} -> Maybe Text
startTime) (\s :: SchedulingConfig
s@SchedulingConfig' {} Maybe Text
a -> SchedulingConfig
s {$sel:startTime:SchedulingConfig' :: Maybe Text
startTime = Maybe Text
a} :: SchedulingConfig)

instance Data.FromJSON SchedulingConfig where
  parseJSON :: Value -> Parser SchedulingConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SchedulingConfig"
      ( \Object
x ->
          Maybe JobEndBehavior
-> Maybe Text -> Maybe Text -> SchedulingConfig
SchedulingConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"endBehavior")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"endTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"startTime")
      )

instance Prelude.Hashable SchedulingConfig where
  hashWithSalt :: Int -> SchedulingConfig -> Int
hashWithSalt Int
_salt SchedulingConfig' {Maybe Text
Maybe JobEndBehavior
startTime :: Maybe Text
endTime :: Maybe Text
endBehavior :: Maybe JobEndBehavior
$sel:startTime:SchedulingConfig' :: SchedulingConfig -> Maybe Text
$sel:endTime:SchedulingConfig' :: SchedulingConfig -> Maybe Text
$sel:endBehavior:SchedulingConfig' :: SchedulingConfig -> Maybe JobEndBehavior
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe JobEndBehavior
endBehavior
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
endTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
startTime

instance Prelude.NFData SchedulingConfig where
  rnf :: SchedulingConfig -> ()
rnf SchedulingConfig' {Maybe Text
Maybe JobEndBehavior
startTime :: Maybe Text
endTime :: Maybe Text
endBehavior :: Maybe JobEndBehavior
$sel:startTime:SchedulingConfig' :: SchedulingConfig -> Maybe Text
$sel:endTime:SchedulingConfig' :: SchedulingConfig -> Maybe Text
$sel:endBehavior:SchedulingConfig' :: SchedulingConfig -> Maybe JobEndBehavior
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe JobEndBehavior
endBehavior
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
endTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
startTime

instance Data.ToJSON SchedulingConfig where
  toJSON :: SchedulingConfig -> Value
toJSON SchedulingConfig' {Maybe Text
Maybe JobEndBehavior
startTime :: Maybe Text
endTime :: Maybe Text
endBehavior :: Maybe JobEndBehavior
$sel:startTime:SchedulingConfig' :: SchedulingConfig -> Maybe Text
$sel:endTime:SchedulingConfig' :: SchedulingConfig -> Maybe Text
$sel:endBehavior:SchedulingConfig' :: SchedulingConfig -> Maybe JobEndBehavior
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"endBehavior" 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 JobEndBehavior
endBehavior,
            (Key
"endTime" 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
endTime,
            (Key
"startTime" 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
startTime
          ]
      )