-
Notifications
You must be signed in to change notification settings - Fork 196
Expand file tree
/
Copy pathArtifacts.hs
More file actions
76 lines (66 loc) · 2.59 KB
/
Artifacts.hs
File metadata and controls
76 lines (66 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE KindSignatures #-}
module GitHub.Data.Actions.Artifacts (
Artifact(..),
ArtifactWorkflowRun(..),
) where
import GitHub.Data.Id (Id)
import GitHub.Data.URL (URL)
import GitHub.Internal.Prelude
import Prelude ()
import GitHub.Data.Actions.Common (WithTotalCount (WithTotalCount))
import GitHub.Data.Actions.WorkflowRuns (WorkflowRun)
import GitHub.Data.Repos (Repo)
-------------------------------------------------------------------------------
-- Artifact
-------------------------------------------------------------------------------
data ArtifactWorkflowRun = ArtifactWorkflowRun
{ artifactWorkflowRunWorkflowRunId :: !(Id WorkflowRun)
, artifactWorkflowRunRepositoryId :: !(Id Repo)
, artifactWorkflowRunHeadRepositoryId :: !(Id Repo)
, artifactWorkflowRunHeadBranch :: !Text
, artifactWorkflowRunHeadSha :: !Text
}
deriving (Show, Data, Eq, Ord, Generic)
data Artifact = Artifact
{ artifactArchiveDownloadUrl :: !URL
, artifactCreatedAt :: !UTCTime
, artifactExpired :: !Bool
, artifactExpiresAt :: !UTCTime
, artifactId :: !(Id Artifact)
, artifactName :: !Text
, artifactNodeId :: !Text
, artifactSizeInBytes :: !Int
, artifactUpdatedAt :: !UTCTime
, artifactUrl :: !URL
, artifactWorkflowRun :: !ArtifactWorkflowRun
}
deriving (Show, Data, Eq, Ord, Generic)
-------------------------------------------------------------------------------
-- JSON instances
-------------------------------------------------------------------------------
instance FromJSON ArtifactWorkflowRun where
parseJSON = withObject "ArtifactWorkflowRun" $ \o -> ArtifactWorkflowRun
<$> o .: "id"
<*> o .: "repository_id"
<*> o .: "head_repository_id"
<*> o .: "head_branch"
<*> o .: "head_sha"
instance FromJSON Artifact where
parseJSON = withObject "Artifact" $ \o -> Artifact
<$> o .: "archive_download_url"
<*> o .: "created_at"
<*> o .: "expired"
<*> o .: "expires_at"
<*> o .: "id"
<*> o .: "name"
<*> o .: "node_id"
<*> o .: "size_in_bytes"
<*> o .: "updated_at"
<*> o .: "url"
<*> o .: "workflow_run"
instance FromJSON (WithTotalCount Artifact) where
parseJSON = withObject "ArtifactList" $ \o -> WithTotalCount
<$> o .: "artifacts"
<*> o .: "total_count"