The following programming language examples are just to show the bare minimum authentication and a sample functional API call. There are numerous modules, libraries, methods, functions, and code examples to further demonstrate how the languages work with the Delphix APIs and JSON data strings/objects.

You can execute PHP, Perl, and Python languages from the command line and/or from within a Web Server such as Apache or IIS. The following examples are formatted for command line / terminal output.

PHP

PHP provides cURL and JSON modules.

$ php -i | grep -iE "cURL|json"
curl
cURL support => enabled
cURL Information => 7.43.0
json
json support => enabled
json version => 1.2.1 


Filename: delphix_curl.php

Sample Output:

$ php -f delphix_curl.php
Session json> {"type":"APISession","version":{"type":"APIVersion","major":1,"minor":7,"micro":0}} 
Session Results> {"type":"OKResult","status":"OK","result":{"type":"APISession","version":{"type":"APIVersion","major":1,"minor":7,"micro":0},"locale":null,"client":null},"job":null,"action":null} 
Login json> {"type":"LoginRequest","username":"delphix_admin","password":"delphix"} 
Login Results> {"type":"OKResult","status":"OK","result":"USER-2","job":null,"action":null} 
Calling About API ...
About Results> {"type":"OKResult","status":"OK","result":{"type":"PublicSystemInfo","productType":"standard","productName":"Delphix Engine","buildTitle":"Delphix Engine 5.1.1.0","buildTimestamp":"2016-07-21T07:23:41.000Z","buildVersion":{"type":"VersionInfo","major":5,"minor":1,"micro":1,"patch":0},"configured":true,"enabledFeatures":["XPP","MSSQLHOOKS"],"apiVersion":{"type":"APIVersion","major":1,"minor":8,"micro":0},"banner":null,"locales":["en-US"],"currentLocale":"en-US"},"job":null,"action":null} 
Converting json string to a PHP Array 
stdClass Object
(
	[type] => OKResult
	[status] => OK
	[result] => stdClass Object
		(
			[type] => PublicSystemInfo
			[productType] => standard
			[productName] => Delphix Engine
			[buildTitle] => Delphix Engine 5.1.1.0
			[buildTimestamp] => 2016-07-21T07:23:41.000Z
			[buildVersion] => stdClass Object
				(
					[type] => VersionInfo
					[major] => 5
					[minor] => 1
					[micro] => 1
					[patch] => 0
				)
			[configured] => 1
			[enabledFeatures] => Array
				(
					[0] => XPP
					[1] => MSSQLHOOKS
				) 

			[apiVersion] => stdClass Object
				(
					[type] => APIVersion
					[major] => 1
					[minor] => 8
					[micro] => 0
				) 
			[banner] => 
			[locales] => Array
				(
					[0] => en-US
				) 
			[currentLocale] => en-US
		) 
	[job] => 
	[action] => 
) 

Perl

Perl provides a couple of methods for working with cURL: operating system calls, WWW::Curl (libcurl) module, or LWP::Curl module. The sample below simply logs into the Delphix Engine and lists the current Delphix Environments.

Filename: perl_curl.pl

Sample Output:

$ perl perl_curl.pl
Testing cURL on Perl ...

Session Results: {"type":"OKResult","status":"OK","result":{"type":"APISession","version":{"type":"APIVersion","major":1,"minor":7,"micro":0},"locale":null,"client":null},"job":null,"action":null} 
Login Results: {"type":"OKResult","status":"OK","result":"USER-2","job":null,"action":null} 


Enviornment Results: {"type":"ListResult","status":"OK","result":[{"type":"WindowsHostEnvironment","reference":"WINDOWS_HOST_ENVIRONMENT-7","namespace":null,"name":"Window Target","description":null,"primaryUser":"HOST_USER-7","enabled":false,"host":"WINDOWS_HOST-6","proxy":null},{"type":"UnixHostEnvironment","reference":"UNIX_HOST_ENVIRONMENT-9","namespace":null,"name":"Oracle Target","description":"","primaryUser":"HOST_USER-9","enabled":true,"host":"UNIX_HOST-8","aseHostEnvironmentParameters":null}],"job":null,"action":null,"total":2,"overflow":false} 


Done 

Python

Delphix has an extensive resource library for using Python with the Delphix Engine.

https://docs.delphix.com/display/DOCS/CLI+to+Python+Transition

Delphix python module

Blogs

https://github.com/CloudSurgeon/delphixpy-examples

Related Videos

Simple Python program to authenticate and get the "about" API results. This script requires the "request" and "json" modules.

http://stackoverflow.com/questions/17309288/importerror-no-module-named-requests

Filename: auth.py

Sample Output

$ python auth.py
Authenticating URL http://172.16.160.195/resources/json/delphix ... 
{"type":"OKResult","status":"OK","result":{"type":"APISession","version":{"type":"APIVersion","major":1,"minor":7,"micro":0},"locale":null,"client":null},"job":null,"action":null}
Login ... 
{"type":"OKResult","status":"OK","result":"USER-2","job":null,"action":null}
About ... 
{"type":"OKResult","status":"OK","result":{"type":"PublicSystemInfo","productType":"standard","productName":"Delphix Engine","buildTitle":"Delphix Engine 5.1.1.0","buildTimestamp":"2016-07-21T07:23:41.000Z","buildVersion":{"type":"VersionInfo","major":5,"minor":1,"micro":1,"patch":0},"configured":true,"enabledFeatures":["XPP","MSSQLHOOKS"],"apiVersion":{"type":"APIVersion","major":1,"minor":8,"micro":0},"banner":null,"locales":["en-US"],"currentLocale":"en-US"},"job":null,"action":null}
JSON Parsing Examples ...
OK
Delphix Engine 5.1.1.0
1

JSP (Java Server Pages)


Java Server Pages are typically used for the web formatting and output, but you can also use JSP for application logic processing and native Java code integration, although this is scorned by the purest and most logical thinking programmers.

Filename: delphix_http.jsp

Sample Output:

Browser URL: http://localhost:8080/delphix_http.jsp


Java


Java methods and classes allow coding logic to be effectively re-used, extended and modularized for flexible applications. Using the Java code embedded within the JSP file, code is logically placed into respective classes and methods.


The Delphix Database Self Service demo application was created using Java with a JSP front end that makes native Java HTTP calls. This code is included in the Landshark environments that include the Employee and Medical Records application.