DNS-Integrationen

DNS-Eintrag erstellen / löschen

createDnsRecord()

Wird ausgeführt, wenn ein Kunde im Storefront einen DNS-Eintrag erstellt.

Parameter

Typ

Name

Beschreibung

IpamRdnsHost

$ipamRdnsHost,

Der DNS-Host

String

$zoneName

Der Zonenname

DnsRecordItem

$dnsRecord

Die DNS-Eintragsklasse mit allen Informationen zur Erstellung eines DNS-Eintrags

Antwort

Keine Antwort.

Wenn Du eine Exception() auslöst, wird eine generische Fehlermeldung angezeigt: Wenn Du eine StorefrontException() auslöst, wird dem Kunden die genaue Meldung angezeigt.

Beispielcode

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));
	}
}

Testen

Du kannst diese Funktion testen, indem Du als Kunde ein Ticket beantwortest.

deleteDnsRecord()

Wird ausgeführt, wenn ein Kunde im Storefront einen DNS-Eintrag löscht.

Die Funktion ist genau dieselbe wie bei der Erstellung.

Beispielcode

public function deleteDnsRecord(IpamRdnsHost $ipamRdnsHost, string $zoneName, DnsRecordItem $dnsRecord) {
	$zoneName = $this->getZoneName($zoneName, $ipamRdnsHost);

	try {
		$this->_sendRequest($ipamRdnsHost, "zones/{$zoneName}/dns_records/{$dnsRecord->id}", "DELETE");
	} catch (ClientException $e) {
		throw new Exception($this->_getErrorMessage($e));
	}
}
War das hilfreich?