Hi,
Noob here, can someone point me to some example code on how to add a subnet under a parent folder, using python and the sdk?
Thanks,
John
I'm not that familiar with python, but the SDK wiki provides examples in PowerShell (what you are looking for is Create new subnet for Hierarchy group):
https://github.com/solarwinds/OrionSDK/wiki/IPAM-2019.4-and-higher-versions-API
Please see my below example to create a supernet in a hierarchyGroup.
if i[0] == 'Net_Type' and i[1] == 'Supernet':#~# Checking or Creating Subnet if not already existssubnetcheck = IPAMSubnetUri_Query(SWIS_Dict['Address'], SWIS_Dict['CIDR'])if str(subnetcheck['results']) != '[]':print('The Supernet [', SWIS_Dict['FriendlyName'], f'] already exists in the Hierarchy Group "{HierarchyGroup}" !')else:print('Creation of the Supernet [', SWIS_Dict['FriendlyName'], f'] in the Hierarchy Group "{HierarchyGroup}" ... ', end = '')invoke = swis.invoke('IPAM.SubnetManagement', 'CreateSubnetForGroup', SWIS_Dict['Address'], SWIS_Dict['CIDR'], HierarchyGroup)print('Done!')
#~# Getting URI after have created the Subnetsubnetquery = IPAMSubnetUri_Query(SWIS_Dict['Address'], SWIS_Dict['CIDR'])subnetUri = subnetquery['results'][0]['Uri']#~# Change Subnet (GroupType) for Supernetgrouptype = IPAMSubnetType_Query(SWIS_Dict['Address'], SWIS_Dict['CIDR'])if grouptype['results'][0]['GroupType'] == 8:print(f"Convert \"GroupType\" : 'Subnet' for 'Supernet' ... ", end = '')swis.update(subnetUri , GroupType=4)print('Done!')else: print('The Supernet [', SWIS_Dict['FriendlyName'], '] has already been converted from Subnet !')