OPNsense Forum

English Forums => Development and Code Review => Topic started by: fraenki on January 05, 2016, 04:09:55 pm

Title: OPNsense API
Post by: fraenki on January 05, 2016, 04:09:55 pm
Hi,

is there any further information available regarding the OPNsense API?



Thanks
- Frank
Title: Re: OPNsense API
Post by: AdSchellevis on January 05, 2016, 10:44:56 pm
Hi Frank,

There is some documentation available on the wiki:
https://wiki.opnsense.org/index.php/Howto_use_the_API (https://wiki.opnsense.org/index.php/Howto_use_the_API)

Although there's no complete list of commands available, the api ready components can easily be found when searching the API directories (find src/opnsense/ -name 'Api').

If you want to create your own api enabled components, just follow the howto guide here:
https://wiki.opnsense.org/index.php/Develop:Creating_the_hello_world_module (https://wiki.opnsense.org/index.php/Develop:Creating_the_hello_world_module)

Regards,

Ad
Title: Re: OPNsense API
Post by: bartjsmit on February 13, 2016, 11:38:33 am
Hi Ad,

I'm looking for an API for backups. I cloned the core branch off github and ran the search for the Api directories you mentioned. I found the seven directories:

src/opnsense/mvc/app/controllers/OPNsense/CaptivePortal/Api
src/opnsense/mvc/app/controllers/OPNsense/Core/Api
src/opnsense/mvc/app/controllers/OPNsense/Cron/Api
src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api
src/opnsense/mvc/app/controllers/OPNsense/IDS/Api
src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api
src/opnsense/mvc/app/controllers/OPNsense/TrafficShaper/Api

I did a 'grep -i backup *' in these but got no hits.

Does that mean that there is no call to download a backup configuration (yet)?

Bart...
Title: Re: OPNsense API
Post by: AdSchellevis on February 13, 2016, 04:42:24 pm
Hi Bart,

The backup/restore code is still legacy code, without api support.
If you just want to download the config.xml from the api, it won't be very difficult to create a plugin that does something like that, but at the moment its not in there yet.

Just out of curiosity, what is your use case? 

Regards,

Ad
Title: Re: OPNsense API
Post by: bartjsmit on February 14, 2016, 12:30:17 am
Thanks Ad,

I'll have a look at the plugin code sample.

I'd like to run a backup from my main filer, rather than use Google drive.

Bart...