Geneos-API
view release on metacpan or search on metacpan
lib/Geneos/API.pm view on Meta::CPAN
# ---------------
# Private methods
sub _init {
my ($self, $sampler, $view, $group) = @_;
croak "Geneos::API::Sampler::View->new was called without SAMPLER!" unless $sampler;
croak "Geneos::API::Sampler::View->new was called without VIEW!" unless $view;
croak "Geneos::API::Sampler::View->new was called without GROUP!" unless $group;
$self->{_sampler} = $sampler;
$self->{_view} = $view;
$self->{_group} = $group;
return $self;
}
sub _method {
my $self = shift;
join(".", $self->{_sampler}->entity, $self->{_sampler}->sampler, "$self->{_group}-$self->{_view}", @_);
}
# --------------
# Public methods
sub api {shift->{_sampler}->api}
# API calls
# ---------------------------------------------
# Combines addTableRow and updateTableRow calls
#
sub add_table_row {
my ($self, $name, $data) = @_;
return unless $self->_add_table_row($name);
# if there is data - add it to the row
$data ? $self->update_table_row($name, $data) : 1;
}
# -----------------------------------------------------
# Each method below is an XML-RPC call to the NetProbe
#
# The first argument passed to the call method is the
# XML-RPC method name. The rest are parameters passed
# with that call to the XML-RPC server:
#
# method->($method_name, @params)
#
sub _add_table_row {shift->call("addTableRow", @_)}
sub remove_table_row {shift->call("removeTableRow", @_)}
sub add_headline {shift->call("addHeadline", @_)}
sub remove_headline {shift->call("removeHeadline", @_)}
sub update_variable {shift->call("updateVariable", @_)}
sub update_headline {shift->call("updateHeadline", @_)}
sub update_table_cell {shift->call("updateTableCell", @_)}
sub update_table_row {shift->call("updateTableRow", @_)}
sub add_table_column {shift->call("addTableColumn", @_)}
sub update_entire_table {shift->call("updateEntireTable", @_)}
sub column_exists {shift->call("columnExists", @_)}
sub row_exists {shift->call("rowExists", @_)}
sub headline_exists {shift->call("headlineExists", @_)}
sub get_column_count {shift->call("getColumnCount")}
sub get_row_count {shift->call("getRowCount")}
sub get_headline_count {shift->call("getHeadlineCount")}
sub get_column_names {shift->call("getColumnNames")}
sub get_row_names {shift->call("getRowNames")}
sub get_headline_names {shift->call("getHeadlineNames")}
sub get_row_names_older_than {shift->call("getRowNamesOlderThan", @_)}
##################################
#
# package Geneos::API::Sampler
#
# Implements all sampler methods
#
##################################
package Geneos::API::Sampler;
use base 'Geneos::API::Base';
use Carp;
# ---------------
# Private methods
sub _init {
my ($self, $api, $entity, $sampler, $type) = @_;
croak "Geneos::API::Sampler->new was called without ENTITY!" unless $entity;
croak "Geneos::API::Sampler->new was called without SAMPLER!" unless $sampler;
$self->{_api} = $api;
$self->{_entity} = $entity;
$self->{_sampler} = $type ? "${sampler}($type)" : $sampler;
return $self;
}
# ---------------------------------------------------------
# XML-RPC methodName for the sampler calls looks like this:
# entity.sampler.action
#
# in case the sampler is part of a type, the call becomes:
# entity.sampler(type).action
#
sub _method {
my $self = shift;
( run in 1.289 second using v1.01-cache-2.11-cpan-39bf76dae61 )