NAME
Zabbix2::API::Macro -- Zabbix usermacro objects
SYNOPSIS
# create a new global macro (set its hostid attribute if you need a
# host macro instead)
my $macro = Zabbix2::API::Macro->new(root => $zabber,
data => { macro => '{$SUPERMACRO}',
value => 'ITSABIRD' });
$macro->create;
# change its value
$macro->value('ITSAPLANE');
$macro->update;
DESCRIPTION
Handles CRUD for Zabbix usermacro objects.
Both global and host macro types are represented by this class. If the hostid
attribute is undef or empty, then we assume it's a global macro.
This class' methods work transparently around the weird Zabbix macro API, which uses different methods on the same object depending on whether it's a global or host macro... except sometimes, for instance the usermacro.get
method which can be called on both and will return different keys... And macros don't seem to have an exists
method. It's kind of a mess.
METHODS
_prefix
This class' _prefix
method is not a class method. The _prefix returned depends on the type of macro (global or host) which is a characteristic of an instance.
globalp
say $macro->globalp ? 'a global macro' : 'a host macro';
Returns a true value when the macro is global, a false value otherwise.
name
say $macro->name;
Returns the macro's name, which is also how it's referred to in expressions, e.g. "{$SUPERMACRO}".
value
$macro->value('new value');
say $macro->value;
Mutator for the macro's value.
SEE ALSO
AUTHOR
Fabrice Gabolde <fga@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2011, 2014 SFR
This library is free software; you can redistribute it and/or modify it under the terms of the GPLv3.