{-|
Low level XMLRPC API based directly on the python API
since that is the only available reference documentation:
<https://koji.fedoraproject.org/koji/api>.

Note that many of the procedures in this module are untested and experimental:
particularly most of those that return a Value.

Higher level wrapper procedures live in Distribution.Koji.

Fixes and enhancements welcome.
-}



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
--       , readStructString
--       , readStructArray
--       , readMethodParams
       , maybeStruct
       , structArray
       , getValue
       )
where

import Data.Maybe
--import Control.Monad.Fail (MonadFail)
--import qualified Data.ByteString.Lazy.Char8 as B
import Network.XmlRpc.Client
import Network.XmlRpc.Internals
--import Network.HTTP.Simple
--import Network.HTTP.Client.Conduit
import Control.Monad.Except (runExceptT)

-- | Low-level variadic XML RPC call to a Koji Hub
koji :: Remote a
     => String -- ^ kojihub url
     -> String -- ^ command
     -> a
koji :: String -> String -> a
koji = String -> String -> a
forall a. Remote a => String -> String -> a
remote

-- xmlrpc :: String -> String -> [Value] -> IO Value
-- xmlrpc url m args = do
--   initreq <- parseRequest url
--   let reqbody = renderCall (MethodCall m args)
--       request = setRequestBody (RequestBodyLBS reqbody) $ setRequestMethod "POST" initreq
--   resp <- httpLBS request
--   let respbody = getResponseBody resp
--   handleError fail $ (parseResponse (B.unpack respbody) >>= handleResponse)
--   where
--     -- | Gets the return value from a method response.
--     --   Throws an exception if the response was a fault.
--     handleResponse :: MonadFail m => MethodResponse -> m Value
--     handleResponse (Return v)       = return v
--     handleResponse (Fault code str) = error ("Error " ++ show code ++ ": " ++ str)

-- FIXME rename to newtype KojiStruct?
type Struct = [(String,Value)]

maybeString :: Maybe String -> Value
maybeString :: Maybe String -> Value
maybeString = Value -> (String -> Value) -> Maybe String -> Value
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Value
ValueNil String -> Value
ValueString

maybeInt :: Maybe Int -> Value
maybeInt :: Maybe Int -> Value
maybeInt = Value -> (Int -> Value) -> Maybe Int -> Value
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Value
ValueNil Int -> Value
ValueInt

maybeValue :: Maybe Value -> Value
maybeValue :: Maybe Value -> Value
maybeValue = Value -> Maybe Value -> Value
forall a. a -> Maybe a -> a
fromMaybe Value
ValueNil

-- | info is either an id or string
data Info = InfoID Int | InfoString String

infoValue :: Info -> Value
infoValue :: Info -> Value
infoValue (InfoID i :: Int
i) = Int -> Value
ValueInt Int
i
infoValue (InfoString s :: String
s) = String -> Value
ValueString String
s

maybeInfo :: Maybe Info -> Value
maybeInfo :: Maybe Info -> Value
maybeInfo = Value -> (Info -> Value) -> Maybe Info -> Value
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Value
ValueNil Info -> Value
infoValue

maybeStruct :: Value -> Maybe Struct
maybeStruct :: Value -> Maybe Struct
maybeStruct (ValueStruct st :: Struct
st) = Struct -> Maybe Struct
forall a. a -> Maybe a
Just Struct
st
maybeStruct _ = Maybe Struct
forall a. Maybe a
Nothing

structArray :: Value -> [Struct]
structArray :: Value -> [Struct]
structArray (ValueArray v :: [Value]
v) = (Value -> Maybe Struct) -> [Value] -> [Struct]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe Value -> Maybe Struct
maybeStruct [Value]
v
structArray _ = []

-- https://koji.fedoraproject.org/koji/api

-- CG*

-- _listapi()

-- add*

-- applyVolumePolicy(build, strict=False)

-- assignTask(task_id, host, force=False)

-- build(src, target, opts=None, priority=None, channel=None)

-- buildContainer(src, target, opts=None, priority=None, channel='container')

-- buildImage(name, version, arch, target, ksfile, img_type, opts=None, priority=None)

-- buildImageIndirection(opts=None, priority=None)

-- buildImageOz(name, version, arches, target, inst_tree, opts=None, priority=None)

-- buildReferences(build, limit=None, lazy=False)

-- cancelBuild(buildID)

-- cancelTask(task_id, recurse=True)

-- cancelTaskChildren(task_id)

-- cancelTaskFull(task_id, strict=True)

-- chainBuild(srcs, target, opts=None, priority=None, channel=None)

-- chainMaven(builds, target, opts=None, priority=None, channel='maven')

-- changeBuildVolume(build, volume, strict=True)

-- | checkTagAccess(tag_id, user_id=None)
checkTagAccess :: String -> Int -> Int -> IO Value
checkTagAccess :: String -> Int -> Int -> IO Value
checkTagAccess hubUrl :: String
hubUrl = String -> String -> Int -> Int -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "checkTagAccess"

-- | checkTagPackage(tag, pkg)
checkTagPackage :: String -> Info -> Info -> IO Bool
checkTagPackage :: String -> Info -> Info -> IO Bool
checkTagPackage hubUrl :: String
hubUrl taginfo :: Info
taginfo pkginfo :: Info
pkginfo = String -> String -> Value -> Value -> IO Bool
forall a. Remote a => String -> String -> a
koji String
hubUrl "checkTagPackage" (Info -> Value
infoValue Info
taginfo) (Info -> Value
infoValue Info
pkginfo)

-- count*

-- create*

-- debugFunction(name, *args, **kwargs)

-- delete*

-- disable*

-- distRepo(tag, keys, **task_opts)

-- downloadTaskOutput(taskID, fileName, offset=0, size=-1, volume=None)

-- dropGroupMember(group, user)

-- echo(*args)

-- edit*

-- enable*

-- error

-- filterResults(methodName, *args, **kw)

-- findBuildID(X, strict=False)

-- freeTask(task_id)

-- | getAPIVersion()
getAPIVersion :: String -> IO String
getAPIVersion :: String -> IO String
getAPIVersion hubUrl :: String
hubUrl = String -> String -> IO String
forall a. Remote a => String -> String -> a
koji String
hubUrl "getAPIVersion"

-- | getActiveRepos()
getActiveRepos :: String -> IO Value
getActiveRepos :: String -> IO Value
getActiveRepos hubUrl :: String
hubUrl = String -> String -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getActiveRepos"

-- | getAllArches
getAllArches :: String -> IO Value
getAllArches :: String -> IO Value
getAllArches hubUrl :: String
hubUrl = String -> String -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getAllArches"

-- | getAllPerms
getAllPerms :: String -> IO [Struct]
getAllPerms :: String -> IO [Struct]
getAllPerms hubUrl :: String
hubUrl = String -> String -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl "getAllPerms"

-- | getArchive(archive_id, strict=False)
getArchive :: String -> Int -> IO (Maybe Struct)
getArchive :: String -> Int -> IO (Maybe Struct)
getArchive hubUrl :: String
hubUrl = (Value -> Maybe Struct) -> IO Value -> IO (Maybe Struct)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Value -> Maybe Struct
maybeStruct (IO Value -> IO (Maybe Struct))
-> (Int -> IO Value) -> Int -> IO (Maybe Struct)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String -> Int -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getArchive"

-- | getArchiveFile(archive_id, filename, strict=False)
getArchiveFile :: String -> Int -> FilePath -> IO (Maybe Struct)
getArchiveFile :: String -> Int -> String -> IO (Maybe Struct)
getArchiveFile hubUrl :: String
hubUrl archiveID :: Int
archiveID file :: String
file = Value -> Maybe Struct
maybeStruct (Value -> Maybe Struct) -> IO Value -> IO (Maybe Struct)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> String -> Int -> String -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getArchiveFile" Int
archiveID String
file

-- | getArchiveType(filename=None, type_name=None, type_id=None, strict=False)
getArchiveType :: String -> Maybe FilePath -> Maybe String -> Maybe Int -> IO Value
getArchiveType :: String -> Maybe String -> Maybe String -> Maybe Int -> IO Value
getArchiveType hubUrl :: String
hubUrl filename :: Maybe String
filename type_name :: Maybe String
type_name type_id :: Maybe Int
type_id =
  String -> String -> Value -> Value -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getArchiveType" (Maybe String -> Value
maybeString Maybe String
filename) (Maybe String -> Value
maybeString Maybe String
type_name) (Maybe Int -> Value
maybeInt Maybe Int
type_id)

-- | getArchiveTypes()
getArchiveTypes :: String -> IO Value
getArchiveTypes :: String -> IO Value
getArchiveTypes hubUrl :: String
hubUrl = String -> String -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getArchiveTypes"

-- | getAverageBuildDuration pkginfo
getAverageBuildDuration :: String -> Info -> IO Value
getAverageBuildDuration :: String -> Info -> IO Value
getAverageBuildDuration hubUrl :: String
hubUrl = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getAverageBuildDuration" (Value -> IO Value) -> (Info -> Value) -> Info -> IO Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Info -> Value
infoValue

-- | getBuild(buildInfo, strict=False)
getBuild :: String
         -> Info -- ^ buildID
         -> IO (Maybe Struct)
getBuild :: String -> Info -> IO (Maybe Struct)
getBuild hubUrl :: String
hubUrl = (Value -> Maybe Struct) -> IO Value -> IO (Maybe Struct)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Value -> Maybe Struct
maybeStruct (IO Value -> IO (Maybe Struct))
-> (Info -> IO Value) -> Info -> IO (Maybe Struct)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getBuild" (Value -> IO Value) -> (Info -> Value) -> Info -> IO Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Info -> Value
infoValue

-- | getBuildConfig tag
getBuildConfig :: String -> String -> IO Value
getBuildConfig :: String -> String -> IO Value
getBuildConfig hubUrl :: String
hubUrl = String -> String -> String -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getBuildConfig"

-- | getBuildLogs build
getBuildLogs :: String -> Info -- ^ buildinfo
             -> IO Value
getBuildLogs :: String -> Info -> IO Value
getBuildLogs hubUrl :: String
hubUrl = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getBuildLogs" (Value -> IO Value) -> (Info -> Value) -> Info -> IO Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Info -> Value
infoValue

-- | getBuildTarget info
getBuildTarget :: String -> String -> IO Value
getBuildTarget :: String -> String -> IO Value
getBuildTarget hubUrl :: String
hubUrl = String -> String -> String -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getBuildTarget"

-- | getBuildTargets info event buildTagID destTagID
getBuildTargets :: String -> Maybe Info -> Maybe Int -> Maybe Int -> Maybe Int -> IO Value
getBuildTargets :: String
-> Maybe Info -> Maybe Int -> Maybe Int -> Maybe Int -> IO Value
getBuildTargets hubUrl :: String
hubUrl info :: Maybe Info
info event :: Maybe Int
event buildTagId :: Maybe Int
buildTagId destTagId :: Maybe Int
destTagId  =
  String -> String -> Value -> Value -> Value -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getBuildTargets" (Maybe Info -> Value
maybeInfo Maybe Info
info) (Maybe Int -> Value
maybeInt Maybe Int
event) (Maybe Int -> Value
maybeInt Maybe Int
buildTagId) (Maybe Int -> Value
maybeInt Maybe Int
destTagId)

-- | getBuildType buildinfo
getBuildType :: String -> Info -- ^ buildinfo
             -> IO Value
getBuildType :: String -> Info -> IO Value
getBuildType hubUrl :: String
hubUrl = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getBuildType" (Value -> IO Value) -> (Info -> Value) -> Info -> IO Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Info -> Value
infoValue

-- | getBuildroot buildrootId
getBuildroot :: String -> Int -> IO Value
getBuildroot :: String -> Int -> IO Value
getBuildroot hubUrl :: String
hubUrl = String -> String -> Int -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getBuildroot"

-- | getBuildrootListing buildrootId
getBuildrootListing :: String -> Int -> IO Value
getBuildrootListing :: String -> Int -> IO Value
getBuildrootListing hubUrl :: String
hubUrl = String -> String -> Int -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getBuildrootListing"

-- | getChangelogEntries(buildID=None, taskID=None, filepath=None, author=None, before=None, after=None, queryOpts=None)
getChangelogEntries :: String
                    -> Maybe Int -- ^ buildID
                    -> Maybe Int -- ^ taskID
                    -> Maybe FilePath
                    -> Maybe String -- ^ author
                    -> Maybe String -- ^ before
                    -> Maybe String -- ^ after
                    -> IO [Struct]
getChangelogEntries :: String
-> Maybe Int
-> Maybe Int
-> Maybe String
-> Maybe String
-> Maybe String
-> Maybe String
-> IO [Struct]
getChangelogEntries hubUrl :: String
hubUrl buildID :: Maybe Int
buildID taskID :: Maybe Int
taskID filepath :: Maybe String
filepath author :: Maybe String
author before :: Maybe String
before after :: Maybe String
after =
  String
-> String
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl "getChangelogEntries" (Maybe Int -> Value
maybeInt Maybe Int
buildID) (Maybe Int -> Value
maybeInt Maybe Int
taskID) (Maybe String -> Value
maybeString Maybe String
filepath) (Maybe String -> Value
maybeString Maybe String
author) (Maybe String -> Value
maybeString Maybe String
before) (Maybe String -> Value
maybeString Maybe String
after)

-- | getChannel channelinfo
getChannel :: String -> Info -> IO Value
getChannel :: String -> Info -> IO Value
getChannel hubUrl :: String
hubUrl = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getChannel" (Value -> IO Value) -> (Info -> Value) -> Info -> IO Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Info -> Value
infoValue

-- | getEvent eventid
getEvent :: String -> Int -> IO Struct
getEvent :: String -> Int -> IO Struct
getEvent hubUrl :: String
hubUrl = String -> String -> Int -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl "getEvent"

-- | getExternalRepo info
getExternalRepo :: String -> Info -> Maybe Int -> IO Struct
getExternalRepo :: String -> Info -> Maybe Int -> IO Struct
getExternalRepo hubUrl :: String
hubUrl info :: Info
info event :: Maybe Int
event =
  String -> String -> Value -> () -> Value -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl "getExternalRepo" (Info -> Value
infoValue Info
info) () (Maybe Int -> Value
maybeInt Maybe Int
event)

-- | getExternalRepoList(tag_info, event=None)
getExternalRepoList :: String -> Info -> Maybe Int -> IO [Struct]
getExternalRepoList :: String -> Info -> Maybe Int -> IO [Struct]
getExternalRepoList hubUrl :: String
hubUrl info :: Info
info event :: Maybe Int
event =
  String -> String -> Value -> Value -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl "getExternalRepoList" (Info -> Value
infoValue Info
info) (Maybe Int -> Value
maybeInt Maybe Int
event)

-- | getFullInheritance(tag, event=None, reverse=False, stops=None, jumps=None)
getFullInheritance :: String -> String -> Maybe Int -> Bool -> IO Value
getFullInheritance :: String -> String -> Maybe Int -> Bool -> IO Value
getFullInheritance hubUrl :: String
hubUrl tag :: String
tag event :: Maybe Int
event =
  String -> String -> String -> Value -> Bool -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getFullInheritance" String
tag (Maybe Int -> Value
maybeInt Maybe Int
event)

-- | getGlobalInheritance(event=None)
getGlobalInheritance :: String -> Maybe Int -> IO Value
getGlobalInheritance :: String -> Maybe Int -> IO Value
getGlobalInheritance hubUrl :: String
hubUrl = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getGlobalInheritance" (Value -> IO Value)
-> (Maybe Int -> Value) -> Maybe Int -> IO Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe Int -> Value
maybeInt

-- | getGroupMembers(group)
getGroupMembers :: String -> String -> IO Value
getGroupMembers :: String -> String -> IO Value
getGroupMembers hubUrl :: String
hubUrl = String -> String -> String -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getGroupMembers"

-- | getHost(hostInfo, strict=False, event=None)
getHost :: String -> Info -> Maybe Int -> IO Struct
getHost :: String -> Info -> Maybe Int -> IO Struct
getHost hubUrl :: String
hubUrl info :: Info
info = String -> String -> Value -> () -> Value -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl "getHost" (Info -> Value
infoValue Info
info) () (Value -> IO Struct)
-> (Maybe Int -> Value) -> Maybe Int -> IO Struct
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe Int -> Value
maybeInt

-- | getImageArchive(archive_id, strict=False)
getImageArchive :: String -> Int -> IO Struct
getImageArchive :: String -> Int -> IO Struct
getImageArchive hubUrl :: String
hubUrl = String -> String -> Int -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl "getImageArchive"

-- | getImageBuild(buildInfo, strict=False)
getImageBuild :: String -> Info -> IO Struct
getImageBuild :: String -> Info -> IO Struct
getImageBuild hubUrl :: String
hubUrl info :: Info
info = String -> String -> Value -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl "getImageBuild" (Info -> Value
infoValue Info
info)

-- | getInheritanceData(tag, event=None)
getInheritanceData :: String -> String -> Maybe Int -> IO Value
getInheritanceData :: String -> String -> Maybe Int -> IO Value
getInheritanceData hubUrl :: String
hubUrl tag :: String
tag event :: Maybe Int
event =
  String -> String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getInheritanceData" String
tag (Maybe Int -> Value
maybeInt Maybe Int
event)


-- | getLastEvent(before=None)
getLastEvent :: String -> Maybe Int -> IO Value
getLastEvent :: String -> Maybe Int -> IO Value
getLastEvent hubUrl :: String
hubUrl = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getLastEvent" (Value -> IO Value)
-> (Maybe Int -> Value) -> Maybe Int -> IO Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe Int -> Value
maybeInt

-- | getLastHostUpdate(hostID)
getLastHostUpdate :: String -> Int -> IO Value
getLastHostUpdate :: String -> Int -> IO Value
getLastHostUpdate hubUrl :: String
hubUrl = String -> String -> Int -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getLastHostUpdate"

-- | getLatestBuilds(tag, event=None, package=None, type=None)
--
-- List latest builds for tag (inheritance enabled)
getLatestBuilds :: String
                -> Info -- ^ tag
                -> Maybe Int -- ^ event
                -> Maybe String -- ^ pkg
                -> Maybe String -- ^ type
                -> IO [Struct]
getLatestBuilds :: String
-> Info -> Maybe Int -> Maybe String -> Maybe String -> IO [Struct]
getLatestBuilds hubUrl :: String
hubUrl tag :: Info
tag event :: Maybe Int
event pkg :: Maybe String
pkg type_ :: Maybe String
type_ =
  String -> String -> Value -> Value -> Value -> Value -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl "getLatestBuilds" (Info -> Value
infoValue Info
tag) (Maybe Int -> Value
maybeInt Maybe Int
event) (Maybe String -> Value
maybeString Maybe String
pkg) (Maybe String -> Value
maybeString Maybe String
type_)

-- | getLatestMavenArchives(tag, event=None, inherit=True)
getLatestMavenArchives :: String -> String -> Maybe Int -> Bool -> IO Value
getLatestMavenArchives :: String -> String -> Maybe Int -> Bool -> IO Value
getLatestMavenArchives hubUrl :: String
hubUrl tag :: String
tag event :: Maybe Int
event =
  String -> String -> String -> Value -> Bool -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getLatestMavenArchives" String
tag (Maybe Int -> Value
maybeInt Maybe Int
event)

-- | getLatestRPMS(tag, package=None, arch=None, event=None, rpmsigs=False, type=None)
getLatestRPMS :: String -> String -> Maybe String -> Maybe String -> Maybe Int -> Bool -> Maybe String -> IO Value
getLatestRPMS :: String
-> String
-> Maybe String
-> Maybe String
-> Maybe Int
-> Bool
-> Maybe String
-> IO Value
getLatestRPMS hubUrl :: String
hubUrl tag :: String
tag pkg :: Maybe String
pkg arch :: Maybe String
arch event :: Maybe Int
event rpmsigs :: Bool
rpmsigs type_ :: Maybe String
type_ =
  String
-> String
-> String
-> Value
-> Value
-> Value
-> Bool
-> Value
-> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getLatestRPMS" String
tag (Maybe String -> Value
maybeString Maybe String
pkg) (Maybe String -> Value
maybeString Maybe String
arch) (Maybe Int -> Value
maybeInt Maybe Int
event) Bool
rpmsigs (Maybe String -> Value
maybeString Maybe String
type_)

-- getLoggedInUser()

-- | getMavenArchive(archive_id, strict=False)
getMavenArchive :: String -> Int -> IO Struct
getMavenArchive :: String -> Int -> IO Struct
getMavenArchive hubUrl :: String
hubUrl = String -> String -> Int -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl "getMavenArchive"

-- | getMavenBuild(buildInfo, strict=False)
getMavenBuild :: String -> Info -> IO Struct
getMavenBuild :: String -> Info -> IO Struct
getMavenBuild hubUrl :: String
hubUrl info :: Info
info = String -> String -> Value -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl "getMavenBuild" (Info -> Value
infoValue Info
info)

-- | getNextRelease(build_info)
--
-- find the last successful or deleted build of this N-V.
-- If building is specified, skip also builds in progress
getNextRelease :: String -> Info -> IO Value
getNextRelease :: String -> Info -> IO Value
getNextRelease hubUrl :: String
hubUrl info :: Info
info = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getNextRelease" (Info -> Value
infoValue Info
info)

-- | getPackage(info, strict=False, create=False)
--
-- Get the id,name for package
getPackage :: String -> Info -> IO Value
getPackage :: String -> Info -> IO Value
getPackage hubUrl :: String
hubUrl info :: Info
info = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getPackage" (Info -> Value
infoValue Info
info)

-- | getPackageConfig(tag, pkg, event=None)
--
-- Get config for package in tag
getPackageConfig :: String -> String -> String -> Maybe Int -> IO Value
getPackageConfig :: String -> String -> String -> Maybe Int -> IO Value
getPackageConfig hubUrl :: String
hubUrl tag :: String
tag pkg :: String
pkg event :: Maybe Int
event =
  String -> String -> String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getPackageConfig" String
tag String
pkg (Maybe Int -> Value
maybeInt Maybe Int
event)

-- | getPackageID(name, strict=False)
--
-- Get package ID by name.
getPackageID :: String -> String -> IO (Maybe Int)
getPackageID :: String -> String -> IO (Maybe Int)
getPackageID hubUrl :: String
hubUrl pkg :: String
pkg = do
  Value
res <- String -> String -> String -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getPackageID" String
pkg
  case Value
res of
    ValueInt i :: Int
i -> Maybe Int -> IO (Maybe Int)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Int -> IO (Maybe Int)) -> Maybe Int -> IO (Maybe Int)
forall a b. (a -> b) -> a -> b
$ Int -> Maybe Int
forall a. a -> Maybe a
Just Int
i
    _ -> Maybe Int -> IO (Maybe Int)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Int
forall a. Maybe a
Nothing

-- | getRPM(rpminfo, strict=False, multi=False)
getRPM :: String -> Info -> IO Struct
getRPM :: String -> Info -> IO Struct
getRPM hubUrl :: String
hubUrl = String -> String -> Value -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl "getRPM" (Value -> IO Struct) -> (Info -> Value) -> Info -> IO Struct
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Info -> Value
infoValue

-- | getRPMDeps(rpmID, depType=None, queryOpts=None, strict=False)
getRPMDeps :: String -> Int -> Maybe String -> IO [Struct]
getRPMDeps :: String -> Int -> Maybe String -> IO [Struct]
getRPMDeps hubUrl :: String
hubUrl rpmid :: Int
rpmid deptype :: Maybe String
deptype =
  String -> String -> Int -> Value -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl "getRPMDeps" Int
rpmid (Maybe String -> Value
maybeString Maybe String
deptype)

-- | getRPMFile(rpmID, filename, strict=False)
getRPMFile :: String -> Int -> FilePath -> IO Struct
getRPMFile :: String -> Int -> String -> IO Struct
getRPMFile hubUrl :: String
hubUrl = String -> String -> Int -> String -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl "getRPMFile"

-- | getRPMHeaders(rpmID=None, taskID=None, filepath=None, headers=None)
getRPMHeaders :: String -> Maybe Int -> Maybe Int -> Maybe FilePath -> Maybe Value -> IO Struct
getRPMHeaders :: String
-> Maybe Int
-> Maybe Int
-> Maybe String
-> Maybe Value
-> IO Struct
getRPMHeaders hubUrl :: String
hubUrl rpmid :: Maybe Int
rpmid taskid :: Maybe Int
taskid file :: Maybe String
file headers :: Maybe Value
headers =
  String -> String -> Value -> Value -> Value -> Value -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl "getRPMHeaders" (Maybe Int -> Value
maybeInt Maybe Int
rpmid) (Maybe Int -> Value
maybeInt Maybe Int
taskid) (Maybe String -> Value
maybeString Maybe String
file) (Value -> Maybe Value -> Value
forall a. a -> Maybe a -> a
fromMaybe Value
ValueNil Maybe Value
headers)

-- | getRepo(tag, state=None, event=None, dist=False)
getRepo :: String -> String -> Maybe Int -> Maybe Int -> Bool -> IO Value
getRepo :: String -> String -> Maybe Int -> Maybe Int -> Bool -> IO Value
getRepo hubUrl :: String
hubUrl tag :: String
tag state :: Maybe Int
state event :: Maybe Int
event =
  String -> String -> String -> Value -> Value -> Bool -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getRepo" String
tag (Maybe Int -> Value
maybeInt Maybe Int
state) (Maybe Int -> Value
maybeInt Maybe Int
event)

-- getSessionInfo()

-- | getTag(tagInfo, strict=False, event=None)
getTag :: String -> Info -> Maybe Int -> IO Struct
getTag :: String -> Info -> Maybe Int -> IO Struct
getTag hubUrl :: String
hubUrl info :: Info
info = String -> String -> Value -> () -> Value -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl "getTag" (Info -> Value
infoValue Info
info) () (Value -> IO Struct)
-> (Maybe Int -> Value) -> Maybe Int -> IO Struct
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe Int -> Value
maybeInt

-- | getTagExternalRepos(tag_info=None, repo_info=None, event=None)
getTagExternalRepos :: String -> Maybe Info -> Maybe Info -> Maybe Int -> IO Struct
getTagExternalRepos :: String -> Maybe Info -> Maybe Info -> Maybe Int -> IO Struct
getTagExternalRepos hubUrl :: String
hubUrl taginfo :: Maybe Info
taginfo repoinfo :: Maybe Info
repoinfo event :: Maybe Int
event =
  String -> String -> Value -> Value -> Value -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl "getTagExternalRepos" (Maybe Info -> Value
maybeInfo Maybe Info
taginfo) (Maybe Info -> Value
maybeInfo Maybe Info
repoinfo) (Maybe Int -> Value
maybeInt Maybe Int
event)

-- | getTagGroups(tag, event=None, inherit=True, incl_pkgs=True, incl_reqs=True, incl_blocked=False)
getTagGroups :: String -> String -> Maybe Int -> Bool -> Bool -> Bool -> Bool -> IO Value
getTagGroups :: String
-> String -> Maybe Int -> Bool -> Bool -> Bool -> Bool -> IO Value
getTagGroups hubUrl :: String
hubUrl tag :: String
tag event :: Maybe Int
event =
  String
-> String
-> String
-> Value
-> Bool
-> Bool
-> Bool
-> Bool
-> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getTagGroups" String
tag (Maybe Int -> Value
maybeInt Maybe Int
event)

-- | getTagID(info, strict=False, create=False)
getTagID :: String -> Info -> IO (Maybe Int)
getTagID :: String -> Info -> IO (Maybe Int)
getTagID hubUrl :: String
hubUrl tag :: Info
tag = do
  Value
res <- String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getTagID" (Info -> Value
infoValue Info
tag)
  case Value
res of
    ValueInt i :: Int
i -> Maybe Int -> IO (Maybe Int)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Int -> IO (Maybe Int)) -> Maybe Int -> IO (Maybe Int)
forall a b. (a -> b) -> a -> b
$ Int -> Maybe Int
forall a. a -> Maybe a
Just Int
i
    _ -> Maybe Int -> IO (Maybe Int)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Int
forall a. Maybe a
Nothing

-- | getTaskChildren(task_id, request=False, strict=False)
getTaskChildren :: String -> Int -> Bool -> IO [Struct]
getTaskChildren :: String -> Int -> Bool -> IO [Struct]
getTaskChildren hubUrl :: String
hubUrl = String -> String -> Int -> Bool -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl "getTaskChildren"

-- | getTaskDescendents(task_id, request=False)
getTaskDescendents :: String -> Int -> Bool -> IO Struct
getTaskDescendents :: String -> Int -> Bool -> IO Struct
getTaskDescendents hubUrl :: String
hubUrl = String -> String -> Int -> Bool -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl "getTaskDescendents"

-- | getTaskInfo(task_id, request=False, strict=False)
getTaskInfo :: String
            -> Int
            -> Bool -- ^ include request details
            -> IO (Maybe Struct)
getTaskInfo :: String -> Int -> Bool -> IO (Maybe Struct)
getTaskInfo hubUrl :: String
hubUrl tid :: Int
tid request :: Bool
request = Value -> Maybe Struct
maybeStruct (Value -> Maybe Struct) -> IO Value -> IO (Maybe Struct)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> String -> Int -> Bool -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getTaskInfo" Int
tid Bool
request
  -- res <- kojiCall "getTaskInfo" [show taskid]
  -- let state = res ^? key "state" % _Integer <&> (toEnum . fromInteger)
  --     arch = res ^? key "arch" % _String
  -- return $ TaskInfo arch state

-- | getTaskRequest(taskId)
getTaskRequest :: String -> Int -> IO Value
getTaskRequest :: String -> Int -> IO Value
getTaskRequest hubUrl :: String
hubUrl = String -> String -> Int -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getTaskRequest"

-- | getTaskResult(taskId, raise_fault=True)
getTaskResult :: String -> Int -> IO Value
getTaskResult :: String -> Int -> IO Value
getTaskResult hubUrl :: String
hubUrl = String -> String -> Int -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getTaskResult"

-- | getUser(userInfo=None, strict=False, krb_princs=True)
getUser :: String -> Info -> Bool -> IO (Maybe Struct)
getUser :: String -> Info -> Bool -> IO (Maybe Struct)
getUser hubUrl :: String
hubUrl info :: Info
info krbprncpl :: Bool
krbprncpl =
  Value -> Maybe Struct
maybeStruct (Value -> Maybe Struct) -> IO Value -> IO (Maybe Struct)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> String -> Value -> () -> Bool -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getUser" (Info -> Value
infoValue Info
info) () Bool
krbprncpl

-- | getUserPerms(userID=None)
getUserPerms :: String -> Maybe Info -> IO Value
getUserPerms :: String -> Maybe Info -> IO Value
getUserPerms hubUrl :: String
hubUrl = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getUserPerms" (Value -> IO Value)
-> (Maybe Info -> Value) -> Maybe Info -> IO Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe Info -> Value
maybeInfo

-- | getVolume(volume, strict=False)
getVolume :: String -> Info -> IO Value
getVolume :: String -> Info -> IO Value
getVolume hubUrl :: String
hubUrl = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getVolume" (Value -> IO Value) -> (Info -> Value) -> Info -> IO Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Info -> Value
infoValue

-- | getWinArchive(archive_id, strict=False)
getWinArchive :: String -> Int -> IO Struct
getWinArchive :: String -> Int -> IO Struct
getWinArchive hubUrl :: String
hubUrl = String -> String -> Int -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl "getWinArchive"

-- | getWinBuild(buildInfo, strict=False)
getWinBuild :: String -> Info -> IO (Maybe Struct)
getWinBuild :: String -> Info -> IO (Maybe Struct)
getWinBuild hubUrl :: String
hubUrl = (Value -> Maybe Struct) -> IO Value -> IO (Maybe Struct)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Value -> Maybe Struct
maybeStruct (IO Value -> IO (Maybe Struct))
-> (Info -> IO Value) -> Info -> IO (Maybe Struct)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "getWinBuild" (Value -> IO Value) -> (Info -> Value) -> Info -> IO Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Info -> Value
infoValue

-- grantCGAccess(user, cg, create=False)

-- grantPermission(userinfo, permission, create=False)

-- groupListAdd(taginfo, grpinfo, block=False, force=False, **opts)

-- groupListBlock(taginfo, grpinfo)

-- groupListRemove(taginfo, grpinfo, force=False)

-- groupListUnblock(taginfo, grpinfo)

-- groupPackageListAdd(taginfo, grpinfo, pkg_name, block=False, force=False, **opts)

-- groupPackageListBlock(taginfo, grpinfo, pkg_name)

-- groupPackageListRemove(taginfo, grpinfo, pkg_name, force=False)

-- groupReqListUnblock(taginfo, grpinfo, reqinfo)

-- hasPerm(perm, strict=False)

-- | Say hello to test XMLRPC connection to Koji Hub
hello :: String -> IO String
hello :: String -> IO String
hello hubUrl :: String
hubUrl = String -> String -> IO String
forall a. Remote a => String -> String -> a
koji String
hubUrl "hello"

-- host.* [skipped]

-- importArchive(filepath, buildinfo, type, typeInfo)

-- importRPM(path, basename)

-- krbLogin(*args, **opts)

-- | listArchiveFiles(archive_id, queryOpts=None, strict=False)
listArchiveFiles :: String -> Int -> IO [Struct]
listArchiveFiles :: String -> Int -> IO [Struct]
listArchiveFiles hubUrl :: String
hubUrl = String -> String -> Int -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl "listArchiveFiles"

-- | listArchives(buildID=None, buildrootID=None, componentBuildrootID=None, hostID=None, type=None, filename=None, size=None, checksum=None, typeInfo=None, queryOpts=None, imageID=None, archiveID=None, strict=False)
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 :: String
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe String
-> Maybe String
-> Maybe Int
-> Maybe String
-> Maybe Info
-> Maybe Int
-> Maybe Int
-> IO [Struct]
listArchives hubUrl :: String
hubUrl buildID :: Maybe Int
buildID buildrootID :: Maybe Int
buildrootID componentBuildrootID :: Maybe Int
componentBuildrootID hostID :: Maybe Int
hostID type_ :: Maybe String
type_ file :: Maybe String
file size :: Maybe Int
size checksum :: Maybe String
checksum typeInfo :: Maybe Info
typeInfo imageID :: Maybe Int
imageID archiveID :: Maybe Int
archiveID =
  String
-> String
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> ()
-> Value
-> Value
-> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl "listArchives" (Maybe Int -> Value
maybeInt Maybe Int
buildID) (Maybe Int -> Value
maybeInt Maybe Int
buildrootID) (Maybe Int -> Value
maybeInt Maybe Int
componentBuildrootID) (Maybe Int -> Value
maybeInt Maybe Int
hostID) (Maybe String -> Value
maybeString Maybe String
type_) (Maybe String -> Value
maybeString Maybe String
file) (Maybe Int -> Value
maybeInt Maybe Int
size) (Maybe String -> Value
maybeString Maybe String
checksum) (Maybe Info -> Value
maybeInfo Maybe Info
typeInfo) () (Maybe Int -> Value
maybeInt Maybe Int
imageID) (Maybe Int -> Value
maybeInt Maybe Int
archiveID)

-- | listBTypes(query=None, queryOpts=None)
listBTypes :: String -> Value -> IO Value
listBTypes :: String -> Value -> IO Value
listBTypes hubUrl :: String
hubUrl = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "listBTypes"

-- | listBuildRPMs(build)
listBuildRPMs :: String -> Int -> IO [Struct]
listBuildRPMs :: String -> Int -> IO [Struct]
listBuildRPMs hubUrl :: String
hubUrl = String -> String -> Int -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl "listBuildRPMs"

-- | listBuildroots(hostID=None, tagID=None, state=None, rpmID=None, archiveID=None, taskID=None, buildrootID=None, queryOpts=None)
listBuildroots :: String -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> IO Value
listBuildroots :: String
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> IO Value
listBuildroots hubUrl :: String
hubUrl hostID :: Maybe Int
hostID tagID :: Maybe Int
tagID state :: Maybe Int
state rpmID :: Maybe Int
rpmID archiveID :: Maybe Int
archiveID taskID :: Maybe Int
taskID buildrootID :: Maybe Int
buildrootID =
  String
-> String
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "listBuildroots" (Maybe Int -> Value
maybeInt Maybe Int
hostID) (Maybe Int -> Value
maybeInt Maybe Int
tagID) (Maybe Int -> Value
maybeInt Maybe Int
state) (Maybe Int -> Value
maybeInt Maybe Int
rpmID) (Maybe Int -> Value
maybeInt Maybe Int
archiveID) (Maybe Int -> Value
maybeInt Maybe Int
taskID) (Maybe Int -> Value
maybeInt Maybe Int
buildrootID)

-- | listBuilds(packageID=None, userID=None, taskID=None, prefix=None, state=None, volumeID=None, source=None, createdBefore=None, createdAfter=None, completeBefore=None, completeAfter=None, type=None, typeInfo=None, queryOpts=None, pattern=None)
--
-- Note that pattern is only supported for koji >= 1.24
listBuilds :: String -> Struct -> IO [Struct]
listBuilds :: String -> Struct -> IO [Struct]
listBuilds hubUrl :: String
hubUrl args :: Struct
args =
  let maybeArg :: String -> Value
maybeArg fld :: String
fld = Maybe Value -> Value
maybeValue (String -> Struct -> Maybe Value
forall a. XmlRpcType a => String -> Struct -> Maybe a
lookupStruct String
fld Struct
args)
  -- koji 1.24 added support for pattern
  in case String -> Value
maybeArg "pattern" of
       ValueNil ->
         String
-> String
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl "listBuilds" (String -> Value
maybeArg "packageID") (String -> Value
maybeArg "userID") (String -> Value
maybeArg "taskID") (String -> Value
maybeArg "prefix") (String -> Value
maybeArg "state") (String -> Value
maybeArg "volumeID") (String -> Value
maybeArg "source") (String -> Value
maybeArg "createdBefore") (String -> Value
maybeArg "createdAfter") (String -> Value
maybeArg "completeBefore") (String -> Value
maybeArg "completeAfter") (String -> Value
maybeArg "type") (String -> Value
maybeArg "typeInfo") (String -> Value
maybeArg "queryOpts")
       pat :: Value
pat -> String
-> String
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl "listBuilds" (String -> Value
maybeArg "packageID") (String -> Value
maybeArg "userID") (String -> Value
maybeArg "taskID") (String -> Value
maybeArg "prefix") (String -> Value
maybeArg "state") (String -> Value
maybeArg "volumeID") (String -> Value
maybeArg "source") (String -> Value
maybeArg "createdBefore") (String -> Value
maybeArg "createdAfter") (String -> Value
maybeArg "completeBefore") (String -> Value
maybeArg "completeAfter") (String -> Value
maybeArg "type") (String -> Value
maybeArg "typeInfo") (String -> Value
maybeArg "queryOpts") Value
pat

-- | listCGs()
listCGs :: String -> IO Struct
listCGs :: String -> IO Struct
listCGs hubUrl :: String
hubUrl = String -> String -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl "listCGs"

-- | listChannels(hostID=None, event=None)
listChannels :: String -> Maybe Int -> Maybe Int -> IO Value
listChannels :: String -> Maybe Int -> Maybe Int -> IO Value
listChannels hubUrl :: String
hubUrl hostID :: Maybe Int
hostID event :: Maybe Int
event =
  String -> String -> Value -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "listChannels" (Maybe Int -> Value
maybeInt Maybe Int
hostID) (Maybe Int -> Value
maybeInt Maybe Int
event)

-- | listExternalRepos(info=None, url=None, event=None, queryOpts=None)
listExternalRepos :: String -> Maybe Info -> Maybe String -> Maybe Int -> IO Value
listExternalRepos :: String -> Maybe Info -> Maybe String -> Maybe Int -> IO Value
listExternalRepos hubUrl :: String
hubUrl info :: Maybe Info
info url :: Maybe String
url event :: Maybe Int
event =
  String -> String -> Value -> Value -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "listExternalRepos" (Maybe Info -> Value
maybeInfo Maybe Info
info) (Maybe String -> Value
maybeString Maybe String
url) (Maybe Int -> Value
maybeInt Maybe Int
event)

-- | listHosts(arches=None, channelID=None, ready=None, enabled=None, userID=None, queryOpts=None)
listHosts :: String -> Maybe Value -> Maybe Int -> Bool -> Bool -> Maybe Int -> IO Value
listHosts :: String
-> Maybe Value
-> Maybe Int
-> Bool
-> Bool
-> Maybe Int
-> IO Value
listHosts hubUrl :: String
hubUrl arches :: Maybe Value
arches channelID :: Maybe Int
channelID ready :: Bool
ready enabled :: Bool
enabled userID :: Maybe Int
userID =
  String
-> String -> Value -> Value -> Bool -> Bool -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "listHosts" (Maybe Value -> Value
maybeValue Maybe Value
arches) (Maybe Int -> Value
maybeInt Maybe Int
channelID) Bool
ready Bool
enabled (Maybe Int -> Value
maybeInt Maybe Int
userID)

-- | listPackages(tagID=None, userID=None, pkgID=None, prefix=None, inherited=False, with_dups=False, event=None, queryOpts=None)
listPackages :: String -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe String -> Bool -> Bool -> Maybe Int -> IO [Struct]
listPackages :: String
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe String
-> Bool
-> Bool
-> Maybe Int
-> IO [Struct]
listPackages hubUrl :: String
hubUrl tagID :: Maybe Int
tagID userID :: Maybe Int
userID pkgID :: Maybe Int
pkgID prefix :: Maybe String
prefix inherited :: Bool
inherited with_dups :: Bool
with_dups event :: Maybe Int
event =
  String
-> String
-> Value
-> Value
-> Value
-> Value
-> Bool
-> Bool
-> Value
-> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl "listPackages" (Maybe Int -> Value
maybeInt Maybe Int
tagID) (Maybe Int -> Value
maybeInt Maybe Int
userID) (Maybe Int -> Value
maybeInt Maybe Int
pkgID) (Maybe String -> Value
maybeString Maybe String
prefix) Bool
inherited Bool
with_dups (Maybe Int -> Value
maybeInt Maybe Int
event)

-- | listPackagesSimple prefix
listPackagesSimple :: String -> String -- ^ package name search prefix
                   -> IO [Struct]
listPackagesSimple :: String -> String -> IO [Struct]
listPackagesSimple hubUrl :: String
hubUrl = String -> String -> String -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl "listPackagesSimple"

-- | listRPMFiles(rpmID, queryOpts=None)
listRPMFiles :: String -> Int -> IO [Struct]
listRPMFiles :: String -> Int -> IO [Struct]
listRPMFiles hubUrl :: String
hubUrl = String -> String -> Int -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl "listRPMFiles"

-- | listRPMs(buildID=None, buildrootID=None, imageID=None, componentBuildrootID=None, hostID=None, arches=None, queryOpts=None)
listRPMs :: String -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Value -> IO [Struct]
listRPMs :: String
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Value
-> IO [Struct]
listRPMs hubUrl :: String
hubUrl buildID :: Maybe Int
buildID buildrootID :: Maybe Int
buildrootID imageID :: Maybe Int
imageID componentBuildrootID :: Maybe Int
componentBuildrootID hostID :: Maybe Int
hostID arches :: Maybe Value
arches =
  String
-> String
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl "listRPMs" (Maybe Int -> Value
maybeInt Maybe Int
buildID) (Maybe Int -> Value
maybeInt Maybe Int
buildrootID) (Maybe Int -> Value
maybeInt Maybe Int
imageID) (Maybe Int -> Value
maybeInt Maybe Int
componentBuildrootID) (Maybe Int -> Value
maybeInt Maybe Int
hostID) (Maybe Value -> Value
maybeValue Maybe Value
arches)

-- | listSideTags(basetag=None, user=None, queryOpts=None)
listSideTags :: String -> Maybe Info -> Maybe Info -> IO Value
listSideTags :: String -> Maybe Info -> Maybe Info -> IO Value
listSideTags hubUrl :: String
hubUrl basetag :: Maybe Info
basetag user :: Maybe Info
user = do
  String -> String -> Value -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "listSideTags" (Maybe Info -> Value
maybeInfo Maybe Info
basetag) (Maybe Info -> Value
maybeInfo Maybe Info
user)

-- | listTagged(tag, event=None, inherit=False, prefix=None, latest=False, package=None, owner=None, type=None)
listTagged :: String -> String -> Maybe Int -> Bool -> Maybe String -> Bool -> Maybe String -> Maybe String -> Maybe String -> IO [Struct]
listTagged :: String
-> String
-> Maybe Int
-> Bool
-> Maybe String
-> Bool
-> Maybe String
-> Maybe String
-> Maybe String
-> IO [Struct]
listTagged hubUrl :: String
hubUrl tag :: String
tag event :: Maybe Int
event inherit :: Bool
inherit prefix :: Maybe String
prefix latest :: Bool
latest package :: Maybe String
package owner :: Maybe String
owner type_ :: Maybe String
type_ =
  String
-> String
-> String
-> Value
-> Bool
-> Value
-> Bool
-> Value
-> Value
-> Value
-> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl "listTagged" String
tag (Maybe Int -> Value
maybeInt Maybe Int
event) Bool
inherit (Maybe String -> Value
maybeString Maybe String
prefix) Bool
latest (Maybe String -> Value
maybeString Maybe String
package) (Maybe String -> Value
maybeString Maybe String
owner) (Maybe String -> Value
maybeString Maybe String
type_)

-- | listTaggedArchives(tag, event=None, inherit=False, latest=False, package=None, type=None)
listTaggedArchives :: String -> String -> Maybe Int -> Bool -> Bool -> Maybe String -> Maybe String -> IO Value
listTaggedArchives :: String
-> String
-> Maybe Int
-> Bool
-> Bool
-> Maybe String
-> Maybe String
-> IO Value
listTaggedArchives hubUrl :: String
hubUrl tag :: String
tag event :: Maybe Int
event inherit :: Bool
inherit latest :: Bool
latest package :: Maybe String
package type_ :: Maybe String
type_ =
  String
-> String
-> String
-> Value
-> Bool
-> Bool
-> Value
-> Value
-> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "listTaggedArchives" String
tag (Maybe Int -> Value
maybeInt Maybe Int
event) Bool
inherit Bool
latest (Maybe String -> Value
maybeString Maybe String
package) (Maybe String -> Value
maybeString Maybe String
type_)

-- | listTaggedRPMS(tag, event=None, inherit=False, latest=False, package=None, arch=None, rpmsigs=False, owner=None, type=None)
listTaggedRPMS :: String -> String -> Maybe Int -> Bool -> Bool -> Maybe String ->  Maybe String -> Bool -> Maybe String -> Maybe String -> IO Value
listTaggedRPMS :: String
-> String
-> Maybe Int
-> Bool
-> Bool
-> Maybe String
-> Maybe String
-> Bool
-> Maybe String
-> Maybe String
-> IO Value
listTaggedRPMS hubUrl :: String
hubUrl tag :: String
tag event :: Maybe Int
event inherit :: Bool
inherit latest :: Bool
latest package :: Maybe String
package arch :: Maybe String
arch rpmsigs :: Bool
rpmsigs owner :: Maybe String
owner type_ :: Maybe String
type_ =
  String
-> String
-> String
-> Value
-> Bool
-> Bool
-> Value
-> Value
-> Bool
-> Value
-> Value
-> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "listTaggedRPMS" String
tag (Maybe Int -> Value
maybeInt Maybe Int
event) Bool
inherit Bool
latest (Maybe String -> Value
maybeString Maybe String
package) (Maybe String -> Value
maybeString Maybe String
arch) Bool
rpmsigs (Maybe String -> Value
maybeString Maybe String
owner) (Maybe String -> Value
maybeString Maybe String
type_)

-- | listTags(build=None, package=None, perms=True, queryOpts=None)
listTags :: String -> Maybe Info -> Maybe Info -> Bool -> IO [Struct]
listTags :: String -> Maybe Info -> Maybe Info -> Bool -> IO [Struct]
listTags hubUrl :: String
hubUrl build :: Maybe Info
build package :: Maybe Info
package =
  String -> String -> Value -> Value -> Bool -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl "listTags" (Maybe Info -> Value
maybeInfo Maybe Info
build) (Maybe Info -> Value
maybeInfo Maybe Info
package)

-- | listTaskOutput(taskID, stat=False, all_volumes=False, strict=False)
listTaskOutput :: String -> Int -> Bool -> Bool -> Bool -> IO Struct
listTaskOutput :: String -> Int -> Bool -> Bool -> Bool -> IO Struct
listTaskOutput hubUrl :: String
hubUrl = String -> String -> Int -> Bool -> Bool -> Bool -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl "listTaskOutput"

-- | listTasks(opts=None, queryOpts=None)
listTasks :: String -> Struct -- ^ opts
          -> Struct -- ^ qopts
          -> IO [Struct]
listTasks :: String -> Struct -> Struct -> IO [Struct]
listTasks hubUrl :: String
hubUrl = String -> String -> Struct -> Struct -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl "listTasks"

-- | listUsers(userType=0, prefix=None, queryOpts=None)
listUsers :: String -> Maybe Int -> Maybe String -> IO [Struct]
listUsers :: String -> Maybe Int -> Maybe String -> IO [Struct]
listUsers hubUrl :: String
hubUrl userType :: Maybe Int
userType prefix :: Maybe String
prefix =
  String -> String -> Value -> Value -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl "listUsers" (Maybe Int -> Value
maybeInt Maybe Int
userType) (Maybe String -> Value
maybeString Maybe String
prefix)

-- | listVolumes()
listVolumes :: String -> IO Value
listVolumes :: String -> IO Value
listVolumes hubUrl :: String
hubUrl = String -> String -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "listVolumes"

-- login(*args, **opts)

-- logout()

-- logoutChild(session_id)

-- makeTask(*args, **opts)

-- mavenBuild(url, target, opts=None, priority=None, channel='maven')

-- mavenEnabled()

-- mergeScratch(task_id)

-- moveAllBuilds(tag1, tag2, package, force=False)

-- moveBuild(tag1, tag2, build, force=False)

-- newGroup(name)

-- newRepo(tag, event=None, src=False, debuginfo=False, separate_src=False)

-- packageListAdd(taginfo, pkginfo, owner=None, block=None, extra_arches=None, force=False, update=False)

-- packageListBlock(taginfo, pkginfo, force=False)

-- packageListRemove(taginfo, pkginfo, force=False)

-- packageListSetArches(taginfo, pkginfo, arches, force=False)

-- packageListSetOwner(taginfo, pkginfo, owner, force=False)

-- packageListUnblock(taginfo, pkginfo, force=False)

-- queryHistory(tables=None, **kwargs)

-- queryRPMSigs(rpm_id=None, sigkey=None, queryOpts=None)

-- remove*

-- repo*

-- | repoInfo(repo_id, strict=False)
repoInfo :: String -> Int -> IO Value
repoInfo :: String -> Int -> IO Value
repoInfo hubUrl :: String
hubUrl = String -> String -> Int -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "repoInfo"

-- resetBuild(build)

-- restartHosts(priority=5, options=None)

-- | resubmitTask(taskID)
resubmitTask :: String -> Int -> IO Value
resubmitTask :: String -> Int -> IO Value
resubmitTask hubUrl :: String
hubUrl = String -> String -> Int -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "resubmitTask"

-- revoke*

-- runroot(tagInfo, arch, command, channel=None, **opts)

-- search(terms, type, matchType, queryOpts=None)

-- set*

-- sharedSession()

-- showOpts()

-- showSession()

-- sslLogin(*args, **opts)

-- subsession()

-- system.*

-- tagBuild(tag, build, force=False, fromtag=None)

-- tagBuildBypass(tag, build, force=False, notify=True)

-- | tagChangedSinceEvent(event, taglist)
tagChangedSinceEvent :: String -> Int -> Value -> IO Bool
tagChangedSinceEvent :: String -> Int -> Value -> IO Bool
tagChangedSinceEvent hubUrl :: String
hubUrl = String -> String -> Int -> Value -> IO Bool
forall a. Remote a => String -> String -> a
koji String
hubUrl "tagChangedSinceEvent"

-- | tagHistory(build=None, tag=None, package=None, active=None, queryOpts=None)
tagHistory :: String -> Maybe Info -> Maybe Info -> Maybe Info -> Bool -> IO Value
tagHistory :: String
-> Maybe Info -> Maybe Info -> Maybe Info -> Bool -> IO Value
tagHistory hubUrl :: String
hubUrl build :: Maybe Info
build tag :: Maybe Info
tag package :: Maybe Info
package =
  String -> String -> Value -> Value -> Value -> Bool -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "tagHistory" (Maybe Info -> Value
maybeInfo Maybe Info
build) (Maybe Info -> Value
maybeInfo Maybe Info
tag) (Maybe Info -> Value
maybeInfo Maybe Info
package)

-- | taskFinished(taskId)
taskFinished :: String -> Int -> IO Bool
taskFinished :: String -> Int -> IO Bool
taskFinished hubUrl :: String
hubUrl = String -> String -> Int -> IO Bool
forall a. Remote a => String -> String -> a
koji String
hubUrl "taskFinished"

-- | taskReport(owner=None)
taskReport :: String -> Maybe String -> IO Value
taskReport :: String -> Maybe String -> IO Value
taskReport hubUrl :: String
hubUrl = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl "taskReport" (Value -> IO Value)
-> (Maybe String -> Value) -> Maybe String -> IO Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe String -> Value
maybeString

-- untag*

-- updateNotification(id, package_id, tag_id, success_only)

-- uploadFile(path, name, size, md5sum, offset, data, volume=None)

-- winBuild(vm, url, target, opts=None, priority=None, channel='vm')

-- winEnabled()

-- wrapperRPM(build, url, target, priority=None, channel='maven', opts=None)

-- writeSignedRPM(an_rpm, sigkey, force=False)


-- readStructString :: String -> Struct -> String
-- readStructString key str =
--   case lookup key str of
--     Just (ValueString s) -> s
--     _ -> error $ "No String for " ++ key

-- readStructArray :: String -> Struct -> Maybe [Value]
-- readStructArray key struct =
--   either error id <$> runExceptT (getField key struct)
-- --    Just (ValueArray s) -> s
-- --    _ -> error $ "No Array for " ++ key

-- readMethodParams :: String -> Maybe [Value]
-- readMethodParams s =
--   either error params <$> runExceptT (parseCall s)
--   where
--     params (MethodCall _m str) = str

-- | Lookup a key in a XML result
lookupStruct :: XmlRpcType a => String -> Struct -> Maybe a
lookupStruct :: String -> Struct -> Maybe a
lookupStruct key :: String
key struct :: Struct
struct =
  (String -> a) -> (a -> a) -> Either String a -> a
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either String -> a
forall a. HasCallStack => String -> a
error a -> a
forall a. a -> a
id (Either String a -> a) -> Maybe (Either String a) -> Maybe a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ExceptT String Maybe a -> Maybe (Either String a)
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (String -> Struct -> ExceptT String Maybe a
forall (m :: * -> *) a.
(MonadFail m, XmlRpcType a) =>
String -> Struct -> Err m a
getField String
key Struct
struct)

getValue :: XmlRpcType a => Value -> Maybe a
getValue :: Value -> Maybe a
getValue = (Either String a -> a) -> Maybe (Either String a) -> Maybe a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((String -> a) -> (a -> a) -> Either String a -> a
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either String -> a
forall a. HasCallStack => String -> a
error a -> a
forall a. a -> a
id) (Maybe (Either String a) -> Maybe a)
-> (Value -> Maybe (Either String a)) -> Value -> Maybe a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExceptT String Maybe a -> Maybe (Either String a)
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT String Maybe a -> Maybe (Either String a))
-> (Value -> ExceptT String Maybe a)
-> Value
-> Maybe (Either String a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> ExceptT String Maybe a
forall a (m :: * -> *).
(XmlRpcType a, MonadFail m) =>
Value -> Err m a
fromValue