doc/REST-API: document new parameters

This commit is contained in:
Thomas Gelf 2022-07-20 09:45:26 +02:00
parent 0d68ee0fda
commit 34d5e445b2
2 changed files with 29 additions and 14 deletions

View File

@ -39,12 +39,15 @@ URL scheme and supported methods
We support GET, POST, PUT and DELETE. We support GET, POST, PUT and DELETE.
| Method | Meaning | Method | Meaning |
| ------ | ------------------------------------------------------------ |--------|---------------------------------------------------------------------|
| GET | Read / fetch data. Not allowed to run operations with the potential to cause any harm | GET | Read / fetch data. Not allowed to run operations with the potential |
| POST | Trigger actions, create or modify objects. Can also be used to partially modify objects | | to cause any harm |
| PUT | Creates or replaces objects, cannot be used to modify single object properties | POST | Trigger actions, create or modify objects. Can also be used to |
| DELETE | Remove a specific object | | partially modify objects |
| PUT | Creates or replaces objects, cannot be used to modify single object |
| | properties |
| DELETE | Remove a specific object |
TODO: more examples showing the difference between POST and PUT TODO: more examples showing the difference between POST and PUT
@ -113,6 +116,14 @@ Icinga Objects
### Special parameters ### Special parameters
| Parameter | Description |
|--------------|-------------------------------------------------------------|
| resolved | Resolve all inherited properties and show a flat object |
| withNull | Retrieve default (null) properties also |
| withServices | Show services attached to a host. `resolved` and `withNull` |
| | are applied for services too |
#### Resolve object properties #### Resolve object properties
In case you add the `resolved` parameter to your URL, all inherited object In case you add the `resolved` parameter to your URL, all inherited object
@ -121,15 +132,20 @@ properties will be resolved. Such a URL could look as follows:
director/host?name=hostname.example.com&resolved director/host?name=hostname.example.com&resolved
#### Retrieve all properties #### Retrieve default (null) properties also
TODO: adjust the code to fix this, current implementation has `withNull`
Per default properties with `null` value are skipped when shipping a result. Per default properties with `null` value are skipped when shipping a result.
You can influence this behavior with the properties parameter. Just append You can influence this behavior with the `properties` parameter. Just append
`properties=ALL` to your URL: `&withNull` to your URL:
director/host?name=hostname.example.com&properties=all director/host?name=hostname.example.com&withNull
#### Fetch host with it's services
This is what the `withServices` parameter exists:
director/host?name=hostname.example.com&withServices
#### Retrieve only specific properties #### Retrieve only specific properties

View File

@ -13,8 +13,7 @@ class RestApiParams
$params = $request->getUrl()->getParams(); $params = $request->getUrl()->getParams();
$resolved = (bool) $params->get('resolved', false); $resolved = (bool) $params->get('resolved', false);
$withNull = $params->shift('withNull'); $withNull = $params->shift('withNull');
$withServices = (bool) $params->get('withServices'); if ($params->get('withServices')) {
if ($withServices) {
if ($shortObjectType !== 'host') { if ($shortObjectType !== 'host') {
throw new InvalidArgumentException('withServices is available for Hosts only'); throw new InvalidArgumentException('withServices is available for Hosts only');
} }