{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingStrategies #-}

module Hercules.API.Projects.JobHandlers.OnScheduleHandler
  ( OnScheduleHandler (..),
    TimeConstraints (..),
  )
where

import Hercules.API.DayOfWeek (DayOfWeek)
import Hercules.API.Prelude

data OnScheduleHandler = OnScheduleHandler
  { OnScheduleHandler -> Text
name :: Text,
    OnScheduleHandler -> Bool
isFlake :: Bool,
    OnScheduleHandler -> TimeConstraints
when :: TimeConstraints,
    OnScheduleHandler -> Bool
mainExists :: Bool
  }
  deriving (forall x. Rep OnScheduleHandler x -> OnScheduleHandler
forall x. OnScheduleHandler -> Rep OnScheduleHandler x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OnScheduleHandler x -> OnScheduleHandler
$cfrom :: forall x. OnScheduleHandler -> Rep OnScheduleHandler x
Generic, Int -> OnScheduleHandler -> ShowS
[OnScheduleHandler] -> ShowS
OnScheduleHandler -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OnScheduleHandler] -> ShowS
$cshowList :: [OnScheduleHandler] -> ShowS
show :: OnScheduleHandler -> String
$cshow :: OnScheduleHandler -> String
showsPrec :: Int -> OnScheduleHandler -> ShowS
$cshowsPrec :: Int -> OnScheduleHandler -> ShowS
Show, OnScheduleHandler -> OnScheduleHandler -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OnScheduleHandler -> OnScheduleHandler -> Bool
$c/= :: OnScheduleHandler -> OnScheduleHandler -> Bool
== :: OnScheduleHandler -> OnScheduleHandler -> Bool
$c== :: OnScheduleHandler -> OnScheduleHandler -> Bool
Eq)
  deriving anyclass (OnScheduleHandler -> ()
forall a. (a -> ()) -> NFData a
rnf :: OnScheduleHandler -> ()
$crnf :: OnScheduleHandler -> ()
NFData, [OnScheduleHandler] -> Encoding
[OnScheduleHandler] -> Value
OnScheduleHandler -> Encoding
OnScheduleHandler -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [OnScheduleHandler] -> Encoding
$ctoEncodingList :: [OnScheduleHandler] -> Encoding
toJSONList :: [OnScheduleHandler] -> Value
$ctoJSONList :: [OnScheduleHandler] -> Value
toEncoding :: OnScheduleHandler -> Encoding
$ctoEncoding :: OnScheduleHandler -> Encoding
toJSON :: OnScheduleHandler -> Value
$ctoJSON :: OnScheduleHandler -> Value
ToJSON, Value -> Parser [OnScheduleHandler]
Value -> Parser OnScheduleHandler
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [OnScheduleHandler]
$cparseJSONList :: Value -> Parser [OnScheduleHandler]
parseJSON :: Value -> Parser OnScheduleHandler
$cparseJSON :: Value -> Parser OnScheduleHandler
FromJSON, Proxy OnScheduleHandler -> Declare (Definitions Schema) NamedSchema
forall a.
(Proxy a -> Declare (Definitions Schema) NamedSchema) -> ToSchema a
declareNamedSchema :: Proxy OnScheduleHandler -> Declare (Definitions Schema) NamedSchema
$cdeclareNamedSchema :: Proxy OnScheduleHandler -> Declare (Definitions Schema) NamedSchema
ToSchema)

data TimeConstraints = TimeConstraints
  { TimeConstraints -> Int
minute :: Int,
    TimeConstraints -> [Int]
hour :: [Int],
    TimeConstraints -> Maybe [DayOfWeek]
dayOfWeek :: Maybe [DayOfWeek],
    TimeConstraints -> Maybe [Int]
dayOfMonth :: Maybe [Int]
  }
  deriving (forall x. Rep TimeConstraints x -> TimeConstraints
forall x. TimeConstraints -> Rep TimeConstraints x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TimeConstraints x -> TimeConstraints
$cfrom :: forall x. TimeConstraints -> Rep TimeConstraints x
Generic, Int -> TimeConstraints -> ShowS
[TimeConstraints] -> ShowS
TimeConstraints -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimeConstraints] -> ShowS
$cshowList :: [TimeConstraints] -> ShowS
show :: TimeConstraints -> String
$cshow :: TimeConstraints -> String
showsPrec :: Int -> TimeConstraints -> ShowS
$cshowsPrec :: Int -> TimeConstraints -> ShowS
Show, TimeConstraints -> TimeConstraints -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimeConstraints -> TimeConstraints -> Bool
$c/= :: TimeConstraints -> TimeConstraints -> Bool
== :: TimeConstraints -> TimeConstraints -> Bool
$c== :: TimeConstraints -> TimeConstraints -> Bool
Eq)
  deriving anyclass (TimeConstraints -> ()
forall a. (a -> ()) -> NFData a
rnf :: TimeConstraints -> ()
$crnf :: TimeConstraints -> ()
NFData, [TimeConstraints] -> Encoding
[TimeConstraints] -> Value
TimeConstraints -> Encoding
TimeConstraints -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [TimeConstraints] -> Encoding
$ctoEncodingList :: [TimeConstraints] -> Encoding
toJSONList :: [TimeConstraints] -> Value
$ctoJSONList :: [TimeConstraints] -> Value
toEncoding :: TimeConstraints -> Encoding
$ctoEncoding :: TimeConstraints -> Encoding
toJSON :: TimeConstraints -> Value
$ctoJSON :: TimeConstraints -> Value
ToJSON, Value -> Parser [TimeConstraints]
Value -> Parser TimeConstraints
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [TimeConstraints]
$cparseJSONList :: Value -> Parser [TimeConstraints]
parseJSON :: Value -> Parser TimeConstraints
$cparseJSON :: Value -> Parser TimeConstraints
FromJSON, Proxy TimeConstraints -> Declare (Definitions Schema) NamedSchema
forall a.
(Proxy a -> Declare (Definitions Schema) NamedSchema) -> ToSchema a
declareNamedSchema :: Proxy TimeConstraints -> Declare (Definitions Schema) NamedSchema
$cdeclareNamedSchema :: Proxy TimeConstraints -> Declare (Definitions Schema) NamedSchema
ToSchema)