-- Note: much of this module is untested and experimental:
-- particularly the functions just returning a Value

module Fedora.Koji.Internal
       ( 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
       , maybeVal
       , 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)

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

data Info = InfoID Int | InfoString String

infoValue :: Info -> Value
infoValue :: Info -> Value
infoValue (InfoID Int
i) = Int -> Value
ValueInt Int
i
infoValue (InfoString 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 Struct
st) = Struct -> Maybe Struct
forall a. a -> Maybe a
Just Struct
st
maybeStruct Value
_ = Maybe Struct
forall a. Maybe a
Nothing

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

-- 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 String
hubUrl = String -> String -> Int -> Int -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"checkTagAccess"

-- | checkTagPackage(tag, pkg)
checkTagPackage :: String -> Info -> Info -> IO Bool
checkTagPackage :: String -> Info -> Info -> IO Bool
checkTagPackage String
hubUrl Info
taginfo Info
pkginfo = String -> String -> Value -> Value -> IO Bool
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> IO String
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"getAPIVersion"

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

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

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

-- | getArchive(archive_id, strict=False)
getArchive :: String -> Int -> IO (Maybe Struct)
getArchive :: String -> Int -> IO (Maybe Struct)
getArchive 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 String
"getArchive"

-- | getArchiveFile(archive_id, filename, strict=False)
getArchiveFile :: String -> Int -> FilePath -> IO (Maybe Struct)
getArchiveFile :: String -> Int -> String -> IO (Maybe Struct)
getArchiveFile String
hubUrl Int
archiveID 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 String
"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 String
hubUrl Maybe String
filename Maybe String
type_name Maybe Int
type_id =
  String -> String -> Value -> Value -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"getArchiveTypes"

-- | getAverageBuildDuration pkginfo
getAverageBuildDuration :: String -> Info -> IO Value
getAverageBuildDuration :: String -> Info -> IO Value
getAverageBuildDuration String
hubUrl = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 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 String
"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 String
hubUrl = String -> String -> String -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"getBuildConfig"

-- | getBuildLogs build
getBuildLogs :: String -> Info -- ^ buildinfo
             -> IO Value
getBuildLogs :: String -> Info -> IO Value
getBuildLogs String
hubUrl = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> String -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl Maybe Info
info Maybe Int
event Maybe Int
buildTagId Maybe Int
destTagId  =
  String -> String -> Value -> Value -> Value -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> Int -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"getBuildroot"

-- | getBuildrootListing buildrootId
getBuildrootListing :: String -> Int -> IO Value
getBuildrootListing :: String -> Int -> IO Value
getBuildrootListing String
hubUrl = String -> String -> Int -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl Maybe Int
buildID Maybe Int
taskID Maybe String
filepath Maybe String
author Maybe String
before Maybe String
after =
  String
-> String
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> Int -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"getEvent"

-- | getExternalRepo info
getExternalRepo :: String -> Info -> Maybe Int -> IO Struct
getExternalRepo :: String -> Info -> Maybe Int -> IO Struct
getExternalRepo String
hubUrl Info
info Maybe Int
event =
  String -> String -> Value -> () -> Value -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl Info
info Maybe Int
event =
  String -> String -> Value -> Value -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl String
tag Maybe Int
event =
  String -> String -> String -> Value -> Bool -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> String -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"getGroupMembers"

-- | getHost(hostInfo, strict=False, event=None)
getHost :: String -> Info -> Maybe Int -> IO Struct
getHost :: String -> Info -> Maybe Int -> IO Struct
getHost String
hubUrl Info
info = String -> String -> Value -> () -> Value -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> Int -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"getImageArchive"

-- | getImageBuild(buildInfo, strict=False)
getImageBuild :: String -> Info -> IO Struct
getImageBuild :: String -> Info -> IO Struct
getImageBuild String
hubUrl Info
info = String -> String -> Value -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl String
tag Maybe Int
event =
  String -> String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> Int -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl Info
tag Maybe Int
event Maybe String
pkg Maybe String
type_ =
  String -> String -> Value -> Value -> Value -> Value -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl String
tag Maybe Int
event =
  String -> String -> String -> Value -> Bool -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl String
tag Maybe String
pkg Maybe String
arch Maybe Int
event Bool
rpmsigs Maybe String
type_ =
  String
-> String
-> String
-> Value
-> Value
-> Value
-> Bool
-> Value
-> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> Int -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"getMavenArchive"

-- | getMavenBuild(buildInfo, strict=False)
getMavenBuild :: String -> Info -> IO Struct
getMavenBuild :: String -> Info -> IO Struct
getMavenBuild String
hubUrl Info
info = String -> String -> Value -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl Info
info = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl Info
info = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl String
tag String
pkg Maybe Int
event =
  String -> String -> String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl String
pkg = do
  Value
res <- String -> String -> String -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"getPackageID" String
pkg
  case Value
res of
    ValueInt 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
    Value
_ -> 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 String
hubUrl = String -> String -> Value -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl Int
rpmid Maybe String
deptype =
  String -> String -> Int -> Value -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> Int -> String -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl Maybe Int
rpmid Maybe Int
taskid Maybe String
file Maybe Value
headers =
  String -> String -> Value -> Value -> Value -> Value -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl String
tag Maybe Int
state Maybe Int
event =
  String -> String -> String -> Value -> Value -> Bool -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl Info
info = String -> String -> Value -> () -> Value -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl Maybe Info
taginfo Maybe Info
repoinfo Maybe Int
event =
  String -> String -> Value -> Value -> Value -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl String
tag Maybe Int
event =
  String
-> String
-> String
-> Value
-> Bool
-> Bool
-> Bool
-> Bool
-> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"getTagGroups" String
tag (Maybe Int -> Value
maybeInt Maybe Int
event)

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

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

-- | getTaskDescendents(task_id, request=False)
getTaskDescendents :: String -> Int -> Bool -> IO Struct
getTaskDescendents :: String -> Int -> Bool -> IO Struct
getTaskDescendents String
hubUrl = String -> String -> Int -> Bool -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl Int
tid 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 String
"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 String
hubUrl = String -> String -> Int -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"getTaskRequest"

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

-- | getUser(userInfo=None, strict=False, krb_princs=True)
getUser :: String -> Info -> Bool -> IO (Maybe Struct)
getUser :: String -> Info -> Bool -> IO (Maybe Struct)
getUser String
hubUrl Info
info 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 String
"getUser" (Info -> Value
infoValue Info
info) () Bool
krbprncpl

-- | getUserPerms(userID=None)
getUserPerms :: String -> Maybe Info -> IO Value
getUserPerms :: String -> Maybe Info -> IO Value
getUserPerms String
hubUrl = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> Int -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"getWinArchive"

-- | getWinBuild(buildInfo, strict=False)
getWinBuild :: String -> Info -> IO (Maybe Struct)
getWinBuild :: String -> Info -> IO (Maybe Struct)
getWinBuild 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 String
"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)

hello :: String -> IO String
hello :: String -> IO String
hello String
hubUrl = String -> String -> IO String
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> Int -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl Maybe Int
buildID Maybe Int
buildrootID Maybe Int
componentBuildrootID Maybe Int
hostID Maybe String
type_ Maybe String
file Maybe Int
size Maybe String
checksum Maybe Info
typeInfo Maybe Int
imageID 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 String
"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 String
hubUrl = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"listBTypes"

-- | listBuildRPMs(build)
listBuildRPMs :: String -> Int -> IO [Struct]
listBuildRPMs :: String -> Int -> IO [Struct]
listBuildRPMs String
hubUrl = String -> String -> Int -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl Maybe Int
hostID Maybe Int
tagID Maybe Int
state Maybe Int
rpmID Maybe Int
archiveID Maybe Int
taskID Maybe Int
buildrootID =
  String
-> String
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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)
listBuilds :: String -> Struct -> IO [Struct]
listBuilds :: String -> Struct -> IO [Struct]
listBuilds String
hubUrl Struct
args =
  let maybeArg :: String -> Value
maybeArg String
fld = Maybe Value -> Value
maybeValue (String -> Struct -> Maybe Value
forall a. XmlRpcType a => String -> Struct -> Maybe a
lookupStruct String
fld Struct
args) in
    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 String
"listBuilds" (String -> Value
maybeArg String
"packageID") (String -> Value
maybeArg String
"userID") (String -> Value
maybeArg String
"taskID") (String -> Value
maybeArg String
"prefix") (String -> Value
maybeArg String
"state") (String -> Value
maybeArg String
"volumeID") (String -> Value
maybeArg String
"source") (String -> Value
maybeArg String
"createdBefore") (String -> Value
maybeArg String
"createdAfter") (String -> Value
maybeArg String
"completeBefore") (String -> Value
maybeArg String
"completeAfter") (String -> Value
maybeArg String
"type") (String -> Value
maybeArg String
"typeInfo") (String -> Value
maybeArg String
"queryOpts")

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

-- | listChannels(hostID=None, event=None)
listChannels :: String -> Maybe Int -> Maybe Int -> IO Value
listChannels :: String -> Maybe Int -> Maybe Int -> IO Value
listChannels String
hubUrl Maybe Int
hostID Maybe Int
event =
  String -> String -> Value -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl Maybe Info
info Maybe String
url Maybe Int
event =
  String -> String -> Value -> Value -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl Maybe Value
arches Maybe Int
channelID Bool
ready Bool
enabled Maybe Int
userID =
  String
-> String -> Value -> Value -> Bool -> Bool -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl Maybe Int
tagID Maybe Int
userID Maybe Int
pkgID Maybe String
prefix Bool
inherited Bool
with_dups Maybe Int
event =
  String
-> String
-> Value
-> Value
-> Value
-> Value
-> Bool
-> Bool
-> Value
-> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> String -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"listPackagesSimple"

-- | listRPMFiles(rpmID, queryOpts=None)
listRPMFiles :: String -> Int -> IO [Struct]
listRPMFiles :: String -> Int -> IO [Struct]
listRPMFiles String
hubUrl = String -> String -> Int -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl Maybe Int
buildID Maybe Int
buildrootID Maybe Int
imageID Maybe Int
componentBuildrootID Maybe Int
hostID Maybe Value
arches =
  String
-> String
-> Value
-> Value
-> Value
-> Value
-> Value
-> Value
-> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl Maybe Info
basetag Maybe Info
user = do
  String -> String -> Value -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl String
tag Maybe Int
event Bool
inherit Maybe String
prefix Bool
latest Maybe String
package Maybe String
owner 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 String
"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 String
hubUrl String
tag Maybe Int
event Bool
inherit Bool
latest Maybe String
package Maybe String
type_ =
  String
-> String
-> String
-> Value
-> Bool
-> Bool
-> Value
-> Value
-> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl String
tag Maybe Int
event Bool
inherit Bool
latest Maybe String
package Maybe String
arch Bool
rpmsigs Maybe String
owner 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 String
"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 String
hubUrl Maybe Info
build Maybe Info
package =
  String -> String -> Value -> Value -> Bool -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> Int -> Bool -> Bool -> Bool -> IO Struct
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"listTaskOutput"

-- | listTasks(opts=None, queryOpts=None)
listTasks :: String -> Struct -- ^ opts
          -> Struct -- ^ qopts
          -> IO [Struct]
listTasks :: String -> Struct -> Struct -> IO [Struct]
listTasks String
hubUrl = String -> String -> Struct -> Struct -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl Maybe Int
userType Maybe String
prefix =
  String -> String -> Value -> Value -> IO [Struct]
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> Int -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"repoInfo"

-- resetBuild(build)

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

-- | resubmitTask(taskID)
resubmitTask :: String -> Int -> IO Value
resubmitTask :: String -> Int -> IO Value
resubmitTask String
hubUrl = String -> String -> Int -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> Int -> Value -> IO Bool
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl Maybe Info
build Maybe Info
tag Maybe Info
package =
  String -> String -> Value -> Value -> Value -> Bool -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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 String
hubUrl = String -> String -> Int -> IO Bool
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"taskFinished"

-- | taskReport(owner=None)
taskReport :: String -> Maybe String -> IO Value
taskReport :: String -> Maybe String -> IO Value
taskReport String
hubUrl = String -> String -> Value -> IO Value
forall a. Remote a => String -> String -> a
koji String
hubUrl String
"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

lookupStruct :: XmlRpcType a => String -> Struct -> Maybe a
lookupStruct :: String -> Struct -> Maybe a
lookupStruct String
key 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)

maybeVal :: String -> Maybe a -> a
maybeVal :: String -> Maybe a -> a
maybeVal String
err = a -> Maybe a -> a
forall a. a -> Maybe a -> a
fromMaybe (String -> a
forall a. HasCallStack => String -> a
error String
err)

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