Nice Work 😃 is there any reason, why you did this as a seperate project and not into the python library itself? I thought about something similiar with the "(async) with" statement directly into the api. when I take your example: for network in target_networks:
new_ssid_name = xp.generate_xkcdpassword(random_word_list, numwords=3)
action1 = dashboard.batch.wireless.updateNetworkWirelessSsid(network['id'], 0, name=new_ssid_name)
action_list_1.append(action1)
new_network_name = xp.generate_xkcdpassword(random_word_list, numwords=5)
action2 = dashboard.batch.networks.updateNetwork(network['id'], name=new_network_name)
action_list_2.append(action2)
action3 = dashboard.batch.networks.updateNetwork(network['id'], timeZone="America/Los_Angeles")
action_list_3.append(action3)
all_actions.extend(action_list_1)
all_actions.extend(action_list_2)
all_actions.extend(action_list_3)
print(len(all_actions))
test_helper = batch_helper.BatchHelper(dashboard, organization_id, all_actions, linear_new_batches=True, actions_per_new_batch=50)
test_helper.prepare()
test_helper.generate_preview()
test_helper.execute() it would become something like this: with meraki.batch_helper(dashboard, organization_id, all_actions, linear_new_batches=True, actions_per_new_batch=50, generate_preview=True) as test_helper:
for network in target_networks:
test_helper.set_group(0) # should be executed in the first batch group
new_ssid_name = xp.generate_xkcdpassword(random_word_list, numwords=3)
dashboard.batch.wireless.updateNetworkWirelessSsid(network['id'], 0, name=new_ssid_name)
test_helper.set_group(1) # should be executed after group 0 is finished
new_network_name = xp.generate_xkcdpassword(random_word_list, numwords=5)
dashboard.batch.networks.updateNetwork(network['id'], name=new_network_name)
test_helper.set_group(2) # should be executed after group 1 is finished
dashboard.batch.networks.updateNetwork(network['id'], timeZone="America/Los_Angeles") normally I would have used 3 different batches with 3 loops, but I think a set_group (which would be a different list in the backend like in your example) looks definitely better. I think it should also be possible to create different settings per group. e.g. running group 2 as parallel batches after group 1 has been finished. the test_helper.prepare/generate_preview/execute methods would be called inside of BatchHelper.__a/exit__() to make this work, we would have to update the generator config for the batches, so that they will do an internal call to test_helper.add_batch(my_batch)
... View more