I have selected an UNASSIGNED ip address, and I want to assign it. I think this means basically two steps: Creating an A record and creating a PTR record (it seems there might be a 3rd step to do first, create the IP address object). Since creating an A record is something we’ll want to do sometimes even when we’re not assigning a new IP, I figured I would start by trying to accomplish the task: Simply write a method to create an A record.
def record_a_create(self, views, fqdn, ipaddresses, change_control_comment = None):
views is a list of strings, e.g. `[‘internal’,’external’]`
fqdn is a str, e.g. “foobar.example.com”
I have a method that takes a fqdn and searches to find which zone(s) that fqdn should be in, so I can POST to zone(s).
ipaddresses is a list of either str, e.g. [‘192.168.1.1’, ‘192.168.1.2’]
I think I need to, for each view, look up its ID. (No problem). And then to create the A record via:
POST /api/v2/views/{view_id}/resourceRecords
{
"type": "HostRecord",
"name": "fqdn",
"addresses": [
{
"id": ipaddress['id'],
"type": "IPv4Address"
},
… if there’s more than one ip address
]
}
This implies there must already exist an ipaddress[‘id’], but of course there doesn’t, because the ipaddress is previously UNASSIGNED.
So really I need to start by creating the ipaddress object:
There is no POST /api/v2/addresses.
The closest thing seems to be POST /api/v2/networks/{networkID}/addresses
So this leads me to ask….. How can I figure out what network an IP address *would* exist in, if the IP address were to exist?
Or am I simply going about this all wrong?