freebox plugin: wip
This commit is contained in:
parent
d108499020
commit
2cf359013e
|
@ -135,6 +135,7 @@ sub settings {
|
||||||
$self->{http}->add_header(key => 'X-Fbx-App-Auth', value => $self->{session_token});
|
$self->{http}->add_header(key => 'X-Fbx-App-Auth', value => $self->{session_token});
|
||||||
}
|
}
|
||||||
$self->{http}->add_header(key => 'Accept', value => 'application/json');
|
$self->{http}->add_header(key => 'Accept', value => 'application/json');
|
||||||
|
$self->{http}->add_header(key => 'Content-type', value => 'application/json');
|
||||||
$self->{http}->set_options(%{$self->{option_results}});
|
$self->{http}->set_options(%{$self->{option_results}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,8 +170,8 @@ sub get_session {
|
||||||
|
|
||||||
$self->settings();
|
$self->settings();
|
||||||
my $content = $self->{http}->request(url_path => '/api/' . $self->{freebox_api_version} . '/login/',
|
my $content = $self->{http}->request(url_path => '/api/' . $self->{freebox_api_version} . '/login/',
|
||||||
critical_status => '', warning_status => '');
|
critical_status => '', warning_status => '', unknown_status => '');
|
||||||
my $decoded = $self->manage_response(content => $content);
|
my $decoded = $self->manage_response(content => $content, type => 'login');
|
||||||
my $challenge = $decoded->{result}->{challenge};
|
my $challenge = $decoded->{result}->{challenge};
|
||||||
my $password = hmac_sha1_hex($challenge, $self->{freebox_app_token});
|
my $password = hmac_sha1_hex($challenge, $self->{freebox_app_token});
|
||||||
|
|
||||||
|
@ -185,8 +186,8 @@ sub get_session {
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = $self->{http}->request(url_path => '/api/' . $self->{freebox_api_version} . '/login/session/', method => 'POST',
|
$content = $self->{http}->request(url_path => '/api/' . $self->{freebox_api_version} . '/login/session/', method => 'POST',
|
||||||
query_form_post => $encoded, critical_status => '', warning_status => '');
|
query_form_post => $encoded, critical_status => '', warning_status => '', unknown_status => '');
|
||||||
$decoded = $self->manage_response(content => $content);
|
$decoded = $self->manage_response(content => $content, type => 'login/session');
|
||||||
|
|
||||||
$self->{session_token} = $decoded->{result}->{session_token};
|
$self->{session_token} = $decoded->{result}->{session_token};
|
||||||
}
|
}
|
||||||
|
@ -200,8 +201,8 @@ sub get_data {
|
||||||
|
|
||||||
$self->settings();
|
$self->settings();
|
||||||
my $content = $self->{http}->request(url_path => '/api/' . $self->{freebox_api_version} . '/' . $options{path},
|
my $content = $self->{http}->request(url_path => '/api/' . $self->{freebox_api_version} . '/' . $options{path},
|
||||||
critical_status => '', warning_status => '');
|
critical_status => '', warning_status => '', unknown_status => '');
|
||||||
my $decoded = $self->manage_response(content => $content);
|
my $decoded = $self->manage_response(content => $content, type => $options{path});
|
||||||
return $decoded->{result};
|
return $decoded->{result};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,14 +226,14 @@ sub get_performance {
|
||||||
$self->settings();
|
$self->settings();
|
||||||
my $content = $self->{http}->request(url_path => '/api/' . $self->{freebox_api_version} . '/' . $options{path},
|
my $content = $self->{http}->request(url_path => '/api/' . $self->{freebox_api_version} . '/' . $options{path},
|
||||||
method => 'POST', query_form_post => $encoded,
|
method => 'POST', query_form_post => $encoded,
|
||||||
critical_status => '', warning_status => '');
|
critical_status => '', warning_status => '', unknown_status => '');
|
||||||
my $decoded = $self->manage_response(content => $content);
|
my $decoded = $self->manage_response(content => $content);
|
||||||
my ($datas, $total) = ({}, 0);
|
my ($datas, $total) = ({}, 0);
|
||||||
foreach my $data (@{$decoded->{result}->{datas}}) {
|
foreach my $data (@{$decoded->{result}->{data}}) {
|
||||||
foreach my $label (keys %$data) {
|
foreach my $label (keys %$data) {
|
||||||
next if ($label eq 'time');
|
next if ($label eq 'time');
|
||||||
$datas->{label} = 0 if (!defined($datas->{$label}));
|
$datas->{$label} = 0 if (!defined($datas->{$label}));
|
||||||
$datas->{label} += $datas->{$label};
|
$datas->{$label} += $data->{$label};
|
||||||
}
|
}
|
||||||
$total++;
|
$total++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ sub set_counters {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{maps_counters_type} = [
|
$self->{maps_counters_type} = [
|
||||||
{ name => 'global', type => 0 },
|
{ name => 'global', type => 0, skipped_code => { -10 => 1 } },
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{global} = [
|
$self->{maps_counters}->{global} = [
|
||||||
|
|
Loading…
Reference in New Issue