APIv1 Uplinks

boomi
Getting noticed

APIv1 Uplinks

Do we really have to retrieve all uplinks for every firewall in the organization? Or is there a hidden way to filter to a single MX. 

 

What I had:

 

/networks/$net_id/devices/$mx_serial/uplink

[
    {
        "interface": "WAN 1",
        "status": "Active",
        "ip": "x.x.x.x",
        "gateway": "x.x.x.x",
        "publicIp": "x.x.x.x",
        "dns": "208.67.222.222, 208.67.220.220",
        "usingStaticIp": true
    },
    {
        "interface": "WAN 2",
        "status": "Ready",
        "ip": "y.y.y.y",
        "gateway": "y.y.y.y",
        "publicIp": "y.y.y.y",
        "dns": "208.67.222.222, 208.67.220.220",
        "usingStaticIp": true
    }
]

 

What I have now:

 

/organizations/$org_id/appliance/uplink/statuses

    {
        "networkId": "12345",
        "serial": "a-b-c",
        "lastReportedAt": "2020-08-12T21:57:23Z",
        "uplinks": [
            {
                "interface": "wan1",
                "status": "active",
                "ip": "x.x.x.x",
                "gateway": "x.x.x.x",
                "publicIp": "x.x.x.x",
                "primaryDns": "8.8.8.8",
                "secondaryDns": "8.8.4.4",
                "ipAssignedBy": "static"
            },
            {
                "interface": "wan2",
                "status": "not connected",
                "ip": null,
                "gateway": null,
                "publicIp": null,
                "primaryDns": null,
                "secondaryDns": null,
                "ipAssignedBy": null
            }
        ]
    }

 

9 REPLIES 9
John-K
Meraki Employee
Meraki Employee

Hi @boomi ! If you already know the serial # for the MX you want to check, then you can filter to a single MX after you've run the API call.

 

E.g. in Python, using the SDK:

mx_selected_serial = 'ACTU_ALSE_RIAL'

mx_statuses = dashboard.appliance.getOrganizationApplianceUplinkStatuses( organization_id, total_pages='all' )

for mx_status in mx_statuses:
    if mx_status['serial'] == mx_selected_serial:
        selected_mx_status = mx_status

print(selected_mx_status['uplinks'])

 

This approach also substantially cuts down the number of API calls you would need to make, so if you are working in an org with a ton of appliances, you are less likely to hit the rate limit. Check out the template for the Python library here: https://developer.cisco.com/meraki/api-v1/#!get-organization-appliance-uplink-statuses

boomi
Getting noticed

Thanks for the example John, however I'm not able to avoid making a call for every MX I need to check. Granted the amount of 'waste' we're talking about is trivial, there should still be a filter available on this call. Caching is also not an option.

 

I understand v1 was just released, so I'm curious if the intent is to stick with bulk requests like this, or if targeted/filtered calls will be introduced down the road.

 

 

John-K
Meraki Employee
Meraki Employee

I might have misunderstood -- calling /organizations/$org_id/appliance/uplink/statuses is a single API call; the rest would be done client-side. What's happening that makes you need to make a call for every MX individually?

boomi
Getting noticed

I'm providing network monitoring with the API, and each firewall is a node that has its own 'instances' that are polled regularly. I can't make a single call and then distribute that data to each node.

John-K
Meraki Employee
Meraki Employee

Hm... Could each node pull all the data and discard what it doesn't need? Is this a fully custom app or built into an existing framework/product that has limitations you're working around?

boomi
Getting noticed

Sure can, and I do, it's just that I would prefer if I had a more direct way to make this query, like the v0 API, which allows a request for a specific MX.

 

Now I have to account not only for searching the data, but presumably pagination as well for sufficiently large organizations.

 

 

John-K
Meraki Employee
Meraki Employee

FYI @boomi you can now use a query param with this endpoint to specify one or more networkIds and your result will only contain those.

Here's an example format for the URI:

{{baseUrl}}/organizations/:organizationId/appliance/uplink/statuses?networkIds[]={{networkId1}}&networkIds[]={{networkId2}}

skyraven
Conversationalist

Hello @John-K,

 

could you give an example to the syntax of the NetworkIDs? Preferably for one ID at a time.

 

When I make the API call {{baseUrl}}/organizations/:organizationId/appliance/uplink/statuses?networkIds[]={{networkId1}} with Postman i get 

 

{
    "errors": [
        "'networkIds' must be an array"
    ]
}
 
Kind regards

Both of these work on my end:

 

{{baseUrl}}/organizations/:organizationId/uplinks/statuses?networkIds[]=L_restOfNetworkIdHere

 

{{baseUrl}}/organizations/:organizationId/appliance/uplink/statuses?networkIds[]=L_restOfNetworkIdHere

Get notified when there are additional replies to this discussion.