new: [queryLocalTools] endpoint added to broods

- show a list of local tools exposed by a remote cerebrate
connector
iglocska 2021-06-01 07:49:59 +02:00
parent c6332dee16
commit 62c43e854f
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 21 additions and 0 deletions

View File

@ -171,4 +171,25 @@ class BroodsTable extends AppTable
return false;
}
}
public function queryLocalTools($brood_id)
{
$query = $this->find();
$brood = $query->where(['id' => $brood_id])->first();
if (empty($brood)) {
throw new NotFoundException(__('Brood not found'));
}
$http = new Client();
$response = $http->get($brood['url'] . '/localTools/exposedTools' , [], [
'headers' => [
'Authorization' => $brood['authkey']
],
'type' => 'json'
]);
if ($response->isOk()) {
return $response->getJson();
} else {
return false;
}
}
}