cloudways-js-client
Version:
A client library to power your applications with Cloudways API
1,603 lines (1,586 loc) • 177 kB
TypeScript
/**
* Represents a cloud provider.
*/
interface Provider {
id: string;
name: string;
}
/**
* Represents the response for getting a list of cloud providers.
*/
interface GetProviderListResponse {
providers: Provider[];
}
/**
* Represents a region.
*/
interface Region {
id: string;
name: string;
}
/**
* Represents the response for getting a list of regions.
*/
interface GetRegionListResponse {
regions: {
[provider: string]: Region[];
};
}
/**
* Represents the response for getting a list of server sizes.
*/
interface GetServerSizesListResponse {
sizes: {
[provider: string]: string[];
};
}
/**
* Represents a single app version.
*/
interface AppVersion {
app_version: string;
application: string;
}
/**
* Represents an app with its versions.
*/
interface AppInfo {
label: string;
versions: AppVersion[];
}
/**
* Represents the response for getting a list of apps.
*/
interface GetAppListResponse {
[appName: string]: AppInfo;
}
/**
* Represents a package with its versions.
*/
interface Package {
[version: string]: string;
}
/**
* Represents a list of available packages and versions.
*/
interface PackageList {
[packageName: string]: {
[os: string]: Package;
};
}
/**
* Represents the settings options.
*/
interface SettingsOptions {
[option: string]: string;
}
/**
* Represents the response for getting a list of settings.
*/
interface GetSettingsListResponse {
settings: {
[setting: string]: SettingsOptions;
};
}
/**
* Represents a backup frequency option.
*/
interface BackupFrequency {
id: string;
label: string;
}
/**
* Represents a country with its ISO code and name.
*/
interface Country {
iso: string;
name: string;
}
/**
* Represents the response for getting monitoring durations.
*/
interface GetMonitorDurationsResponse {
durations: string[];
}
/**
* Represents the response for getting monitor targets.
*/
interface GetMonitorTargetsResponse {
targets: {
[provider: string]: string[];
};
}
/**
* Represents a server size entry for a provider.
*/
interface ServerSize {
provider: string;
sizes: string[];
}
/**
* Represents a setting entry and its possible values.
*/
interface Setting {
setting: string;
values: string[];
}
/**
* Represents a server monitoring target for a provider.
*/
interface ServerMonitoringTarget {
provider: string;
targets: string[];
}
/**
* Gets a list of available apps and their versions.
* @returns {Promise<AppInfo[]>} A promise resolving with an array of apps and their versions.
* @example
* ```
* [
* {
* label: "WordPress",
* versions: [
* { app_version: "4.7", application: "wordpress" },
* ...
* ]
* },
* {
* label: "PHP Stack",
* versions: [
* { app_version: "5.4", application: "phpstack" },
* ...
* ]
* },
* ...
* ]
* ```
*/
declare function getAppList(): Promise<AppInfo[]>;
/**
* Gets possible backup frequencies.
* @returns {Promise<BackupFrequency[]>} A promise resolving with an array of backup frequencies.
* @example
* ```
* [
* { "id": "1h", "label": "1 Hour" },
* { "id": "3h", "label": "3 Hours" },
* ...
* ]
* ```
*/
declare function getBackupFrequencies(): Promise<BackupFrequency[]>;
/**
* Gets the list of countries.
* @returns {Promise<Country[]>} A promise resolving with the list of countries.
* @example
* ```
* // The API response is an empty object "{}" for countries.
* []
* ```
*/
declare function getCountriesList(): Promise<Country[]>;
/**
* Gets possible monitoring durations.
* @returns {Promise<string[]>} A promise resolving with monitoring durations.
* @example
* ```
* ["1 Hour", "12 Hours", "1 Day", "7 Days", "1 Month", "6 Months"]
* ```
*/
declare function getMonitorDurations(): Promise<string[]>;
/**
* Gets a list of server monitoring graph types.
* @returns {Promise<ServerMonitoringTarget[]>} A promise resolving with monitoring targets for each provider.
* @example
* ```
* [
* { provider: "amazon", targets: ["Idle CPU", "Free Disk (DB)", ...] },
* { provider: "do", targets: ["Idle CPU", "Free Disk", ...] },
* ...
* ]
* ```
*/
declare function getMonitorTargets(): Promise<ServerMonitoringTarget[]>;
/**
* Gets a list of available packages and their versions.
* @returns {Promise<PackageList>} A promise resolving with a list of packages and their versions.
* @example
* ```
* {
* "php": {
* "debian10": {
* "7.0": "PHP 7.0",
* "7.1": "PHP 7.1",
* ...
* },
* ...
* },
* "phpConfig": {
* "debian10": {
* "7.4": ["7.4", "8.0", ...],
* ...
* },
* ...
* },
* "mysql": {
* "debian10": {
* "mysql,5.7": "MySQL 5.7",
* ...
* },
* ...
* },
* "redis": {
* "0": "Uninstall",
* "latest": "Install"
* },
* ...
* }
* ```
*/
declare function getPackageList(): Promise<PackageList>;
/**
* Gets a list of available cloud providers.
* @returns {Promise<Provider[]>} A promise resolving with an array of cloud providers.
* @example
* ```
* [
* { "id": "do", "name": "DigitalOcean" },
* { "id": "vultr", "name": "Vultr" },
* ...
* ]
* ```
*/
declare function getProviderList(): Promise<Provider[]>;
/**
* Gets a list of regions.
* @returns {Promise<Region[]>} A promise resolving with an array of regions.
* @example
* ```
* [
* { "id": "us-east-1", "name": "US N.Virginia" },
* { "id": "us-west-1", "name": "California" },
* ...
* ]
* ```
*/
declare function getRegionList(): Promise<Region[]>;
/**
* Gets a list of server sizes available.
* @returns {Promise<ServerSize[]>} A promise resolving with an array of server sizes available for each provider.
* @example
* ```
* [
* { provider: "Amazon", sizes: ["Small", "Medium", ...] },
* { provider: "DO", sizes: ["512MB", "1GB", ...] },
* { provider: "GCE", sizes: ["small", "n1-std-1", ...] },
* { provider: "Vultr", sizes: ["768MB", "1GB", ...] },
* { provider: "Kyup", sizes: ["1 Core", "2 Cores", ...] },
* { provider: "Linode", sizes: ["1GB", "2GB", ...] }
* ]
* ```
*/
declare function getServerSizesList(): Promise<ServerSize[]>;
/**
* Gets a list of available settings and corresponding values.
* @returns {Promise<Setting[]>} A promise resolving with an array of settings and their possible values.
* @example
* ```
* [
* { setting: "timezone", values: ["Pacific/Midway", "Pacific/Samoa", ...] },
* { setting: "character_set", values: ["ascii", "greek", ...] },
* { setting: "status", values: [" ----", "Off", "On"] },
* { setting: "error_reporting", values: [" ----", "E_ALL & ~E_DEPRECATED & ~E_STRICT", ...] },
* { setting: "statuses", values: ["disabled", "enabled"] }
* ]
* ```
*/
declare function getSettingsList(): Promise<Setting[]>;
/**
* Represents the request parameters for getting an OAuth access token.
*/
interface GetOAuthAccessTokenRequest {
/**
* The email address used to access the Cloudways Platform.
*/
email: string;
/**
* The API key generated on the Cloudways Platform API Section.
*/
api_key: string;
}
/**
* Represents the response received after successfully obtaining an OAuth access token.
*/
interface GetOAuthAccessTokenResponse {
/**
* The access token used for authorization in subsequent API calls.
*/
access_token: string;
/**
* The type of the token, typically "Bearer".
*/
token_type: "Bearer";
/**
* The number of seconds until the access token expires due to inactivity.
*/
expires_in: number;
}
declare enum HttpMethod {
GET = "GET",
POST = "POST",
PUT = "PUT",
DELETE = "DELETE",
PATCH = "PATCH"
}
interface AuthToken {
token: string;
expiration: number;
}
/**
* Initializes the Cloudways API with user-provided configuration. This function
* sets up the necessary credentials for subsequent API calls. It accepts the user's
* email address and an API key generated from the Cloudways platform.
*
* This function should be called once to configure the library. After initial setup,
* the library will automatically handle token renewal, ensuring continued access
* to the Cloudways API without needing to reinitialize or manually refresh tokens.
*
* @param {string} email - The email address used to access the Cloudways Platform.
* @param {string} apiKey - The API key generated on the Cloudways Platform API Section.
* @returns {void}
*/
declare function initializeCloudwaysApi(email: string, apiKey: string): void;
/**
* Make an API call to Cloudways API.
* @param endpoint - The API endpoint to call.
* @param method - The HTTP method to use (default: HttpMethod.GET).
* @param data - The data to send in the request (if applicable).
* @returns {Promise<any>} - Promise resolving to the API response data.
* @throws {Error} if the API call fails.
*/
declare function apiCall(endpoint: string, method?: HttpMethod, data?: any): Promise<any>;
/**
* Represents the response structure for the create project API.
*/
interface CreateProjectResponse {
/**
* The project object.
*/
project: Project;
}
interface Project {
/**
* Unique identifier of the project.
*/
id: string;
/**
* Name of the project.
*/
name: string;
/**
* User ID associated with the project.
*/
user_id: string;
/**
* Indicates if this is the default project.
*/
is_default: string;
/**
* Date and time when the project was created.
*/
created_at: string;
/**
* Date and time when the project was last updated.
*/
updated_at: string;
/**
* Image associated with the project, if any.
*/
image?: string | null;
}
/**
* Represents the response structure for the get project list API.
*/
interface GetProjectListResponse {
/**
* Array of projects.
*/
projects: Project[];
}
/**
* Represents the response structure for the update project API.
*/
interface UpdateProjectResponse {
/**
* The updated project object.
*/
project: Project;
}
/**
* Creates a new project.
*
* @param name - The name of the new project.
* @param appIds - Comma-separated list of app IDs to attach to the project.
* @returns {Promise<Project>} A promise resolving to the details of the newly created project.
* @example
* ```
* // Example of a successful response:
* {
* "id": "1574",
* "name": "Project Name",
* "user_id": "12847",
* "is_default": "0",
* "created_at": "2016-07-13 13:28:58",
* "updated_at": "0000-00-00 00:00:00",
* "image": null
* }
* ```
*/
declare function createProject(name: string, appIds: string): Promise<Project>;
/**
* Deletes a project by its ID.
*
* @param id - The numeric ID of the project to delete.
* @returns A promise that resolves when the project is deleted.
*/
declare function deleteProject(id: number): Promise<void>;
/**
* Retrieves a list of all projects.
*
* @returns {Promise<Project[]>} A promise resolving to an array of project details.
* @example
* ```
* // Example of a successful response:
* [
* {
* "id": "1",
* "name": "Default project",
* "user_id": "123",
* "is_default": "1",
* "created_at": "2016-04-14 15:48:35",
* "image": "https://example.com/project_pic.png"
* }
* ]
* ```
*/
declare function getProjectList(): Promise<Project[]>;
/**
* Updates an existing project.
*
* @param id - The numeric ID of the project to update.
* @param name - The new name of the project.
* @param appIds - Comma-separated list of app IDs to attach to the project.
* @returns {Promise<Project>} A promise resolving to the updated project details.
* @example
* ```
* // Example of a successful response:
* {
* "id": "1574",
* "name": "Updated Project Name",
* "user_id": "12847",
* "is_default": "0",
* "created_at": "2016-07-13 13:28:58",
* "updated_at": "2024-01-01 12:00:00",
* "image": null
* }
* ```
*/
declare function updateProject(id: number, name: string, appIds: string): Promise<Project>;
interface OperationStatus {
id: string;
type: string;
server_id: string;
estimated_time_remaining: string;
frontend_step_number: string;
status: string;
is_completed: string;
parameters?: string;
message: string;
app_id: string;
}
/**
* Gets the status of an operation that is running in the background.
*
* @param id - The numeric ID of the operation.
* @returns {Promise<OperationStatus>} A promise resolving to the operation status details.
* @example
* ```
* {
* "operation": {
* "id": "596283",
* "type": "restarting_server",
* "server_id": "50482",
* "estimated_time_remaining": "2",
* "frontend_step_number": "1",
* "status": "Process is initiated",
* "is_completed": "0",
* "message": "Process is initiated",
* "app_id": "0"
* }
* }
* ```
*/
declare function getOperationStatus(id: string): Promise<OperationStatus>;
declare function getAndWaitForOperationStatusCompleted(operationId: string): Promise<OperationStatus>;
/**
* Start the process of adding an app to a server.
* @param {number} serverId Numeric id of the server.
* @param {string} application App to be installed (e.g., "wordpress", "joomla").
* @param {string} appLabel Name of the app.
* @param {string} projectName (Optional) Name of the project to tag the newly created app with.
* @returns {Promise<OperationStatus>} A promise resolving with the operation id.
* @example
* ```
*
* 12345
*
* ```
*/
declare function addApp(serverId: number, application: string, appLabel: string, projectName?: string): Promise<OperationStatus>;
/**
* Clone an app to the same server.
* @param {number} serverId Numeric id of the server.
* @param {number} appId Numeric id of the application.
* @param {string} appLabel Name of the app.
* @returns {Promise<OperationStatus>} A promise resolving with the cloned app's id and operation id.
* @example
* ```
* {
* "appId": 1111,
* "operationId": 12345
* }
* ```
*/
declare function cloneApp(serverId: number, appId: number, appLabel: string): Promise<OperationStatus>;
/**
* Clone an app to another existing server.
* @param {number} serverId Numeric id of the source server.
* @param {number} appId Numeric id of the application.
* @param {number} destinationServerId Numeric id of the destination server.
* @returns {Promise<OperationStatus>} A promise resolving with the source and destination operation ids along with the cloned app's id.
* @example
* ```
* {
* "sourceOperationId": 12345,
* "destinationOperationId": 12346,
* "appId": 1111
* }
* ```
*/
declare function cloneAppToOtherServer(serverId: number, appId: number, destinationServerId: number): Promise<OperationStatus>;
/**
* Clone a staging app to the same server.
* @param {number} serverId Numeric id of the server.
* @param {number} appId Numeric id of the staging application.
* @returns {Promise<OperationStatus>} A promise resolving with the cloned staging app's id and operation id.
* @example
* ```
* {
* "appId": 1111,
* "operationId": 12345
* }
* ```
*/
declare function cloneStagingApp(serverId: number, appId: number): Promise<OperationStatus>;
/**
* Clone a staging app to another existing server.
* @param {number} serverId Numeric id of the source server.
* @param {number} appId Numeric id of the staging application.
* @param {number} destinationServerId Numeric id of the destination server.
* @returns {Promise<OperationStatus>} A promise resolving with the operation ids and the cloned staging app's id.
* @example
* ```
* {
* "sourceOperationId": 12345,
* "destinationOperationId": 12346,
* "appId": 1111
* }
* ```
*/
declare function cloneStagingAppToOtherServer(serverId: number, appId: number, destinationServerId: number): Promise<OperationStatus>;
/**
* Start the process of removing an app.
* @param {number} serverId Numeric id of the server.
* @param {number} appId Numeric id of the application.
* @returns {Promise<OperationStatus>} A promise resolving with the operation id.
* @example
* ```
* 12345
* ```
*/
declare function DeleteApp(serverId: number, appId: number): Promise<OperationStatus>;
/**
* Update the label of an application.
* @param {number} appId Numeric id of the application.
* @param {number} serverId Numeric id of the server.
* @param {string} label New label of the application.
* @returns {Promise<boolean>} A promise resolving with a boolean indicating the update status.
* @example
* ```
* true
* ```
*/
declare function updateAppLabel(appId: number, serverId: number, label: string): Promise<boolean>;
/**
* Represents a server entry.
*/
interface Server {
id: string;
label: string;
status: string;
tenant_id: string;
backup_frequency: string;
local_backups: boolean;
is_terminated: string;
created_at: string;
updated_at: string;
platform: string;
cloud: string;
region: string;
zone: string | null;
instance_type: string;
db_volume_size: string | null;
data_volume_size: string | null;
server_fqdn: string;
public_ip: string;
volume_size: string;
master_user: string;
master_password: string;
snapshot_frequency: string | null;
apps: App[];
}
/**
* Represents an application entry.
*/
interface App {
id: string;
label: string;
application: string;
app_version: string;
app_fqdn: string;
app_user: string;
app_password: string;
sys_user: string;
sys_password: string;
cname: string;
mysql_db_name: string;
mysql_user: string;
mysql_password: string;
aliases: string[];
symlink: string | null;
server_id: string;
project_id: string;
created_at: string;
webroot: string | null;
is_csr_available: boolean;
lets_encrypt: string | null;
app_version_id: string;
cms_app_id: string;
}
interface DiskUsageResponse {
status: boolean;
operation_id: string;
}
/**
* Attaches block storage to a server.
* @param {number} serverId The numeric id of the server.
* @param {number} storageSize The size of the block storage to attach.
* @returns {Promise<OperationStatus>} A promise resolving with an object containing the operation id.
* @example
* ```
*
* 12345
*
* ```
*/
declare function attachBlockStorage(serverId: number, storageSize: number): Promise<OperationStatus>;
/**
* Clones a server.
* @param {number} sourceServerId The ID of the server to be cloned.
* @param {string} cloud Cloud provider (do, amazon, vultr, gce, or linode).
* @param {string} region Cloud region (nyc3, ams2, ...).
* @param {string} instanceType Instance type (512MB, Small, ...).
* @param {string} appLabel Name of the app.
* @param {number} applicationId ID of the application if you want to clone only a single app in the new server.
* @param {number} dbVolumeSize DB volume size on the server.
* @param {number} dataVolumeSize Data volume size on the server.
* @param {number} serverStorage Block storage size (only available for DO servers).
* @param {boolean} advanceClone Whether to clone server through the advance clone feature.
* @param {boolean} serverSettings Whether to copy the server's basic and advanced settings, disk optimization settings, security settings, and SMTP settings.
* @param {boolean} appDomains Whether to copy domain(s) of the application(s) along with the SSL certificate(s) from the source server.
* @param {boolean} appCrons Whether to copy the scheduled cron jobs for all application(s) from the source server to the new server.
* @param {boolean} appSupervisorJobs Whether to copy the supervisord cron jobs for all application(s) from the source server to the new server.
* @param {boolean} appSettings Whether to copy each application's general, php-fpm, varnish, and git configuration settings.
* @param {boolean} appCredentials Whether to copy the application credentials of each application(s) from the source server to the new server (if exist).
* @param {boolean} teamAccess Whether to copy the team access settings to the new server.
* @returns {Promise<OperationStatus>} A promise resolving with an object containing the operation id.
* @example
* ```
*
* 12345
*
* ```
*/
declare function cloneServer(sourceServerId: number, cloud: string, region: string, instanceType: string, appLabel: string, applicationId: number, dbVolumeSize: number, dataVolumeSize: number, serverStorage: number, advanceClone: boolean, serverSettings: boolean, appDomains: boolean, appCrons: boolean, appSupervisorJobs: boolean, appSettings: boolean, appCredentials: boolean, teamAccess: boolean): Promise<OperationStatus>;
/**
* Starts the process to create a server.
* @param {string} cloud Cloud provider (do, amazon, vultr, gce, or linode).
* @param {string} region Cloud region (nyc3, ams2, ...).
* @param {string} instanceType Instance type (512MB, Small, ...).
* @param {string} application App to be installed (wordpress, joomla, ...).
* @param {string} appVersion Version of the app to be installed.
* @param {string} serverLabel Name of the server.
* @param {string} appLabel Name of the app.
* @param {string} projectName Add this parameter when you want to create a project and tag this newly created app with it.
* @param {number} dbVolumeSize DB volume size on server (Only required for Amazon and GCE).
* @param {number} dataVolumeSize Data volume size on server (Only required for Amazon and GCE).
* @returns {Promise<Server>} A promise resolving with the server object.
* @example
* ```
* {
* "id" : "50710",
* "label" : "sadf",
* "status" : "",
* "tenant_id" : "1",
* "backup_frequency" : "1",
* "local_backups" : "no",
* "is_terminated" : "0",
* "created_at" : "2016-07-13 15:19:25",
* "updated_at" : "2016-07-13 15:19:25",
* "cloud" : "do",
* "region" : "lon1",
* "zone" : null,
* "instance_type" : "512MB",
* "db_volume_size" : null,
* "data_volume_size" : null,
* "server_fqdn" : "12847-50710.cloudwaysapps.com",
* "public_ip" : "",
* "volume_size" : "20",
* "master_user" : "asdfasdf",
* "master_password" : "asdfasdf",
* "platform" : "debian8",
* "ssh_keys" : [ ],
* "addons" : [ ],
* "operations" : [ {
* "id" : "596406",
* "type" : "add_server",
* "server_id" : "50710",
* "estimated_time_remaining" : "7",
* "frontend_step_number" : "1",
* "status" : "Process is initiated",
* "is_completed" : "0",
* "message" : "Process is initiated"
* } ]
* }
* ```
*/
declare function createServer(cloud: string, region: string, instanceType: string, application: string, appVersion: string, serverLabel: string, appLabel: string, projectName: string, dbVolumeSize: number, dataVolumeSize: number): Promise<Server>;
/**
* Starts the process to remove a server.
* @param {number} serverId Numeric id of the server to be removed.
* @returns {Promise<OperationStatus>} A promise resolving with the operation id.
* @example
* ```
*
* 12345
*
* ```
*/
declare function deleteServer(serverId: number): Promise<OperationStatus>;
/**
* Initiates a fetch disk usage operation for a server.
* @param {number} serverId Numeric id of the server.
* @returns {Promise<OperationStatus>} A promise resolving with the operation id.
* @example
* ```
* {
* "status": true,
* "operation_id": "ec7a2d1a-0a3d-4ed9-9523-315875618f54"
* }
* ```
*/
declare function getDiskUsage(serverId: number): Promise<OperationStatus>;
/**
* Gets the list of servers.
* @returns {Promise<Server[]>} A promise resolving with an array of server entries.
* @example
* ```
* [
* {
* id: "50482",
* label: "My Live Server",
* status: "running",
* tenant_id: "1",
* backup_frequency: "1",
* local_backups: false,
* is_terminated: "0",
* created_at: "2016-07-11 11:41:31",
* updated_at: "2016-07-13 14:07:47",
* platform: "debian8",
* cloud: "do",
* region: "lon1",
* zone: null,
* instance_type: "512MB",
* db_volume_size: null,
* data_volume_size: null,
* server_fqdn: "11111-50482.cloudwaysapps.com",
* public_ip: "11.62.111.11",
* volume_size: "20",
* master_user: "master_username",
* master_password: "password",
* snapshot_frequency: null,
* apps: [
* {
* id: "131933",
* label: "dsf",
* application: "wordpressmu",
* app_version: "4.5.2",
* app_fqdn: "wordpressmu-1442-50482-131933.cloudwaysapps.com",
* app_user: "user@domain.com",
* app_password: "asdfasdf",
* sys_user: "sys-user",
* sys_password: "password",
* cname: "",
* mysql_db_name: "password",
* mysql_user: "password",
* mysql_password: "password",
* aliases: [],
* symlink: null,
* server_id: "50482",
* project_id: "1574",
* created_at: "2016-07-11 11:41:31",
* webroot: null,
* is_csr_available: true,
* lets_encrypt: null,
* app_version_id: "545",
* cms_app_id: "23"
* }
* ]
* }
* ]
* ```
*/
declare function getServersList(): Promise<Server[]>;
/**
* Restarts the server.
* @param {number} serverId Numeric id of the server to be restarted.
* @returns {Promise<OperationStatus>} A promise resolving with the operation id.
* @example
* ```
*
* 12345
*
* ```
*/
declare function restartServer(serverId: number): Promise<OperationStatus>;
/**
* Scales block storage for a DigitalOcean server.
* @param {number} serverId Numeric id of the server.
* @param {number} storageSize New block storage size.
* @returns {Promise<number>} A promise resolving with the operation id.
* @example
* ```
*
* 12345
*
* ```
*/
declare function scaleBlockStorage(serverId: number, storageSize: number): Promise<OperationStatus>;
/**
* Scales volume size for Amazon and GCE servers.
* @param {number} serverId Numeric id of the server.
* @param {number} volumeSize New volume size.
* @param {string} volumeType Volume type.
* @returns {Promise<OperationStatus>} A promise resolving with the operation id.
* @example
* ```
*
* 12345
*
* ```
*/
declare function scaleVolumeSize(serverId: number, volumeSize: number, volumeType: string): Promise<OperationStatus>;
/**
* Starts the server.
* @param {number} serverId Numeric id of the server.
* @returns {Promise<OperationStatus>} A promise resolving with the operation id.
* @example
* ```
*
* 12345
*
* ```
*/
declare function startServer(serverId: number): Promise<OperationStatus>;
/**
* Stops the server.
* @param {number} serverId Numeric id of the server.
* @returns {Promise<OperationStatus>} A promise resolving with the operation id.
* @example
* ```
*
* 12345
*
* ```
*/
declare function stopServer(serverId: number): Promise<OperationStatus>;
/**
* Update server label.
* @param {number} serverId Numeric id of the server.
* @param {string} label New label of the server.
* @returns {Promise<{ status: boolean }>} A promise resolving with the status indicating success.
* @example
* ```
* {
* "status": true
* }
* ```
*/
declare function updateServerLabel(serverId: number, label: string): Promise<{
status: boolean;
}>;
/**
* Upgrade server instance type.
* @param {number} serverId Numeric id of the server.
* @param {string} instanceType New instance type (e.g., "512MB", "Small").
* @returns {Promise<OperationStatus>} A promise resolving with the operation id.
* @example
* ```
*
* 12345
*
* ```
*/
declare function upgradeServer(serverId: number, instanceType: string): Promise<OperationStatus>;
/**
* Create an SSH key for a server.
* @param {number} serverId Numeric id of the server.
* @param {string} sshKeyName Label for the SSH key.
* @param {string} sshKey The SSH key.
* @param {number} appCredsId Numeric id of the App Credentials (required for app level SSH keys).
* @returns {Promise<number>} A promise resolving with the id of the created SSH key.
* @example
* ```
* 1234
* ```
*/
declare function createSSHKey(serverId: number, sshKeyName: string, sshKey: string, appCredsId: number): Promise<number>;
/**
* Delete an SSH key from a server.
* @param {number} serverId Numeric id of the server.
* @param {number} sshKeyId Numeric id of the SSH key to delete.
* @returns {Promise<void>} A promise resolving when the SSH key is successfully deleted.
*/
declare function deleteSSHKey(serverId: number, sshKeyId: number): Promise<void>;
/**
* Update an SSH key on a server.
* @param {number} serverId Numeric id of the server.
* @param {number} sshKeyId Numeric id of the SSH key to update.
* @param {string} sshKeyName New label for the SSH key.
* @returns {Promise<void>} A promise resolving when the SSH key is successfully updated.
*/
declare function updateSSHKey(serverId: number, sshKeyId: number, sshKeyName: string): Promise<void>;
/**
* Get server bandwidth usage or disk size per application.
* @param {number} serverId Numeric id of the server.
* @param {string} type Possible values are "bw" for bandwidth usage of the server or "db" for application size on disk.
* @returns {Promise<{ name: string, datapoint: [number, number][], type: string }[]>} A promise resolving with the bandwidth usage or disk size per application.
*/
declare function getServerSummary(serverId: number, type: string): Promise<{
name: string;
datapoint: [number, number][];
type: string;
}[]>;
/**
* Get server usage.
* @param {number} serverId Numeric id of the server.
* @returns {Promise<OperationStatus>} A promise resolving with the operation id.
*/
declare function getServerUsage(serverId: number): Promise<OperationStatus>;
/**
* Get application disk usage.
* @param {number} serverId Numeric id of the server.
* @param {number} appId Numeric id of the app.
* @param {string} type String type (summary, disk, db, etc.).
* @returns {Promise<any>} A promise resolving with the application disk usage data.
*/
declare function getApplicationDiskUsage(serverId: number, appId: number, type: string): Promise<any>;
/**
* Get application disk usage graph (Deprecated).
* @param {number} serverId Numeric id of the server.
* @param {string} appId System user of the application.
* @param {string} timezone String of the server timezone.
* @param {number} target String of the target (cpuiddle, memory, etc.).
* @param {number} duration Integer of the duration.
* @returns {Promise<any>} A promise resolving with the application disk usage graph data.
*/
declare function getApplicationDiskUsageGraph(serverId: number, appId: string, timezone: string, target: number, duration: number): Promise<any>;
/**
* Get application traffic analytics.
* @param {number} serverId Numeric id of the server.
* @param {number} appId Numeric id of the app.
* @param {string} duration String duration (e.g., "15m", "30m", "1h", "1d").
* @param {string} resource String type ("top_ips", "top_bots", "top_urls", "top_statuses").
* @returns {Promise<any>} A promise resolving with the application traffic analytics data.
*/
declare function getApplicationTrafficAnalytics(serverId: number, appId: number, duration: string, resource: string): Promise<any>;
/**
* Get application traffic details.
* @param {number} serverId Numeric id of the server.
* @param {number} appId Numeric id of the app.
* @param {string} from Start time in the format "DD/MM/YYYY HH:mm".
* @param {string} until End time in the format "DD/MM/YYYY HH:mm".
* @param {string[]} resourceList Array of resources returned from the traffic call (e.g., ["127.0.0.1", "192.168.1.1"]).
* @returns {Promise<any>} A promise resolving with the application traffic details.
*/
declare function getApplicationTrafficDetail(serverId: number, appId: number, from: string, until: string, resourceList: string[]): Promise<any>;
/**
* Get PHP information.
* @param {number} serverId Numeric id of the server.
* @param {number} appId Numeric id of the app.
* @param {string} duration String duration (e.g., "15m", "30m", "1h", "1d").
* @param {string} resource String type ("url_durations", "processes", "slow_pages").
* @returns {Promise<any>} A promise resolving with the PHP information.
*/
declare function getPHPInformation(serverId: number, appId: number, duration: string, resource: string): Promise<any>;
/**
* Get MySQL information.
* @param {number} serverId Numeric id of the server.
* @param {number} appId Numeric id of the app.
* @param {string} duration String duration (e.g., "15m", "30m", "1h", "1d").
* @param {string} resource String resource ("running_queries", "slow_queries").
* @returns {Promise<any>} A promise resolving with the MySQL information.
*/
declare function getMySQLInformation(serverId: number, appId: number, duration: string, resource: string): Promise<any>;
/**
* Get application cron information.
* @param {number} serverId Numeric id of the server.
* @param {number} appId Numeric id of the app.
* @returns {Promise<any>} A promise resolving with the application cron information.
*/
declare function getApplicationCron(serverId: number, appId: number): Promise<any>;
/**
* Search for queries in the Knowledge Base.
* @param {string} query The string to search in the Knowledge Base.
* @returns {Promise<{ articles: { guid: string, post_title: string }[], articles_found: number, status: number }>} A promise resolving with the search results.
*/
declare function searchKnowledgeBase(query: string): Promise<{
articles: {
guid: string;
post_title: string;
}[];
articles_found: number;
status: number;
}>;
/**
* Represents the response received after activating an addon on account level.
*/
interface ActivateAddonAccountLevelResponse {
/**
* A message indicating the success or result of the activation process.
*/
message: string;
/**
* Additional information about the activated addon, if applicable.
*/
sub: {
/**
* The ID of the user addon.
*/
id_user_addons: string;
/**
* The status of the addon activation.
*/
status: string;
/**
* The ID of the package associated with the addon, if any.
*/
id_package: number | string | null;
};
}
/**
* Represents the response received after deactivating an addon.
*/
interface DeactivateAnAddonResponse {
/**
* A message indicating the success or result of the deactivation process.
*/
message: string;
/**
* Additional information about the deactivated addon, if applicable.
*/
sub: {
/**
* The ID of the user addon.
*/
id_user_addons: string;
/**
* The status of the addon deactivation.
*/
status: number;
};
}
interface AddonList {
id: string;
label: string;
custom_field_1: string | null;
name: string;
external_link: string;
vendor: string;
binding: string;
form: string;
incompatible: number[] | null;
view_type: string;
sort_order: string;
packages: {
[key: string]: {
id_package: string;
id_addons: string;
package_name: string;
period: string;
package_price: string;
addon_limit: string;
sort_order: string;
};
};
}
interface AddonsListResponse {
addons: {
[key: string]: AddonList;
};
}
/**
* Interface for the response of upgrading an addon package.
*/
interface UpgradeAddonResponse {
message: string;
sub: {
id_user_addons: string;
status: string;
id_package: string;
};
}
/**
* Interface for the response containing domain details.
*/
interface ElasticEmailDomainsResponse {
status: boolean;
data: {
domains: {
domain: string;
spf: boolean;
mx: boolean;
dkim: boolean;
dmarc: boolean;
tracking: boolean;
}[];
};
}
/**
* Interface for the response to verify elastic email domain
*/
interface verifyEmailDomainResponse {
status: boolean;
data: {
domain: string;
spf: boolean;
mx: boolean;
dkim: boolean;
dmarc: boolean;
tracking: boolean;
};
}
/**
* Activates an add-on on a specified server, especially applicable for SMTP add-ons.
* @param {number} serverId - The numeric ID of the server where the add-on will be activated.
* @param {number} addonId - The numeric ID of the add-on to be activated.
* @param {string} username - The username required for SMTP add-ons.
* @param {string} password - The password required for SMTP add-ons.
* @param {string} mode - The mode required for SMTP add-ons. Allowed values are 'enable' or 'update'.
* @param {string} provider - The SMTP provider to be selected.
* @param {string} host - The host required for SMTP add-ons.
* @param {string} port - The port required for SMTP add-ons.
* @returns {Promise<void>} A promise that resolves when the add-on is successfully activated.
* @example
* ```
* []
*
* ```
*/
declare function activateAddOnServer(serverId: number, addonId: number, username: string, password: string, mode: string, provider: string, host: string, port: string): Promise<void>;
/**
* Activates an addon on the account level.
* @param {number} addonId - The numeric ID of the addon to be activated.
* @param {number} packageId - The package ID. Not necessary in case of SMTP addon.
* @returns {Promise<ActivateAddonAccountLevelResponse>} A promise that resolves to the response containing information about the activated addon.
* @example
* {
"message" : "Your Own SMTP has been successfully enabled.",
"sub" : {
"id_user_addons" : "1234",
"status" : "1",
"id_package" : null
}
}
*/
declare function activateAddonOnAccountLevel(addonId: number, packageId: number): Promise<ActivateAddonAccountLevelResponse>;
/**
* Requests an addon for a specific application.
* @param {number} addonId - The numeric ID of the addon to be requested.
* @param {number} serverId - The numeric ID of the server where the application resides.
* @param {number} appId - The numeric ID of the application to which the addon will be added.
* @param {number} version - The desired version of the application. Required only for Application Upgradation Add-on.
* @returns {Promise<void>} A promise that resolves when the addon request is successful.
* @example
* ```
* []
*
* ```
*/
declare function addonRequestForApplication(addonId: number, serverId: number, appId: number, version: number): Promise<void>;
/**
* Deactivates an addon on a specified server.
* @param {number} serverId - The numeric ID of the server where the addon will be deactivated.
* @param {number} addonId - The numeric ID of the addon to be deactivated.
* @returns {Promise<void>} A promise that resolves when the addon deactivation is successful.
* @example
* ```
* []
*
* ```
*/
declare function deactivateAddOnYourServer(serverId: number, addonId: number): Promise<void>;
/**
* Deactivates an addon on the specified server.
* @param {number} serverId - The ID of the server where the addon will be deactivated.
* @param {number} addonId - The ID of the addon to deactivate.
* @returns {Promise<DeactivateAnAddonResponse>} A promise that resolves to the response containing information about the deactivated addon.
* @example
* ```
* {
"message" : "Your Own SMTP has been successfully deactivated.",
"sub" : {
"id_user_addons" : "1234",
"status" : 0
}
}
* ```
*/
declare function deactivateAnAddon(addonId: number): Promise<DeactivateAnAddonResponse>;
/**
* Retrieve the list of addons from the Cloudways API.
* @returns {Promise<AddonsListResponse>} - Promise resolving to the list of addons.
*/
declare function getAddonsList(): Promise<AddonsListResponse>;
/**
* Upgrade an addon package.
* @param addonId - The numeric id of the addon.
* @param packageId - The ID of the package to subscribe to.
* @returns {Promise<UpgradeAddonResponse>} - Promise resolving to the response of upgrading an addon package.
* @example
* {
"message" : "DNS Made Easy request has been successfully received. Our 24/7 support will contact you in a while with further details.",
"sub" : {
"id_user_addons" : "1234",
"status" : "2",
"id_package" : "7"
}
}
*
*/
declare function upgradeAddonPackage(addonId: number, packageId: number): Promise<UpgradeAddonResponse>;
/**
* Get the list of Elastic Email domains.
* @returns {Promise<ElasticEmailDomainsResponse>} - Promise resolving to the response containing domain details.
* @example
* {
* "status": true,
* "data": {
* "domains": [
* {
* "domain": "indoorplants.pk",
* "spf": false,
* "mx": true,
* "dkim": false,
* "dmarc": false,
* "tracking": false
* }
* ]
* }
* }
*/
declare function getElasticEmailDomains(): Promise<ElasticEmailDomainsResponse>;
/**
* Verify an Elastic Email domain.
* @param {string} domain - The domain to verify.
* @returns {Promise<verifyEmailDomainResponse>} - Promise resolving to the response of verifying the domain.
* @example
* {
"status": true,
"data": {
"domain": "indoorplants.pk",
"spf": false,
"mx": true,
"dkim": false,
"dmarc": false,
"tracking": false
}
}
*/
declare function verifyElasticEmailDomain(domain: string): Promise<verifyEmailDomainResponse>;
/**
* Deletes an Elastic Email domain.
* @param {string} domain - The domain to delete.
* @returns {Promise<{status: boolean, message: string}>} - A promise that resolves to an object containing the status and message of the deletion.
* @example
* {
"status": true,
"message": "Domain successfully deleted"
}
*/
declare function deleteElasticEmailDomain(domain: string): Promise<{
status: boolean;
message: string;
}>;
/**
* Interface for the response of getting application backup status.
*/
interface AppBackupStatusResponse {
/**
* Indicates the status of the backup operation.
*/
status: boolean;
/**
* The ID associated with the backup operation.
*/
operation_id: number;
/**
* Index signature to handle unknown properties.
*/
[key: string]: any;
}
/**
* Interface for the response containing information about App Credentials.
*/
interface AppCredentialsResponse {
app_creds: {
id: string;
sys_password: string;
sys_user: string;
ssh_keys: {
label: string;
ssh_key_id: string;
}[];
}[];
}
/**
* Interface for the response containing SSH access status.
*/
interface SSHAccessStatusResponse {
response: {
ssh_status: {
[appId: string]: boolean;
};
};
}
/**
* Interface for the response containing application access status.
*/
interface ApplicationAccessStateResponse {
response: {
app_status: {
[appId: string]: boolean;
};
};
status: boolean;
}
/**
* Interface for the response of getting the cron list.
*/
interface CronListResponse {
basic: {
cmd_type: string;
command: string;
days: string;
hours: string;
minutes: string;
months: string;
weekdays: string;
}[];
script: string;
}
/**
* Interface for the response containing FPM settings.
*/
interface FpmSettingsResponse {
response: {
fpm_enabled: boolean;
settings: string;
};
}
/**
* Interface for the response containing Varnish settings.
*/
interface VarnishSettingsResponse {
response: {
varnish_app_enabled: boolean;
varnish_enabled: boolean;
vcl_list: {
method: string;
type: string;
value: string;
}[];
};
}
/**
* Interface for the response to get app setting value
*/
interface getAppSettingResponse {
status: boolean;
application_id: string;
from_address: string | null;
cors_header: number;
enforce_https: number;
}
/**
* Interface for the response to update app geo Ip Header status.
*/
interface UpdateGeoIpHeaderResponse {
response: {
geo_ip: {
[key: string]: boolean;
};
};
status: boolean;
}
/**
* Interface for the response to update App XMLRPC Header status.
*/
interface UpdateAppXMLRPCHeaderResponse {
response: {
xml_rpc: {
[key: string]: boolean;
};
};
status: boolean;
}
/**
* Change the access state of an application on a server.
* @param {number} serverId - The ID of the server.
* @param {number} appId - The ID of the application.
* @param {string} state - The new state to set for the application.
* @returns {Promise<void[]>} - Promise resolving to an empty array upon successful state change.
* @example
* []
*/
declare function changeAppAccessState(serverId: number, appId: number, state: string): Promise<void[]>;
/**
* Retrieve the backup status of an application.
* @param {number} serverId - The numeric ID of the server.
* @param {number} appId - The numeric ID of the application.
* @returns {Promise<OperationStatus>} - Promise resolving to an object containing the backup status.
* The backup status object includes a boolean indicating the status and an operation ID
* And it could sometimes return additional properties
* @example
* {
* "status": true,
* "operation_id": 123456
* }
* Operation polling will return backup_dates (An array of restore points available for the app)
* and local_backup_exists (a local backup created before restorinig the app)
*/
declare function getAppBackupStatus(serverId: number, appId: number): Promise<OperationStatus>;
/**
* Create new application credentials.
* @param {number} serverId - The numeric ID of the server.
* @param {number} appId - The numeric ID of the application.
* @param {string} username - The new username.
* @param {string} password - The new password.
* @returns {Promise<{app_cred_id: number}>} - Promise resolving to an object containing the ID of the created app credential.
* @example
* {
* "app_cred_id": 12345
* }
*/
declare function createAppCredentials(serverId: number, appId: number, username: string, password: string): Promise<{
app_cred_id: number;
}>;
/**
* Delete an application credential.
* @param {number} serverId - The numeric ID of the server.
* @param {number} appId - The numeric ID of the application.
* @param {number} appCredId - The numeric ID of the application credential to delete.
* @returns {Promise<void[]>} - Promise indicating the success of the operation.
* @example
* []
* The response is an empty array.
*/
declare function deleteAppCredential(serverId: number, appId: number, appCredId: number): Promise<void[]>;
/**
* Delete CNAME records associated with an application.
* @param {number} serverId - The numeric ID of the server.
* @param {number} appId - The numeric ID of the application.
* @returns {Promise<OperationStatus>} - Promise resolving to an object containing the operation ID.
* The operation ID indicates the status of the delete operation.
* @example
* {
* "operation_id": 123456
* }
*/
declare function deleteCname(serverId: number, appId: number): Promise<OperationStatus>;
/**
* Delete a local backup associated with an application.
* @param {number} serverId - The numeric ID of the server.
* @param {number} appId - The numeric ID of the application.
* @returns {Promise<OperationStatus>} - Promise resolving to an object containing the operation ID.
* The operation ID indicates the status of the delete operation.
* @example
* {
* "operation_id": 123456
* }
*/
declare function deleteLocalBackup(serverId: number, appId: number): Promise<OperationStatus>;
/**
* Retrieve all available App Credentials.
* @param {number} serverId - The numeric ID of the server.
* @param {number} appId - The numeric ID of the application.
* @returns {Promise<AppCredentialsResponse>} - Promise resolving to an object containing information about App Credentials.
* @example
* {
* "app_creds" : [ {
* "id" : "12345",
* "sys_password" : "12345678",
* "sys_user" : "abc12345",
* "ssh_keys" : [ {
* "label" : "new ssh key",
* "ssh_key_id" : "111"
* } ]
* } ]
* }
*/
declare function getAppCredentials(serverId: number, appId: number): Promise<AppCredentialsResponse>;
/**
* Get the SSH access status for the application.
* @param {number} serverId - The numeric ID of the server.
* @param {number} appId - The numeric ID of the application.
* @returns {Promise<SSHAccessStatusResponse>} - Promise resolving to an object containing the SSH access status.
* @example
* {
* response: {
* ssh_status: {
* "abcdefgh": true
* }
* }
* }
*/
declare function getApplicationSshAccessStatus(serverId: number, appId: number): Promise<SSHAccessStatusResponse>;
/**
* Get the application access state.
* @param {number} serverId - The numeric ID of the server.
* @param {number} appId - The numeric ID of the application.
* @returns {Promise<ApplicationAccessStateResponse>} - Promise resolving to an object containing the application access status.
* @example
* {
* response: {
* app_status: {
* "a