DNS integrations

Create / Delete DNS record

createDnsRecord()

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

$dnsRecord

The DNS record class containing all information for dns record creation

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 createDnsRecord(IpamRdnsHost $ipamRdnsHost, string $zoneName, DnsRecordItem $dnsRecord) {
	$zoneName = $this->getZoneName($zoneName, $ipamRdnsHost);

	try {
		$response = $this->_sendRequest($ipamRdnsHost, "zones/{$zoneName}/dns_records", "POST", [
			"content" => $dnsRecord->content,
			"name" => $dnsRecord->hostname,
			"type" => $dnsRecord->type,
			"ttl" => $dnsRecord->ttl,
		]);

		return $response->result->id;
	} catch (ClientException $e) {
		throw new Exception($this->_getErrorMessage($e));
	}
}

Testing

You can test this function by answering a ticket as a customer.

deleteDnsRecord()

Gets executed when a customer deletes a dns record in the storefront.

The function is exactly the same as the creation.

Example Code

Was this helpful?