{-# LANGUAGE DataKinds         #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE KindSignatures    #-}

module GitHub.Data.Actions.Workflows (
    Workflow(..),
    CreateWorkflowDispatchEvent(..),
    ) where

import Prelude ()
import GitHub.Internal.Prelude

import GitHub.Data.Actions.Common (WithTotalCount (WithTotalCount))
import GitHub.Data.Id             (Id)
import GitHub.Data.URL            (URL)

data Workflow = Workflow
    { Workflow -> Id Workflow
workflowWorkflowId :: !(Id Workflow)
    , Workflow -> Text
workflowName       :: !Text
    , Workflow -> Text
workflowPath       :: !Text
    , Workflow -> Text
workflowState      :: !Text
    , Workflow -> UTCTime
workflowCreatedAt  :: !UTCTime
    , Workflow -> UTCTime
workflowUpdatedAt  :: !UTCTime
    , Workflow -> URL
workflowUrl        :: !URL
    , Workflow -> URL
workflowHtmlUrl    :: !URL
    , Workflow -> URL
workflowBadgeUrl   :: !URL
    }
  deriving (Int -> Workflow -> ShowS
[Workflow] -> ShowS
Workflow -> String
(Int -> Workflow -> ShowS)
-> (Workflow -> String) -> ([Workflow] -> ShowS) -> Show Workflow
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Workflow -> ShowS
showsPrec :: Int -> Workflow -> ShowS
$cshow :: Workflow -> String
show :: Workflow -> String
$cshowList :: [Workflow] -> ShowS
showList :: [Workflow] -> ShowS
Show, Typeable Workflow
Typeable Workflow =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Workflow -> c Workflow)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Workflow)
-> (Workflow -> Constr)
-> (Workflow -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Workflow))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Workflow))
-> ((forall b. Data b => b -> b) -> Workflow -> Workflow)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Workflow -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Workflow -> r)
-> (forall u. (forall d. Data d => d -> u) -> Workflow -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Workflow -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Workflow -> m Workflow)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Workflow -> m Workflow)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Workflow -> m Workflow)
-> Data Workflow
Workflow -> Constr
Workflow -> DataType
(forall b. Data b => b -> b) -> Workflow -> Workflow
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Workflow -> u
forall u. (forall d. Data d => d -> u) -> Workflow -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Workflow -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Workflow -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Workflow -> m Workflow
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Workflow -> m Workflow
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Workflow
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Workflow -> c Workflow
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Workflow)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Workflow)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Workflow -> c Workflow
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Workflow -> c Workflow
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Workflow
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Workflow
$ctoConstr :: Workflow -> Constr
toConstr :: Workflow -> Constr
$cdataTypeOf :: Workflow -> DataType
dataTypeOf :: Workflow -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Workflow)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Workflow)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Workflow)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Workflow)
$cgmapT :: (forall b. Data b => b -> b) -> Workflow -> Workflow
gmapT :: (forall b. Data b => b -> b) -> Workflow -> Workflow
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Workflow -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Workflow -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Workflow -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Workflow -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Workflow -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Workflow -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Workflow -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Workflow -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Workflow -> m Workflow
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Workflow -> m Workflow
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Workflow -> m Workflow
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Workflow -> m Workflow
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Workflow -> m Workflow
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Workflow -> m Workflow
Data, Typeable, Workflow -> Workflow -> Bool
(Workflow -> Workflow -> Bool)
-> (Workflow -> Workflow -> Bool) -> Eq Workflow
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Workflow -> Workflow -> Bool
== :: Workflow -> Workflow -> Bool
$c/= :: Workflow -> Workflow -> Bool
/= :: Workflow -> Workflow -> Bool
Eq, Eq Workflow
Eq Workflow =>
(Workflow -> Workflow -> Ordering)
-> (Workflow -> Workflow -> Bool)
-> (Workflow -> Workflow -> Bool)
-> (Workflow -> Workflow -> Bool)
-> (Workflow -> Workflow -> Bool)
-> (Workflow -> Workflow -> Workflow)
-> (Workflow -> Workflow -> Workflow)
-> Ord Workflow
Workflow -> Workflow -> Bool
Workflow -> Workflow -> Ordering
Workflow -> Workflow -> Workflow
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Workflow -> Workflow -> Ordering
compare :: Workflow -> Workflow -> Ordering
$c< :: Workflow -> Workflow -> Bool
< :: Workflow -> Workflow -> Bool
$c<= :: Workflow -> Workflow -> Bool
<= :: Workflow -> Workflow -> Bool
$c> :: Workflow -> Workflow -> Bool
> :: Workflow -> Workflow -> Bool
$c>= :: Workflow -> Workflow -> Bool
>= :: Workflow -> Workflow -> Bool
$cmax :: Workflow -> Workflow -> Workflow
max :: Workflow -> Workflow -> Workflow
$cmin :: Workflow -> Workflow -> Workflow
min :: Workflow -> Workflow -> Workflow
Ord, (forall x. Workflow -> Rep Workflow x)
-> (forall x. Rep Workflow x -> Workflow) -> Generic Workflow
forall x. Rep Workflow x -> Workflow
forall x. Workflow -> Rep Workflow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Workflow -> Rep Workflow x
from :: forall x. Workflow -> Rep Workflow x
$cto :: forall x. Rep Workflow x -> Workflow
to :: forall x. Rep Workflow x -> Workflow
Generic)

data CreateWorkflowDispatchEvent a = CreateWorkflowDispatchEvent
    { forall a. CreateWorkflowDispatchEvent a -> Text
createWorkflowDispatchEventRef    :: !Text
    , forall a. CreateWorkflowDispatchEvent a -> a
createWorkflowDispatchEventInputs :: !a
    }
  deriving (Int -> CreateWorkflowDispatchEvent a -> ShowS
[CreateWorkflowDispatchEvent a] -> ShowS
CreateWorkflowDispatchEvent a -> String
(Int -> CreateWorkflowDispatchEvent a -> ShowS)
-> (CreateWorkflowDispatchEvent a -> String)
-> ([CreateWorkflowDispatchEvent a] -> ShowS)
-> Show (CreateWorkflowDispatchEvent a)
forall a. Show a => Int -> CreateWorkflowDispatchEvent a -> ShowS
forall a. Show a => [CreateWorkflowDispatchEvent a] -> ShowS
forall a. Show a => CreateWorkflowDispatchEvent a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> CreateWorkflowDispatchEvent a -> ShowS
showsPrec :: Int -> CreateWorkflowDispatchEvent a -> ShowS
$cshow :: forall a. Show a => CreateWorkflowDispatchEvent a -> String
show :: CreateWorkflowDispatchEvent a -> String
$cshowList :: forall a. Show a => [CreateWorkflowDispatchEvent a] -> ShowS
showList :: [CreateWorkflowDispatchEvent a] -> ShowS
Show, (forall x.
 CreateWorkflowDispatchEvent a
 -> Rep (CreateWorkflowDispatchEvent a) x)
-> (forall x.
    Rep (CreateWorkflowDispatchEvent a) x
    -> CreateWorkflowDispatchEvent a)
-> Generic (CreateWorkflowDispatchEvent a)
forall x.
Rep (CreateWorkflowDispatchEvent a) x
-> CreateWorkflowDispatchEvent a
forall x.
CreateWorkflowDispatchEvent a
-> Rep (CreateWorkflowDispatchEvent a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x.
Rep (CreateWorkflowDispatchEvent a) x
-> CreateWorkflowDispatchEvent a
forall a x.
CreateWorkflowDispatchEvent a
-> Rep (CreateWorkflowDispatchEvent a) x
$cfrom :: forall a x.
CreateWorkflowDispatchEvent a
-> Rep (CreateWorkflowDispatchEvent a) x
from :: forall x.
CreateWorkflowDispatchEvent a
-> Rep (CreateWorkflowDispatchEvent a) x
$cto :: forall a x.
Rep (CreateWorkflowDispatchEvent a) x
-> CreateWorkflowDispatchEvent a
to :: forall x.
Rep (CreateWorkflowDispatchEvent a) x
-> CreateWorkflowDispatchEvent a
Generic)

instance (NFData a) => NFData (CreateWorkflowDispatchEvent a) where rnf :: CreateWorkflowDispatchEvent a -> ()
rnf = CreateWorkflowDispatchEvent a -> ()
forall a. (Generic a, GNFData (Rep a)) => a -> ()
genericRnf
instance (Binary a) => Binary (CreateWorkflowDispatchEvent a)

-------------------------------------------------------------------------------
-- JSON instances
-------------------------------------------------------------------------------

instance FromJSON Workflow where
    parseJSON :: Value -> Parser Workflow
parseJSON = String -> (Object -> Parser Workflow) -> Value -> Parser Workflow
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"Workflow" ((Object -> Parser Workflow) -> Value -> Parser Workflow)
-> (Object -> Parser Workflow) -> Value -> Parser Workflow
forall a b. (a -> b) -> a -> b
$ \Object
o -> Id Workflow
-> Text
-> Text
-> Text
-> UTCTime
-> UTCTime
-> URL
-> URL
-> URL
-> Workflow
Workflow
        (Id Workflow
 -> Text
 -> Text
 -> Text
 -> UTCTime
 -> UTCTime
 -> URL
 -> URL
 -> URL
 -> Workflow)
-> Parser (Id Workflow)
-> Parser
     (Text
      -> Text
      -> Text
      -> UTCTime
      -> UTCTime
      -> URL
      -> URL
      -> URL
      -> Workflow)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Id Workflow)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"id"
        Parser
  (Text
   -> Text
   -> Text
   -> UTCTime
   -> UTCTime
   -> URL
   -> URL
   -> URL
   -> Workflow)
-> Parser Text
-> Parser
     (Text
      -> Text -> UTCTime -> UTCTime -> URL -> URL -> URL -> Workflow)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"name"
        Parser
  (Text
   -> Text -> UTCTime -> UTCTime -> URL -> URL -> URL -> Workflow)
-> Parser Text
-> Parser
     (Text -> UTCTime -> UTCTime -> URL -> URL -> URL -> Workflow)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"path"
        Parser
  (Text -> UTCTime -> UTCTime -> URL -> URL -> URL -> Workflow)
-> Parser Text
-> Parser (UTCTime -> UTCTime -> URL -> URL -> URL -> Workflow)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"state"
        Parser (UTCTime -> UTCTime -> URL -> URL -> URL -> Workflow)
-> Parser UTCTime
-> Parser (UTCTime -> URL -> URL -> URL -> Workflow)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser UTCTime
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"created_at"
        Parser (UTCTime -> URL -> URL -> URL -> Workflow)
-> Parser UTCTime -> Parser (URL -> URL -> URL -> Workflow)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser UTCTime
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"updated_at"
        Parser (URL -> URL -> URL -> Workflow)
-> Parser URL -> Parser (URL -> URL -> Workflow)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser URL
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"url"
        Parser (URL -> URL -> Workflow)
-> Parser URL -> Parser (URL -> Workflow)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser URL
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"html_url"
        Parser (URL -> Workflow) -> Parser URL -> Parser Workflow
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser URL
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"badge_url"

instance FromJSON (WithTotalCount Workflow) where
    parseJSON :: Value -> Parser (WithTotalCount Workflow)
parseJSON = String
-> (Object -> Parser (WithTotalCount Workflow))
-> Value
-> Parser (WithTotalCount Workflow)
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"WorkflowList" ((Object -> Parser (WithTotalCount Workflow))
 -> Value -> Parser (WithTotalCount Workflow))
-> (Object -> Parser (WithTotalCount Workflow))
-> Value
-> Parser (WithTotalCount Workflow)
forall a b. (a -> b) -> a -> b
$ \Object
o -> Vector Workflow -> Int -> WithTotalCount Workflow
forall a. Vector a -> Int -> WithTotalCount a
WithTotalCount
        (Vector Workflow -> Int -> WithTotalCount Workflow)
-> Parser (Vector Workflow)
-> Parser (Int -> WithTotalCount Workflow)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Vector Workflow)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"workflows"
        Parser (Int -> WithTotalCount Workflow)
-> Parser Int -> Parser (WithTotalCount Workflow)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"total_count"

instance ToJSON a => ToJSON (CreateWorkflowDispatchEvent a) where
    toJSON :: CreateWorkflowDispatchEvent a -> Value
toJSON (CreateWorkflowDispatchEvent Text
ref a
inputs) =
        [Pair] -> Value
object [ Key
"ref" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
.= Text
ref, Key
"inputs" Key -> a -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
.= a
inputs ]