2 LuCI UCI model library.
4 The typical workflow for UCI is: Get a cursor instance from the
5 cursor factory, modify data (via Cursor.add, Cursor.delete, etc.),
6 save the changes to the staging area via Cursor.save and finally
7 Cursor.commit the data to the actual config files.
8 LuCI then needs to Cursor.apply the changes so deamons etc. are
12 module "luci.model.uci"
15 Create a new UCI-Cursor.
23 Create a new Cursor initialized to the state directory.
31 Applies UCI configuration changes
35 @param configlist List of UCI configurations
36 @param command Don't apply only return the command
40 Delete all sections of a given type that match certain criteria.
43 @name Cursor.delete_all
44 @param config UCI config
45 @param type UCI section type
46 @param comparator Function that will be called for each section and
47 returns a boolean whether to delete the current section (optional)
51 Create a new section and initialize it with data.
55 @param config UCI config
56 @param type UCI section type
57 @param name UCI section name (optional)
58 @param values Table of key - value pairs to initialize the section with
59 @return Name of created section
63 Updated the data of a section using data from a table.
67 @param config UCI config
68 @param section UCI section name (optional)
69 @param values Table of key - value pairs to update the section with
73 Get a boolean option and return it's value as true or false.
77 @param config UCI config
78 @param section UCI section name
79 @param option UCI option
84 Get an option or list and return values as table.
88 @param config UCI config
89 @param section UCI section name
90 @param option UCI option
91 @return table. If the option was not found, you will simply get
96 Get the given option from the first section with the given type.
99 @name Cursor.get_first
100 @param config UCI config
101 @param type UCI section type
102 @param option UCI option (optional)
103 @param default Default value (optional)
108 Set given values as list. Setting a list option to an empty list
109 has the same effect as deleting the option.
112 @name Cursor.set_list
113 @param config UCI config
114 @param section UCI section name
115 @param option UCI option
116 @param value value or table. Raw values will become a single item table.
117 @return Boolean whether operation succeeded
121 Create a sub-state of this cursor. The sub-state is tied to the parent
123 curser, means it the parent unloads or loads configs, the sub state will
126 @name Cursor.substate
127 @return UCI state cursor tied to the parent cursor
131 Add an anonymous section.
135 @param config UCI config
136 @param type UCI section type
137 @return Name of created section
141 Get a table of saved but uncommitted changes.
145 @param config UCI config
146 @return Table of changes
151 Commit saved changes.
155 @param config UCI config
156 @return Boolean whether operation succeeded
162 Deletes a section or an option.
166 @param config UCI config
167 @param section UCI section name
168 @param option UCI option (optional)
169 @return Boolean whether operation succeeded
173 Call a function for every section of a certain type.
177 @param config UCI config
178 @param type UCI section type
179 @param callback Function to be called
180 @return Boolean whether operation succeeded
184 Get a section type or an option
188 @param config UCI config
189 @param section UCI section name
190 @param option UCI option (optional)
195 Get all sections of a config or all values of a section.
199 @param config UCI config
200 @param section UCI section name (optional)
201 @return Table of UCI sections or table of UCI values
205 Manually load a config.
209 @param config UCI config
210 @return Boolean whether operation succeeded
216 Revert saved but uncommitted changes.
220 @param config UCI config
221 @return Boolean whether operation succeeded
227 Saves changes made to a config to make them committable.
231 @param config UCI config
232 @return Boolean whether operation succeeded
238 Set a value or create a named section.
240 When invoked with three arguments `config`, `sectionname`, `sectiontype`,
241 then a named section of the given type is created.
243 When invoked with four arguments `config`, `sectionname`, `optionname` and
244 `optionvalue` then the value of the specified option is set to the given value.
248 @param config UCI config
249 @param section UCI section name
250 @param option UCI option or UCI section type
251 @param value UCI value or nothing if you want to create a section
252 @return Boolean whether operation succeeded
256 Get the configuration directory.
259 @name Cursor.get_confdir
260 @return Configuration directory
264 Get the directory for uncomitted changes.
267 @name Cursor.get_savedir
268 @return Save directory
272 Set the configuration directory.
275 @name Cursor.set_confdir
276 @param directory UCI configuration directory
277 @return Boolean whether operation succeeded
281 Set the directory for uncommited changes.
284 @name Cursor.set_savedir
285 @param directory UCI changes directory
286 @return Boolean whether operation succeeded
290 Discard changes made to a config.
294 @param config UCI config
295 @return Boolean whether operation succeeded