NAME
WWW::Hetzner::Role::HTTP - HTTP client role for Hetzner API clients
VERSION
version 0.002
SYNOPSIS
package WWW::Hetzner::Cloud;
use Moo;
has token => ( is => 'ro' );
has base_url => ( is => 'ro', default => 'https://api.hetzner.cloud/v1' );
with 'WWW::Hetzner::Role::HTTP';
DESCRIPTION
This role provides HTTP methods (GET, POST, PUT, DELETE) for Hetzner API clients. It handles JSON encoding/decoding, authentication, and error handling.
Uses Log::Any for logging HTTP requests and responses.
REQUIRED ATTRIBUTES
Classes consuming this role must provide:
token- API authentication tokenbase_url- Base URL for the API
ua
LWP::UserAgent instance for making HTTP requests.
get
my $data = $self->get('/path', params => { key => 'value' });
Perform a GET request.
post
my $data = $self->post('/path', { key => 'value' });
Perform a POST request with JSON body.
put
my $data = $self->put('/path', { key => 'value' });
Perform a PUT request with JSON body.
delete
my $data = $self->delete('/path');
Perform a DELETE request.
_set_auth
Override this method to change authentication. Default is Bearer token:
sub _set_auth {
my ($self, $request) = @_;
$request->header('Authorization' => 'Bearer ' . $self->token);
}
For Basic Auth (e.g. Robot API):
sub _set_auth {
my ($self, $request) = @_;
$request->authorization_basic($self->user, $self->password);
}
SEE ALSO
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.