Quick Reference

Quickstart.CreateVPS

Estimated reading: 11 minutes 711 views

CreateEnvironment (appid, session, env, nodes, [actionkey], [ownerUid], [envGroups] ) :

Creates a new environment with the required settings.

URL

https://[hoster-api-host]/1.0/environment/control/rest/createenvironment

Parameters

  • appid : “string”unique identifier of the target application (required for authentication).
  • session : “string” user session or personal access token.
  • env : “json” JSON object with environment settings:
    {
       "displayName": "string",  (Mandatory)  // Environment name for display purpose
       "engine": "string",  (Optional) // java6java7java8php5.3php5.4php5.5, etc. more details ..
       "ishaenabled": "boolean", (Optional)
       "region": "string", // (Optional) more details ..
       "shortdomain": "string", (Mandatory) // ex ... env-0203918  (this env can be accessed from env-0203918.us-accuweb.cloud)
       "sslstate": "boolean" (Optional)
    }
  • nodes : “json” JSON object with a list of environment nodes and their settings:
    [{   
       "nodeGroup": "string", // cp, vps, etc. more details .. 
       "nodeType": "string", // apache, centos-vps, etc. more details ..  
    }, ...]
  • actionkey : “string” (optional) name of the action and domain name.
  • ownerUid : “int” (optional) unique identifier of the environment owner (if installing as collaborator on another user account).
  • envGroups : “string” (optional) target group name or JSON array of group names.

Example

Method: POST

https://[hoster-api-host]/1.0/environment/control/rest/createenvironment?envGroups=[string]&nodes=[json]&session=[string]&appid=[string]&actionkey=[string]&env=[json]&ownerUid=[int]

Response

{
  "result": 0, // successful
  "response": {
    "result": 0,
    "date": "2024-05-10 15:08:07", // creation date
    "envGroups": [],
    "nodes": [
      {
        "guestOSType": "LINUX",
        "diskIopsLimit": 5000,
        "addons": [],
        "customitem": {
          "dockerVolumes": [],
          "dockerOs": ".centos-minimal-7-x86_64",
          "nodeVersion": "7.9",
          "dockerName": "jelastic/centosvps",
          "dockerTag": "7.9",
          "dockerVolumesFrom": [],
          "dockerManifest": {
            "imageId": "sha256:e3458f5169e752fc3d176ec586xxxxxx813630fd0afbcb36466467053a2ed00cf",
            "workdir": "",
            "os": "linux",
            "entrypoint": null,
            "created": "2022-03-22T16:50:09.959271553Z",
            "volumes": null,
            "id": "sha256:f878f2f6f58a3fxxxxx614e0722ba96d2995c3f338ecebe3a591a0e9c2bb4e5",
            "cmd": [
              "/bin/bash"
            ],
            "env": [
              "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
              "CENTOS_VERSION=7.9"
            ]
          }
        },
        "bandwidthLimit": 100000,
        "isCustomSslSupport": false,
        "isResetPassword": false,
        "type": "DOCKERIZED",
        "features": [
          "FIREWALL"
        ],
        "osType": "LINUX",
        "ismaster": true,
        "canBeExported": false,
        "diskIoLimit": 201088640,
        "id": 5356,
        "isWebAccess": false,
        "isHighAvailability": false,
        "adminUrl": "http://node5356-api-test-123.us-accuweb.cloud",
        "isVcsSupport": false,
        "endpoints": [],
        "ctid": 6364,
        "address": "10.xxx.3.75",
        "isClusterSupport": false,
        "diskLimit": 400000,
        "maxchanks": 100,
        "nodemission": "vds",
        "singleContext": false,
        "flexibleCloudlets": 100,
        "nodeType": "centos-vps",
        "packages": [],
        "intIP": "10.xxx.3.75",
        "version": "7.9",
        "nodeGroup": "vds",
        "url": "http://node5356-api-test-123.us-accuweb.cloud",
        "hasPackages": false,
        "isExternalIpRequired": false,
        "contextValidatorRegex": "ROOT",
        "port": 80,
        "cloudletsMinCount": 1,
        "vType": "CT",
        "name": "CentOS",
        "messages": [],
        "fixedCloudlets": 50,
        "user": "root",
        "status": 6
      }
    ],
    "appid": "adxxxxxxxxxca64e1003a82d",
    "name": "api-test-123",
    "env": {
      "displayName": "thisIsfortest-123",
      "ishaenabled": false,
      "isRemote": false,
      "shortdomain": "api-test-123",
      "contexts": [],
      "sslstate": false,
      "isTransferring": false,
      "createdOn": "2024-05-10 15:07:18",
      "uid": 22,
      "creatorUid": 22,
      "extdomains": [],
      "envName": "api-test-123",
      "isFirewallEnabled": true,
      "appid": "ad9d17a22xxxxxx0889dca64e1003a82d",
      "domain": "api-test-123.us-accuweb.cloud",
      "attributes": {},
      "hostGroup": {
        "uniqueName": "user_host_group",
        "displayName": "Users"
      },
      "ownerUid": 22,
      "hardwareNodeGroup": "user_host_group",
      "status": 1
    },
    "nodeGroups": [
      {
        "templateType": "DOCKERIZED",
        "displayName": "centos Node",
        "scalingMode": "STATEFUL",
        "restartContainerDelay": 0,
        "isSequentialDeploy": false,
        "redeployContextDelay": 30,
        "isSLBAccessEnabled": true,
        "features": [
          "FIREWALL"
        ],
        "deployments": [],
        "restartNodeDelay": 0,
        "vType": "CT",
        "redeployContainerDelay": 30,
        "name": "vds"
      }
    ],
    "creatorAppid": "dashboard"
  }
}

This guide explains how to create a Virtual Private Server (VPS) with Apache pre-installed using the AccuWeb.Cloud API’s “Installs a custom JPS manifest” functionality. This streamlined approach combines environment creation, configuration, and Apache installation into a single API call.

Authentication:

  • You can authenticate using either an application ID (appid) or a user session token (session).

API Parameters

  • appid (optional): Unique identifier for your target application (required for authentication if no session is provided).
  • session (optional): Your user session token or a personal access token (refer to the user session or personal access token for details on obtaining these)..
  • jps (required): A custom JPS manifest containing deployment instructions.
  • envName (optional): Name for your target environment (specified within the JPS itself).
  • nodeGroup (optional): Unique identifier of the target node group (layer) (specified within the JPS itself).
  • displayName (optional): A custom alias (display name) for the deployed JPS application.

Sample Request

URL: https://[hoster-api-host]/1.0/marketplace/jps/rest/install

POST Fields:

{
  "session": "user session token",
  "shortdomain": "unique_string" (avoid duplicates with existing environments),
  "jps": {
  "type": "install",
  "name": "YourEnvironmentName",
  "nodes": {
    "nodeGroup": "application_layer" (e.g., "vps" for default application server),
    "nodeType": "your_vps_type",
    "fixedCloudlets": "number_of_always_running_cloudlets",
    "cloudlets": "maximum_cloudlets_during_traffic_spikes"
  },
  "onInstall": {
    "cmd [application_layer]": [
      "commands to execute on installation" (e.g., update packages, install Apache, start/enable services, configure firewall)
    ]
  }
}  
}

Replace placeholders:

  • user session token: Your actual user session token.
  • unique_string: Choose a unique string for your environment’s short domain.
  • YourEnvironmentName: The desired name for your environment.
  • application_layer: The target node group (e.g., “cp”).
  • your_vps_type: The type of VPS you want to install (e.g., “almalinux-vps”).
  • number_of_always_running_cloudlets: The number of cloudlets that should always be running.
  • maximum_cloudlets_during_traffic_spikes: The maximum number of cloudlets that can scale up during traffic surges.
  • "commands to execute on installation": Replace these with the actual commands needed to prepare your environment (e.g., update packages, install software, configure services).
    • In our case we put :

           [  “sudo yum update -y”,
              “sudo yum install httpd -y”,
              “sudo yum -y install php”,
              “sudo systemctl start httpd”,
              “sudo systemctl enable httpd” ]’

Sample Response

The response will be similar to the following, indicating successful deployment:

{
  "result": 0,
  "uniqueName": "...",  // Unique identifier for the deployment
  "response": {
    "result": 0,
    "uniqueName": "...",  // Unique identifier for the environment
    "successText": "",
    "appid": "..."       // Unique identifier for the application
  },
  "appid": "..."  // Unique identifier for the application
  "successText": ""
}

This approach simplifies VPS creation and Apache installation, saving you time and effort.

This guide builds upon the previous article, which covered the steps for creating VPS along with the Apache to AccuWeb.Cloud. Here, we’ll see how we can deploy our PHP Application using the jps (JavaScript Provisioning Script) functionality.

API Parameters

  • appid (optional): Unique identifier for your target application (required for authentication if no session is provided).
  • session (optional): Your user session token or a personal access token (refer to the user session or personal access token for details on obtaining these).
  • jps (required): JSON code generated from cloud scripting (a sample is provided below).
  • envName (required as we want to update existing environment ): Name for your target environment.
  • nodeGroup (optional): Unique identifier of the target node group (layer) (can be specified within the JSON itself).

Sample Request

URL: https://[hoster-api-host]/1.0/marketplace/jps/rest/install

POST Fields:

{
  "session": "your_user_session_token",
  "envName": "YourEnvironmentName", (make sure it is same as you entered while creating VPS)
  "shortdomain": "unique_string", (make sure it is same as you entered while creating VPS)
  "jps": {
    "type": "update",
    "name": "YourEnvironmentName", (make sure it is same as you entered while creating VPS)    
    "onInstall": {
      "cmd [application_layer]": [
        "commands to execute on installation" (e.g., update packages, install Apache and PHP, start/enable services, configure firewall, clone your application code)
      ]
    }
  }
}

Replace placeholders:

  • your_user_session_token: Your actual user session token.
  • unique_string: Choose a unique string for your environment’s short domain.
  • YourEnvironmentName: The desired name for your environment.
  • application_layer: The target node group (e.g., “vps” here).
  • "commands to execute on installation": Replace these with array of the actual commands needed to prepare your environment (e.g., update packages, install software, configure services, clone your application code). In our case we put :

[  “sudo yum install firewalld”,
“sudo systemctl start firewalld”,
“sudo systemctl enable firewalld”,
“sudo firewall-cmd –add-service=http”,
“cd /var/www/html”,
“git init”,
“git pull https://github.com/<your_user>/<your_repo>.git” ]’

Note : For Private Git Repo Format will be:

https://<YOUR_GIT_USERNAME>:<PERSONAL_ACCESS_TOKEN>@github.com/<OWNER_URL_SLUG>.git
  • YOUR_GIT_USERNAME: Username of user who is cloning the repo. eg. code_dev
  • PERSONAL_ACCESS_TOKEN: your actual Personal Access Token. eg. 40_DIGIT_PRIVATE_TOKEN (Refer : How to generate PAT in GitHub)
  • OWNER_URL_SLUG: Private git url slug.
    eg. https://github.com/Accuweb.cloud/Private-repo.git
Example URL:- https://code_dev:[email protected]/Accuweb.cloud/Private-repo.git

Sample Response

The response will be similar to the following, indicating successful deployment:

{
  "result": 0,
  "uniqueName": "...",  // Unique identifier for the deployment
  "response": {
    "result": 0,
    "uniqueName": "...",  // Unique identifier for the environment
    "successText": "",
    "appid": "..."       // Unique identifier for the application
  },
  "appid": "..."  // Unique identifier for the application
  "successText": ""
}

This approach simplifies the deployment process by combining environment creation, configuration, and application deployment into a single API call.

This guide builds upon the previous article, which covered the steps for deploying a PHP application to AccuWeb.Cloud. Here, we’ll streamline the process into a single API call using the jps (JavaScript Provisioning Script) functionality.

API Parameters

  • appid (optional): Unique identifier for your target application (required for authentication if no session is provided).
  • session (optional): Your user session token or a personal access token (refer to the user session or personal access token for details on obtaining these).
  • jps (required): JSON code generated from cloud scripting (a sample is provided below).
  • envName (optional): Name for your target environment (can be specified within the JSON itself that’s what we will do here).
  • nodeGroup (optional): Unique identifier of the target node group (layer) (can be specified within the JSON itself that’s what we will do here).

Sample Request

URL: https://[hoster-api-host]/1.0/marketplace/jps/rest/install

POST Fields:

{
  "session": "your_user_session_token",
  "shortdomain": "unique_string" (avoid duplicates with existing environments),
  "jps": {
    "type": "install",
    "name": "YourEnvironmentName",
    "nodes": {
      "nodeGroup": "application_layer", (e.g., "vps" for creating vps)
      "nodeType": "your_vps_type", (e.g., "almalinux-vps" for creating almalinux vps)
      "fixedCloudlets": "number_of_always_running_cloudlets",
      "cloudlets": "maximum_cloudlets_during_traffic_spikes",
      "extip": true (for attaching Public IP address, by default it will be false)
    },
    "onInstall": {
      "cmd [application_layer]": [
        "commands to execute on installation" (e.g., update packages, install Apache and PHP, start/enable services, configure firewall, clone your application code)
      ]
    }
  }
}

Replace placeholders:

  • your_user_session_token: Your actual user session token.
  • unique_string: Choose a unique string for your environment’s short domain.
  • YourEnvironmentName: The desired name for your environment.
  • application_layer: The target node group (e.g., “vps” here).
  • your_vps_type: The type of VPS you want to install (e.g., “almalinux-vps”).
  • number_of_always_running_cloudlets: The number of cloudlets that should always be running. (e.g., 10).
  • maximum_cloudlets_during_traffic_spikes: The maximum number of cloudlets that can scale up during traffic surges. (e.g., 20).
  • "commands to execute on installation": Replace these with array of the actual commands needed to prepare your environment (e.g., update packages, install software, configure services, clone your application code). In our case we will put :

[  “sudo yum update -y”,
“sudo yum install httpd -y”,
“sudo yum -y install php”,
“sudo systemctl start httpd”,
“sudo systemctl enable httpd”,
“sudo yum install firewalld”,
“sudo systemctl start firewalld”,
“sudo systemctl enable firewalld”,
“sudo firewall-cmd –add-service=http”,
“cd /var/www/html”,
“git init”,
“git pull https://github.com/<your_user>/<your_repo>.git” ]’

Note : For Private Git Repo Format will be:

https://<YOUR_GIT_USERNAME>:<PERSONAL_ACCESS_TOKEN>@github.com/<OWNER_URL_SLUG>.git
  • YOUR_GIT_USERNAME: Username of user who is cloning the repo. eg. code_dev
  • PERSONAL_ACCESS_TOKEN: your actual Personal Access Token. eg. 40_DIGIT_PRIVATE_TOKEN (Refer : How to generate PAT in GitHub)
  • OWNER_URL_SLUG: Private git url slug.
    eg. https://github.com/Accuweb.cloud/Private-repo.git
Example URL:- https://code_dev:[email protected]/Accuweb.cloud/Private-repo.git

Sample Response

The response will be similar to the following, indicating successful deployment:

{
  "result": 0,
  "uniqueName": "...",  // Unique identifier for the deployment
  "response": {
    "result": 0,
    "uniqueName": "...",  // Unique identifier for the environment
    "successText": "",
    "appid": "..."       // Unique identifier for the application
  },
  "appid": "..."  // Unique identifier for the application
  "successText": ""
}

This approach simplifies the deployment process by combining environment creation, configuration, and application deployment into a single API call.

Leave a Comment