DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:idoit

i-doit Syntax Plugin

Compatible with DokuWiki

Weatherwax

plugin This plugin provides a basic integration of the i-doit JSON-RPC API client in PHP with DokuWiki.

Last updated on
2014-11-20
Provides
Syntax
Repository
Source

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Security warning (please read plugin security guidelines): The syntax block allows to pass an arbitrary JSON request to the remote JSON-RPC url without security checks.

Tagged with api, i-doit, integration

Installation

:!: Requirements: This plugin depends on a functional i-doit setup with a working JSON-RPC API endpoint set up.

Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

Initial API setup

The PHP client API for i-doit requires a manual initialization of the codebase in order to adapt to your installation. To do that, locate the PHP API root contained in the idoit plugin folder (<Dokuwiki Root directory>/lib/plugins/idoit/idoit/php) and execute the following command:

make initialize

See the Client API documentation for detailed instructions.

Syntax / Usage

The plugin adds a protected syntax block <idoitAPI></idoitAPI> which contains a JSON request passed to the API.

<idoitAPI>
{
  "method": "cmdb.object.read",
  "params": { "id": 1234 },
  "filter": [
    { "desc": "SYS-ID", "path": [ "sysid" ] },
    { "desc": "Foo", "path": [ "foo", "bar" ] }
  ]
}
</idoitAPI>

The JSON request must contain the following attributes:

  • method: The method string as defined in CMDB/Methods.class.php of the PHP API
  • request: The actual JSON request as sent to the API.

And may contain an optional filter attribute for filtering the result object as an array of the following objects:

  • path: An array that denotes the accessor hierarchy in the response object.
  • desc: The name to be used for printing the retrieved value

A filter { “desc”: “My Hostname”, “path”: [0, “hostaddress”, “ref_title”] } would return the line *'My Hostname myhostname'* for the following API response:

[{
    "hostaddress": {
        id: 128,
        type: "C__OBJTYPE__LAYER3_NET",
        title: "Management",
        ref_title: "myhostname"
    }
},
...
]

For available methods and categories as strings, see the constant definitions in https://bitbucket.org/dstuecken/i-doit-api-clients.

Examples

Retrieving objects by IDs

<idoitAPI>
{
  "method": "cmdb.object.read",
  "params": { "id": 578 }
}
</idoitAPI>

Output <pre> id 578 title NOS sysid SYSID_1404992452 objecttype 5 type_title Server …. updated 2014-10-17 11:53:54 </pre>

Retrieve single attribute pairs

<idoitAPI>
{
  "method": "cmdb.object.read",
  "params": { "id": 578 },
  "filter": [
    { "desc": "SYS-ID", "path": [ "sysid" ] },
    { "desc": "Foo", "path": [ "foo", "bar" ] }
  ]
}
</idoitAPI>

If a filter does not match the response, a warning is instead printed:

Output <pre> SYS-ID SYSID_1404992452 Foo Filter 'Foo' (path foo/bar) does not match response </pre>

Retrieve, Filter values from categories

<idoitAPI>
{
  "method": "cmdb.category.read",
  "params": { "objID": 578, "catgID": "C__CATG__IP" },
  "filter": [
    { "desc": "Hostname", "path": [ "1", "hostname" ] },
    { "desc": "IPv4", "path": [ "1", "hostaddress", "ref_title" ] }
  ]
}
</idoitAPI>

Output <pre> Hostname myhostname.example.com IPv4 123.456.789.0 </pre>

Configuration and Settings

Use the configuration manager to set your API credentials:

  • API endpoint: The URL to the JSON-RPC API
  • API key: The API key
  • Username: API username
  • Password: API password

Change Log

  • 2014-11-20 : v0.1
    • Initial release
plugin/idoit.txt · Last modified: 2022-07-29 23:25 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki