uci.luadoc 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. ---[[
  2. LuCI UCI model library.
  3. The typical workflow for UCI is: Get a cursor instance from the
  4. cursor factory, modify data (via Cursor.add, Cursor.delete, etc.),
  5. save the changes to the staging area via Cursor.save and finally
  6. Cursor.commit the data to the actual config files.
  7. LuCI then needs to Cursor.apply the changes so deamons etc. are
  8. reloaded.
  9. @cstyle instance
  10. module "luci.model.uci"
  11. ]]
  12. ---[[
  13. Create a new UCI-Cursor.
  14. @class function
  15. @name cursor
  16. @return UCI-Cursor
  17. ]]
  18. ---[[
  19. Create a new Cursor initialized to the state directory.
  20. @class function
  21. @name cursor_state
  22. @return UCI cursor
  23. ]]
  24. ---[[
  25. Applies UCI configuration changes
  26. @class function
  27. @name Cursor.apply
  28. @param configlist List of UCI configurations
  29. @param command Don't apply only return the command
  30. ]]
  31. ---[[
  32. Delete all sections of a given type that match certain criteria.
  33. @class function
  34. @name Cursor.delete_all
  35. @param config UCI config
  36. @param type UCI section type
  37. @param comparator Function that will be called for each section and
  38. returns a boolean whether to delete the current section (optional)
  39. ]]
  40. ---[[
  41. Create a new section and initialize it with data.
  42. @class function
  43. @name Cursor.section
  44. @param config UCI config
  45. @param type UCI section type
  46. @param name UCI section name (optional)
  47. @param values Table of key - value pairs to initialize the section with
  48. @return Name of created section
  49. ]]
  50. ---[[
  51. Updated the data of a section using data from a table.
  52. @class function
  53. @name Cursor.tset
  54. @param config UCI config
  55. @param section UCI section name (optional)
  56. @param values Table of key - value pairs to update the section with
  57. ]]
  58. ---[[
  59. Get a boolean option and return it's value as true or false.
  60. @class function
  61. @name Cursor.get_bool
  62. @param config UCI config
  63. @param section UCI section name
  64. @param option UCI option
  65. @return Boolean
  66. ]]
  67. ---[[
  68. Get an option or list and return values as table.
  69. @class function
  70. @name Cursor.get_list
  71. @param config UCI config
  72. @param section UCI section name
  73. @param option UCI option
  74. @return UCI value
  75. ]]
  76. ---[[
  77. Get the given option from the first section with the given type.
  78. @class function
  79. @name Cursor.get_first
  80. @param config UCI config
  81. @param type UCI section type
  82. @param option UCI option (optional)
  83. @param default Default value (optional)
  84. @return UCI value
  85. ]]
  86. ---[[
  87. Set given values as list.
  88. @class function
  89. @name Cursor.set_list
  90. @param config UCI config
  91. @param section UCI section name
  92. @param option UCI option
  93. @param value UCI value
  94. @return Boolean whether operation succeeded
  95. ]]
  96. ---[[
  97. Create a sub-state of this cursor. The sub-state is tied to the parent
  98. curser, means it the parent unloads or loads configs, the sub state will
  99. do so as well.
  100. @class function
  101. @name Cursor.substate
  102. @return UCI state cursor tied to the parent cursor
  103. ]]
  104. ---[[
  105. Add an anonymous section.
  106. @class function
  107. @name Cursor.add
  108. @param config UCI config
  109. @param type UCI section type
  110. @return Name of created section
  111. ]]
  112. ---[[
  113. Get a table of saved but uncommitted changes.
  114. @class function
  115. @name Cursor.changes
  116. @param config UCI config
  117. @return Table of changes
  118. @see Cursor.save
  119. ]]
  120. ---[[
  121. Commit saved changes.
  122. @class function
  123. @name Cursor.commit
  124. @param config UCI config
  125. @return Boolean whether operation succeeded
  126. @see Cursor.revert
  127. @see Cursor.save
  128. ]]
  129. ---[[
  130. Deletes a section or an option.
  131. @class function
  132. @name Cursor.delete
  133. @param config UCI config
  134. @param section UCI section name
  135. @param option UCI option (optional)
  136. @return Boolean whether operation succeeded
  137. ]]
  138. ---[[
  139. Call a function for every section of a certain type.
  140. @class function
  141. @name Cursor.foreach
  142. @param config UCI config
  143. @param type UCI section type
  144. @param callback Function to be called
  145. @return Boolean whether operation succeeded
  146. ]]
  147. ---[[
  148. Get a section type or an option
  149. @class function
  150. @name Cursor.get
  151. @param config UCI config
  152. @param section UCI section name
  153. @param option UCI option (optional)
  154. @return UCI value
  155. ]]
  156. ---[[
  157. Get all sections of a config or all values of a section.
  158. @class function
  159. @name Cursor.get_all
  160. @param config UCI config
  161. @param section UCI section name (optional)
  162. @return Table of UCI sections or table of UCI values
  163. ]]
  164. ---[[
  165. Manually load a config.
  166. @class function
  167. @name Cursor.load
  168. @param config UCI config
  169. @return Boolean whether operation succeeded
  170. @see Cursor.save
  171. @see Cursor.unload
  172. ]]
  173. ---[[
  174. Revert saved but uncommitted changes.
  175. @class function
  176. @name Cursor.revert
  177. @param config UCI config
  178. @return Boolean whether operation succeeded
  179. @see Cursor.commit
  180. @see Cursor.save
  181. ]]
  182. ---[[
  183. Saves changes made to a config to make them committable.
  184. @class function
  185. @name Cursor.save
  186. @param config UCI config
  187. @return Boolean whether operation succeeded
  188. @see Cursor.load
  189. @see Cursor.unload
  190. ]]
  191. ---[[
  192. Set a value or create a named section.
  193. @class function
  194. @name Cursor.set
  195. @param config UCI config
  196. @param section UCI section name
  197. @param option UCI option or UCI section type
  198. @param value UCI value or nil if you want to create a section
  199. @return Boolean whether operation succeeded
  200. ]]
  201. ---[[
  202. Get the configuration directory.
  203. @class function
  204. @name Cursor.get_confdir
  205. @return Configuration directory
  206. ]]
  207. ---[[
  208. Get the directory for uncomitted changes.
  209. @class function
  210. @name Cursor.get_savedir
  211. @return Save directory
  212. ]]
  213. ---[[
  214. Set the configuration directory.
  215. @class function
  216. @name Cursor.set_confdir
  217. @param directory UCI configuration directory
  218. @return Boolean whether operation succeeded
  219. ]]
  220. ---[[
  221. Set the directory for uncommited changes.
  222. @class function
  223. @name Cursor.set_savedir
  224. @param directory UCI changes directory
  225. @return Boolean whether operation succeeded
  226. ]]
  227. ---[[
  228. Discard changes made to a config.
  229. @class function
  230. @name Cursor.unload
  231. @param config UCI config
  232. @return Boolean whether operation succeeded
  233. @see Cursor.load
  234. @see Cursor.save
  235. ]]