Skip to content
Snippets Groups Projects
Commit 070fb4c6 authored by Tomasz Wolniewicz's avatar Tomasz Wolniewicz
Browse files

modifications to the action_edugain_status action - the list now excludes...

modifications to the action_edugain_status action - the list now excludes technically suspened and the action allows for two parameters: problems and valid_sec, allowing to limit the results list
parent c8c743d8
No related branches found
No related tags found
1 merge request!7changes for action_edugain_status
......@@ -95,6 +95,7 @@ class API {
'mod_time',
'lang',
'details',
'valid_sec'
];
foreach ($supportedOptions as $opt) {
......@@ -303,7 +304,11 @@ class API {
if ($optValue != 1) {
$optValue = 0;
}
case 'valid_sec':
$optValue = filter_var($optValue, FILTER_SANITIZE_NUMBER_INT);
if ($optValue == '') {
$optValue = 0;
}
default:
}
$this->opts[$optName] = $optValue;
......@@ -568,6 +573,18 @@ class API {
'arguments' => [
$this->addStdArgument('fed_id'),
$this->addStdArgument('reg_auth'),
[
'arg' => 'only_errors',
'required' => FALSE,
'default' => '0',
'values' => '0, 1',
'description' => '0 - show all; 1 - only federations with feed problems including close to expiry'],
[
'arg' => 'valid_sec',
'required' => FALSE,
'default' => VALIDITY_WARNING_THRESHOLD . ' (108 hours or 4.5 days)',
'values' => 'any non-negative integer',
'description' => 'set the alert expiry time to this number of seconds'],
$this->addStdArgument('format'),
],
'returns' => [
......@@ -583,6 +600,7 @@ class API {
when no federation code is present an array of code-indexed participating federations with details as described above'
],
'examples' => [
['opt' => ['only_errors'], 'title' => 'only fedrations with problems',],
['opt' => ['fed_id' => 'PIONIER-ID',],'title' => 'show status of PIONIER.Id',],
['opt' => ['fed_id' => 'PIONIER-ID',], 'format' => 'json', 'title' => 'show status of PIONIER.Id in JSON',]
]
......@@ -590,9 +608,25 @@ class API {
if ($this->opts['help'] == 1) {
return "";
}
$edugain = new eduGAIN(1, $this->fed_id, true);
Utils::debug(5, $this->opts, "OPTS: ", "\n");
$edugain = new eduGAIN(5, $this->fed_id, true);
$edugain->load_federations_state();
$out = $edugain->FEDS;
if ($this->opts['only_errors'] == 1) {
$out = [];
if ($this->opts['valid_sec'] > 0) {
$sec = $this->opts['valid_sec'];
} else {
$sec = VALIDITY_WARNING_THRESHOLD;
}
foreach ($edugain->FEDS as $fed) {
if ($fed['feed_problem'] > 0 || $fed['valid_sec'] < $sec) {
$out[] = $fed;
}
}
} else {
$out = $edugain->FEDS;
}
return $out;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment