def fmcapi_post_bulk(fmc, post_data): # Bulk POST of network groups api_path = '/object/networkgroups?bulk=true' post_resp = fmc.send_to_api(method='post', url=fmc.configuration_url+api_path, json_data=post_data) return post_resp with FMC(**myfmc) as fmc1: bulk_post = [] objgrp1 = NetworkGroups(fmc1, name='TEST-objgrp1', dry_run=True) objgrp1.unnamed_networks(action='add', value='10.10.10.0/24') objgrp1.named_networks(action='add', name='PYTHON-TEST-NET') objgrp1.named_networks(action='addgroup', name='PYTON-TEST-GRP') bulk_post.append(objgrp1.format_data()) objgrp2 = NetworkGroups(fmc1, name='TEST-objgrp2', dry_run=True) objgrp2.unnamed_networks(action='add', value='1.1.1.1') objgrp2.unnamed_networks(action='add', value='2.2.2.2') bulk_post.append(objgrp2.format_data()) post_resp = fmcapi_post_bulk(fmc1, bulk_post)