unistra / python-glpi-api

Python module for interacting with GLPI using the API.
GNU General Public License v3.0
18 stars 10 forks source link

Nested search criteria #4

Closed jplitza closed 3 years ago

jplitza commented 3 years ago

The API supports "search criteria groups" like so:

criteria:
  - field: name
    searchtype: contains
    value: example.org
  - link: AND
    criteria:
      - field: Item_OperatingSystem.OperatingSystem.name
        searchtype: contains
        value: Debian
      - link: OR
        field: Item_OperatingSystem.OperatingSystem.name
        searchtype: contains
        value: Ubuntu     

The library doesn't, however:

Traceback (most recent call last):
[...]
  File "glpi_api.py", line 96, in wrapper
    return func(self, *args, **kwargs)
  File "glpi_api.py", line 615, in search
    for param in ('criteria', 'metacriteria')
  File "glpi_api.py", line 617, in <dictcomp>
    for filter_param, value in c.items()})
AttributeError: 'list' object has no attribute 'replace'
fmenabe commented 3 years ago

I push an update in the @search branch for this.

Before merging and tagging, can you test and confirm it works as expected for you?

jplitza commented 3 years ago

Looks good!

I'm testing with unistra/ansible-inventory-glpi@b600f44a4682cfd59e3aa1f8313c6530d9d85f1e and there seems to be some problem with merging the criteria of groups with their children when they contain nested criteria, but that probably is a different bug in a different project.