Tuesday, July 19, 2016

Create Application in WSO2 App Cloud via REST API

This blog post gives you some examples on how to use createApplication REST API correctly in WSO2 App Cloud https://docs.wso2.com/display/AppCloud/Published+APIs

Before invoke createApplication API, you need to login to the WSO2 App Cloud and get the session cookie.
curl -c cookies -v -k -X POST -k https://apps.cloud.wso2.com/appmgt/site/blocks/user/login/ajax/login.jag -d 'action=login&userName=amalka.wso2.com@<tenant>&password=<password>’

This are some basic example to create applications in WSO2 App Cloud.

Create application via upload from file system

curl -v -k -b cookies -X POST https://apps.cloud.wso2.com/appmgt/site/blocks/application/application.jag -F action=createApplication -F applicationName=SampleFile -F applicationDescription=desc -F runtime=1 -F appTypeName=war -F applicationRevision=1.0.0 -F uploadedFileName=sample.war -F runtimeProperties=[] -F tags=[]  -F fileupload=@/home/amalka/Downloads/sample.war -F isFileAttached=true -F conSpec=3 -F isNewVersion=false -F appCreationMethod=default

Create a version of the application created above

curl -v -k -b cookies -X POST https://apps.cloud.wso2.com/appmgt/site/blocks/application/application.jag -F action=createApplication -F applicationName=SampleFile -F applicationDescription=desc -F runtime=1 -F appTypeName=war -F applicationRevision=2.0.0 -F uploadedFileName=sample.war -F runtimeProperties=[] -F tags=[]  -F fileupload=@/home/amalka/Downloads/sample.war -F isFileAttached=true -F conSpec=3 -F isNewVersion=true -F appCreationMethod=default

Create application via upload from url

curl -v -k -b cookies -X POST https://apps.cloud.wso2.com/appmgt/site/blocks/application/application.jag -F action=createApplication -F applicationName=SampleURL -F applicationDescription=desc -F runtime=1 -F appTypeName=war -F applicationRevision=1.0.0 -F uploadedFileName=war_sample.war -F runtimeProperties=[] -F tags=[]  -F artifactUrl=https://github.com/wso2/app-cloud/raw/master/samples/artifacts/war_sample.war -F conSpec=3 -F isNewVersion=false -F appCreationMethod=url

Create application via clone GitHub repository

curl -v -k -b cookies -X POST https://apps.cloud.wso2.com/appmgt/site/blocks/application/application.jag -F action=createApplication -F applicationName=SampleGitHub -F applicationDescription=desc -F runtime=5 -F appTypeName=jaggery -F applicationRevision=1.0.0 -F runtimeProperties=[] -F tags=[]  -F conSpec=3 -F isNewVersion=false -F appCreationMethod=github -F gitRepoUrl=https://github.com/SabraO/DSSample.git -F gitRepoBranch=master -F projectRoot=/JaggerySample



action=createApplication
The action we are calling
applicationName=
Valid characters a-z A-Z 0-9 -
Space are not allowed
Numbers only names not allowed
Not case sensitive
applicationDescription=
Give a description for the application
appTypeName=
values [war, mss, php, jaggery, wso2dataservice]
runtime=
values [1, 2, 3, 4, 5, 6, 7]
applicationRevision=
format major.minor.patch
uploadedFileName=
Name of the file uploading
runtimeProperties=
Define runtime properties
[{"key":"enableAnalytics","value":"true"}]
tags=
Define tags
[{"key":"lifecycle","value":"development"}]
fileupload=
should starts with @
isFileAttached=
values [true, false]
conSpec=
values [1, 2, 3, 4, 5, 6, 7, 8]
isNewVersion=
values [true, false]
appCreationMethod=
values [default, url, github]
artifactUrl=
Specify url to download the artifact
gitRepoUrl=
Specify GitHub repository url
gitRepoBranch=
Specify GitHub repository branch
projectRoot=
Specify project root
applicationContext=
Specify application context.


Currently, WSO2 App Cloud supports number of app types, runtimes and container specifications. Following tables will help you to identify relevant runtimes, container specifications, supported app creation methods per app types.

Supported runtimes and app creation methods per app types


App type
Supported Runtime
Supported App creation method
1
war
1, 6
default, url
2
mss
2, 8
default, url
3
php
3
default, url, github
4
jaggery
5
default, url, github
5
wso2dataservice
7
default, url

Supported container specifications per runtimes


Runtimes
Supported Container specs
1
Apache Tomcat 8.0.28 / WSO2 Application Server 6.0.0-M1
3, 4
2
OpenJDK 8 + WSO2 MSF4J 1.0.0
2, 3, 4
3
Apache 2.4.10  
1, 2, 3
4
Carbon 4.2.0      

5
Jaggery 0.11.0
3, 4
6
Apache Tomcat 8.0.28 / WSO2 Application Server 6.0.0-M2
3, 4
7
WSO2 Data Services Server - 3.5.0
3, 4
8
OpenJDK 8 + WSO2 MSF4J 2.0.0
2, 3, 4

Container Specifications

Spec Id
Spec Name
CPU
Memory
1
128MB RAM and 0.1x vCPU
100
128
2
256MB RAM and 0.2x vCPU
200
256
3
512MB RAM and 0.3x vCPU
300
512
4
1024MB RAM and 0.5x vCPU
500
1024



No comments: