From c169e5846574b946f72d498447830ee3bde0c564 Mon Sep 17 00:00:00 2001
From: Jesse Norell <jesse@kci.net>
Date: Tue, 28 Apr 2020 16:01:57 -0600
Subject: [PATCH] add dns_naptr_* api examples

---
 remoting_client/examples/dns_naptr_add.php    | 58 +++++++++++++++++++
 remoting_client/examples/dns_naptr_delete.php | 45 ++++++++++++++
 remoting_client/examples/dns_naptr_get.php    | 45 ++++++++++++++
 remoting_client/examples/dns_naptr_update.php | 53 +++++++++++++++++
 4 files changed, 201 insertions(+)
 create mode 100644 remoting_client/examples/dns_naptr_add.php
 create mode 100644 remoting_client/examples/dns_naptr_delete.php
 create mode 100644 remoting_client/examples/dns_naptr_get.php
 create mode 100644 remoting_client/examples/dns_naptr_update.php

diff --git a/remoting_client/examples/dns_naptr_add.php b/remoting_client/examples/dns_naptr_add.php
new file mode 100644
index 0000000000..5abd220d1b
--- /dev/null
+++ b/remoting_client/examples/dns_naptr_add.php
@@ -0,0 +1,58 @@
+<?php
+
+require 'soap_config.php';
+
+$context = stream_context_create([
+	'ssl' => [
+		// set some SSL/TLS specific options
+		'verify_peer' => false,
+		'verify_peer_name' => false,
+		'allow_self_signed' => true
+	]
+]);
+
+
+$client = new SoapClient(null, array('location' => $soap_location,
+		'uri'      => $soap_uri,
+		'trace' => 1,
+		'exceptions' => 1,
+		'stream_context' => $context));
+
+
+try {
+	if($session_id = $client->login($username, $password)) {
+		echo 'Logged successfull. Session ID:'.$session_id.'<br />';
+	}
+
+	$timestamp = date("Y-m-d H:i:s");
+
+	//* Set the function parameters.
+	$client_id = 1;
+	$params = array(
+		'server_id' => 1,
+		'zone' => 10,
+		'name' => 'server',
+		'type' => 'naptr',
+		'data' => '100 "s" "thttp+L2R" "" thttp.example.com.',
+		'aux' => '100',
+		'ttl' => '3600',
+		'active' => 'y',
+		'stamp' => $timestamp,
+		'serial' => '1',
+	);
+
+	$id = $client->dns_naptr_add($session_id, $client_id, $params);
+
+	echo "ID: ".$id."<br>";
+
+	if($client->logout($session_id)) {
+		echo 'Logged out.<br />';
+	}
+
+
+} catch (SoapFault $e) {
+	echo $client->__getLastResponse();
+	die('SOAP Error: '.$e->getMessage());
+}
+
+?>
diff --git a/remoting_client/examples/dns_naptr_delete.php b/remoting_client/examples/dns_naptr_delete.php
new file mode 100644
index 0000000000..ca252132f0
--- /dev/null
+++ b/remoting_client/examples/dns_naptr_delete.php
@@ -0,0 +1,45 @@
+<?php
+
+require 'soap_config.php';
+
+$context = stream_context_create([
+	'ssl' => [
+		// set some SSL/TLS specific options
+		'verify_peer' => false,
+		'verify_peer_name' => false,
+		'allow_self_signed' => true
+	]
+]);
+
+
+$client = new SoapClient(null, array('location' => $soap_location,
+		'uri'      => $soap_uri,
+		'trace' => 1,
+		'exceptions' => 1,
+		'stream_context' => $context));
+
+
+try {
+	if($session_id = $client->login($username, $password)) {
+		echo 'Logged successfull. Session ID:'.$session_id.'<br />';
+	}
+
+	//* Parameters
+	$id = 11;
+
+
+	$affected_rows = $client->dns_naptr_delete($session_id, $id);
+
+	echo "Number of records that have been deleted: ".$affected_rows."<br>";
+
+	if($client->logout($session_id)) {
+		echo 'Logged out.<br />';
+	}
+
+
+} catch (SoapFault $e) {
+	echo $client->__getLastResponse();
+	die('SOAP Error: '.$e->getMessage());
+}
+
+?>
diff --git a/remoting_client/examples/dns_naptr_get.php b/remoting_client/examples/dns_naptr_get.php
new file mode 100644
index 0000000000..db9dffde9b
--- /dev/null
+++ b/remoting_client/examples/dns_naptr_get.php
@@ -0,0 +1,45 @@
+<?php
+
+require 'soap_config.php';
+
+
+$context = stream_context_create([
+	'ssl' => [
+		// set some SSL/TLS specific options
+		'verify_peer' => false,
+		'verify_peer_name' => false,
+		'allow_self_signed' => true
+	]
+]);
+
+
+$client = new SoapClient(null, array('location' => $soap_location,
+		'uri'      => $soap_uri,
+		'trace' => 1,
+		'exceptions' => 1,
+		'stream_context' => $context));
+
+
+try {
+	if($session_id = $client->login($username, $password)) {
+		echo 'Logged successfull. Session ID:'.$session_id.'<br />';
+	}
+
+	//* Set the function parameters.
+	$id = 11;
+
+	$dns_record = $client->dns_naptr_get($session_id, $id);
+
+	print_r($dns_record);
+
+	if($client->logout($session_id)) {
+		echo 'Logged out.<br />';
+	}
+
+
+} catch (SoapFault $e) {
+	echo $client->__getLastResponse();
+	die('SOAP Error: '.$e->getMessage());
+}
+
+?>
diff --git a/remoting_client/examples/dns_naptr_update.php b/remoting_client/examples/dns_naptr_update.php
new file mode 100644
index 0000000000..9b0784a69d
--- /dev/null
+++ b/remoting_client/examples/dns_naptr_update.php
@@ -0,0 +1,53 @@
+<?php
+
+require 'soap_config.php';
+
+
+$context = stream_context_create([
+	'ssl' => [
+		// set some SSL/TLS specific options
+		'verify_peer' => false,
+		'verify_peer_name' => false,
+		'allow_self_signed' => true
+	]
+]);
+
+
+$client = new SoapClient(null, array('location' => $soap_location,
+		'uri'      => $soap_uri,
+		'trace' => 1,
+		'exceptions' => 1,
+		'stream_context' => $context));
+
+
+try {
+	if($session_id = $client->login($username, $password)) {
+		echo 'Logged successfull. Session ID:'.$session_id.'<br />';
+	}
+
+	//* Parameters
+	$id = 11;
+	$client_id = 1;
+
+
+	//* Get the dns record
+	$dns_record = $client->dns_naptr_get($session_id, $id);
+
+	//* Change active to inactive
+	$dns_record['active'] = 'n';
+
+	$affected_rows = $client->dns_naptr_update($session_id, $client_id, $id, $dns_record);
+
+	echo "Number of records that have been changed in the database: ".$affected_rows."<br>";
+
+	if($client->logout($session_id)) {
+		echo 'Logged out.<br />';
+	}
+
+
+} catch (SoapFault $e) {
+	echo $client->__getLastResponse();
+	die('SOAP Error: '.$e->getMessage());
+}
+
+?>
-- 
GitLab