- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Python dictionary to list
Hi everyone,
this is more basic python, but I stuck with this problem:
When I get the data of an ssid, the response is always a dictionary ('name' : 'something, ' number' : 22...) from Meraki which is fine.
But if I want to update the ssid, it has to be done in a form of name = 'something, number = '22'...
How do you convert this?
I don't want to hard code the config, I just want to change one of the values.
Thanks and best
Fabian
Solved! Go to solution.
- Labels:
-
Dashboard API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@PhilipDAthIs correct and this is probably the easiest way to do it.
A simple for loop through networks and ssids will get you through the data you need to change. Something like the below.
nets = meraki.organizations.getOrganizationNetworks(organizationId)
for net in nets:
ssids = meraki.wireless.getNetworkWirelessSsids(net['id'])
for ssid in ssids:
if ssid['name'] == "something":
ssid.update({'psk' : 'newpassword'}) # use the update() function when working with dictionaries. #
ssidChange = meraki.wireless.updateNetworkWirelessSsid(net['id'], **ssid) # the double * (**) will unpack the dictionary and allow you to post the full dictionary as the new variables. Be careful with this as you may get a return value that won't post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Iterate through the dictionary and test each row for the value you are looking for (such as SSID) and then change that one row.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@PhilipDAthIs correct and this is probably the easiest way to do it.
A simple for loop through networks and ssids will get you through the data you need to change. Something like the below.
nets = meraki.organizations.getOrganizationNetworks(organizationId)
for net in nets:
ssids = meraki.wireless.getNetworkWirelessSsids(net['id'])
for ssid in ssids:
if ssid['name'] == "something":
ssid.update({'psk' : 'newpassword'}) # use the update() function when working with dictionaries. #
ssidChange = meraki.wireless.updateNetworkWirelessSsid(net['id'], **ssid) # the double * (**) will unpack the dictionary and allow you to post the full dictionary as the new variables. Be careful with this as you may get a return value that won't post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The **ssid and ssid.update did the trick, this is awsome, thank you guys 🙂
