Reply

Modify IPv4 Address with WAPI

New Member
Posts: 3
2895     2

 Hi,

 

Can I modify IPv4 Address with API ? 

 

I googled but most of my findings are says Its not possible to modify existing IP Addrs with API.

 

Thanks for help!

 

Regards

Re: Modify IPv4 Address with WAPI

[ Edited ]
Superuser
Posts: 38
2895     2

Hello,

 

Are you trying to modify an existing IP address assigned to a host record?

If thats what you want to do you can modify it using API

 

You can get the associated IP addresses for the host using API, get the _ref for the IP you want to modify, and then do a PUT request to modify the IP.


Example queries.

https://<grid-ip>/wapi/v2.10/record:host/ZG5zLmhvc3QkLl9kZWZhdWx0LmNvbS5pbmZvLmhvc3Qx:host1.info.com/default

 

Sample Output

{
        "_ref": "record:host/ZG5zLmhvc3QkLl9kZWZhdWx0LmNvbS5pbmZvLmhvc3Qx:host1.info.com/default",
        "ipv4addrs": [
            {
                "_ref": "record:host_ipv4addr/ZG5zLmhvc3RfYWRkcmVzcyQuX2RlZmF1bHQuY29tLmluZm8uaG9zdDEuMTAuMTAuMTAuMjEu:10.10.10.21/host1.info.com/default",
                "configure_for_dhcp": false,
                "host": "host1.info.com",
                "ipv4addr": "10.10.10.21"
            }
        ],
        "name": "host1.info.com",
        "view": "default"
    }


Example PUT request.

curl -L -X PUT 'https://<grid-ip>/wapi/v2.10/record:host_ipv4addr/ZG5zLmhvc3RfYWRkcmVzcyQuX2RlZmF1bHQuY29tLmluZm8uaG9zdDEuMTAuMTAuMTAuMjEu:10.10.10.21/host1.info.com/default' -H 'Content-Type: application/json' -H  --data-raw '{ "ipv4addr": "10.10.10.20" }'

 

Shukran

Re: Modify IPv4 Address with WAPI

New Member
Posts: 3
2895     2

Hi Shukran,

 

Thanks for reply. 

 

Can I Modify A record Ip Address ? I try to replace host with a record but i cannot run that .

 

Regards,

Re: Modify IPv4 Address with WAPI

Superuser
Posts: 17
2895     2

As Shukran said, you can modify the record by doing a PUT against that record. If it is an A-Record you want to modify (including IP Address), you will have to get the A-Record reference. (i.e. record:a/ZG5zLmJpbmRfYSQuX2RlZtLmJtYyxyZGV2cmllcywxMC4wLjAuNQ:test.mydomain.org/default).

If you're trying to modify a host record, you will need to get the host record reference.

 

I just tried changing the IP Address on one of my A-Records, and it works flawlessly with a PUT.

Re: Modify IPv4 Address with WAPI

New Member
Posts: 3
2895     2

Hi,

 

I understood the logic, I was getting an error because I wrote ipv4_addr after A record.

 

Thank you very much for your answers.

Showing results for 
Search instead for 
Did you mean: 

Recommended for You