REST API-based provisioning in complex network environments


I have a requirement for API based provisioning in my organization. We use
PXE and ip-helpers to relay DHCP across VLAN's.
In our organization we have 25 geographical sites, each site may have up to
20 class C VLAN's. I am looking for an optimal way to utilize API to
provision across all sites.

Initially, for my Foreman POC, I used API call without Hostgroups property,
as below:

curl -s -H "Accept:application/json"
-k -u admin:xxx
-d "host[name]=linux-node-xxx"
-d "host[mac]=00:50:56:99:08:f7"
-d "host[ip]="
-d "host[architecture_id]=1"
-d "host[environment_id]=1"
-d "host[operatingsystem_id]=1"
-d "host[domain_id]=1"
-d "host[subnet_id]=1"
-d "host[ptable_id]=9"
-d "host[medium_id]=5"
-d "host[root_pass]=xxx"
-d "host[build]=1"

The above works, but real complication is, if I have 20 locations, I need
to build a mapping for ID's, because I can't use corresponding values in
the API call.

Then I discovered the Hostgroup, that allowed to pre-define majority of the
properties and embed them into Hostgroup object. I was able to shrink the
above request down to:

curl -s -H "Accept:application/json"
-k -u admin:changeme
-d "host[hostgroup_id]=1"
-d "host[name]=linux-node-xxx"
-d "host[mac]=00:50:56:99:08:f7"
-d "host[root_pass]=xxx"
-d "host[build]=1"

However, this doesn't scale either, as I can't map multiple Subnets or
Smart-Proxy to the Hostgroup. Given that single Subnet can be mapped to the
Hostgroup, I will need to create few hundred Hostgroups to cover my network
topology across all sites. Yet again, I need to hold the mapping between ID
and the name somewhere.

The way I see it is to either allow mapping multiple Subnets to the
Hostgroup, or do it through Proxy. If you know any other way to do API
based provisioning across large number of sites/VLAN's, could you share it?