enhance typo

This commit is contained in:
garnier-quentin 2020-02-12 17:56:48 +01:00
parent 61b5858838
commit ad5af78524
1 changed files with 55 additions and 55 deletions

View File

@ -45,17 +45,17 @@ sub new {
if (!defined($options{noptions})) {
$options{options}->add_options(arguments => {
"subscription:s" => { name => 'subscription' },
"tenant:s" => { name => 'tenant' },
"client-id:s" => { name => 'client_id' },
"client-secret:s" => { name => 'client_secret' },
"login-endpoint:s" => { name => 'login_endpoint' },
"management-endpoint:s" => { name => 'management_endpoint' },
"timeframe:s" => { name => 'timeframe' },
"interval:s" => { name => 'interval' },
"aggregation:s@" => { name => 'aggregation' },
"zeroed" => { name => 'zeroed' },
"timeout:s" => { name => 'timeout' },
'subscription:s' => { name => 'subscription' },
'tenant:s' => { name => 'tenant' },
'client-id:s' => { name => 'client_id' },
'client-secret:s' => { name => 'client_secret' },
'login-endpoint:s' => { name => 'login_endpoint' },
'management-endpoint:s' => { name => 'management_endpoint' },
'timeframe:s' => { name => 'timeframe' },
'interval:s' => { name => 'interval' },
'aggregation:s@' => { name => 'aggregation' },
'zeroed' => { name => 'zeroed' },
'timeout:s' => { name => 'timeout' },
});
}
$options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1);
@ -177,9 +177,11 @@ sub get_access_token {
$self->settings();
my $content = $self->{http}->request(method => 'POST', query_form_post => $post_data,
full_url => $self->{login_endpoint} . '/' . $self->{tenant} . '/oauth2/token',
hostname => '');
my $content = $self->{http}->request(
method => 'POST', query_form_post => $post_data,
full_url => $self->{login_endpoint} . '/' . $self->{tenant} . '/oauth2/token',
hostname => ''
);
if (!defined($content) || $content eq '' || $self->{http}->get_header(name => 'content-length') == 0) {
$self->{output}->add_option_msg(short_msg => "Login endpoint API returns empty content [code: '" . $self->{http}->get_code() . "'] [message: '" . $self->{http}->get_message() . "']");
@ -191,7 +193,7 @@ sub get_access_token {
$decoded = JSON::XS->new->utf8->decode($content);
};
if ($@) {
$self->{output}->output_add(long_msg => $content, debug => 1);
$self->{output}->output_add(long_msg => $@, debug => 1);
$self->{output}->add_option_msg(short_msg => "Cannot decode response (add --debug option to display returned content)");
$self->{output}->option_exit();
}
@ -232,7 +234,7 @@ sub request_api {
$decoded = JSON::XS->new->utf8->decode($content);
};
if ($@) {
$self->{output}->output_add(long_msg => $content, debug => 1);
$self->{output}->output_add(long_msg => $@, debug => 1);
$self->{output}->add_option_msg(short_msg => "Cannot decode response (add --debug option to display returned content)");
$self->{output}->option_exit();
}
@ -255,15 +257,19 @@ sub convert_duration {
my $duration;
if ($options{time_string} =~ /^P.*S$/) {
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'DateTime::Format::Duration::ISO8601',
error_msg => "Cannot load module 'DateTime::Format::Duration::ISO8601'.");
centreon::plugins::misc::mymodule_load(
output => $self->{output}, module => 'DateTime::Format::Duration::ISO8601',
error_msg => "Cannot load module 'DateTime::Format::Duration::ISO8601'."
);
my $format = DateTime::Format::Duration::ISO8601->new;
my $d = $format->parse_duration($options{time_string});
$duration = $d->minutes * 60 + $d->seconds;
} elsif ($options{time_string} =~ /^(\d+):(\d+):(\d+)\.\d+$/) {
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'DateTime::Duration',
error_msg => "Cannot load module 'DateTime::Format::Duration'.");
centreon::plugins::misc::mymodule_load(
output => $self->{output}, module => 'DateTime::Duration',
error_msg => "Cannot load module 'DateTime::Format::Duration'."
);
my $d = DateTime::Duration->new(hours => $1, minutes => $2, seconds => $3);
$duration = $d->minutes * 60 + $d->seconds;
@ -411,7 +417,6 @@ sub azure_list_groups_set_url {
my ($self, %options) = @_;
my $url = $self->{management_endpoint} . "/subscriptions/" . $self->{subscription} . "/resourcegroups?api-version=" . $self->{api_version};
return $url;
}
@ -420,7 +425,6 @@ sub azure_list_groups {
my $full_url = $self->azure_list_groups_set_url(%options);
my $response = $self->request_api(method => 'GET', full_url => $full_url, hostname => '');
return $response->{value};
}
@ -438,7 +442,6 @@ sub azure_list_deployments {
my $full_url = $self->azure_list_deployments_set_url(%options);
my $response = $self->request_api(method => 'GET', full_url => $full_url, hostname => '');
return $response->{value};
}
@ -448,7 +451,6 @@ sub azure_list_vaults_set_url {
my $url = $self->{management_endpoint} . "/subscriptions/" . $self->{subscription};
$url .= "/resourceGroups/" . $options{resource_group} if (defined($options{resource_group}) && $options{resource_group} ne '');
$url .= "/providers/Microsoft.RecoveryServices/vaults?api-version=" . $self->{api_version};
return $url;
}
@ -457,7 +459,6 @@ sub azure_list_vaults {
my $full_url = $self->azure_list_vaults_set_url(%options);
my $response = $self->request_api(method => 'GET', full_url => $full_url, hostname => '');
return $response->{value};
}
@ -476,7 +477,6 @@ sub azure_list_backup_jobs {
my $full_url = $self->azure_list_backup_jobs_set_url(%options);
my $response = $self->request_api(method => 'GET', full_url => $full_url, hostname => '');
return $response->{value};
}