mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-28 08:14:04 +02:00
CoreApi: use new objects api
This commit is contained in:
parent
bff5d328c2
commit
3a9580e4ca
@ -19,27 +19,15 @@ class CoreApi
|
|||||||
{
|
{
|
||||||
$name = strtolower($name);
|
$name = strtolower($name);
|
||||||
$params = (object) array(
|
$params = (object) array(
|
||||||
'attrs' => array($name . '.__name', $name.'.templates')
|
|
||||||
);
|
);
|
||||||
|
if (! empty($attrs)) {
|
||||||
foreach ($attrs as $attr) {
|
$params->attrs = $attrs;
|
||||||
$params->attrs[] = $name . '.' . $attr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return json_encode(json_decode($this->client->getRaw(
|
return $this->client->get(
|
||||||
'objects/' . urlencode(strtolower($pluraltype))
|
|
||||||
//$params
|
|
||||||
)), JSON_PRETTY_PRINT);
|
|
||||||
|
|
||||||
$result = array();
|
|
||||||
foreach (json_decode($this->client->getRaw(
|
|
||||||
'objects/' . urlencode(strtolower($pluraltype)),
|
'objects/' . urlencode(strtolower($pluraltype)),
|
||||||
$params
|
$params
|
||||||
))->results as $res) {
|
)->getResult('name');
|
||||||
$result[$res->attrs->{$name . '.__name'}] = $res->attrs;
|
|
||||||
$result[$res->attrs->{$name . '.__name'}]->__used_by = $res->used_by;
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTypes()
|
public function getTypes()
|
||||||
@ -61,12 +49,13 @@ return json_encode(json_decode($this->client->getRaw(
|
|||||||
public function listObjects($type, $pluralType)
|
public function listObjects($type, $pluralType)
|
||||||
{
|
{
|
||||||
// TODO: more abstraction needed
|
// TODO: more abstraction needed
|
||||||
|
// TODO: autofetch and cache pluraltypes
|
||||||
return $this->client->get(
|
return $this->client->get(
|
||||||
'objects/' . $pluralType,
|
'objects/' . $pluralType,
|
||||||
array(
|
array(
|
||||||
'attrs' => array($type . '.__name', $type . '.name'),
|
'attrs' => array($type . '.__name', $type . '.name'),
|
||||||
)
|
)
|
||||||
)->getResult('__name');
|
)->getResult('name');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getModules()
|
public function getModules()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user