{-# 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.TimeStreamQuery.Types.ScheduleConfiguration
-- 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.TimeStreamQuery.Types.ScheduleConfiguration 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 of the schedule of the query.
--
-- /See:/ 'newScheduleConfiguration' smart constructor.
data ScheduleConfiguration = ScheduleConfiguration'
  { -- | An expression that denotes when to trigger the scheduled query run. This
    -- can be a cron expression or a rate expression.
    ScheduleConfiguration -> Text
scheduleExpression :: Prelude.Text
  }
  deriving (ScheduleConfiguration -> ScheduleConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScheduleConfiguration -> ScheduleConfiguration -> Bool
$c/= :: ScheduleConfiguration -> ScheduleConfiguration -> Bool
== :: ScheduleConfiguration -> ScheduleConfiguration -> Bool
$c== :: ScheduleConfiguration -> ScheduleConfiguration -> Bool
Prelude.Eq, ReadPrec [ScheduleConfiguration]
ReadPrec ScheduleConfiguration
Int -> ReadS ScheduleConfiguration
ReadS [ScheduleConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScheduleConfiguration]
$creadListPrec :: ReadPrec [ScheduleConfiguration]
readPrec :: ReadPrec ScheduleConfiguration
$creadPrec :: ReadPrec ScheduleConfiguration
readList :: ReadS [ScheduleConfiguration]
$creadList :: ReadS [ScheduleConfiguration]
readsPrec :: Int -> ReadS ScheduleConfiguration
$creadsPrec :: Int -> ReadS ScheduleConfiguration
Prelude.Read, Int -> ScheduleConfiguration -> ShowS
[ScheduleConfiguration] -> ShowS
ScheduleConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScheduleConfiguration] -> ShowS
$cshowList :: [ScheduleConfiguration] -> ShowS
show :: ScheduleConfiguration -> String
$cshow :: ScheduleConfiguration -> String
showsPrec :: Int -> ScheduleConfiguration -> ShowS
$cshowsPrec :: Int -> ScheduleConfiguration -> ShowS
Prelude.Show, forall x. Rep ScheduleConfiguration x -> ScheduleConfiguration
forall x. ScheduleConfiguration -> Rep ScheduleConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ScheduleConfiguration x -> ScheduleConfiguration
$cfrom :: forall x. ScheduleConfiguration -> Rep ScheduleConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ScheduleConfiguration' 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', 'scheduleConfiguration_scheduleExpression' - An expression that denotes when to trigger the scheduled query run. This
-- can be a cron expression or a rate expression.
newScheduleConfiguration ::
  -- | 'scheduleExpression'
  Prelude.Text ->
  ScheduleConfiguration
newScheduleConfiguration :: Text -> ScheduleConfiguration
newScheduleConfiguration Text
pScheduleExpression_ =
  ScheduleConfiguration'
    { $sel:scheduleExpression:ScheduleConfiguration' :: Text
scheduleExpression =
        Text
pScheduleExpression_
    }

-- | An expression that denotes when to trigger the scheduled query run. This
-- can be a cron expression or a rate expression.
scheduleConfiguration_scheduleExpression :: Lens.Lens' ScheduleConfiguration Prelude.Text
scheduleConfiguration_scheduleExpression :: Lens' ScheduleConfiguration Text
scheduleConfiguration_scheduleExpression = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduleConfiguration' {Text
scheduleExpression :: Text
$sel:scheduleExpression:ScheduleConfiguration' :: ScheduleConfiguration -> Text
scheduleExpression} -> Text
scheduleExpression) (\s :: ScheduleConfiguration
s@ScheduleConfiguration' {} Text
a -> ScheduleConfiguration
s {$sel:scheduleExpression:ScheduleConfiguration' :: Text
scheduleExpression = Text
a} :: ScheduleConfiguration)

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

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

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