UNPKG

cloudways-js-client

Version:

A client library to power your applications with Cloudways API

1,778 lines (1,756 loc) 63.2 kB
// src/services/core/index.ts import axios from "axios"; // src/services/core/types.ts var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => { HttpMethod2["GET"] = "GET"; HttpMethod2["POST"] = "POST"; HttpMethod2["PUT"] = "PUT"; HttpMethod2["DELETE"] = "DELETE"; HttpMethod2["PATCH"] = "PATCH"; return HttpMethod2; })(HttpMethod || {}); // src/services/core/index.ts var config = { email: "", api_key: "" }; var authToken = null; function initializeCloudwaysApi(email, apiKey) { config = { email, api_key: apiKey }; } async function getNewToken() { if (!config.email || !config.api_key) { throw new Error( "Configuration is incomplete. Please initialize with email and api_key." ); } try { const response = await axios.post( "https://api.cloudways.com/api/v1/oauth/access_token", config ); authToken = { token: response.data.access_token, expiration: Date.now() + (response.data.expires_in - 300) * 1e3 }; } catch (error) { throw new Error( `Error getting new token: ${error instanceof Error ? error.message : String(error)}` ); } } async function apiCall(endpoint, method = "GET" /* GET */, data = null) { if (!authToken || Date.now() >= authToken.expiration) { await getNewToken(); } if (!authToken) { throw new Error("No API token available."); } try { const response = await axios({ url: `https://api.cloudways.com/api/v1${endpoint}`, method, headers: { Authorization: `Bearer ${authToken.token}` }, data }); return response.data; } catch (error) { throw new Error( `API call failed: ${error instanceof Error ? error.message : String(error)}` ); } } // src/services/Lists/index.ts function getAppList() { return apiCall("/apps").then((response) => { const appList = []; for (const app in response.apps) { appList.push({ label: app, versions: response.apps[app] }); } return appList; }); } function getBackupFrequencies() { return apiCall("/backup-frequencies").then( (response) => response.frequencies ); } function getCountriesList() { return apiCall("/countries").then((response) => response); } function getMonitorDurations() { return apiCall("/monitor_durations").then((response) => response.durations); } function getMonitorTargets() { return apiCall("/monitor_targets").then((response) => { const monitorTargetsList = []; for (const provider in response) { monitorTargetsList.push({ provider, targets: response[provider] }); } return monitorTargetsList; }); } function getPackageList() { return apiCall("/packages"); } function getProviderList() { return apiCall("/providers").then((response) => response.providers); } function getRegionList() { return apiCall("/regions").then((response) => { const regionsArray = Object.values(response.regions).flat(); return regionsArray; }); } function getServerSizesList() { return apiCall("/server_sizes").then((response) => { const serverSizesList = []; for (const provider in response.sizes) { serverSizesList.push({ provider, sizes: response.sizes[provider] }); } return serverSizesList; }); } function getSettingsList() { return apiCall("/settings").then((response) => { const settingsList = []; for (const setting in response.settings) { settingsList.push({ setting, values: Object.keys(response.settings[setting]) }); } return settingsList; }); } // src/services/projects/index.ts async function createProject(name, appIds) { const data = { name, app_ids: appIds }; return apiCall("/project", "POST" /* POST */, data).then( (response) => response.project ); } async function deleteProject(id) { return apiCall(`/project/${id}`, "DELETE" /* DELETE */); } async function getProjectList() { return apiCall("/project").then((response) => response.projects); } async function updateProject(id, name, appIds) { const data = { name, app_ids: appIds }; return apiCall(`/project/${id}`, "PUT" /* PUT */, data).then( (response) => response.project ); } // src/utils.ts var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); // src/services/operation/index.ts function getOperationStatus(id) { return apiCall(`/operation/${id}`, "GET" /* GET */).then( (response) => response.operation ); } async function getAndWaitForOperationStatusCompleted(operationId) { let operationStatus = await getOperationStatus(operationId); while (operationStatus.is_completed !== "1") { const waitTime = operationStatus.estimated_time_remaining ? parseInt(operationStatus.estimated_time_remaining) * 6e4 : 5e3; await sleep(waitTime); operationStatus = await getOperationStatus(operationId); } return operationStatus; } // src/services/application/index.ts async function addApp(serverId, application, appLabel, projectName) { const data = { server_id: serverId, application, app_label: appLabel, project_name: projectName || "" }; const req = await apiCall("/app", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function cloneApp(serverId, appId, appLabel) { const data = { server_id: serverId, app_id: appId, app_label: appLabel }; const req = await apiCall("/app/clone", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function cloneAppToOtherServer(serverId, appId, destinationServerId) { const data = { server_id: serverId, app_id: appId, destination_server_id: destinationServerId }; const req = await apiCall("/app/cloneToOtherServer", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function cloneStagingApp(serverId, appId) { const data = { server_id: serverId, app_id: appId }; const req = await apiCall("/staging/app/cloneApp", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.destination_operation_id); } async function cloneStagingAppToOtherServer(serverId, appId, destinationServerId) { const data = { server_id: serverId, app_id: appId, destination_server_id: destinationServerId }; const req = await apiCall("/staging/app/cloneToOtherServer", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.destination_operation_id); } async function DeleteApp(serverId, appId) { const req = await apiCall(`/app/${appId}`, "DELETE" /* DELETE */, { server_id: serverId }); return await getAndWaitForOperationStatusCompleted(req.operation_id); } function updateAppLabel(appId, serverId, label) { const data = { server_id: serverId, label }; return apiCall(`/app/${appId}`, "PUT" /* PUT */, data).then( (response) => response.status ); } // src/services/server/index.ts async function attachBlockStorage(serverId, storageSize) { const requestData = { server_id: serverId, server_storage: storageSize }; const req = await apiCall("/server/attachStorage", "POST" /* POST */, requestData); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function cloneServer(sourceServerId, cloud, region, instanceType, appLabel, applicationId, dbVolumeSize, dataVolumeSize, serverStorage, advanceClone, serverSettings, appDomains, appCrons, appSupervisorJobs, appSettings, appCredentials, teamAccess) { const requestData = { source_server_id: sourceServerId, cloud, region, instance_type: instanceType, app_label: appLabel, application_id: applicationId, db_volume_size: dbVolumeSize, data_volume_size: dataVolumeSize, server_storage: serverStorage, advance_clone: advanceClone, server_settings: serverSettings, app_domains: appDomains, app_crons: appCrons, app_supervisor_jobs: appSupervisorJobs, app_settings: appSettings, app_credentials: appCredentials, team_access: teamAccess }; const req = await apiCall("/server/cloneServer", "POST" /* POST */, requestData); return await getAndWaitForOperationStatusCompleted(req.operation_id); } function createServer(cloud, region, instanceType, application, appVersion, serverLabel, appLabel, projectName, dbVolumeSize, dataVolumeSize) { const requestData = { cloud, region, instance_type: instanceType, application, app_version: appVersion, server_label: serverLabel, app_label: appLabel, project_name: projectName, db_volume_size: dbVolumeSize, data_volume_size: dataVolumeSize }; return apiCall("/server", "POST" /* POST */, requestData).then( (response) => response.server ); } async function deleteServer(serverId) { const req = await apiCall(`/server/${serverId}`, "DELETE" /* DELETE */); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function getDiskUsage(serverId) { const req = await apiCall(`/server/${serverId}/diskUsage`); return await getAndWaitForOperationStatusCompleted(req.operation_id); } function getServersList() { return apiCall("/server").then((response) => response.servers); } async function restartServer(serverId) { const req = await apiCall("/server/restart", "POST" /* POST */, { server_id: serverId }); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function scaleBlockStorage(serverId, storageSize) { const req = await apiCall("/server/scaleStorage", "POST" /* POST */, { server_id: serverId, server_storage: storageSize }); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function scaleVolumeSize(serverId, volumeSize, volumeType) { const req = await apiCall("/server/scaleVolume", "POST" /* POST */, { server_id: serverId, volume_size: volumeSize, volume_type: volumeType }); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function startServer(serverId) { const req = await apiCall("/server/start", "POST" /* POST */, { server_id: serverId }); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function stopServer(serverId) { const req = await apiCall("/server/stop", "POST" /* POST */, { server_id: serverId }).then( (response) => response.operation_id ); return await getAndWaitForOperationStatusCompleted(req.operation_id); } function updateServerLabel(serverId, label) { return apiCall(`/server/${serverId}`, "PUT" /* PUT */, { label }); } async function upgradeServer(serverId, instanceType) { const req = await apiCall(`/server/scaleServer`, "POST" /* POST */, { server_id: serverId, instance_type: instanceType }); return await getAndWaitForOperationStatusCompleted(req.operation_id); } // src/services/ssh-keys/index.ts function createSSHKey(serverId, sshKeyName, sshKey, appCredsId) { const data = { server_id: serverId, ssh_key_name: sshKeyName, ssh_key: sshKey, app_creds_id: appCredsId }; return apiCall("/ssh_key", "POST" /* POST */, data).then( (response) => response.id ); } function deleteSSHKey(serverId, sshKeyId) { const endpoint = `/ssh_key/${sshKeyId}`; const data = { server_id: serverId }; return apiCall(endpoint, "DELETE" /* DELETE */, data); } function updateSSHKey(serverId, sshKeyId, sshKeyName) { const endpoint = `/ssh_key/${sshKeyId}`; const data = { server_id: serverId, ssh_key_name: sshKeyName }; return apiCall(endpoint, "PUT" /* PUT */, data); } // src/services/monitor-analytic/index.ts function getServerSummary(serverId, type) { const data = { server_id: serverId, type }; return apiCall("/server/monitor/summary", "GET" /* GET */, data).then( (response) => response.content ); } async function getServerUsage(serverId) { const data = { server_id: serverId }; const req = await apiCall( "/server/analytics/serverUsage", "GET" /* GET */, data ); return await getAndWaitForOperationStatusCompleted(req.operation_id); } function getApplicationDiskUsage(serverId, appId, type) { const data = { server_id: serverId, app_id: appId, type }; return apiCall("/app/monitor/summary", "GET" /* GET */, data); } function getApplicationDiskUsageGraph(serverId, appId, timezone, target, duration) { const data = { server_id: serverId, app_id: appId, timezone, target, duration }; return apiCall("/app/monitor/detail", "GET" /* GET */, data); } function getApplicationTrafficAnalytics(serverId, appId, duration, resource) { const data = { server_id: serverId, app_id: appId, duration, resource }; return apiCall("/app/analytics/traffic", "GET" /* GET */, data); } function getApplicationTrafficDetail(serverId, appId, from, until, resourceList) { const data = { server_id: serverId, app_id: appId, from, until, resource_list: resourceList }; return apiCall("/app/analytics/trafficDetail", "GET" /* GET */, data); } function getPHPInformation(serverId, appId, duration, resource) { const data = { server_id: serverId, app_id: appId, duration, resource }; return apiCall("/app/analytics/php", "GET" /* GET */, data); } function getMySQLInformation(serverId, appId, duration, resource) { const data = { server_id: serverId, app_id: appId, duration, resource }; return apiCall("/app/analytics/mysql", "GET" /* GET */, data); } function getApplicationCron(serverId, appId) { const data = { server_id: serverId, app_id: appId }; return apiCall("/app/analytics/cron", "GET" /* GET */, data); } // src/services/knowledge-base/index.ts function searchKnowledgeBase(query) { const endpoint = `/kb/search?kb_title=${encodeURIComponent(query)}`; return apiCall(endpoint); } // src/services/addons-management/index.ts function activateAddOnServer(serverId, addonId, username, password, mode, provider, host, port) { const data = { server_id: serverId, addon_id: addonId, username, password, mode, provider, host, port }; return apiCall("/addon/activateOnServer", "POST" /* POST */, data); } function activateAddonOnAccountLevel(addonId, packageId) { const data = { addon_id: addonId, package_id: packageId }; return apiCall("/addon/activate", "POST" /* POST */, data).then((response) => { return { message: response.message, sub: { id_user_addons: response.sub.id_user_addons, status: response.sub.status, id_package: response.sub.id_package } }; }); } function addonRequestForApplication(addonId, serverId, appId, version) { const data = { addon_id: addonId, server_id: serverId, app_id: appId, version }; return apiCall("/addon/request", "POST" /* POST */, data); } function deactivateAddOnYourServer(serverId, addonId) { const data = { server_id: serverId, addon_id: addonId }; return apiCall("/addon/deactivateOnServer", "POST" /* POST */, data); } function deactivateAnAddon(addonId) { const data = { addon_id: addonId }; return apiCall("/addon/deactivate", "POST" /* POST */, data).then( (response) => { return { message: response.message, sub: { id_user_addons: response.sub.id_user_addons, status: response.sub.status } }; } ); } function getAddonsList() { return apiCall("/addon", "GET" /* GET */).then( (response) => response ); } function upgradeAddonPackage(addonId, packageId) { const data = { addon_id: addonId, package_id: packageId }; return apiCall("/addon/upgrade", "POST" /* POST */, data).then((response) => { return { message: response.message, sub: { id_user_addons: response.sub.id_user_addons, status: response.sub.status, id_package: response.sub.id_package } }; }); } function getElasticEmailDomains() { return apiCall("/addon/elastic/domains", "GET" /* GET */).then((response) => { return { status: response.status, data: { domains: [ { domain: response.data.domain, spf: response.data.spf, mx: response.data.mx, dkim: response.data.dkim, dmarc: response.data.dmarc, tracking: response.data.tracking } ] } }; }); } function verifyElasticEmailDomain(domain) { const data = { domain }; return apiCall("/addon/elastic/verify_domain", "POST" /* POST */, data).then( (response) => { return { status: response.status, data: { domain: response.data.domain, spf: response.data.spf, mx: response.data.mx, dkim: response.data.dkim, dmarc: response.data.dmarc, tracking: response.data.tracking } }; } ); } function deleteElasticEmailDomain(domain) { const data = { domain }; return apiCall("/addon/elastic/domain", "DELETE" /* DELETE */, data).then( (response) => ({ status: response.status, message: response.message }) ); } // src/services/app-management/index.ts function changeAppAccessState(serverId, appId, state) { const data = { server_id: serverId, app_id: appId, state }; return apiCall("/app/state", "POST" /* POST */, data); } async function getAppBackupStatus(serverId, appId) { const data = { server_id: serverId, app_id: appId }; const req = await apiCall("/app/manage/backup", "GET" /* GET */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } function createAppCredentials(serverId, appId, username, password) { const data = { server_id: serverId, app_id: appId, username, password }; return apiCall("/app/creds", "POST" /* POST */, data).then((response) => ({ app_cred_id: response.app_cred_id })); } function deleteAppCredential(serverId, appId, appCredId) { const data = { server_id: serverId, appId }; return apiCall(`/app/creds/${appCredId}`, "DELETE" /* DELETE */, data); } async function deleteCname(serverId, appId) { const data = { server_id: serverId, app_id: appId }; const req = await apiCall("/app/manage/cname", "DELETE" /* DELETE */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function deleteLocalBackup(serverId, appId) { const data = { server_id: serverId, app_id: appId }; const req = await apiCall("/app/manage/backup", "DELETE" /* DELETE */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } function getAppCredentials(serverId, appId) { const data = { server_id: serverId, app_id: appId }; return apiCall("/app/creds", "GET" /* GET */, data).then( (response) => response ); } function getApplicationSshAccessStatus(serverId, appId) { const data = { server_id: serverId, app_id: appId }; return apiCall("/app/getAppSshPerms", "GET" /* GET */, data).then( (response) => response ); } function getApplicationAccessState(serverId, appId) { const data = { server_id: serverId, app_id: appId }; return apiCall("/app/getApplicationAccess", "GET" /* GET */, data).then( (response) => response ); } function getCronList(serverId, appId) { const data = { server_id: serverId, app_id: appId }; return apiCall("/app/manage/cronList", "GET" /* GET */, data).then( (response) => response ); } function getFpmSettings(serverId, appId) { const data = { server_id: serverId, app_id: appId }; return apiCall("/app/manage/fpm_setting", "GET" /* GET */, data).then( (response) => response ); } function getVarnishSettings(serverId, appId) { const data = { server_id: serverId, app_id: appId }; return apiCall("/app/manage/varnish_setting", "GET" /* GET */, data).then( (response) => response ); } function resetFilePermissions(serverId, appId, ownership) { const data = { server_id: serverId, app_id: appId, ownership }; return apiCall("/app/manage/reset_permissions", "POST" /* POST */, data); } async function restoreApp(serverId, appId, time, type) { const data = { server_id: serverId, app_id: appId, time, type }; const req = await apiCall("/app/manage/restore", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function rollbackRestore(serverId, appId) { const data = { server_id: serverId, app_id: appId }; const req = await apiCall("/app/manage/rollback", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function aplicationBackup(serverId, appId) { const data = { server_id: serverId, app_id: appId }; const req = await apiCall("/app/manage/takeBackup", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } function updateAppAlias(serverId, appId, aliases) { const data = { server_id: serverId, app_id: appId, aliases }; return apiCall("/app/manage/takeBackup", "POST" /* POST */, data); } async function updateAppCname(serverId, appId, cname) { const data = { server_id: serverId, app_id: appId, cname }; const req = await apiCall("/app/manage/cname", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } function updateAppCredential(serverId, appId, username, password, app_cred_id) { const data = { server_id: serverId, app_id: appId, username, password, app_cred_id }; return apiCall(`/app/creds/${app_cred_id}`, "PUT" /* PUT */, data); } function updateApplicationSshAccessStatus(serverId, appId, update_perms_action) { const data = { server_id: serverId, app_id: appId, update_perms_action }; return apiCall("/app/updateAppSshPerms", "POST" /* POST */, data).then( (response) => ({ status: response.status, confirmation: response.confirmation }) ); } function updateCronList(serverId, appId, crons, is_script) { const data = { server_id: serverId, app_id: appId, crons, is_script }; return apiCall("/app/manage/cronList", "POST" /* POST */, data); } function updateDBPassword(serverId, appId, password) { const data = { server_id: serverId, app_id: appId, password }; return apiCall("/app/manage/dbPassword", "POST" /* POST */, data); } function updateFPMsettings(serverId, appId, fpm_setting) { const data = { server_id: serverId, app_id: appId, fpm_setting }; return apiCall("/app/manage/fpm_setting", "POST" /* POST */, data); } function updateSymlink(serverId, appId, symlink) { const data = { server_id: serverId, app_id: appId, symlink }; return apiCall("/app/manage/symlink", "POST" /* POST */, data); } async function updateVarnishSettings(serverId, appId, vcl_list) { const data = { server_id: serverId, app_id: appId, vcl_list }; const req = await apiCall("/app/manage/varnish_setting", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } function updateWebroot(serverId, appId, webroot) { const data = { server_id: serverId, app_id: appId, webroot }; return apiCall("/app/manage/webroot", "POST" /* POST */, data); } async function updateCorsHeaders(serverId, appId, corsHeaders) { const data = { server_id: serverId, app_id: appId, corsHeaders }; const req = await apiCall("/app/cors_header", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function getAplicacionWebPRedirectionStatus(serverId, appId, status) { const data = { server_id: serverId, app_id: appId, status }; const req = await apiCall("/app/manage/webP", "GET" /* GET */, data); return await getAndWaitForOperationStatusCompleted(req.response.operation_id); } async function enforceHTTPS(serverId, appId, status) { const data = { server_id: serverId, app_id: appId, status }; const req = await apiCall("/app/manage/enforce_https", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } function getAppSettingValue(serverId, appId) { const data = { server_id: serverId, app_id: appId }; return apiCall("/app/get_settings_value", "GET" /* GET */, data).then( (response) => response ); } function updateAppGeoIpHeaderStatus(serverId, appId, status) { const data = { server_ip: serverId, app_id: appId, status }; return apiCall("/app/manage/geo_ip_header", "POST" /* POST */, data).then( (response) => response ); } function updateAppXMLRCPheaderStatus(serverId, appId, status) { const data = { server_ip: serverId, app_id: appId, status }; return apiCall("/app/manage/xmlrpc", "POST" /* POST */, data).then( (response) => response ); } async function updateDeviceDetentionStatus(serverId, appId, status) { const data = { server_id: serverId, app_id: appId, status }; const req = await apiCall("/app/device/detection", "GET" /* GET */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function updateIgnoreQueryStringStatus(serverId, appId, status) { const data = { server_id: serverId, app_id: appId, status }; const req = await apiCall("/app/ignore/query_string", "GET" /* GET */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function updateDirectPHPExecutionStatus(serverId, appId, status) { const data = { server_id: serverId, app_id: appId, status }; const req = await apiCall("/app/manage/php_direct_execution", "GET" /* GET */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function updateCronOptimizerStatus(serverId, appId, status) { const data = { server_id: serverId, app_id: appId, status }; const req = await apiCall("/app/manage/cron_setting", "GET" /* GET */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function updateAppAdminPassword(serverId, appId, password) { const data = { server_id: serverId, app_id: appId, password }; const req = await apiCall("/app/creds/changeAdminCredentials", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.response.operation_id); } // src/services/application-vulnerability/index.ts function listApplicationVulnerabilities(appId, serverId) { const data = { app_id: appId, server_id: serverId }; return apiCall(`/app/vulnerabilities/${appId}`, "GET" /* GET */, data).then( (response) => response ); } async function refreshApplicationVulnerabilities(appId, serverId) { const data = { app_id: appId, server_id: serverId }; const req = await apiCall(`/app/vulnerabilities/${appId}/refresh`, "GET" /* GET */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } // src/services/bot-protection/index.ts function BotProtectionStatus(serverId, appId) { const data = { server_id: serverId, app_id: appId }; return apiCall("/app/malcare", "GET" /* GET */, data).then((response) => ({ enable: response.enable })); } function BotProtectionTraffic(serverId, appId) { const data = { server_id: serverId, app_id: appId }; return apiCall("/app/malcare/traffic", "GET" /* GET */, data).then( (response) => response ); } function BotProtectionTrafficSummary(serverId, appId) { const data = { server_id: serverId, app_id: appId }; return apiCall("/app/malcare/traffic/summary", "GET" /* GET */, data).then( (response) => response ); } function BotProtectionLoginTraffic(serverId, appId) { const data = { server_id: serverId, app_id: appId }; return apiCall("/app/malcare/logins", "GET" /* GET */, data).then( (response) => response ); } function BotProtectionLoginTrafficSummary(serverId, appId) { const data = { server_id: serverId, app_id: appId }; return apiCall("/app/malcare/logins/summary", "GET" /* GET */, data).then( (response) => response ); } function BotProtectionBadBotsList(serverId, appId, limit) { const data = { server_id: serverId, app_id: appId, limit }; return apiCall("/app/malcare/bots/bad", "GET" /* GET */, data).then( (response) => response ); } function BotProtectionWhiteListedIps(serverId, appId) { const data = { server_id: serverId, app_id: appId }; return apiCall("/app/malcare/whitelisted_ips", "GET" /* GET */, data).then( (response) => ({ whitelistedIps: response.whitelistedIps }) ); } function BotProtectionWhiteListedBots(serverId, appId) { const data = { server_id: serverId, app_id: appId }; return apiCall("/app/malcare/whitelisted_bots", "GET" /* GET */, data).then( (response) => ({ whitelistedBots: response.whitelistedBots }) ); } async function BotProtectionActivation(serverId, appId) { const data = { server_id: serverId, app_id: appId }; const req = await apiCall("/app/malcare/enable", "PUT" /* PUT */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function BotProtectionDeactivation(serverId, appId) { const data = { server_id: serverId, app_id: appId }; const req = await apiCall("/app/malcare/disable", "PUT" /* PUT */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } function BotProtectionIpWhitelisting(serverId, appId, ip, status) { const data = { server_id: serverId, app_id: appId, ip, status }; return apiCall("/app/malcare/whitelist_ip", "PUT" /* PUT */, data).then( (response) => ({ whitelistedIps: response.whitelistedIps }) ); } function BotProtectionBadBotsWhitelisting(serverId, appId, bot, status) { const data = { server_id: serverId, app_id: appId, bot, status }; return apiCall("/app/malcare/whitelist_bot", "PUT" /* PUT */, data).then( (response) => ({ whitelistedBots: response.whitelistedBots }) ); } async function ClearAppCache(serverId, appId) { const data = { server_id: serverId, app_id: appId }; const req = await apiCall("/app/cache/purge", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } // src/services/cloudflare-enterprise/index.ts function getCloudflareDetails(serverId, appId) { const data = { server_id: serverId, app_id: appId }; return apiCall("/app/cloudflareCdn", "GET" /* GET */, data).then( (response) => response ); } function setUpCloudflareforYourApp(serverId, appId, domain) { const data = { server_id: serverId, app_id: appId, domain }; return apiCall("/app/cloudflareCdn", "POST" /* POST */, data).then( (response) => response ); } function fetchTxtRecords(serverId, appId, domain) { const data = { server_id: serverId, app_id: appId, domain }; return apiCall("/app/cloudflareCdn/fetchTXT", "GET" /* GET */, data).then( (response) => response ); } async function deleteDomain(serverId, appId, domains, customerId) { const data = { server_id: serverId, app_id: appId, domains, customer_id: customerId }; const req = await apiCall("/app/cloudflareCdn/delete", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function transferDomain(serverId, appId, domains, dest_server_id, dest_app_id) { const data = { server_id: serverId, app_id: appId, domains, dest_server_id, est_app_id: dest_app_id }; const req = await apiCall( "/app/cloudflareCdn/transferDomain", "POST" /* POST */, data ); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function purgeDomain(serverId, appId, customerId) { const data = { server_id: serverId, app_id: appId, customer_id: customerId }; const req = await apiCall("/app/cloudflareCdn/purgeDomain", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } function getDnsQuery(serverId, appId, domain) { const data = { server_id: serverId, app_id: appId, domain }; return apiCall("/app/cloudflareCdn/getDnsQuery", "GET" /* GET */, data).then( (response) => ({ status: response.status, primary_domain: response.primary_domain, primary_domain_name: response.primary_domain_name }) ); } function verifyTxtRecords(serverId, appId, domain) { const data = { server_id: serverId, app_id: appId, domain }; return apiCall( "/app/cloudflareCdn/verifyTxtRecords", "POST" /* POST */, data ).then((response) => ({ status: response.status, domain_status: response.domain_status })); } function getSmartCachePurgeStatus(serverId, appId) { const data = { server_id: serverId, app_id: appId }; return apiCall( "/app/cloudflareCdn/checkFPCStatus", "GET" /* GET */, data ).then((response) => response); } async function configureSmartCachePurge(serverId, appId) { const data = { server_id: serverId, app_id: appId }; const req = await apiCall("/app/cloudflareCdn/deployFPC", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } function getClouflareSettings(serverId, appId) { const data = { server_id: serverId, app_id: appId }; return apiCall("/app/cloudflareCdn/appSetting", "GET" /* GET */, data).then( (response) => response ); } async function updateCloudflareSettings(serverId, appId, caching, early_hints, edgecaching, image_optimization, minification, mobile_optimization, scrapeshield) { const data = { server_id: serverId, app_id: appId, caching, early_hints, edgecaching, image_optimization, minification, mobile_optimization, scrapeshield }; const req = await apiCall("/app/cloudflareCdn/appSetting", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } function getClouflareCacheAnalytics(serverId, appId, mins) { const data = { server_id: serverId, app_id: appId, mins }; return apiCall( `/app/cloudflare/${appId}/analytics`, "GET" /* GET */, data ).then((response) => response); } function getClouflareSecurityAnalytics(serverId, appId, mins) { const data = { server_id: serverId, app_id: appId, mins }; return apiCall( `/app/cloudflare/${appId}/security`, "GET" /* GET */, data ).then((response) => response); } // src/services/cloudways-bot/index.ts function createAlertChannel(name, channel, events, is_active, to, url) { const data = { name, channel, events, is_active, to, url }; return apiCall("/integrations", "POST" /* POST */, data).then( (response) => response ); } function deleteCloudwaysBotChannel(channel_id) { const data = { channel_id }; return apiCall(`/integrations/${channel_id}`, "DELETE" /* DELETE */, data); } function getAllAlerts() { return apiCall("/alerts/", "GET" /* GET */).then( (response) => response ); } function getPaginatedAlerts(lastId) { return apiCall(`/alerts/${lastId}`, "GET" /* GET */).then( (response) => response ); } function getAllAlertChannels() { return apiCall("/integrations/create", "GET" /* GET */).then( (response) => response ); } function getUserAlertChannels() { return apiCall("/integrations", "GET" /* GET */).then( (response) => response ); } function markAllAlertsAsRead() { return apiCall("/alert/markAllRead", "POST" /* POST */); } function markAlertAsRead(alertId) { const data = { alert_id: alertId }; return apiCall(`/alert/markAsRead/${alertId}`, "POST" /* POST */, data); } function updateCloudwaysBotIntegration(channelId, name, channel, events, isActive, to, url) { const data = { channel_id: channelId, name, channel, events, is_active: isActive, to, url }; return apiCall(`/integrations/${channelId}`, "PUT" /* PUT */, data).then( (response) => response ); } // src/services/dns-made-easy/index.ts function listDNSMadeEasyDomains() { return apiCall("/dme/domains", "GET" /* GET */).then( (response) => response ); } function AddDNSMadeEasyDomains(names) { const data = { names }; return apiCall("/dme/domains", "POST" /* POST */, data).then((response) => ({ message: response.message })); } function DeleteDNSMadeEasyDomains(ids) { const data = { ids }; return apiCall("/dme/domains", "DELETE" /* DELETE */, data).then((response) => ({ deleted: response.deleted, message: response.message })); } function getDNSMadeEasyDomainsStatus(uid) { return apiCall(`/dme/domains/${uid}/status`, "GET" /* GET */).then( (response) => ({ status: response.status }) ); } function getDNSMadeEasyDomainsRecords(domainId) { return apiCall(`/dme/domains/${domainId}/records`, "GET" /* GET */).then( (response) => response ); } function AddRecordToDnsMadeEasyDomain(domainId, records) { const data = { records, domain_id: domainId }; return apiCall( `/dme/domains/${domainId}/records`, "POST" /* POST */, data ).then((response) => response); } function DeleteRecordfromDnsMadeEasyDomain(domainId, records_id) { const data = { records_id, domain_id: domainId }; return apiCall( `/dme/domains/${domainId}/records`, "DELETE" /* DELETE */, data ).then((response) => ({ status: response.status, message: response.message })); } function updateRecordOfDnsMadeEasyDomain(domainId, record_id, record) { const data = { record }; return apiCall( `/dme/domains/${domainId}/records/${record_id}`, "PUT" /* PUT */, data ).then((response) => ({ status: response.status, message: response.message })); } function GetCurrentMonthDnsMadeEasyDomainUsage(domainId) { return apiCall(`/dme/domains/${domainId}/usage`, "GET" /* GET */).then( (response) => response ); } // src/services/git-api/index.ts function generateGitSsh(serverId, appId) { const data = { server_id: serverId, app_id: appId }; return apiCall("/git/generateKey", "POST" /* POST */, data); } function getBranchNames(serverId, appId, gitUrl) { const data = { server_id: serverId, app_id: appId, git_url: gitUrl }; return apiCall("/git/branchNames", "GET" /* GET */, data).then((response) => ({ branches: response.branches })); } function getGitDeploymentHistory(serverId, appId) { const data = { server_id: serverId, app_id: appId }; return apiCall("/git/history", "GET" /* GET */, data).then( (response) => response ); } function getGitSsh(serverId, appId) { const data = { server_id: serverId, app_id: appId }; return apiCall("/git/key", "GET" /* GET */, data).then((response) => ({ key: response.key })); } async function startGitClone(serverId, appId, git_url, brach_name, deploy_path) { const data = { server_id: serverId, app_id: appId, git_url, brach_name, deploy_path }; const req = await apiCall("/git/clone", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function startGitPull(serverId, appId, brach_name, deploy_path) { const data = { server_id: serverId, app_id: appId, brach_name, deploy_path }; const req = await apiCall("/git/pull", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } // src/services/safe-updates/index.ts async function getSafeUpdatesDetail(server_id, app_id) { const req = await apiCall(`/app/safeupdates?server_id=${server_id}&app_id=${app_id}`, "GET" /* GET */); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function UpdateSafeupdates(server_id, app_id, core, plugin, theme) { const data = { server_id, app_id, core, plugin, theme }; const req = await apiCall(`/app/safeupdates/${app_id}`, "PUT" /* PUT */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } function getSafeUpdatesStatus(server_id, app_id) { return apiCall(`/app/safeupdates/${app_id}/status?app_id=${app_id}&server_id=${server_id}`, "GET" /* GET */).then( (response) => ({ status: response.status, data: { is_active: response.data.is_active } }) ); } function UpdateSafeupdatesStatus(appType, app_id, app_name, enable, feedback, options, checked, desc, label, server_id) { const data = { appType, app_id, app_name, enable, feedback, options, checked, desc, label, server_id }; return apiCall("/app/safeupdates/status", "POST" /* POST */, data).then( (response) => ({ status: response.status, data: { enabled: response.data.enabled } }) ); } function getSafeUpdatesList() { return apiCall("/app/safeupdates/list", "GET" /* GET */).then( (response) => response ); } function getSafeUpdatesSettings(server_id, app_id) { return apiCall(`/app/safeupdates/${app_id}/settings?app_id=${app_id}&server_id=${server_id}`, "GET" /* GET */).then( (response) => response ); } function postSafeUpdatesSettings(app_id, core, emails, failed_updates, plugin, pre_notification, server_id, status, successful_updates, theme, update_day, update_slot) { const data = { app_id, core, emails, failed_updates, plugin, pre_notification, server_id, status, successful_updates, theme, update_day, update_slot }; return apiCall("/safeupdates/settings", "POST" /* POST */, data).then( (response) => ({ status: response.status }) ); } function getSafeUpdatesSchedule(server_id, app_id) { return apiCall(`/app/safeupdates/${app_id}/schedule?app_id=${app_id}&server_id=${server_id}`, "GET" /* GET */).then( (response) => response ); } function getSafeUpdatesHistory(server_id, app_id) { return apiCall(`/app/safeupdates/${app_id}/history?server_id=${server_id}&app_id=${app_id}`, "GET" /* GET */).then( (response) => response ); } // src/services/security/index.ts function allowAdminer(serverId, ip) { const data = { server_id: serverId, ip_address: ip }; return apiCall("/security/adminer", "POST" /* POST */, data); } function allowSiab(serverId, ip) { const data = { server_id: serverId, ip_address: ip }; return apiCall("/security/siab", "POST" /* POST */, data); } function changeAutoRenewalPolicy(serverId, appId, auto) { const data = { server_id: serverId, app_id: appId, auto }; return apiCall("/security/lets_encrypt_auto", "POST" /* POST */, data); } function checkIfIpBlacklist(serverId, ip) { const data = { server_id: serverId, ip_adress: ip }; return apiCall("/security/isBlacklisted", "GET" /* GET */, data).then( (response) => response.ip_status ); } function getWhitelistedIpsMysqlConnections(serverId) { const data = { server_id: serverId }; return apiCall("/security/whitelistedIpsMysql", "GET" /* GET */, data).then( (response) => response.ip_list ); } function getWhiteListedIpsForSshSftp(serverId) { const data = { server_id: serverId }; return apiCall("/security/whitelistedIpsMysql", "GET" /* GET */, data).then( (response) => response.ip_list ); } function createDns(serverId, appId, sslEmail, wildCard, sslDomain) { const data = { server_id: serverId, app_id: appId, ssl_email: sslEmail, wild_card: wildCard, ssl_domain: sslDomain }; return apiCall("/security/createDNS", "POST" /* POST */, data).then( (response) => { return { wildcard_ssl: { message: response.wildcard_ssl.message, status: response.wildcard_ssl.status, wildcard: { app_prefix: response.wildcard_ssl.wildcard.app_prefix, auto: response.wildcard_ssl.wildcard.auto, is_installed: response.wildcard_ssl.wildcard.is_installed, is_verified: response.wildcard_ssl.wildcard.is_verified, ssl_domains: response.wildcard_ssl.wildcard.ssl_domains, ssl_email: response.wildcard_ssl.wildcard.ssl_email, type: response.wildcard_ssl.wildcard.type } } }; } ); } function verifyDns(serverId, appId, sslEmail, wildCard, sslDomain) { const data = { server_id: serverId, app_id: appId, ssl_email: sslEmail, wild_card: wildCard, ssl_domain: sslDomain }; return apiCall("/security/verifyDNS", "POST" /* POST */, data).then( (response) => { return { wildcard_ssl: { message: response.wildcard_ssl.message, status: response.wildcard_ssl.status, wildcard: { app_prefix: response.wildcard_ssl.wildcard.app_prefix, auto: response.wildcard_ssl.wildcard.auto, is_installed: response.wildcard_ssl.wildcard.is_installed, is_verified: response.wildcard_ssl.wildcard.is_verified, ssl_domains: response.wildcard_ssl.wildcard.ssl_domains, ssl_email: response.wildcard_ssl.wildcard.ssl_email, type: response.wildcard_ssl.wildcard.type } } }; } ); } async function installLetsEncrypt(serverId, appId, sslEmail, wildCard, sslDomains) { const data = { server_id: serverId, app_id: appId, ssl_email: sslEmail, wild_card: wildCard, ssl_domains: sslDomains }; const req = await apiCall("/security/lets_encrypt_install", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function renewLetsEncryptManually(serverId, appId, wildCard, domain) { const data = { server_id: serverId, app_id: appId, wild_card: wildCard, domain_name: domain }; const req = await apiCall("/security/lets_encrypt_manual_renew", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } async function revokeLetsEncrypt(serverId, appId, wildCard, ssl_domain) { const data = { server_id: serverId, app_id: appId, wild_card: wildCard, Ssl_domain: ssl_domain }; const req = await apiCall("/security/lets_encrypt_revoke", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } function ownSslCertificate(serverId, appId, sslCertificate, sslKey) { const data = { server_id: serverId, app_id: appId, ssl_crt: sslCertificate, ssl_key: sslKey }; return apiCall("/security/own_ssl", "POST" /* POST */, data); } async function removeOwnSslCertificate(serverId, appId) { const data = { server_id: serverId, app_id: appId }; const req = await apiCall("/security/removeCustomSSL", "DELETE" /* DELETE */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } function updateWhitelistedIps(serverId, ipPolicy, tab, Ips, type_connection) { const data = { server_id: serverId, ip_policy: ipPolicy, tab, ips: Ips, type: type_connection }; return apiCall("/security/whitelisted", "POST" /* POST */, data); } // src/services/server-management/index.ts async function backupServer(serverId) { const data = { server_id: serverId }; const req = await apiCall("/server/manage/backup", "POST" /* POST */, data); return await getAndWaitForOperationStatusCompleted(req.operation_id); } function deleteLocalServerBackups(serverId) { const data = { server_id: serverId }; return apiCall("/server/manage/remove_local_backup", "POST" /* POST */, data); } function getMonitoringGraph(serverId, target, duration, timezone, output_format) { const data = { server_id: serverId, target, duration, timezone, output_format }; return apiCall("/server/monitor/detail", "GET" /* GET */, data).then( (response) => ({ contents: response.contents }) ); } function getServerSettings(serverId) { const data = { server_id: serverId }; return apiCall("/server/manage/settings", "GET" /* GET */, data).then( (response) => response ); } function getServerMaintenanceWindowSettings(serverId) { const data = { server_id: serverId }; return apiCall( "/server/manage/getMaintenanceWinSettings", "GET" /* GET */, data ).then((response) => ({ maintenance_settings: { day: response.maintenance_settings.day, hour: response.maintenance_settings.hour } })); } function updateServerMaintenanceWindowSettings(serverId, day, hour) { const data = { server_id: serverId, day, hour }; return apiCall("/server/manage/postMaintenanceWinSettings", "POST" /* POST */, data).then( (response) => ({ message: response.message }) ); } function updateBackupSettings(serverId, local_backups, backup_frequency, backup_retention, backup_time) { const data = { server_id: serverId, local_backups, backup_frequency, backup_retention, backup_time }; return apiCall("/server/manage/backupSettings", "POST" /* POST */, data); } function updateMasterPassword(serverId, password) { const data = { server_id: serverId, password }; return apiCall("/server/manage/masterPassword", "POST" /* POST */, data); } function updateMasterUsername(serverId, username) { const data = { server_i