{-# 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.KinesisVideo.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.KinesisVideo.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

-- | This API enables you to specify the duration that the camera, or local
-- media file, should record onto the Edge Agent. The @ScheduleConfig@
-- consists of the @ScheduleExpression@ and the @DurationInMinutes@
-- attributes.
--
-- If the @ScheduleExpression@ is not provided, then the Edge Agent will
-- always be set to recording mode.
--
-- /See:/ 'newScheduleConfig' smart constructor.
data ScheduleConfig = ScheduleConfig'
  { -- | The Quartz cron expression that takes care of scheduling jobs to record
    -- from the camera, or local media file, onto the Edge Agent. If the
    -- @ScheduleExpression@ is not provided for the @RecorderConfig@, then the
    -- Edge Agent will always be set to recording mode.
    --
    -- For more information about Quartz, refer to the
    -- <http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html Cron Trigger Tutorial>
    -- page to understand the valid expressions and its use.
    ScheduleConfig -> Text
scheduleExpression :: Prelude.Text,
    -- | The total duration to record the media. If the @ScheduleExpression@
    -- attribute is provided, then the @DurationInSeconds@ attribute should
    -- also be specified.
    ScheduleConfig -> Natural
durationInSeconds :: Prelude.Natural
  }
  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' - The Quartz cron expression that takes care of scheduling jobs to record
-- from the camera, or local media file, onto the Edge Agent. If the
-- @ScheduleExpression@ is not provided for the @RecorderConfig@, then the
-- Edge Agent will always be set to recording mode.
--
-- For more information about Quartz, refer to the
-- <http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html Cron Trigger Tutorial>
-- page to understand the valid expressions and its use.
--
-- 'durationInSeconds', 'scheduleConfig_durationInSeconds' - The total duration to record the media. If the @ScheduleExpression@
-- attribute is provided, then the @DurationInSeconds@ attribute should
-- also be specified.
newScheduleConfig ::
  -- | 'scheduleExpression'
  Prelude.Text ->
  -- | 'durationInSeconds'
  Prelude.Natural ->
  ScheduleConfig
newScheduleConfig :: Text -> Natural -> ScheduleConfig
newScheduleConfig
  Text
pScheduleExpression_
  Natural
pDurationInSeconds_ =
    ScheduleConfig'
      { $sel:scheduleExpression:ScheduleConfig' :: Text
scheduleExpression =
          Text
pScheduleExpression_,
        $sel:durationInSeconds:ScheduleConfig' :: Natural
durationInSeconds = Natural
pDurationInSeconds_
      }

-- | The Quartz cron expression that takes care of scheduling jobs to record
-- from the camera, or local media file, onto the Edge Agent. If the
-- @ScheduleExpression@ is not provided for the @RecorderConfig@, then the
-- Edge Agent will always be set to recording mode.
--
-- For more information about Quartz, refer to the
-- <http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html Cron Trigger Tutorial>
-- page to understand the valid expressions and its use.
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)

-- | The total duration to record the media. If the @ScheduleExpression@
-- attribute is provided, then the @DurationInSeconds@ attribute should
-- also be specified.
scheduleConfig_durationInSeconds :: Lens.Lens' ScheduleConfig Prelude.Natural
scheduleConfig_durationInSeconds :: Lens' ScheduleConfig Natural
scheduleConfig_durationInSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduleConfig' {Natural
durationInSeconds :: Natural
$sel:durationInSeconds:ScheduleConfig' :: ScheduleConfig -> Natural
durationInSeconds} -> Natural
durationInSeconds) (\s :: ScheduleConfig
s@ScheduleConfig' {} Natural
a -> ScheduleConfig
s {$sel:durationInSeconds:ScheduleConfig' :: Natural
durationInSeconds = Natural
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 -> Natural -> 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")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"DurationInSeconds")
      )

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

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

instance Data.ToJSON ScheduleConfig where
  toJSON :: ScheduleConfig -> Value
toJSON ScheduleConfig' {Natural
Text
durationInSeconds :: Natural
scheduleExpression :: Text
$sel:durationInSeconds:ScheduleConfig' :: ScheduleConfig -> Natural
$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),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"DurationInSeconds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
durationInSeconds)
          ]
      )