Virtual application patterns REST API

Use this REST API to manage your virtual application patterns.

List all application patterns

GET /resources/virtualApplicationPatterns/
Table 1. List all virtual application patterns
REST API information Value Description
Example URL https://localhost/resources/virtualApplicationPatterns/  
Response content-type application/json  
Response example
[
   {
      "content_type": "application/json",
      "last_modifier": "tester",
      "create_time": "2011-02-24T05:41:34Z",
      "last_modified": "2011-02-24T05:41:34Z",
      "access_rights": {
         "tester": "F"
      },
      "content_md5": "661D31C9F14615539E537E9AA5CB02E9",
      "app_type": "application",
      "app_id": "a-faac12d0-23d7-4f57-b3cb-13ce92d5e07f",
      "app_name": "untitled",
      "creator": "tester"
   },
   ...   
]
 
Response code 200 OK
  401 The user is not authorized to perform this action.
  403 Access forbidden
  500 Unexpected error

Return a specific virtual application pattern

GET /resources/virtualApplicationPatterns/{app_id}
Table 2. Return detailed information about a virtual application pattern
REST API information Value Description
Example URL https://localhost/resources/irtualApplicationPatterns/a-679a68f4-6798-424f-8039-1f682f949f45  
Response content-type application/json  
Response example
{
   "last_modifier": "cbadmin",
   "content_type": "application/json",
   "app_name": "Secured JEE web application",
   "creator": "cbadmin",
   "create_time": "2011-02-24T05:41:34Z",
   "last_modified": "2011-02-24T05:41:34Z",
   "access_rights": {
      "AllUsers": "R"
   },
   "content_md5": "60136D4754C7CEE19E827665FE601C33",
   "app_type": "application",
   "app_id": "a-679a68f4-6798-424f-8039-1f682f949f45",
   "description": "HitCount is a secured Java Platform, Enterprise Edition (Java EE) web application demonstrating how to increment a counter with WebSphere Application Server,Tivoli Direcotry Service, and DB2. Access HitCount via http://[IP]:9080/hitcount, where [IP] is the IP of the deployed WebSphere Application Server virtual machine."
}
 
Response code 200 OK
  401 The user is not authorized to perform this action.
  403 Access forbidden
  404 The application that is specified by {appID} is not found.
  500 Unexpected error

Create an application pattern with specific attributes

POST /resources/virtualApplicationPatterns/
Different kinds of attributes can be combined. A unique ID is generated for the application.
Table 3. Create a virtual application pattern with specific attributes
REST API information Value Description
Example URL https://localhost/resources/virtualApplicationPatterns/  
Request body

Content-type

Content-Type - application/json (appmodel.json file)

Content-Type - application/zip file (compressed file that includes the application model and artifacts files)

 
Request body example JSON Application model  
Response content-type application/json  
Response example
{
   "content_type": "application/json",
   "last_modifier": "tester",
   "create_time": "2011-02-24T05:41:34Z",
   "last_modified": "2011-02-24T05:41:34Z",
   "access_rights": {
      "tester": "F"
   },
   "content_md5": "EF7142254CD653D987E9A9E8A48C01D3",
   "app_type": "application",
   "app_id": "a-4e21f6e9-2ca7-4a3a-a5cc-00f04f7b7f08",
   "app_name": "test",
   "creator": "tester"
}
 
Response header location https://localhost/resources/virtualApplicationPatterns/a-4e21f6e9-2ca7-4a3a-a5cc-00f04f7b7f08  
Response code 201 Created
  401 The user is not authorized to perform this action.
  403 Access forbidden
  412 Invalid parameter supplied, for example, the JSON file is invalid.
  415 Invalid content type
  500 Unexpected error

Create an application pattern from an existing application or template (clone)

POST /resources/virtualApplicationPatterns/?source={app_id}&app_name={name}&app_type={app_type}
A unique ID is generated for the application.
  • Attribute "source": specify application template or application (required)
  • Attribute "app_name": specify application name (required)
  • Attribute "app_type": specify application type for target application. The values can be application or template. The default value is application.
Table 4. Create an application pattern from an existing application or template (clone)
REST API information Value Description
Example URL https://localhost/resources/virtualApplicationPatterns/?source=a-679a68f4-6798-424f-8039-1f682f949f45&app_name=testApp

Create an application name testAppfrom application with ID a-679a68f4-6798-424f-8039-1f682f949f45

 
Response content-type application/json  
Response example
{
   "content_type": "application/json",
   "last_modifier": "tester",
   "create_time": "2011-02-24T05:41:34Z",
   "last_modified": "2011-02-24T05:41:34Z",
   "access_rights": {
      "AllUsers": "R",
      "tester": "F"
   },
   "content_md5": "7AB9C3524906672BB0E1EA0209FF3803",
   "app_type": "application",
   "app_id": "a-fb70796e-1b13-467a-babe-b8b700bd563b",
   "app_name": "testApp",
   "creator": "tester"
}
 
Response header location https://localhost/resources/virtualApplicationPatterns/a-fb70796e-1b13-467a-babe-b8b700bd563b  
Response code 201 Created
  401 The user is not authorized to perform this action.
  403 Access forbidden
  412 Invalid parameter supplied, for example, the application ID is not found.
  415 Invalid content type
  500 Unexpected error

Deploy a virtual application pattern

There are two options when you deploy a virtual application pattern:
  1. Deploy the application with the placement that is determined by the system, if applicable, or by not using placement if it is not supported by the application. To deploy the application with this method, use the POST REST API and do not include the placement_only parameter in the request body, or set it to False.
  2. Modify the placement before you deploy the application, and use the modified placement for the deployment. To use this method, the deployment must be called in two phases:
    • First, generate the placement and topology by including placement_only:"True" in the request body.

      This parameter tells the system to generate a placement for the deployment, which is returned in response body. You can modify this placement before you pass it to the system in the second phase to deploy the pattern.

    • Then, deploy the pattern by calling the PUT REST API with the deployPlacement operation, and pass the modified placement for the deployment in the request body.
Note:
  • Because placement is handled by the system, you do not have to specify a cloud group or IP group if an environment profile is specified. If the pattern cannot use placement, then the cloud group and IP group parameters are required. For example, if some of the plug-ins in the pattern do not require Foundation 2.1, the application cannot use placement. In this scenario, the cloud group and IP group are required. If you do not specify these parameters for a pattern that cannot use placement, the deployment fails.
  • If "placement_only":True is in the request body, but placement is not supported for the pattern, that parameter is ignored by the system. The pattern is deployed as if the placement_only was not specified, or was set to False.
Restriction: If your API version is less than 5.0.0.0:
  • The cloud group and IP group are required parameters.
  • Deploying to an environment profile with the cloud management type set to "By way of external network" is not supported.
Deploy the application, or generate the placement if you are using the two-phase method:
POST /resources/virtualApplicationPatterns/pattern ID/virtualApplicationInstances/ 
Table 5. Deploy a virtual application pattern
REST API information Value Description
Example URL http://server/resources/virtualApplicationPatterns/a-123/virtualApplicationInstances/  
Request content-type application/json  
Request body example Request body example for a one-phase deployment that either uses the placement that is determined by the system, or does not use placement:
{
	"deployment_name": "My Virtual Application",
  "environment_profile_id": "1",
  "ssh_keys":["ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCevpm4/EYFrjQ9NkC535Whr3Yswv2xJkxGz44/2g5uC6385hWvEycSAyoUQ3pt6/n4BxMHxilLVrT3y9FhyGBfIkJsySvzsiMVe0shh7JWct03uCiiQ5emoe2eaVOiYz2P5vBe9V8amTC1Is+Uv/SXFF7UuKlV7gP8hBuBNGwnN2/hI6dKtZKH2GDcJbPz9J9dFl2XQYoX7XnaJ3eea+UZfIvS21Gi7SF3Ff+/UdPuOumHGhw1S1POGbApFStjOWXU92p6Mz4wON+mRtWzYXGEdlXDAQisX8yBlZdVZ6+g4HB2cv5TWvYchiAYqG6M1B5tZIr/ZYzEZVTjd4ZCQMwR auto generated key"] 
}
Request body for the first phase of a two-phase deployment. Set "placement_only": true in the request body:
{
	"deployment_name": "Two nodes_testname",
	"ssh_keys": ["ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCoh/DkvoUoio7rMUtoYFGuqFVF+07igSjxylqhTt/8xM8jjTpBY6qngFBqyjI76ss522Gf8ubqNarqzL6cqLm7ZLI5Fz4FvwQmbux9xK9zicoZ/Hi1QAzN9mcYt0w7zFKrx79HEye7VZMCeR5PzsATb9oI8F3frx2oS/kFTUNRyul8nTSND3Ae98dcxUUYaXCLkNuSdQsZV1rUjxJxQcL0010EiV5TYRtucvznIQ4U5MU2uKP7iLz2/AYojnFafIZi8xD/W/tEj9lCzvKYLiQzsfmsD/2boziE44d+Af0MjX7DRjZDgF1LJpfnoSFS3PEjeN03jQCqq53LkkWkN5Wb iwd-generated-rsa-key-20140522",
	"environment_profile_id": "1",
	"placement_only": true
} 
 
Response headers content-type application/json  
Response body example Response body example for a one-phase deployment that either uses the placement that is determined by the system, or does not use placement:
{
   "status": "RUNNING",
   "deployment_id": "d-7956c64e-0fac-49f2-b04e-efbc131a4cc4",
   "deployment_name": "db2",
   "app_type": "application",
   "app_id": "a-3761fe57-2bda-4f9b-b90c-d2c435d69cb7",
   "start_time": "2011-03-25T17:02:57.878Z",
   "virtual_system": {
    "id":"1"
}
   "instances": [
      {
         "status": "RUNNING",
         "master": true,
         "last_update": "2011-03-25T17:11:13.750Z",
         "private_ip": "1xx.1x2.165.49",
         "reboot.count": 0,
         "stopped.by": "",
         "volumes": [
         ],
         "start_time": "2011-03-25T17:03:51.654Z",
         "id": "rack9.xdblade32b04.22889.03473",
         "name": "database-db2.11301072577884",
         "roles": [
            {
               "node": "database-db2.11301072577884",
               "status": "RUNNING",
               "last_update": "2011-03-25T17:11:14.840Z",
               "external_uri": "jdbc:db2://1xx.1x2.165.49:50000/mydb:user=appdba;password=FgxmZv47TM8GwJD62Y1;",
               "id": "database-db2.11301072577884.DB2"
            }
         ],
         "public_ip": "1x.1xx.165.49"
      }
   ],
   "role_error": false
}
Response body example for the first phase of a two-phase deployment. When "placement_only": true is included in the request body, placement is returned in the response body:
{
   "placement": {
     ...
   },
   "deployment_url": "https://1xx.0.0.1:9443/services/deployments/d-55e08a31-a3f0-419e-b262-3cdba2cf6be2",
   "app_type": null,
   "topology": [
      {
         "component_id": "OS Node",
         "name": "OS_Node",
         "parameters": [{
         "placement": true,
         "id": "WAS.PASSWORD",
         "label": "ADMIN_USER_PWD_LABEL",
         "description":"ADMIN_USER_PWD_DESCRIPTION",
         "type":"string",
         "displayType":"password"
      }],
         "scaling": {
         "min": 1,
         "max": 10,
         "init": 2
         }
      }
   ],
   "app_id": "a-3712cdf6-c919-45e7-b010-b032cc03e35b",
   "creator_name": "cbadmin",
   "deployment_name": "Two nodes_testname",
   "role_error": false,
   "deployment_id": "d-55e08a31-a3f0-419e-b262-3cdba2cf6be2",
   "creator": "cbadmin"
}
 
Response code 201 Created successfully
  403 Access forbidden
  500 Unexpected error
Second phase of a two-phase deployment:
PUT /resources/virtualApplicationPatterns/pattern ID
You can specify three parameters in the request body:
placement
Required. The modified placement for the deployment.
topology_parameters
Optional. Define the topology parameters that are needed for deployment as a key value map. The key format is topologyname.parameterid. For example, WAS.PASSWORD.
addon_parameters
Optional. Define the topology parameters that are needed for deployment as a key value map.
Table 6. Deploy a virtual application pattern - second phase with modified placement
REST API information Value Description
Example URL https://localhost/resources/virtualApplications/d-55e08a31-a3f0-419e-b262-3cdba2cf6be2  
Request content-type application/json

Specify the updated placement in the request body.

 
Request example
{
    "operation": "deployPlacement",
    "topology_parameters": {},
    "addon_parameters": {},
    "placement": { //required
        "vm-templates": [{
            "locations": [{
                "name": "1721665121",
                "cloud_groups": [{
                    "name": "esxset15",
                    "instances": [{
                        "new_instances": 1,
                        "nics": [{
                            "ip_groups": [{
                                "name": "172",
                                "new_instances": 1,
                                "purpose": "data"
                            }],
                            "name": "management",
                            "purpose": "data"
                        }]
                    }]
                }],
                "new_instances": 1
            },
            {
                "name": "1721665123",
                "cloud_groups": [{
                    "name": "esxset16",
                    "instances": [{
                        "new_instances": 1,
                        "nics": [{
                            "ip_groups": [{
                                "name": "172_2",
                                "purpose": "data",
                                "new_instances": 1
                            }],
                            "name": "management",
                            "purpose": "data"
                        }]
                    }]
                }],
                "messages": ["CWZKS6401E: 1721665123 is missing image IBM OS Image for Red Hat Linux Systems:2.1.0.0."],
                "new_instances": 1
            }],
            "environment_profile": "MyTest",
            "name": "Web_Application-was",
            "new_instances": 2
        }],
        "version": "5.0.0.0"
    }
}
 
Response code 200 OK
  401 The user is not authorized to perform this action.
  403 Access forbidden
  404 The application that is specified by {appID} is not found.
  412 A specified parameter is not valid. For example, the JSON file is not valid.
  500 Unexpected error

Update a virtual application pattern

PUT /resources/virtualApplicationPatterns/{app_id}
Table 7. Update a virtual application pattern
REST API information Value Description
Example URL https://localhost/resources/virtualApplicationPatterns/a-cdaac959-672c-4df7-a648-b333a3843422  
Request content-type and body Content-Type - application/json (body is the application model JSON file)

Content-Type - application/zip (body is compressed file, including the application model and artifacts files)

 
Request content-type application/json  
Response body example
{
   "content_type": "application/json",
   "last_modifier": "tester",
   "create_time": "2011-02-24T05:41:34Z",
   "last_modified": "2011-02-24T05:41:34Z",
   "access_rights": {
      "tester": "F"
   },
   "content_md5": "5B8F7E6CF56F7CE804788C0086589AFF",
   "app_type": "application",
   "app_id": "a-fb70796e-1b13-467a-babe-b8b700bd563b",
   "name": "App for Testing",
   "locked": "false",
	"creator": "tester"
}
 
Response code 200 OK
  401 The user is not authorized to perform this action.
  403 Access forbidden
  404 The application that is specified by {appID} is not found.
  412 A specified parameter is not valid. For example, the JSON file is not valid.
  500 Unexpected error

Delete a specified application pattern

DELETE /resources/virtualApplicationPatterns/{app_id}
Table 8. Delete a specified virtual application pattern
REST API information Value Description
Example URL https://localhost/resources/virtualApplicationPatterns/a-cdaac959-672c-4df7-a648-b333a3843422  
Response content-type application/json  
Response code 200 OK
Note: If an application specified by {appID} is not found, the 200 response code returns, response body: {"success": "false"})
  401 The user is not authorized to perform this action.
  403 Access forbidden
  409 Conflict
  500 Unexpected error