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

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

import Data.OpenApi qualified as O3
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. OnScheduleHandler -> Rep OnScheduleHandler x)
-> (forall x. Rep OnScheduleHandler x -> OnScheduleHandler)
-> Generic OnScheduleHandler
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
$cfrom :: forall x. OnScheduleHandler -> Rep OnScheduleHandler x
from :: forall x. OnScheduleHandler -> Rep OnScheduleHandler x
$cto :: forall x. Rep OnScheduleHandler x -> OnScheduleHandler
to :: forall x. Rep OnScheduleHandler x -> OnScheduleHandler
Generic, Int -> OnScheduleHandler -> ShowS
[OnScheduleHandler] -> ShowS
OnScheduleHandler -> String
(Int -> OnScheduleHandler -> ShowS)
-> (OnScheduleHandler -> String)
-> ([OnScheduleHandler] -> ShowS)
-> Show OnScheduleHandler
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> OnScheduleHandler -> ShowS
showsPrec :: Int -> OnScheduleHandler -> ShowS
$cshow :: OnScheduleHandler -> String
show :: OnScheduleHandler -> String
$cshowList :: [OnScheduleHandler] -> ShowS
showList :: [OnScheduleHandler] -> ShowS
Show, OnScheduleHandler -> OnScheduleHandler -> Bool
(OnScheduleHandler -> OnScheduleHandler -> Bool)
-> (OnScheduleHandler -> OnScheduleHandler -> Bool)
-> Eq OnScheduleHandler
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: OnScheduleHandler -> OnScheduleHandler -> Bool
== :: OnScheduleHandler -> OnScheduleHandler -> Bool
$c/= :: OnScheduleHandler -> OnScheduleHandler -> Bool
/= :: OnScheduleHandler -> OnScheduleHandler -> Bool
Eq)
  deriving anyclass (OnScheduleHandler -> ()
(OnScheduleHandler -> ()) -> NFData OnScheduleHandler
forall a. (a -> ()) -> NFData a
$crnf :: OnScheduleHandler -> ()
rnf :: OnScheduleHandler -> ()
NFData, [OnScheduleHandler] -> Value
[OnScheduleHandler] -> Encoding
OnScheduleHandler -> Value
OnScheduleHandler -> Encoding
(OnScheduleHandler -> Value)
-> (OnScheduleHandler -> Encoding)
-> ([OnScheduleHandler] -> Value)
-> ([OnScheduleHandler] -> Encoding)
-> ToJSON OnScheduleHandler
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: OnScheduleHandler -> Value
toJSON :: OnScheduleHandler -> Value
$ctoEncoding :: OnScheduleHandler -> Encoding
toEncoding :: OnScheduleHandler -> Encoding
$ctoJSONList :: [OnScheduleHandler] -> Value
toJSONList :: [OnScheduleHandler] -> Value
$ctoEncodingList :: [OnScheduleHandler] -> Encoding
toEncodingList :: [OnScheduleHandler] -> Encoding
ToJSON, Value -> Parser [OnScheduleHandler]
Value -> Parser OnScheduleHandler
(Value -> Parser OnScheduleHandler)
-> (Value -> Parser [OnScheduleHandler])
-> FromJSON OnScheduleHandler
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser OnScheduleHandler
parseJSON :: Value -> Parser OnScheduleHandler
$cparseJSONList :: Value -> Parser [OnScheduleHandler]
parseJSONList :: Value -> Parser [OnScheduleHandler]
FromJSON, Proxy OnScheduleHandler -> Declare (Definitions Schema) NamedSchema
(Proxy OnScheduleHandler
 -> Declare (Definitions Schema) NamedSchema)
-> ToSchema OnScheduleHandler
forall a.
(Proxy a -> Declare (Definitions Schema) NamedSchema) -> ToSchema a
$cdeclareNamedSchema :: Proxy OnScheduleHandler -> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy OnScheduleHandler -> Declare (Definitions Schema) NamedSchema
ToSchema, Typeable OnScheduleHandler
Typeable OnScheduleHandler
-> (Proxy OnScheduleHandler
    -> Declare (Definitions Schema) NamedSchema)
-> ToSchema OnScheduleHandler
Proxy OnScheduleHandler -> Declare (Definitions Schema) NamedSchema
forall a.
Typeable a
-> (Proxy a -> Declare (Definitions Schema) NamedSchema)
-> ToSchema a
$cdeclareNamedSchema :: Proxy OnScheduleHandler -> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy OnScheduleHandler -> Declare (Definitions Schema) NamedSchema
O3.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. TimeConstraints -> Rep TimeConstraints x)
-> (forall x. Rep TimeConstraints x -> TimeConstraints)
-> Generic TimeConstraints
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
$cfrom :: forall x. TimeConstraints -> Rep TimeConstraints x
from :: forall x. TimeConstraints -> Rep TimeConstraints x
$cto :: forall x. Rep TimeConstraints x -> TimeConstraints
to :: forall x. Rep TimeConstraints x -> TimeConstraints
Generic, Int -> TimeConstraints -> ShowS
[TimeConstraints] -> ShowS
TimeConstraints -> String
(Int -> TimeConstraints -> ShowS)
-> (TimeConstraints -> String)
-> ([TimeConstraints] -> ShowS)
-> Show TimeConstraints
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TimeConstraints -> ShowS
showsPrec :: Int -> TimeConstraints -> ShowS
$cshow :: TimeConstraints -> String
show :: TimeConstraints -> String
$cshowList :: [TimeConstraints] -> ShowS
showList :: [TimeConstraints] -> ShowS
Show, TimeConstraints -> TimeConstraints -> Bool
(TimeConstraints -> TimeConstraints -> Bool)
-> (TimeConstraints -> TimeConstraints -> Bool)
-> Eq TimeConstraints
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TimeConstraints -> TimeConstraints -> Bool
== :: TimeConstraints -> TimeConstraints -> Bool
$c/= :: TimeConstraints -> TimeConstraints -> Bool
/= :: TimeConstraints -> TimeConstraints -> Bool
Eq)
  deriving anyclass (TimeConstraints -> ()
(TimeConstraints -> ()) -> NFData TimeConstraints
forall a. (a -> ()) -> NFData a
$crnf :: TimeConstraints -> ()
rnf :: TimeConstraints -> ()
NFData, [TimeConstraints] -> Value
[TimeConstraints] -> Encoding
TimeConstraints -> Value
TimeConstraints -> Encoding
(TimeConstraints -> Value)
-> (TimeConstraints -> Encoding)
-> ([TimeConstraints] -> Value)
-> ([TimeConstraints] -> Encoding)
-> ToJSON TimeConstraints
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: TimeConstraints -> Value
toJSON :: TimeConstraints -> Value
$ctoEncoding :: TimeConstraints -> Encoding
toEncoding :: TimeConstraints -> Encoding
$ctoJSONList :: [TimeConstraints] -> Value
toJSONList :: [TimeConstraints] -> Value
$ctoEncodingList :: [TimeConstraints] -> Encoding
toEncodingList :: [TimeConstraints] -> Encoding
ToJSON, Value -> Parser [TimeConstraints]
Value -> Parser TimeConstraints
(Value -> Parser TimeConstraints)
-> (Value -> Parser [TimeConstraints]) -> FromJSON TimeConstraints
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser TimeConstraints
parseJSON :: Value -> Parser TimeConstraints
$cparseJSONList :: Value -> Parser [TimeConstraints]
parseJSONList :: Value -> Parser [TimeConstraints]
FromJSON, Proxy TimeConstraints -> Declare (Definitions Schema) NamedSchema
(Proxy TimeConstraints -> Declare (Definitions Schema) NamedSchema)
-> ToSchema TimeConstraints
forall a.
(Proxy a -> Declare (Definitions Schema) NamedSchema) -> ToSchema a
$cdeclareNamedSchema :: Proxy TimeConstraints -> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy TimeConstraints -> Declare (Definitions Schema) NamedSchema
ToSchema, Typeable TimeConstraints
Typeable TimeConstraints
-> (Proxy TimeConstraints
    -> Declare (Definitions Schema) NamedSchema)
-> ToSchema TimeConstraints
Proxy TimeConstraints -> Declare (Definitions Schema) NamedSchema
forall a.
Typeable a
-> (Proxy a -> Declare (Definitions Schema) NamedSchema)
-> ToSchema a
$cdeclareNamedSchema :: Proxy TimeConstraints -> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy TimeConstraints -> Declare (Definitions Schema) NamedSchema
O3.ToSchema)