---------------------------------
--! @file
--! @brief A Lua Interface to libsystemd
---------------------------------


systemd = require("luasystemd") 



M={}

--! @brief List all the loaded systemd unit file in alphabetical order
--! @param types The type of units to filter can be any of 
--!              all,service,socket,busname,target,device,mount,automount,swap,timer,path,slice,scope
--!              defaults to all
--! @return On success a table with all unit file objects with the following fields
--!           unit.name,unit.description,unit.state,unit.sub_state
--!         On error return nil,error string  
function M.list_units(types)
  return luasystemd_list_units(types)
end

--! @brief List all the available systemd unit files and their enablement state in alphabetical order
--! @param types The type of units to filter can be any of 
--!              all,service,socket,busname,target,device,mount,automount,swap,timer,path,slice,scope
--!              defaults to all
--! @return On success a table with all unit file objects with the following fields
--!           unit.name,unit.status
--!         On error return nil,error string  
function M.list_unit_files(types)
  return luasystemd_list_unit_files(types)
end

--! @brief Start the specified unit
--! @param unit The unit name 
--! @return On success return true
--!         On error return nil,error string  
function M.start_unit(unit)
  return luasystemd_start_unit(unit)
end

--! @brief Stop the specified unit
--! @param unit The unit name 
--! @return On success return true
--!         On error return nil,error string  
function M.stop_unit(unit)
  return luasystemd_stop_unit(unit)
end

--! @brief enable the specified unit
--! @param unit The unit name 
--! @return On success return true
--!         On error return nil,error string  
function M.enable_unit(unit)
  return luasystemd_enable_unit(unit)
end

--! @brief disable the specified unit
--! @param unit The unit name 
--! @return On success return true
--!         On error return nil,error string  
function M.disable_unit(unit)
  return luasystemd_disable_unit(unit)
end

return M

