blib/lib/Zabbix7/API/Proxy.pm untested

filter: Statementstmt 0.0% 0 / 43 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 12 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 72 CC 2 SCAR 10.0
CC
2
Cov
0%
id
6.0
_readonly_properties
2.0
_prefix
2.0
CRAP 2.7
1 package Zabbix7::API::Proxy;
2
3 use strict;
4 use warnings;
5 use 5.010;
6 use Carp;
7
8 use Moo;
9 extends qw/Zabbix7::API::CRUDE/;
10
11 sub id {
12 my ($self, $value) = @_;
13 if (defined $value) {
14 $self->data->{proxyid} = $value;
15 Log::Any->get_logger->debug("Set proxyid: $value for proxy");
16 return $self->data->{proxyid};
17 }
18 my $id = $self->data->{proxyid};
19 Log::Any->get_logger->debug("Retrieved proxyid for proxy: " . ($id // 'none'));
20 return $id;
21 }
22
23 sub _readonly_properties {
24 return {
25 proxyid => 1,
26 lastaccess => 1,
27 status => 1, # Added for Zabbix 7.0 (read-only)
28 };
29 }
30
31 sub _prefix {
32 my (undef, $suffix) = @_;
33 return 'proxy' . ($suffix // '');
34 }
35
36 sub _extension {
37 return (
38 output => 'extend',
39 selectHosts => ['hostid', 'host'], # Added for Zabbix 7.0
40 );
41 }
42
43 sub name {
44 my $self = shift;
45 my $name = $self->data->{host} || '???';
46 Log::Any->get_logger->debug("Retrieved name for proxy ID: " . ($self->id // 'new') . ": $name");
47 return $name;
48 }
49
50 before 'create' => sub {
51 my ($self) = @_;
52 delete $self->data->{proxyid}; # Ensure proxyid is not sent
53 delete $self->data->{status}; # status is read-only
54 Log::Any->get_logger->debug("Preparing to create proxy: " . ($self->data->{host} // 'unknown'));
55 };
56
57 before 'update' => sub {
58 my ($self) = @_;
59 delete $self->data->{status}; # status is read-only
60 Log::Any->get_logger->debug("Preparing to update proxy ID: " . ($self->id // 'new'));
61 };
62
63 1;
64 __END__