NAME

WebService::OPNsense::OpenVPN::Instances - OpenVPN instances controller

VERSION

version 0.002

SYNOPSIS

use WebService::OPNsense::Constants qw( $PROTO_UDP $OPN_ENABLED $OPN_DISABLED );

my $instances = $opn->openvpn_instances;

# List instances
my $list = $instances->search(current => 1, rowCount => 50);

# Create an instance
$instances->add({
    server => {
        enabled  => $OPN_ENABLED,
        port     => 1194,
        protocol => $PROTO_UDP,
    },
});

# Toggle an instance
$instances->toggle($uuid, $OPN_DISABLED);

# Generate a key
my $key = $instances->gen_key('tls-crypt');

DESCRIPTION

OpenVPN server and client instances.

METHODS

set_instance

my $result = $instances->set_instance($uuid, $instance_data);

Updates instance.

gen_key

my $key = $instances->gen_key;
my $key = $instances->gen_key($type);

Generates an OpenVPN key. Optionally specify a key type (e.g. 'tls-crypt').

search_static_key

my $results = $instances->search_static_key(%params);

Searches for static keys.

get_static_key

my $key = $instances->get_static_key($uuid);

Returns a single static key by UUID.

add_static_key

my $result = $instances->add_static_key($key_data);

Creates static key.

set_static_key

my $result = $instances->set_static_key($uuid, $key_data);

Updates static key.

del_static_key

my $result = $instances->del_static_key($uuid);

Deletes a static key by UUID.

CONSTANTS

Protocol constants are available from WebService::OPNsense::Constants:

$PROTO_UDP
$PROTO_TCP

Use them when setting the protocol field in an instance.

SEE ALSO

WebService::OPNsense::Role::Crud

PROVIDED METHODS

The following methods are inherited from consumed roles.

my $results = $ctrl->search( %params );

Searches for OpenVPN instances.

get

my $instance = $ctrl->get( $uuid );

Returns a single instance by UUID. Throws if $uuid is not a valid UUID.

add

my $result = $ctrl->add( $instance_data );

Creates an instance.

del

my $result = $ctrl->del( $uuid );

Deletes an instance by UUID. Throws if $uuid is not a valid UUID.

toggle

my $result = $ctrl->toggle( $uuid, $enabled );

Enables or disables an instance. Throws if $uuid is not a valid UUID.

client

my $http_client = $ctrl->client;

Returns the underlying HTTP client object used for API requests.

AUTHOR

Dean Hamstead <dean@fragfest.com.au>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2026 by Dean Hamstead.

This is free software, licensed under:

The MIT (X11) License