Automic Workload Automation

 View Only
Expand all | Collapse all

api meraki (cisco) with JWEB / one automation 12.3

  • 1.  api meraki (cisco) with JWEB / one automation 12.3

    Posted Oct 04, 2022 06:44 PM
    Hello

    we are using one automation 12.3
    We have a JWEB in order to connect to the meraki api  with a RESTCONNEXION
    it works:
    the request is : 
    https://api.meraki.com/api/v1/organizations/YYYYYYYY

    and the result of this request is bellow (I have too much information)


    but as i  have many answers,  I would like to filter  :
    for example, bellow, I wave plenty of devices with some information and I would like to get only the list of the devices, for example :
    result wanted :
    AAAAA
    BBBBBB
    CCCCCC

        (and why not AAAAA,BBBBB,CCCCC with one other propriety for each )


    the result of the request, I want to improve : 
    [
    {
    "name": "AAAAAAA",
    "serial": "xxxxx",
    "mac": "xxxx",
    "publicIp": "xxxx",
    "networkId": "xxxxx",
    "status": "online",
    "lastReportedAt": "xxxx",
    "productType": "appliance",
    "components": {
    "powerSupplies": [

    ]
    },
    "model": "VMX-L",
    "tags": [

    ],
    "lanIp": "1xxxxx",
    "gateway": "xxxxx",
    "ipType": "dhcp",
    "primaryDns": "1xxxx",
    "secondaryDns": null
    },
    {
    "name": "BBBBBBBBB",
    "serial": "xxxx",
    "mac": "xxxxx",
    "publicIp": "xxxx",
    "networkId": "xxxx1",
    "status": "online",
    "lastReportedAt": "2022-10-04T15:28:02.263000Z",
    "productType": "appliance",
    "components": {
    "powerSupplies": [

    ]
    },
    "model": "VMX-L",
    "tags": [

    ],
    "lanIp": "xxxx",
    "gateway": "xxx",
    "ipType": "dhcp",
    "primaryDns": "xxx",
    "secondaryDns": null
    },
    {
    "name": "CCCCCCCCC",
    "serial": "vvvvv",
    "mac": "vvvv",
    "publicIp": null,
    "networkId": "vvvvv",
    "status": "dormant",
    "lastReportedAt": null,
    "productType": "wireless",
    "model": "MR36",
    "tags": [
    "vvvvv"
    ],
    "lanIp": null
    },



    can you help

    thanks a lot


    marc broussard
    INEO EQUANS


  • 2.  RE: api meraki (cisco) with JWEB / one automation 12.3

    Broadcom Employee
    Posted Oct 05, 2022 02:57 AM
    Hi Marc,

    in the REST job, go to the "Response" tab and add a response parsing. Click "Test" to verify the parsing. In your case the expression $..name gives you an array of the names only.

    Regards, Markus


  • 3.  RE: api meraki (cisco) with JWEB / one automation 12.3

    Posted Oct 05, 2022 03:28 AM
    Hello Markus

    so fast! thanks

    so far so good

    I manage to get the list of the names of the device, great

    now i am trying to get the model associated with the name (2 things and not only one):
    name1, model1
    name2,model2
    ...
    if you know ...
    i am looking for, and will answer again if i find

    thanks again


  • 4.  RE: api meraki (cisco) with JWEB / one automation 12.3

    Broadcom Employee
    Posted Oct 05, 2022 04:03 AM
    Hi Marc,
    JSONPath is a query language, it removes the structure and returns values. You can optionally use Groovy or create a second response variable to query only the model. Please note that you have the option of having Automic to create a script array instead.
    Regards, Markus


  • 5.  RE: api meraki (cisco) with JWEB / one automation 12.3

    Posted Oct 05, 2022 11:36 AM
    thanks
    I tried with groovy
    not easy to start
    can you give an example of a groovy request in a  "OA   JWEB"  ?
    or any new help?

    thanks a lot


  • 6.  RE: api meraki (cisco) with JWEB / one automation 12.3

    Posted Oct 11, 2022 02:19 AM
    Hello

    some more news

    I managed to do what I wnated in perl :
    I have to copy the JSON file on a server with perl and to transform it in XLS
    I found the solution thanks to this post:
    https://stackoverflow.com/questions/39520245/perl-convert-json-format-into-comma-separated-values


    put I am still looking for a "native" solution in OA, without additional, code elsewhere

    if ever anybody somewhere knows ...
    thanks a lot

    Marc Broussard
    INEO Equans


  • 7.  RE: api meraki (cisco) with JWEB / one automation 12.3

    Posted Oct 13, 2022 05:45 AM
    Hello

    i do not manage to strat with grrovy

    any help welcome !
    thanks a lot



    thanks a lot

    marc broussard
    Ineo Equans



  • 8.  RE: api meraki (cisco) with JWEB / one automation 12.3
    Best Answer

    Broadcom Employee
    Posted Oct 13, 2022 10:39 AM
    Hi Marc,

    start with:

    def res = path."name"
    return res

    Regards, Markus


  • 9.  RE: api meraki (cisco) with JWEB / one automation 12.3

    Posted Oct 18, 2022 11:55 AM
    hello Markus,

    well done, it works.

    and  as I had to do something more, I post it:
    I had to find  the name and the model for each equipment

    I managed to do it, by this way :




    and &NBELEMENTS#  is a variable: between 0 and the number of elements in  the array created in the response (json file) to the request


    Marc Broussard
    Ineo Equans


  • 10.  RE: api meraki (cisco) with JWEB / one automation 12.3

    Broadcom Employee
    Posted Oct 19, 2022 02:13 AM
    Edited by Markus Embacher Oct 19, 2022 02:15 AM
    Hi Marc,

    glad it works! You might also want to try the option "Use Array", which will return a script variable array that contains one item per result. This allows you to loop through the elements without parsing the JSON array (in string format).

    Regards, Markus