{-# LANGUAGE CPP #-}
module Web.Fedora.Copr.API
( coprGetProject
, coprGetProjectsList
, coprSearchProjects
, coprGetBuild
, coprGetBuildSourceChroot
, coprGetBuildSourceConfig
, coprGetBuildPackageList
, coprGetBuildChroot
, coprGetBuildChrootList
, coprGetBuildChrootConfig
, coprMockChrootList
, coprGetPackage
, coprGetPackageList
, coprGetProjectChroot
, coprGetProjectChrootBuildConfig
, queryCopr
, maybeKey
, makeKey
, makeItem
, lookupKey
, lookupKey'
)
where
import Data.Aeson.Types
import Network.HTTP.Query
coprGetProject :: String -> String -> String -> IO Object
coprGetProject :: String -> String -> String -> IO Object
coprGetProject String
server String
owner String
project = do
let path :: String
path = String
"project"
params :: [QueryItem]
params = [String -> String -> QueryItem
makeItem String
"ownername" String
owner, String -> String -> QueryItem
makeItem String
"projectname" String
project]
String -> String -> [QueryItem] -> IO Object
forall a. FromJSON a => String -> String -> [QueryItem] -> IO a
queryCopr String
server String
path [QueryItem]
params
coprGetProjectsList :: String -> String -> IO Value
coprGetProjectsList :: String -> String -> IO Value
coprGetProjectsList String
server String
owner = do
let path :: String
path = String
"project/list"
params :: [QueryItem]
params = String -> String -> [QueryItem]
makeKey String
"ownername" String
owner
String -> String -> [QueryItem] -> IO Value
forall a. FromJSON a => String -> String -> [QueryItem] -> IO a
queryCopr String
server String
path [QueryItem]
params
coprSearchProjects :: String -> String -> IO Value
coprSearchProjects :: String -> String -> IO Value
coprSearchProjects String
server String
query = do
let path :: String
path = String
"project/search"
params :: [QueryItem]
params = String -> String -> [QueryItem]
makeKey String
"query" String
query
String -> String -> [QueryItem] -> IO Value
forall a. FromJSON a => String -> String -> [QueryItem] -> IO a
queryCopr String
server String
path [QueryItem]
params
coprGetBuild :: String -> Int -> IO Object
coprGetBuild :: String -> Int -> IO Object
coprGetBuild String
server Int
bid = do
let path :: String
path = String
"build" String -> String -> String
+/+ Int -> String
forall a. Show a => a -> String
show Int
bid
String -> String -> [QueryItem] -> IO Object
forall a. FromJSON a => String -> String -> [QueryItem] -> IO a
queryCopr String
server String
path []
coprGetBuildSourceChroot :: String -> Int -> IO Object
coprGetBuildSourceChroot :: String -> Int -> IO Object
coprGetBuildSourceChroot String
server Int
bid = do
let path :: String
path = String
"build/source-chroot" String -> String -> String
+/+ Int -> String
forall a. Show a => a -> String
show Int
bid
String -> String -> [QueryItem] -> IO Object
forall a. FromJSON a => String -> String -> [QueryItem] -> IO a
queryCopr String
server String
path []
coprGetBuildSourceConfig :: String -> Int -> IO Object
coprGetBuildSourceConfig :: String -> Int -> IO Object
coprGetBuildSourceConfig String
server Int
bid = do
let path :: String
path = String
"build/source-build-config" String -> String -> String
+/+ Int -> String
forall a. Show a => a -> String
show Int
bid
String -> String -> [QueryItem] -> IO Object
forall a. FromJSON a => String -> String -> [QueryItem] -> IO a
queryCopr String
server String
path []
coprGetBuildPackageList :: String -> Query -> IO Value
coprGetBuildPackageList :: String -> [QueryItem] -> IO Value
coprGetBuildPackageList String
server [QueryItem]
params = do
let path :: String
path = String
"build/list"
String -> String -> [QueryItem] -> IO Value
forall a. FromJSON a => String -> String -> [QueryItem] -> IO a
queryCopr String
server String
path [QueryItem]
params
coprGetBuildChroot :: String -> Int -> String -> IO Value
coprGetBuildChroot :: String -> Int -> String -> IO Value
coprGetBuildChroot String
server Int
bid String
chroot = do
let path :: String
path = String
"build-chroot" String -> String -> String
+/+ Int -> String
forall a. Show a => a -> String
show Int
bid String -> String -> String
+/+ String
chroot
String -> String -> [QueryItem] -> IO Value
forall a. FromJSON a => String -> String -> [QueryItem] -> IO a
queryCopr String
server String
path []
coprGetBuildChrootList :: String -> Int -> IO Value
coprGetBuildChrootList :: String -> Int -> IO Value
coprGetBuildChrootList String
server Int
bid = do
let path :: String
path = String
"build-chroot/list" String -> String -> String
+/+ Int -> String
forall a. Show a => a -> String
show Int
bid
String -> String -> [QueryItem] -> IO Value
forall a. FromJSON a => String -> String -> [QueryItem] -> IO a
queryCopr String
server String
path []
coprGetBuildChrootConfig :: String -> Int -> String -> IO Value
coprGetBuildChrootConfig :: String -> Int -> String -> IO Value
coprGetBuildChrootConfig String
server Int
bid String
chroot = do
let path :: String
path = String
"build-chroot/build-config" String -> String -> String
+/+ Int -> String
forall a. Show a => a -> String
show Int
bid String -> String -> String
+/+ String
chroot
String -> String -> [QueryItem] -> IO Value
forall a. FromJSON a => String -> String -> [QueryItem] -> IO a
queryCopr String
server String
path []
coprMockChrootList :: String -> IO Value
coprMockChrootList :: String -> IO Value
coprMockChrootList String
server = do
let path :: String
path = String
"mock-chroots/list"
String -> String -> [QueryItem] -> IO Value
forall a. FromJSON a => String -> String -> [QueryItem] -> IO a
queryCopr String
server String
path []
coprGetPackage :: String -> String -> String -> String -> IO Value
coprGetPackage :: String -> String -> String -> String -> IO Value
coprGetPackage String
server String
owner String
project String
package = do
let path :: String
path = String
"package"
params :: [QueryItem]
params = [String -> String -> QueryItem
makeItem String
"ownername" String
owner,
String -> String -> QueryItem
makeItem String
"projectname" String
project,
String -> String -> QueryItem
makeItem String
"packagename" String
package]
String -> String -> [QueryItem] -> IO Value
forall a. FromJSON a => String -> String -> [QueryItem] -> IO a
queryCopr String
server String
path [QueryItem]
params
coprGetPackageList :: String -> String -> String -> IO Value
coprGetPackageList :: String -> String -> String -> IO Value
coprGetPackageList String
server String
owner String
project = do
let path :: String
path = String
"package/list"
params :: [QueryItem]
params = [String -> String -> QueryItem
makeItem String
"ownername" String
owner, String -> String -> QueryItem
makeItem String
"projectname" String
project]
String -> String -> [QueryItem] -> IO Value
forall a. FromJSON a => String -> String -> [QueryItem] -> IO a
queryCopr String
server String
path [QueryItem]
params
coprGetProjectChroot :: String -> String -> String -> String -> IO Value
coprGetProjectChroot :: String -> String -> String -> String -> IO Value
coprGetProjectChroot String
server String
owner String
project String
chroot = do
let path :: String
path = String
"project-chroot"
params :: [QueryItem]
params = [String -> String -> QueryItem
makeItem String
"ownername" String
owner,
String -> String -> QueryItem
makeItem String
"projectname" String
project,
String -> String -> QueryItem
makeItem String
"chrootname" String
chroot]
String -> String -> [QueryItem] -> IO Value
forall a. FromJSON a => String -> String -> [QueryItem] -> IO a
queryCopr String
server String
path [QueryItem]
params
coprGetProjectChrootBuildConfig :: String -> String -> String -> String -> IO Value
coprGetProjectChrootBuildConfig :: String -> String -> String -> String -> IO Value
coprGetProjectChrootBuildConfig String
server String
owner String
project String
chroot = do
let path :: String
path = String
"project-chroot/build-config"
params :: [QueryItem]
params = [String -> String -> QueryItem
makeItem String
"ownername" String
owner,
String -> String -> QueryItem
makeItem String
"projectname" String
project,
String -> String -> QueryItem
makeItem String
"chrootname" String
chroot]
String -> String -> [QueryItem] -> IO Value
forall a. FromJSON a => String -> String -> [QueryItem] -> IO a
queryCopr String
server String
path [QueryItem]
params
queryCopr :: FromJSON a
=> String
-> String
-> Query
-> IO a
queryCopr :: String -> String -> [QueryItem] -> IO a
queryCopr String
server String
path [QueryItem]
params =
let url :: String
url = String
"https://" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
server String -> String -> String
+/+ String
"api_3" String -> String -> String
+/+ String
path
in String -> [QueryItem] -> IO a
forall (m :: * -> *) a.
(MonadIO m, FromJSON a) =>
String -> [QueryItem] -> m a
webAPIQuery String
url [QueryItem]
params