2
0

uci.luadoc 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. ]]
  11. module "luci.model.uci"
  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 table. If the option was not found, you will simply get
  75. -- an empty table.
  76. ]]
  77. ---[[
  78. Get the given option from the first section with the given type.
  79. @class function
  80. @name Cursor.get_first
  81. @param config UCI config
  82. @param type UCI section type
  83. @param option UCI option (optional)
  84. @param default Default value (optional)
  85. @return UCI value
  86. ]]
  87. ---[[
  88. Set given values as list. Setting a list option to an empty list
  89. has the same effect as deleting the option.
  90. @class function
  91. @name Cursor.set_list
  92. @param config UCI config
  93. @param section UCI section name
  94. @param option UCI option
  95. @param value value or table. Raw values will become a single item table.
  96. @return Boolean whether operation succeeded
  97. ]]
  98. ---[[
  99. Create a sub-state of this cursor. The sub-state is tied to the parent
  100. curser, means it the parent unloads or loads configs, the sub state will
  101. do so as well.
  102. @class function
  103. @name Cursor.substate
  104. @return UCI state cursor tied to the parent cursor
  105. ]]
  106. ---[[
  107. Add an anonymous section.
  108. @class function
  109. @name Cursor.add
  110. @param config UCI config
  111. @param type UCI section type
  112. @return Name of created section
  113. ]]
  114. ---[[
  115. Get a table of saved but uncommitted changes.
  116. @class function
  117. @name Cursor.changes
  118. @param config UCI config
  119. @return Table of changes
  120. @see Cursor.save
  121. ]]
  122. ---[[
  123. Commit saved changes.
  124. @class function
  125. @name Cursor.commit
  126. @param config UCI config
  127. @return Boolean whether operation succeeded
  128. @see Cursor.revert
  129. @see Cursor.save
  130. ]]
  131. ---[[
  132. Deletes a section or an option.
  133. @class function
  134. @name Cursor.delete
  135. @param config UCI config
  136. @param section UCI section name
  137. @param option UCI option (optional)
  138. @return Boolean whether operation succeeded
  139. ]]
  140. ---[[
  141. Call a function for every section of a certain type.
  142. @class function
  143. @name Cursor.foreach
  144. @param config UCI config
  145. @param type UCI section type
  146. @param callback Function to be called
  147. @return Boolean whether operation succeeded
  148. ]]
  149. ---[[
  150. Get a section type or an option
  151. @class function
  152. @name Cursor.get
  153. @param config UCI config
  154. @param section UCI section name
  155. @param option UCI option (optional)
  156. @return UCI value
  157. ]]
  158. ---[[
  159. Get all sections of a config or all values of a section.
  160. @class function
  161. @name Cursor.get_all
  162. @param config UCI config
  163. @param section UCI section name (optional)
  164. @return Table of UCI sections or table of UCI values
  165. ]]
  166. ---[[
  167. Manually load a config.
  168. @class function
  169. @name Cursor.load
  170. @param config UCI config
  171. @return Boolean whether operation succeeded
  172. @see Cursor.save
  173. @see Cursor.unload
  174. ]]
  175. ---[[
  176. Revert saved but uncommitted changes.
  177. @class function
  178. @name Cursor.revert
  179. @param config UCI config
  180. @return Boolean whether operation succeeded
  181. @see Cursor.commit
  182. @see Cursor.save
  183. ]]
  184. ---[[
  185. Saves changes made to a config to make them committable.
  186. @class function
  187. @name Cursor.save
  188. @param config UCI config
  189. @return Boolean whether operation succeeded
  190. @see Cursor.load
  191. @see Cursor.unload
  192. ]]
  193. ---[[
  194. Set a value or create a named section.
  195. When invoked with three arguments `config`, `sectionname`, `sectiontype`,
  196. then a named section of the given type is created.
  197. When invoked with four arguments `config`, `sectionname`, `optionname` and
  198. `optionvalue` then the value of the specified option is set to the given value.
  199. @class function
  200. @name Cursor.set
  201. @param config UCI config
  202. @param section UCI section name
  203. @param option UCI option or UCI section type
  204. @param value UCI value or nothing if you want to create a section
  205. @return Boolean whether operation succeeded
  206. ]]
  207. ---[[
  208. Get the configuration directory.
  209. @class function
  210. @name Cursor.get_confdir
  211. @return Configuration directory
  212. ]]
  213. ---[[
  214. Get the directory for uncomitted changes.
  215. @class function
  216. @name Cursor.get_savedir
  217. @return Save directory
  218. ]]
  219. ---[[
  220. Set the configuration directory.
  221. @class function
  222. @name Cursor.set_confdir
  223. @param directory UCI configuration directory
  224. @return Boolean whether operation succeeded
  225. ]]
  226. ---[[
  227. Set the directory for uncommited changes.
  228. @class function
  229. @name Cursor.set_savedir
  230. @param directory UCI changes directory
  231. @return Boolean whether operation succeeded
  232. ]]
  233. ---[[
  234. Discard changes made to a config.
  235. @class function
  236. @name Cursor.unload
  237. @param config UCI config
  238. @return Boolean whether operation succeeded
  239. @see Cursor.load
  240. @see Cursor.save
  241. ]]