OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • English Forums »
  • Development and Code Review (Moderator: fabian) »
  • OPNsense API
« previous next »
  • Print
Pages: [1]

Author Topic: OPNsense API  (Read 9150 times)

fraenki

  • Full Member
  • ***
  • Posts: 175
  • Karma: 29
    • View Profile
    • GitHub
OPNsense API
« on: January 05, 2016, 04:09:55 pm »
Hi,

is there any further information available regarding the OPNsense API?

  • examples on how to use the API
  • some sort of client code or example code or even a ready-to-use library (I don't want to reinvent the wheel)
  • a reference for all API calls?


Thanks
- Frank
Logged

AdSchellevis

  • Administrator
  • Hero Member
  • *****
  • Posts: 907
  • Karma: 184
    • View Profile
Re: OPNsense API
« Reply #1 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

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

Regards,

Ad
Logged

bartjsmit

  • Hero Member
  • *****
  • Posts: 2023
  • Karma: 194
    • View Profile
Re: OPNsense API
« Reply #2 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...
Logged

AdSchellevis

  • Administrator
  • Hero Member
  • *****
  • Posts: 907
  • Karma: 184
    • View Profile
Re: OPNsense API
« Reply #3 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
Logged

bartjsmit

  • Hero Member
  • *****
  • Posts: 2023
  • Karma: 194
    • View Profile
Re: OPNsense API
« Reply #4 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...
Logged

  • Print
Pages: [1]
« previous next »
  • OPNsense Forum »
  • English Forums »
  • Development and Code Review (Moderator: fabian) »
  • OPNsense API
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2