This topic describes using the CLI to understand the Python APIs.

The command line interface is a direct translation of the web services API to an interactive environment. This allows you to use the CLI to explore functionality with tab completion, integrated help, stronger type checking, and indication of expected types and required fields. When trying to determine how to invoke an operation through the Python API or interpret the results, it is recommended that you first learn how to do the same through the CLI, and then use the provided tools to translate that into Python calls.


The Delphix Python API is available through PyPI and you may install it with pip.

pip install delphixpy

Minimum Python version

Requiring Version 2.7 and above.

Connecting to the Delphix Engine

In the Delphix Python API, all operations take an engine object which represents your connection to a Delphix Engine. Here is how you connect to the Delphix Engine using the Python API and acquire the engine object.

from delphixpy.delphix_engine import DelphixEngine
engine = DelphixEngine("delphix-address", "delphix-user", "delphix-password", "DOMAIN")  # Instead of DOMAIN, use SYSTEM if you are using the sysadmin user.

CLI Translation to Python

For backwards compatibility purposes, delphixpy provides the ability to write integrations against a specific API version. The latest version is always in the root of the package. Writing against the latest version requires you to update your integrations if the API changes in future versions of the API.

Specific API versions can be used by importing the corresponding sub package. The sub packages are named after the API versions in the format v<major>_<minor>_<micro>. For example, if you want to look into API 1.5.0, you should be using modules from delphixpy.v1_5_0. Modules from different sub package versions cannot interact with each other so be careful if you wish to mix API versions in the same code base.

All CLI namespaces have a corresponding Python package in which operations can be accessed. The main Python package is called web. All value objects which can be manipulated or read through the CLI can be found in web.vo.

delphix> database provision

Is equivalent to:

from delphixpy.web import database
database.provision(engine, provision_parameters)

The provision_parameters object in this example is an instance of ProvisionParameters which can be found in delphixpy.web.vo. The properties of the object maps to the parameters you would need to specify before doing a commit in the CLI provision context.

This is an example of an "operation", as they are invoked on an object. Operations that are invoked on a particular object takes a reference to that object.

delphix> database "dexample" refresh

Is equivalent to (connection code omitted):

from delphixpy.web import database
database.refresh(engine, "ORACLE_DB_CONTAINER-3")

While the CLI uses names to refer to objects, the Python API, just like the web services, use references (ORACLE_DB_CONTAINER-3). Persistent objects (those with a permanent unique identity) have a reference field that is used in all cases to refer to the object. This allows references to remain constant even if objects are renamed.

For the standard CRUD (create, read, update, delete) operations, the mapping is slightly different:

CLI OperationPython API
group listgroup.get_all(engine)
group creategroup.create(engine, group=<delphixpy.web.vo.Group>)
group "dexample" getgroup.get(engine, <reference>)
group "dexample" updategroup.update(engine, <reference>, group=<delphixpy.web.vo.Group>)
group "dexample" deletegroup.delete(engine, <reference>)

Example: Creating a Group

This is how you can create a group as a fully working example.

from delphixpy.web import group
from delphixpy.web.vo import Group
from delphixpy.delphix_engine import DelphixEngine
engine = DelphixEngine("delphix-address", "delphix-user", "delphix-password", "DOMAIN")
my_group = Group() = "My Group"
my_group.description = "This is my new group!"
group.create(engine, my_group)

Asynchronous Mode

The Python API runs by default in synchronous mode. If you would wish to perform operations asynchronously there is a context manager that allows you to do that. If you need to track job progress in asynchronous mode, you can get the reference of the last job started from engine.last_job. When exiting the async context manager, it will wait for all jobs started within the context to finish. You can also clear the job from the context so that you do not wait for its completion or status when exiting the context manager.  If a job fails, exceptions.JobError will be thrown.

Here is how you would perform a sync operation on all databases asynchronously.

from delphixpy.delphix_engine import DelphixEngine
from delphixpy import job_context
from delphixpy.web import database
engine = DelphixEngine("delphix-address", "delphix-user", "delphix-password", "DOMAIN")
all_databases = database.get_all(engine)
with job_context.async(engine):
    for db in all_databases:
        database.sync(engine, db.reference)