Menu

Help needed with API querie

Wilco
2024-12-13
2024-12-13
  • Wilco

    Wilco - 2024-12-13

    Hi all,

    I’ve started using the TeemIP API and need some help with the following:

    I want to perform a query via the API to retrieve the subnet mask for a specific IP address. In MySQL, I use the following query:

    SELECT ipaddressv4.ip AS ipaddr, ipsubnetv4.mask AS subnetmask
    FROM ipaddressv4
    INNER JOIN ipsubnetv4 ON ipsubnetv4.id = ipaddressv4.subnet_id
    WHERE ipaddressv4.ip = '192.168.249.200';

    Now, I’d like to achieve the same result using an OQL query. Could someone explain how to do this? If I have a starting point, I can figure out the rest.

    Much appreciated!

     
  • Xtophe38

    Xtophe38 - 2024-12-13

    Hello,

    Thanks for using TeemIP. Please, refer to the wiki :
    * here to learn how to build an OQL request,
    * here to learn how to use iTop's REST/JSON API,
    * and here to see the specific verbs for the API brought by TeemIP.

    In short, your request will look something like (in the IPv4 space):
    SELECT IPv4Subnet AS s JOIN IPv4Address AS ip ON ip.subnet_id = s.id WHERE ip.ip = '192.168.249.200' AND ip.org_name = 'Demo'

    Notes:
    * you'll need to specify the organization if your IP space is spread over multiple ones,
    * you'll need to list, in your API call, the attributes that you are interested in.

    With the hope that helps.

     

Log in to post a comment.