Forum Discussion

MaelJ's avatar
MaelJ
Icon for Making Connections rankMaking Connections
2 months ago

Python script to add or delete a network in a site

Hy,
I am trying to create a Python script to delete a network from one site and create it on another site.

Do you have any examples of Python scripts available to make these changes?

This page https://support.catonetworks.com/hc/en-us/articles/360013823477-Example-Scripts-Using-the-Cato-API-with-Python no longer exists.

Best regards,
Maël JAUBERT

3 Replies

  • Hi,
    As an alternative to using python to send the graphql queries, we can look to use the cato-cli to make any call that the API supports.  Please see the following resources published on how to use python to call the CLI with a few examples for windows and unix.
    https://github.com/catonetworks/cato-cli?tab=readme-ov-file#advanced-cato-cli-topics
    pip3 install cato-cli
    catocli configure

    Please see the following examples for how to delete a network from one site:
    catocli mutation site removeNetworkRange '{
        "networkRangeId": "UzU2NjQwMA=="
    }'

    Please see an example of how to add a network range to a site below:
    catocli mutation site addNetworkRange '{
        "addNetworkRangeInput": {
            "localIp": "10.11.0.1",
            "name": "MyNetwork Range",
            "rangeType": "Direct",
            "subnet": "10.11.0.0/24"
        },
        "lanSocketInterfaceId": "177643"
    }'

    Please note that I used  the cato api explorer application to generate these code examples, this is a docker application you can run locally on your machine that will generate cli commands, as well as python code snippits on the fly for you for any API that is in the schema. 

    https://github.com/catonetworks/cato-api-explorer

     

      

    • MaelJ's avatar
      MaelJ
      Icon for Making Connections rankMaking Connections

      Thanks for your return yaakov_simon​ but i don't find any python scripts on "entityLookup" or "accountSnapshot"  in the Cato Github repository.
      Is there another link to these scripts, or are they no longer available?

      Best regards