mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
host/ticket: add new REST API endpoint
This commit is contained in:
parent
bd03ec62e5
commit
630cf488f1
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Icinga\Module\Director\Controllers;
|
namespace Icinga\Module\Director\Controllers;
|
||||||
|
|
||||||
|
use Icinga\Exception\NotFoundError;
|
||||||
use Icinga\Module\Director\Objects\IcingaEndpoint;
|
use Icinga\Module\Director\Objects\IcingaEndpoint;
|
||||||
use Icinga\Module\Director\Objects\IcingaZone;
|
use Icinga\Module\Director\Objects\IcingaZone;
|
||||||
use Icinga\Module\Director\Util;
|
use Icinga\Module\Director\Util;
|
||||||
@ -83,6 +84,20 @@ class HostController extends ObjectController
|
|||||||
$this->view->globalzone = $this->db()->getDefaultGlobalZoneName();
|
$this->view->globalzone = $this->db()->getDefaultGlobalZoneName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function ticketAction()
|
||||||
|
{
|
||||||
|
if (! $this->getRequest()->isApiRequest() || ! $this->object) {
|
||||||
|
throw new NotFoundError('Not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$host = $this->object;
|
||||||
|
if ($host->getResolvedProperty('has_agent') !== 'y') {
|
||||||
|
throw new NotFoundError('The host "%s" is not an agent', $host->object_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->sendJson(Util::getIcingaTicket($host->object_name, $this->api()->getTicketSalt()));
|
||||||
|
}
|
||||||
|
|
||||||
public function renderAction()
|
public function renderAction()
|
||||||
{
|
{
|
||||||
$this->renderAgentExtras();
|
$this->renderAgentExtras();
|
||||||
|
@ -487,3 +487,24 @@ Content-Type: application/json
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Agent Tickets
|
||||||
|
|
||||||
|
The Director is very helpful when it goes to manage your Icinga Agents. In
|
||||||
|
case you want to fetch tickets through the API, please do as follows:
|
||||||
|
|
||||||
|
GET director/host/ticket?name=apitest
|
||||||
|
|
||||||
|
```
|
||||||
|
HTTP/1.1 200 OK
|
||||||
|
Date: Thu, 07 Apr 2016 22:19:24 GMT
|
||||||
|
Server: Apache
|
||||||
|
Content-Length: 43
|
||||||
|
Content-Type: application/json
|
||||||
|
```
|
||||||
|
|
||||||
|
```json
|
||||||
|
"5de9883080e03278039bce57e4fbdbe8fd262c40"
|
||||||
|
```
|
||||||
|
|
||||||
|
Please expect an error in case the host does not exist or has not been
|
||||||
|
configured to be an Icinga Agent.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user