Update DNS record
updateDnsRecord()
Gets executed when a customer creates a dns record in the storefront.
Parameters
Type | Name | Description |
|---|---|---|
IpamRdnsHost | $ipamRdnsHost, | The DNS host |
String | $zoneName | The zone name |
DnsRecordItem | $originalDnsRecord | The DNS record BEFORE |
DnsRecordItem | $updatedDnsRecord | The new, updated DNS record. |
Response
No response.
Throwing an Exception() will display a generic error message: Throwing a StorefrontException() will display the exact message to the customer.
Example Code
public function updateDnsRecord(IpamRdnsHost $ipamRdnsHost, string $zoneName, DnsRecordItem $originalDnsRecord, DnsRecordItem $updatedDnsRecord) {
$zoneName = $this->getZoneName($zoneName, $ipamRdnsHost);
try {
$this->_sendRequest($ipamRdnsHost, "zones/{$zoneName}/dns_records/{$originalDnsRecord->id}", "PUT", [
"content" => $updatedDnsRecord->content,
"name" => $updatedDnsRecord->hostname,
"type" => $updatedDnsRecord->type,
"ttl" => $updatedDnsRecord->ttl,
]);
} catch (ClientException $e) {
throw new Exception($this->_getErrorMessage($e));
}
}Testing
You can test this function by updating a dns record as a customer.
Was this helpful?