Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLPI meta search #8

Open
Rico29 opened this issue Apr 3, 2024 · 1 comment
Open

GLPI meta search #8

Rico29 opened this issue Apr 3, 2024 · 1 comment

Comments

@Rico29
Copy link

Rico29 commented Apr 3, 2024

Hello
I'm actually integrating your work in our ansible setup, to get inventory from GLPI API. works fine.

One problem though : the fact that it's not possible to get elements by name (uid_cols=true).
The inherent problem is when using meta search : if a meta filed has the same id in its category, it overwrites the result.

example when trying to get computers with a specific version of a software installed :

GET PARAMS :

uid_cols:1
criteria[0][field]:5161
criteria[0][searchtype]:contains
criteria[0][value]:freepbx
criteria[1][link]:AND
criteria[1][meta]:true
criteria[1][itemtype]:Software
criteria[1][field]:1
criteria[1][searchtype]:contains
criteria[1][value]:freepbx-module-core
criteria[2][link]:AND
criteria[2][meta]:true
criteria[2][itemtype]:Software
criteria[2][field]:5
criteria[2][searchtype]:contains
criteria[2][value]:^16

result of query :

    "data": [
        {
            "Computer.name": "117-freepbx",
            "Computer.Entity.completename": "/",
            "Computer.Location.completename": null,
            "Computer.State.completename": "actif",
            "Computer.ComputerType.name": "QEMU",
            "Computer.PluginFusioninventoryInventoryComputerComputer.last_fusioninventory_update": "2024-04-03 17:00:50",
            "Computer.comment": null,
            "Computer.ComputerModel.name": "Standard PC (i440FX + PIIX, 1996)",
            "Computer.Item_OperatingSystem.OperatingSystem.name": "Debian GNU/Linux",
            "Computer.Item_OperatingSystem.OperatingSystemVersion.name": "12.5",
            "Computer.ComputerVirtualMachine.name": null,
            "Computer.PluginFusioninventoryAgent.tag": "freepbx location_client",
            "Software.name": "freepbx-module-core",
            "Software.SoftwareVersion.name": "freepbx-module-core - 16.0.68.20"
        },
...

but if I remove the "uid_cols:1" I get this result, which does not display anymore the targeted hostname :

    "data": [
        {
            "1": "freepbx-module-core",
            "80": "/",
            "3": null,
            "31": "actif",
            "4": "QEMU",
            "5150": "2024-04-03 17:00:50",
            "16": null,
            "40": "Standard PC (i440FX + PIIX, 1996)",
            "45": "Debian GNU/Linux",
            "46": "12.5",
            "160": null,
            "5161": "freepbx location_client",
            "5": "freepbx-module-core - 16.0.68.20"
        },
...

because "Software.name" has id 1 in software itemtype.

Is there any workaround ?
Regards

@Rico29
Copy link
Author

Rico29 commented Apr 3, 2024

from https://github.com/glpi-project/glpi/blob/main/apirest.md#search-items :

uid_cols (default false): a boolean to identify cols by the 'uniqid' of the searchoptions instead of a numeric value (see List searchOptions and 'uid' field)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant