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
95 Get the given option from the first section with the given type.
98 @name Cursor.get_first
99 @param config UCI config
100 @param type UCI section type
101 @param option UCI option (optional)
102 @param default Default value (optional)
107 Set given values as list.
110 @name Cursor.set_list
111 @param config UCI config
112 @param section UCI section name
113 @param option UCI option
114 @param value UCI value
115 @return Boolean whether operation succeeded
119 Create a sub-state of this cursor. The sub-state is tied to the parent
121 curser, means it the parent unloads or loads configs, the sub state will
124 @name Cursor.substate
125 @return UCI state cursor tied to the parent cursor
129 Add an anonymous section.
133 @param config UCI config
134 @param type UCI section type
135 @return Name of created section
139 Get a table of saved but uncommitted changes.
143 @param config UCI config
144 @return Table of changes
149 Commit saved changes.
153 @param config UCI config
154 @return Boolean whether operation succeeded
160 Deletes a section or an option.
164 @param config UCI config
165 @param section UCI section name
166 @param option UCI option (optional)
167 @return Boolean whether operation succeeded
171 Call a function for every section of a certain type.
175 @param config UCI config
176 @param type UCI section type
177 @param callback Function to be called
178 @return Boolean whether operation succeeded
182 Get a section type or an option
186 @param config UCI config
187 @param section UCI section name
188 @param option UCI option (optional)
193 Get all sections of a config or all values of a section.
197 @param config UCI config
198 @param section UCI section name (optional)
199 @return Table of UCI sections or table of UCI values
203 Manually load a config.
207 @param config UCI config
208 @return Boolean whether operation succeeded
214 Revert saved but uncommitted changes.
218 @param config UCI config
219 @return Boolean whether operation succeeded
225 Saves changes made to a config to make them committable.
229 @param config UCI config
230 @return Boolean whether operation succeeded
236 Set a value or create a named section.
240 @param config UCI config
241 @param section UCI section name
242 @param option UCI option or UCI section type
243 @param value UCI value or nil if you want to create a section
244 @return Boolean whether operation succeeded
248 Get the configuration directory.
251 @name Cursor.get_confdir
252 @return Configuration directory
256 Get the directory for uncomitted changes.
259 @name Cursor.get_savedir
260 @return Save directory
264 Set the configuration directory.
267 @name Cursor.set_confdir
268 @param directory UCI configuration directory
269 @return Boolean whether operation succeeded
273 Set the directory for uncommited changes.
276 @name Cursor.set_savedir
277 @param directory UCI changes directory
278 @return Boolean whether operation succeeded
282 Discard changes made to a config.
286 @param config UCI config
287 @return Boolean whether operation succeeded