Created
November 27, 2016 06:48
-
-
Save anonymous/2406725a44b24288eb2a391a0210419b to your computer and use it in GitHub Desktop.
/tmp/nix-build-hydra-frontend.drv-0/frontend/src/Hercules.elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Hercules exposing (..) | |
import Json.Decode exposing (..) | |
import Json.Decode.Pipeline exposing (..) | |
import Json.Encode | |
import Http | |
import String | |
import Task | |
type alias Project' = | |
{ projectName : String | |
, projectDisplayname : String | |
, projectDescription : Maybe (String) | |
, projectEnabled : Int | |
, projectHidden : Int | |
, projectOwner : String | |
, projectHomepage : Maybe (String) | |
} | |
decodeProject' : Decoder Project' | |
decodeProject' = | |
decode Project | |
|> required "projectName" string | |
|> required "projectDisplayname" string | |
|> required "projectDescription" (maybe string) | |
|> required "projectEnabled" int | |
|> required "projectHidden" int | |
|> required "projectOwner" string | |
|> required "projectHomepage" (maybe string) | |
type alias Jobset' = | |
{ jobsetName : String | |
, jobsetProject : String | |
, jobsetDescription : Maybe (String) | |
, jobsetNixexprinput : String | |
, jobsetNixexprpath : String | |
, jobsetErrormsg : Maybe (String) | |
, jobsetErrortime : Maybe (Int) | |
, jobsetLastcheckedtime : Maybe (Int) | |
, jobsetTriggertime : Maybe (Int) | |
, jobsetEnabled : Int | |
, jobsetEnableemail : Int | |
, jobsetHidden : Int | |
, jobsetEmailoverride : String | |
, jobsetKeepnr : Int | |
, jobsetCheckinterval : Int | |
, jobsetSchedulingshares : Int | |
, jobsetFetcherrormsg : Maybe (String) | |
} | |
decodeJobset' : Decoder Jobset' | |
decodeJobset' = | |
decode Jobset | |
|> required "jobsetName" string | |
|> required "jobsetProject" string | |
|> required "jobsetDescription" (maybe string) | |
|> required "jobsetNixexprinput" string | |
|> required "jobsetNixexprpath" string | |
|> required "jobsetErrormsg" (maybe string) | |
|> required "jobsetErrortime" (maybe int) | |
|> required "jobsetLastcheckedtime" (maybe int) | |
|> required "jobsetTriggertime" (maybe int) | |
|> required "jobsetEnabled" int | |
|> required "jobsetEnableemail" int | |
|> required "jobsetHidden" int | |
|> required "jobsetEmailoverride" string | |
|> required "jobsetKeepnr" int | |
|> required "jobsetCheckinterval" int | |
|> required "jobsetSchedulingshares" int | |
|> required "jobsetFetcherrormsg" (maybe string) | |
type alias ProjectWithJobsets = | |
{ projectWithJobsetsProject :Project' | |
, projectWithJobsetsJobsets : List (Jobset') | |
} | |
decodeProjectWithJobsets : Decoder ProjectWithJobsets | |
decodeProjectWithJobsets = | |
decode ProjectWithJobsets | |
|> required "projectWithJobsetsProject" decodeProject' | |
|> required "projectWithJobsetsJobsets" (list decodeJobset') | |
getProjectNames : Task.Task Http.Error (List (String)) | |
getProjectNames = | |
let | |
request = | |
{ verb = | |
"GET" | |
, headers = | |
[("Content-Type", "application/json")] | |
, url = | |
"/" ++ "projectNames" | |
, body = | |
Http.empty | |
} | |
in | |
Http.fromJson | |
(list string) | |
(Http.send Http.defaultSettings request) | |
getProject : Task.Task Http.Error (List (Project')) | |
getProject = | |
let | |
request = | |
{ verb = | |
"GET" | |
, headers = | |
[("Content-Type", "application/json")] | |
, url = | |
"/" ++ "project" | |
, body = | |
Http.empty | |
} | |
in | |
Http.fromJson | |
(list decodeProject') | |
(Http.send Http.defaultSettings request) | |
getProjectByProjectName : String -> Task.Task Http.Error (Maybe (Project')) | |
getProjectByProjectName projectName = | |
let | |
request = | |
{ verb = | |
"GET" | |
, headers = | |
[("Content-Type", "application/json")] | |
, url = | |
"/" ++ "project" | |
++ "/" ++ (projectName |> toString |> Http.uriEncode) | |
, body = | |
Http.empty | |
} | |
in | |
Http.fromJson | |
(maybe decodeProject') | |
(Http.send Http.defaultSettings request) | |
getProjectWithJobsets : Task.Task Http.Error (List (ProjectWithJobsets)) | |
getProjectWithJobsets = | |
let | |
request = | |
{ verb = | |
"GET" | |
, headers = | |
[("Content-Type", "application/json")] | |
, url = | |
"/" ++ "projectWithJobsets" | |
, body = | |
Http.empty | |
} | |
in | |
Http.fromJson | |
(list decodeProjectWithJobsets) | |
(Http.send Http.defaultSettings request) | |
getProtected : String -> Task.Task Http.Error (String) | |
getProtected authorization = | |
let | |
request = | |
{ verb = | |
"GET" | |
, headers = | |
[("Content-Type", "application/json") | |
,("authorization", toString authorization)] | |
, url = | |
"/" ++ "protected" | |
, body = | |
Http.empty | |
} | |
in | |
Http.fromJson | |
string | |
(Http.send Http.defaultSettings request) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment