Integration and Automation Capabilities
This chapter provides a bird's eye view of Plesk integration capabilities. Using these, you can control Plesk objects, react to Plesk events, make your applications available to Plesk users, and build own GUI into Plesk. In this chapter, we will briefly mention each of the integration capabilities and give our recommendations on when to use them.
Performing Create, Read, Update, Delete (CRUD) Operations on Plesk Objects
A typical integration task is to manage Plesk objects (service plans, customer accounts, and so on) more quickly, bypassing the Plesk GUI. This task is relevant to administrators who manage a number of Plesk servers and wish to automate day-to-day operations. It is also important for integrators who need to set up relations between objects in Plesk and their application. There are two ways to complete the task:
- Make an appropriate Command Line Interface (CLI) call.
- Make an appropriate XML API call.
CRUD operations from CLI
CLI is a set of utilities that perform almost all operations on Plesk objects from the command line. A popular use of this interface is to replace typical GUI operations with utility calls, create shell scripts, and run them on demand. To call one of the utilities, you should have administrative permissions on Plesk server.
Each CLI utility specializes in operations on a certain Plesk object (for example, a customer account) and has a specific syntax. You can learn about the syntax either from the built-in help or from the corresponding documentation.
Learn more about how to get started using CLI in the chapter Command-Line Interface (CLI).
The major limitation of CLI is that you can only use it from a local server and only on behalf of the administrator. Alternatively, use the XML API protocol if you require more flexibility, for example:
- Work with a remote Plesk server.
- Manage objects located on several Plesk servers at the same time.
- Run operations on behalf of a reseller or a customer.
CRUD operations from XML API
The XML API protocol allows you to manipulate Plesk objects by exchanging XML-structured packets with Plesk. Each operation in XML API is presented as an XML structure that you send to a certain HTTP endpoint. Plesk receives the operation request, processes it, and also responds with an XML-structured packet. Each such response includes an operation status and operation-related details. For example, if you request information about a customer account, the account details will be returned in XML.
An operation request packet also includes information about a Plesk user on behalf of whom the operation is performed. This lets you automate the routines of any Plesk user.
Every operation available through CLI is also available through XML API. This makes XML API a more powerful tool, though the protocol implementation assumes programming efforts on your part (you should write a client application that sends and receives XML-over-HTTP packets).
Learn more about how to get started using XML API in the XML API Protocol chapter.
Monitoring Plesk Events by Using Event Handlers
Another typical integration task is to react to a particular operation on a Plesk object. Examples of when such a reaction is important are as follows:
Keep the app and Plesk objects synced.
For example, if your application needs to have the same list of customer accounts as Plesk does, you should track the creation of customer accounts and create a new account every time Plesk creates one.
Generate custom statistics and notifications.
For instance, one may need to receive an email each time a service utilized by Plesk is stopped.
To track Plesk operations and react correspondingly, employ event handlers.
An event handler is a link between a particular operation and an instruction: when Plesk completes the operation, it runs the linked instruction. The operation list is vast, so you can control almost all business logic operations. The instruction to trigger is usually a script or a binary. Depending on the operation, the instruction receives environmental variables that contain information about an operation target (Plesk object) "before" and "after" the operation. For example, the environment variables keep "old" and "new" customer account names in case the account name was changed.
Learn more about how to get started using event handlers in the Event Handlers chapter.
Receiving Notifications About Changes in Subscriptions, Sites, and Email Accounts with Plesk Notifications
The other way for you to integrate an application into Plesk is to register it as an additional service. Such services are assigned to service plans and receive notifications about changes to plans instances - subscriptions and related objects (sites and email accounts). Registration is advisable only if you want to track these changes. For example, mail processing software should register in Plesk Notifications to track changes in the email account names of subscribers. In other words, Plesk Notifications is an extension of the event handler mechanism.
Learn more in Plesk Notifications.
Deliver Your Application as APS Package
When a web application is ready to market, the most convenient way for vendors to distribute the app is by adding it to the APS Catalog. The catalog is a part of Plesk where customers can find an application and install it to their website. This ability to present third-party software in Plesk might be interesting to integrators especially if their application uses Plesk resources and has peculiarities in deployment and maintenance.
APS - Application Packaging Standard - is a set of rules that regulates web application installation, updates, licensing, and removal. If you make your application APS-compatible, you will not need to worry about application delivery because Plesk will carry out all the installation and maintenance operations for you.
Learn more about how to get started with APS packaging in the APS Packages chapter.
For complete information about APS packaging, refer to http://doc.apsstandard.org/_downloads/package-format-specification-12.pdf.
Plesk Database Scheme
To manage Plesk objects with one of the described methods, you need to know the structure of the Plesk database objects. The Plesk database scheme is provided in the three formats. For more details, refer to the Plesk Database Scheme chapter.
Build Your App into the Plesk GUI as an Extension
A Plesk extension, as the name suggests, is a third-party software that adds new functionality to Plesk. The former name of Plesk extensions is modules. On one hand, these solutions access information about Plesk entities, particularly, user accounts, and, on the other hand, they provide their own tools to help administrators and customers communicate with each other.
Extensions are written in PHP and their organization reuses Zend framework practices to a large extent. For more details about developing extension, refer to the separate guide Developing Extensions for Plesk.