module Distribution.Koji.API
( Info(..)
, koji
, hello
, checkTagAccess
, checkTagPackage
, getAPIVersion
, getActiveRepos
, getAllArches
, getAllPerms
, getArchive
, getArchiveFile
, getArchiveType
, getArchiveTypes
, getAverageBuildDuration
, getBuild
, getBuildConfig
, getBuildLogs
, getBuildTarget
, getBuildTargets
, getBuildType
, getBuildroot
, getBuildrootListing
, getChangelogEntries
, getChannel
, getEvent
, getExternalRepo
, getExternalRepoList
, getFullInheritance
, getGlobalInheritance
, getGroupMembers
, getHost
, getImageArchive
, getImageBuild
, getInheritanceData
, getLastEvent
, getLastHostUpdate
, getLatestBuilds
, getLatestMavenArchives
, getLatestRPMS
, getMavenArchive
, getMavenBuild
, getNextRelease
, getPackage
, getPackageConfig
, getPackageID
, getRPM
, getRPMDeps
, getRPMFile
, getRPMHeaders
, getRepo
, getTag
, getTagExternalRepos
, getTagGroups
, getTagID
, getTaskChildren
, getTaskDescendents
, getTaskInfo
, getTaskRequest
, getTaskResult
, getUser
, getUserPerms
, getVolume
, getWinArchive
, getWinBuild
, listArchiveFiles
, listArchives
, listBTypes
, listBuildRPMs
, listBuildroots
, listBuilds
, listCGs
, listChannels
, listExternalRepos
, listHosts
, listPackages
, listPackagesSimple
, listRPMFiles
, listRPMs
, listSideTags
, listTagged
, listTaggedArchives
, listTaggedRPMS
, listTags
, listTaskOutput
, listTasks
, listUsers
, listVolumes
, repoInfo
, resubmitTask
, tagChangedSinceEvent
, tagHistory
, taskFinished
, taskReport
, Value(..)
, Struct
, lookupStruct
, maybeStruct
, structArray
, getValue
)
where
import Data.Maybe
import Network.XmlRpc.Client
import Network.XmlRpc.Internals
import Control.Monad.Except (runExceptT)
koji :: Remote a
=> String
-> String
-> a
koji = remote
type Struct = [(String,Value)]
maybeString :: Maybe String -> Value
maybeString = maybe ValueNil ValueString
maybeInt :: Maybe Int -> Value
maybeInt = maybe ValueNil ValueInt
maybeValue :: Maybe Value -> Value
maybeValue = fromMaybe ValueNil
data Info = InfoID Int | InfoString String
infoValue :: Info -> Value
infoValue (InfoID i) = ValueInt i
infoValue (InfoString s) = ValueString s
maybeInfo :: Maybe Info -> Value
maybeInfo = maybe ValueNil infoValue
maybeStruct :: Value -> Maybe Struct
maybeStruct (ValueStruct st) = Just st
maybeStruct _ = Nothing
structArray :: Value -> [Struct]
structArray (ValueArray v) = mapMaybe maybeStruct v
structArray _ = []
checkTagAccess :: String -> Int -> Int -> IO Value
checkTagAccess hubUrl = koji hubUrl "checkTagAccess"
checkTagPackage :: String -> Info -> Info -> IO Bool
checkTagPackage hubUrl taginfo pkginfo = koji hubUrl "checkTagPackage" (infoValue taginfo) (infoValue pkginfo)
getAPIVersion :: String -> IO String
getAPIVersion hubUrl = koji hubUrl "getAPIVersion"
getActiveRepos :: String -> IO Value
getActiveRepos hubUrl = koji hubUrl "getActiveRepos"
getAllArches :: String -> IO Value
getAllArches hubUrl = koji hubUrl "getAllArches"
getAllPerms :: String -> IO [Struct]
getAllPerms hubUrl = koji hubUrl "getAllPerms"
getArchive :: String -> Int -> IO (Maybe Struct)
getArchive hubUrl = fmap maybeStruct . koji hubUrl "getArchive"
getArchiveFile :: String -> Int -> FilePath -> IO (Maybe Struct)
getArchiveFile hubUrl archiveID file = maybeStruct <$> koji hubUrl "getArchiveFile" archiveID file
getArchiveType :: String -> Maybe FilePath -> Maybe String -> Maybe Int -> IO Value
getArchiveType hubUrl filename type_name type_id =
koji hubUrl "getArchiveType" (maybeString filename) (maybeString type_name) (maybeInt type_id)
getArchiveTypes :: String -> IO Value
getArchiveTypes hubUrl = koji hubUrl "getArchiveTypes"
getAverageBuildDuration :: String -> Info -> IO Value
getAverageBuildDuration hubUrl = koji hubUrl "getAverageBuildDuration" . infoValue
getBuild :: String
-> Info
-> IO (Maybe Struct)
getBuild hubUrl = fmap maybeStruct . koji hubUrl "getBuild" . infoValue
getBuildConfig :: String -> String -> IO Value
getBuildConfig hubUrl = koji hubUrl "getBuildConfig"
getBuildLogs :: String -> Info
-> IO Value
getBuildLogs hubUrl = koji hubUrl "getBuildLogs" . infoValue
getBuildTarget :: String -> String -> IO Value
getBuildTarget hubUrl = koji hubUrl "getBuildTarget"
getBuildTargets :: String -> Maybe Info -> Maybe Int -> Maybe Int -> Maybe Int -> IO Value
getBuildTargets hubUrl info event buildTagId destTagId =
koji hubUrl "getBuildTargets" (maybeInfo info) (maybeInt event) (maybeInt buildTagId) (maybeInt destTagId)
getBuildType :: String -> Info
-> IO Value
getBuildType hubUrl = koji hubUrl "getBuildType" . infoValue
getBuildroot :: String -> Int -> IO Value
getBuildroot hubUrl = koji hubUrl "getBuildroot"
getBuildrootListing :: String -> Int -> IO Value
getBuildrootListing hubUrl = koji hubUrl "getBuildrootListing"
getChangelogEntries :: String
-> Maybe Int
-> Maybe Int
-> Maybe FilePath
-> Maybe String
-> Maybe String
-> Maybe String
-> IO [Struct]
getChangelogEntries hubUrl buildID taskID filepath author before after =
koji hubUrl "getChangelogEntries" (maybeInt buildID) (maybeInt taskID) (maybeString filepath) (maybeString author) (maybeString before) (maybeString after)
getChannel :: String -> Info -> IO Value
getChannel hubUrl = koji hubUrl "getChannel" . infoValue
getEvent :: String -> Int -> IO Struct
getEvent hubUrl = koji hubUrl "getEvent"
getExternalRepo :: String -> Info -> Maybe Int -> IO Struct
getExternalRepo hubUrl info event =
koji hubUrl "getExternalRepo" (infoValue info) () (maybeInt event)
getExternalRepoList :: String -> Info -> Maybe Int -> IO [Struct]
getExternalRepoList hubUrl info event =
koji hubUrl "getExternalRepoList" (infoValue info) (maybeInt event)
getFullInheritance :: String -> String -> Maybe Int -> Bool -> IO Value
getFullInheritance hubUrl tag event =
koji hubUrl "getFullInheritance" tag (maybeInt event)
getGlobalInheritance :: String -> Maybe Int -> IO Value
getGlobalInheritance hubUrl = koji hubUrl "getGlobalInheritance" . maybeInt
getGroupMembers :: String -> String -> IO Value
getGroupMembers hubUrl = koji hubUrl "getGroupMembers"
getHost :: String -> Info -> Maybe Int -> IO Struct
getHost hubUrl info = koji hubUrl "getHost" (infoValue info) () . maybeInt
getImageArchive :: String -> Int -> IO Struct
getImageArchive hubUrl = koji hubUrl "getImageArchive"
getImageBuild :: String -> Info -> IO Struct
getImageBuild hubUrl info = koji hubUrl "getImageBuild" (infoValue info)
getInheritanceData :: String -> String -> Maybe Int -> IO Value
getInheritanceData hubUrl tag event =
koji hubUrl "getInheritanceData" tag (maybeInt event)
getLastEvent :: String -> Maybe Int -> IO Value
getLastEvent hubUrl = koji hubUrl "getLastEvent" . maybeInt
getLastHostUpdate :: String -> Int -> IO Value
getLastHostUpdate hubUrl = koji hubUrl "getLastHostUpdate"
getLatestBuilds :: String
-> Info
-> Maybe Int
-> Maybe String
-> Maybe String
-> IO [Struct]
getLatestBuilds hubUrl tag event pkg type_ =
koji hubUrl "getLatestBuilds" (infoValue tag) (maybeInt event) (maybeString pkg) (maybeString type_)
getLatestMavenArchives :: String -> String -> Maybe Int -> Bool -> IO Value
getLatestMavenArchives hubUrl tag event =
koji hubUrl "getLatestMavenArchives" tag (maybeInt event)
getLatestRPMS :: String -> String -> Maybe String -> Maybe String -> Maybe Int -> Bool -> Maybe String -> IO Value
getLatestRPMS hubUrl tag pkg arch event rpmsigs type_ =
koji hubUrl "getLatestRPMS" tag (maybeString pkg) (maybeString arch) (maybeInt event) rpmsigs (maybeString type_)
getMavenArchive :: String -> Int -> IO Struct
getMavenArchive hubUrl = koji hubUrl "getMavenArchive"
getMavenBuild :: String -> Info -> IO Struct
getMavenBuild hubUrl info = koji hubUrl "getMavenBuild" (infoValue info)
getNextRelease :: String -> Info -> IO Value
getNextRelease hubUrl info = koji hubUrl "getNextRelease" (infoValue info)
getPackage :: String -> Info -> IO Value
getPackage hubUrl info = koji hubUrl "getPackage" (infoValue info)
getPackageConfig :: String -> String -> String -> Maybe Int -> IO Value
getPackageConfig hubUrl tag pkg event =
koji hubUrl "getPackageConfig" tag pkg (maybeInt event)
getPackageID :: String -> String -> IO (Maybe Int)
getPackageID hubUrl pkg = do
res <- koji hubUrl "getPackageID" pkg
case res of
ValueInt i -> return $ Just i
_ -> return Nothing
getRPM :: String -> Info -> IO Struct
getRPM hubUrl = koji hubUrl "getRPM" . infoValue
getRPMDeps :: String -> Int -> Maybe String -> IO [Struct]
getRPMDeps hubUrl rpmid deptype =
koji hubUrl "getRPMDeps" rpmid (maybeString deptype)
getRPMFile :: String -> Int -> FilePath -> IO Struct
getRPMFile hubUrl = koji hubUrl "getRPMFile"
getRPMHeaders :: String -> Maybe Int -> Maybe Int -> Maybe FilePath -> Maybe Value -> IO Struct
getRPMHeaders hubUrl rpmid taskid file headers =
koji hubUrl "getRPMHeaders" (maybeInt rpmid) (maybeInt taskid) (maybeString file) (fromMaybe ValueNil headers)
getRepo :: String -> String -> Maybe Int -> Maybe Int -> Bool -> IO Value
getRepo hubUrl tag state event =
koji hubUrl "getRepo" tag (maybeInt state) (maybeInt event)
getTag :: String -> Info -> Maybe Int -> IO Struct
getTag hubUrl info = koji hubUrl "getTag" (infoValue info) () . maybeInt
getTagExternalRepos :: String -> Maybe Info -> Maybe Info -> Maybe Int -> IO Struct
getTagExternalRepos hubUrl taginfo repoinfo event =
koji hubUrl "getTagExternalRepos" (maybeInfo taginfo) (maybeInfo repoinfo) (maybeInt event)
getTagGroups :: String -> String -> Maybe Int -> Bool -> Bool -> Bool -> Bool -> IO Value
getTagGroups hubUrl tag event =
koji hubUrl "getTagGroups" tag (maybeInt event)
getTagID :: String -> Info -> IO (Maybe Int)
getTagID hubUrl tag = do
res <- koji hubUrl "getTagID" (infoValue tag)
case res of
ValueInt i -> return $ Just i
_ -> return Nothing
getTaskChildren :: String -> Int -> Bool -> IO [Struct]
getTaskChildren hubUrl = koji hubUrl "getTaskChildren"
getTaskDescendents :: String -> Int -> Bool -> IO Struct
getTaskDescendents hubUrl = koji hubUrl "getTaskDescendents"
getTaskInfo :: String
-> Int
-> Bool
-> IO (Maybe Struct)
getTaskInfo hubUrl tid request = maybeStruct <$> koji hubUrl "getTaskInfo" tid request
getTaskRequest :: String -> Int -> IO Value
getTaskRequest hubUrl = koji hubUrl "getTaskRequest"
getTaskResult :: String -> Int -> IO Value
getTaskResult hubUrl = koji hubUrl "getTaskResult"
getUser :: String -> Info -> Bool -> IO (Maybe Struct)
getUser hubUrl info krbprncpl =
maybeStruct <$> koji hubUrl "getUser" (infoValue info) () krbprncpl
getUserPerms :: String -> Maybe Info -> IO Value
getUserPerms hubUrl = koji hubUrl "getUserPerms" . maybeInfo
getVolume :: String -> Info -> IO Value
getVolume hubUrl = koji hubUrl "getVolume" . infoValue
getWinArchive :: String -> Int -> IO Struct
getWinArchive hubUrl = koji hubUrl "getWinArchive"
getWinBuild :: String -> Info -> IO (Maybe Struct)
getWinBuild hubUrl = fmap maybeStruct . koji hubUrl "getWinBuild" . infoValue
hello :: String -> IO String
hello hubUrl = koji hubUrl "hello"
listArchiveFiles :: String -> Int -> IO [Struct]
listArchiveFiles hubUrl = koji hubUrl "listArchiveFiles"
listArchives :: String -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe String -> Maybe FilePath -> Maybe Int -> Maybe String -> Maybe Info -> Maybe Int -> Maybe Int -> IO [Struct]
listArchives hubUrl buildID buildrootID componentBuildrootID hostID type_ file size checksum typeInfo imageID archiveID =
koji hubUrl "listArchives" (maybeInt buildID) (maybeInt buildrootID) (maybeInt componentBuildrootID) (maybeInt hostID) (maybeString type_) (maybeString file) (maybeInt size) (maybeString checksum) (maybeInfo typeInfo) () (maybeInt imageID) (maybeInt archiveID)
listBTypes :: String -> Value -> IO Value
listBTypes hubUrl = koji hubUrl "listBTypes"
listBuildRPMs :: String -> Int -> IO [Struct]
listBuildRPMs hubUrl = koji hubUrl "listBuildRPMs"
listBuildroots :: String -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> IO Value
listBuildroots hubUrl hostID tagID state rpmID archiveID taskID buildrootID =
koji hubUrl "listBuildroots" (maybeInt hostID) (maybeInt tagID) (maybeInt state) (maybeInt rpmID) (maybeInt archiveID) (maybeInt taskID) (maybeInt buildrootID)
listBuilds :: String -> Struct -> IO [Struct]
listBuilds hubUrl args =
let maybeArg fld = maybeValue (lookupStruct fld args) in
koji hubUrl "listBuilds" (maybeArg "packageID") (maybeArg "userID") (maybeArg "taskID") (maybeArg "prefix") (maybeArg "state") (maybeArg "volumeID") (maybeArg "source") (maybeArg "createdBefore") (maybeArg "createdAfter") (maybeArg "completeBefore") (maybeArg "completeAfter") (maybeArg "type") (maybeArg "typeInfo") (maybeArg "queryOpts")
listCGs :: String -> IO Struct
listCGs hubUrl = koji hubUrl "listCGs"
listChannels :: String -> Maybe Int -> Maybe Int -> IO Value
listChannels hubUrl hostID event =
koji hubUrl "listChannels" (maybeInt hostID) (maybeInt event)
listExternalRepos :: String -> Maybe Info -> Maybe String -> Maybe Int -> IO Value
listExternalRepos hubUrl info url event =
koji hubUrl "listExternalRepos" (maybeInfo info) (maybeString url) (maybeInt event)
listHosts :: String -> Maybe Value -> Maybe Int -> Bool -> Bool -> Maybe Int -> IO Value
listHosts hubUrl arches channelID ready enabled userID =
koji hubUrl "listHosts" (maybeValue arches) (maybeInt channelID) ready enabled (maybeInt userID)
listPackages :: String -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe String -> Bool -> Bool -> Maybe Int -> IO [Struct]
listPackages hubUrl tagID userID pkgID prefix inherited with_dups event =
koji hubUrl "listPackages" (maybeInt tagID) (maybeInt userID) (maybeInt pkgID) (maybeString prefix) inherited with_dups (maybeInt event)
listPackagesSimple :: String -> String
-> IO [Struct]
listPackagesSimple hubUrl = koji hubUrl "listPackagesSimple"
listRPMFiles :: String -> Int -> IO [Struct]
listRPMFiles hubUrl = koji hubUrl "listRPMFiles"
listRPMs :: String -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Value -> IO [Struct]
listRPMs hubUrl buildID buildrootID imageID componentBuildrootID hostID arches =
koji hubUrl "listRPMs" (maybeInt buildID) (maybeInt buildrootID) (maybeInt imageID) (maybeInt componentBuildrootID) (maybeInt hostID) (maybeValue arches)
listSideTags :: String -> Maybe Info -> Maybe Info -> IO Value
listSideTags hubUrl basetag user = do
koji hubUrl "listSideTags" (maybeInfo basetag) (maybeInfo user)
listTagged :: String -> String -> Maybe Int -> Bool -> Maybe String -> Bool -> Maybe String -> Maybe String -> Maybe String -> IO [Struct]
listTagged hubUrl tag event inherit prefix latest package owner type_ =
koji hubUrl "listTagged" tag (maybeInt event) inherit (maybeString prefix) latest (maybeString package) (maybeString owner) (maybeString type_)
listTaggedArchives :: String -> String -> Maybe Int -> Bool -> Bool -> Maybe String -> Maybe String -> IO Value
listTaggedArchives hubUrl tag event inherit latest package type_ =
koji hubUrl "listTaggedArchives" tag (maybeInt event) inherit latest (maybeString package) (maybeString type_)
listTaggedRPMS :: String -> String -> Maybe Int -> Bool -> Bool -> Maybe String -> Maybe String -> Bool -> Maybe String -> Maybe String -> IO Value
listTaggedRPMS hubUrl tag event inherit latest package arch rpmsigs owner type_ =
koji hubUrl "listTaggedRPMS" tag (maybeInt event) inherit latest (maybeString package) (maybeString arch) rpmsigs (maybeString owner) (maybeString type_)
listTags :: String -> Maybe Info -> Maybe Info -> Bool -> IO [Struct]
listTags hubUrl build package =
koji hubUrl "listTags" (maybeInfo build) (maybeInfo package)
listTaskOutput :: String -> Int -> Bool -> Bool -> Bool -> IO Struct
listTaskOutput hubUrl = koji hubUrl "listTaskOutput"
listTasks :: String -> Struct
-> Struct
-> IO [Struct]
listTasks hubUrl = koji hubUrl "listTasks"
listUsers :: String -> Maybe Int -> Maybe String -> IO [Struct]
listUsers hubUrl userType prefix =
koji hubUrl "listUsers" (maybeInt userType) (maybeString prefix)
listVolumes :: String -> IO Value
listVolumes hubUrl = koji hubUrl "listVolumes"
repoInfo :: String -> Int -> IO Value
repoInfo hubUrl = koji hubUrl "repoInfo"
resubmitTask :: String -> Int -> IO Value
resubmitTask hubUrl = koji hubUrl "resubmitTask"
tagChangedSinceEvent :: String -> Int -> Value -> IO Bool
tagChangedSinceEvent hubUrl = koji hubUrl "tagChangedSinceEvent"
tagHistory :: String -> Maybe Info -> Maybe Info -> Maybe Info -> Bool -> IO Value
tagHistory hubUrl build tag package =
koji hubUrl "tagHistory" (maybeInfo build) (maybeInfo tag) (maybeInfo package)
taskFinished :: String -> Int -> IO Bool
taskFinished hubUrl = koji hubUrl "taskFinished"
taskReport :: String -> Maybe String -> IO Value
taskReport hubUrl = koji hubUrl "taskReport" . maybeString
lookupStruct :: XmlRpcType a => String -> Struct -> Maybe a
lookupStruct key struct =
either error id <$> runExceptT (getField key struct)
getValue :: XmlRpcType a => Value -> Maybe a
getValue = fmap (either error id) . runExceptT . fromValue