enhance indent

This commit is contained in:
garnier-quentin 2020-04-08 17:11:02 +02:00
parent 4a505c0251
commit 041b8fda41
2 changed files with 21 additions and 23 deletions

View File

@ -28,7 +28,7 @@ use Digest::SHA 'sha1_hex';
my %map_ovh_type = ( my %map_ovh_type = (
OVH_API_EU => 'https://eu.api.ovh.com/1.0', OVH_API_EU => 'https://eu.api.ovh.com/1.0',
OVH_API_CA => 'https://ca.api.ovh.com/1.0', OVH_API_CA => 'https://ca.api.ovh.com/1.0'
); );
sub new { sub new {
@ -47,11 +47,11 @@ sub new {
if (!defined($options{noptions})) { if (!defined($options{noptions})) {
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"ovh-type:s@" => { name => 'ovh_type' }, 'ovh-type:s@' => { name => 'ovh_type' },
"ovh-application-key:s@" => { name => 'ovh_application_key' }, 'ovh-application-key:s@' => { name => 'ovh_application_key' },
"ovh-application-secret:s@" => { name => 'ovh_application_secret' }, 'ovh-application-secret:s@' => { name => 'ovh_application_secret' },
"ovh-consumer-key:s@" => { name => 'ovh_consumer_key' }, 'ovh-consumer-key:s@' => { name => 'ovh_consumer_key' },
"timeout:s@" => { name => 'timeout' }, 'timeout:s@' => { name => 'timeout' }
}); });
} }
$options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1);
@ -61,23 +61,17 @@ sub new {
$self->{http} = centreon::plugins::http->new(%options); $self->{http} = centreon::plugins::http->new(%options);
return $self; return $self;
} }
# Method to manage multiples
sub set_options { sub set_options {
my ($self, %options) = @_; my ($self, %options) = @_;
# options{options_result}
$self->{option_results} = $options{option_results}; $self->{option_results} = $options{option_results};
} }
# Method to manage multiples
sub set_defaults { sub set_defaults {
my ($self, %options) = @_; my ($self, %options) = @_;
# options{default}
# Manage default value
foreach (keys %{$options{default}}) { foreach (keys %{$options{default}}) {
if ($_ eq $self->{mode}) { if ($_ eq $self->{mode}) {
for (my $i = 0; $i < scalar(@{$options{default}->{$_}}); $i++) { for (my $i = 0; $i < scalar(@{$options{default}->{$_}}); $i++) {
@ -181,8 +175,12 @@ sub get {
$self->settings(%options); $self->settings(%options);
my $response = $self->{http}->request(full_url => $map_ovh_type{uc($self->{ovh_type})} . $options{path}, my $response = $self->{http}->request(
hostname => '', critical_status => '', warning_status => ''); full_url => $map_ovh_type{uc($self->{ovh_type})} . $options{path},
hostname => '',
critical_status => '',
warning_status => ''
);
my ($client_warning) = $self->{http}->get_header(name => 'Client-Warning'); my ($client_warning) = $self->{http}->get_header(name => 'Client-Warning');
if (defined($client_warning) && $client_warning eq 'Internal response') { if (defined($client_warning) && $client_warning eq 'Internal response') {
$self->{output}->add_option_msg(short_msg => "Internal LWP::UserAgent error: $response"); $self->{output}->add_option_msg(short_msg => "Internal LWP::UserAgent error: $response");