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.
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 Plesk API call.
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 Plesk API 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.
You can perform CRUD operations on Plesk objects using Plesk API. Plesk supports two types of API: REST API, and also a legacy XML API. We recommend that you use REST API for integrating with Plesk whenever possible. Only use XML API if you find the capabilities of REST API insufficient.
You interact with REST API by sending API requests. A request represents
an HTTP method sent to a specific URL. The HTTP method varies depending
on the action you want to perform (for example, POST to create a new
object or DELETE to remove the object). The URL contains a so-called API
endpoint that varies depending on the Plesk object you interact with
/client for Plesk users). With certain requests, you
also need to send data.
After sending a request, you receive a response. It usually contains the information you have requested and an HTTP status code. In REST API, data sent in requests and received in responses have the JSON format.
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.
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.
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.
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.