OPNsenseAPI
Library interacting with OPNsense's API.
Installation
Install the gem and add to the application's Gemfile by executing:
$ bundle add opnsense_api
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install opnsense_api
Usage
To setup the client, you need to provide the API key and the API secret. You can create one in the OPNsense web interface under System -> Access -> Users -> -> API Keys.
client = OPNsenseAPI::Client.new(
host: 'https://opnsense.example.com',
api_key: '<api_key>',
api_secret: '<api_secret>'
)Captive Portal
To interact with the captive portal module:
client.captive_portalThe controllers can be accessed under the captive_portal method.
client.captive_portal.access
client.captive_portal.service
client.captive_portal.session
client.captive_portal.settings
client.captive_portal.voucherCore
To interact with the core module:
client.coreThe controllers can be accessed under the core method.
client.core.firmware
client.core.menu
client.core.systemCron
To interact with cron module:
client.coreThe controllers can be accessed under the cron method.
client.core.service
client.core.settingsDiagnostics
To interact with the diagnostics module:
client.diagnosticsThe controllers can be accessed under the diagnostics method.
client.diagnostics.activity
client.diagnostics.dns
client.diagnostics.dns_diagnostics
client.diagnostics.firewall
client.diagnostics.interface
client.diagnostics.lv_template
client.diagnostics.netflow
client.diagnostics.network_insight
client.diagnostics.packet_capture
client.diagnostics.system
client.diagnostics.system_health
client.diagnostics.trafficFirewall
To interact with the firewall module:
client.firewallThe controllers can be accessed under the firewall method.
client.firewall.alias
client.firewall.alias_util
client.firewall.category
client.firewall.filter_utilIDS
To interact with the IDS module:
client.idsThe controllers can be accessed under the ids method.
client.ids.service
client.ids.settingsInterfaces
To interact with the interfaces module:
client.interfacesThe controllers can be accessed under the interfaces method.
client.interfaces.loopback_settings
client.interfaces.vip_settings
client.interfaces.vlan_settings
client.interfaces.vxlan_settingsIPSec
To interact with the IPSec module:
client.ipsecThe controllers can be accessed under the ipsec method.
client.ipsec.key_pairs
client.ipsec.leases
client.ipsec.legacy_subsystem
client.ipsec.pre_shared_keys
client.ipsec.sad
client.ipsec.service
client.ipsec.sessions
client.ipsec.spd
client.ipsec.tunnelMonit
To interact with the monit module:
client.monitThe controllers can be accessed under the monit method.
client.monit.service
client.monit.settings
client.monit.statusOpenVPN
To interact with the OpenVPN module:
client.open_vpnThe controllers can be accessed under the open_vpn method.
client.open_vpn.exportProxy
To interact with the proxy module:
client.proxyThe controllers can be accessed under the proxy method.
client.proxy.service
client.proxy.settings
client.proxy.templateRoutes
To interact with the routes module:
client.routesThe controllers can be accessed under the routes method.
client.routes.gateway
client.routes.routesSyslog
To interact with the syslog module:
client.syslogThe controllers can be accessed under the syslog method.
client.syslog.service
client.syslog.settingsTraffic Shaping
To interact with the traffic shaping module:
client.traffic_shapingThe controllers can be accessed under the traffic_shaping method.
client.traffic_shaping.service
client.traffic_shaping.settingsUnbound
To interact with the unbound module:
client.unboundThe controllers can be accessed under the unbound method.
client.unbound.diagnostics
client.unbound.service
client.unbound.settingsDevelopment
After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/zaben903/opnsense_api.
License
The gem is available as open source under the terms of the Lesser GNU General Public Licence.