Use --api-password

so that tocken is hidden thanks to https://github.com/centreon/centreon/pull/7975
This commit is contained in:
CPbN 2020-01-16 07:46:10 +01:00
parent c04eac18de
commit 7b8c412a79
1 changed files with 6 additions and 6 deletions

View File

@ -47,7 +47,7 @@ sub new {
"hostname:s" => { name => 'hostname' }, "hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port'}, "port:s" => { name => 'port'},
"proto:s" => { name => 'proto' }, "proto:s" => { name => 'proto' },
"api-token:s" => { name => 'api_token' }, "api-password:s" => { name => 'api_password' },
"timeout:s" => { name => 'timeout', default => 30 }, "timeout:s" => { name => 'timeout', default => 30 },
}); });
} }
@ -91,14 +91,14 @@ sub check_options {
$self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'https'; $self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'https';
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 30; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 30;
$self->{ssl_opt} = (defined($self->{option_results}->{ssl_opt})) ? $self->{option_results}->{ssl_opt} : undef; $self->{ssl_opt} = (defined($self->{option_results}->{ssl_opt})) ? $self->{option_results}->{ssl_opt} : undef;
$self->{api_token} = (defined($self->{option_results}->{api_token})) ? $self->{option_results}->{api_token} : undef; $self->{api_password} = (defined($self->{option_results}->{api_password})) ? $self->{option_results}->{api_password} : undef;
if (!defined($self->{hostname}) || $self->{hostname} eq '') { if (!defined($self->{hostname}) || $self->{hostname} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify --hostname option."); $self->{output}->add_option_msg(short_msg => "Need to specify --hostname option.");
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
if (!defined($self->{api_token}) || $self->{api_token} eq '') { if (!defined($self->{api_password}) || $self->{api_password} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify --api-token option."); $self->{output}->add_option_msg(short_msg => "Need to specify --api-password option.");
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
@ -120,7 +120,7 @@ sub settings {
$self->build_options_for_httplib(); $self->build_options_for_httplib();
$self->{http}->add_header(key => 'Content-Type', value => 'application/json;charset=UTF-8'); $self->{http}->add_header(key => 'Content-Type', value => 'application/json;charset=UTF-8');
$self->{http}->add_header(key => 'Authorization', value => 'Api-Token ' . $self->{option_results}->{api_token}); $self->{http}->add_header(key => 'Authorization', value => 'Api-Token ' . $self->{option_results}->{api_password});
$self->{http}->set_options(%{$self->{option_results}}); $self->{http}->set_options(%{$self->{option_results}});
} }
@ -189,7 +189,7 @@ Set Dynatrace Port (Default: '443').
Specify http if needed (Default: 'https'). Specify http if needed (Default: 'https').
=item B<--api-token> =item B<--api-password>
Set Dynatrace API token. Set Dynatrace API token.