NAME

WWW::Hetzner::Cloud::Firewall - Hetzner Cloud Firewall object

VERSION

version 0.002

SYNOPSIS

my $fw = $cloud->firewalls->get($id);

# Read attributes
print $fw->name, "\n";

# Set rules
$fw->set_rules(
    { direction => 'in', protocol => 'tcp', port => '22', source_ips => ['0.0.0.0/0'] },
    { direction => 'in', protocol => 'tcp', port => '443', source_ips => ['0.0.0.0/0'] },
);

# Apply to server
$fw->apply_to_resources({ type => 'server', server => { id => 123 } });

# Update name
$fw->name('new-name');
$fw->update;

# Delete
$fw->delete;

DESCRIPTION

This class represents a Hetzner Cloud firewall. Objects are returned by WWW::Hetzner::Cloud::API::Firewalls methods.

id

Firewall ID (read-only).

name

Firewall name (read-write).

rules

Arrayref of firewall rules (read-write via set_rules method).

applied_to

Arrayref of resources this firewall is applied to (read-only).

labels

Labels hash (read-write).

created

Creation timestamp (read-only).

update

$fw->name('new-name');
$fw->update;

Saves changes to name and labels.

delete

$fw->delete;

Deletes the firewall.

set_rules

$fw->set_rules(
    { direction => 'in', protocol => 'tcp', port => '22', source_ips => ['0.0.0.0/0'] },
    { direction => 'in', protocol => 'tcp', port => '443', source_ips => ['0.0.0.0/0'] },
);

Set firewall rules.

apply_to_resources

$fw->apply_to_resources({ type => 'server', server => { id => 123 } });

Apply firewall to resources.

remove_from_resources

$fw->remove_from_resources({ type => 'server', server => { id => 123 } });

Remove firewall from resources.

refresh

$fw->refresh;

Reloads firewall data from the API.

data

my $hashref = $fw->data;

Returns all firewall data as a hashref (for JSON serialization).

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-www-hetzner/issues.

IRC

Join #kubernetes on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.