Hi Shiro,

I found a problem with GET cartridges method:
Now it is not possible to get cartridges for a given cartridge type:

GET /cartridges/{cartridgeType}


On Thu, Dec 11, 2014 at 12:19 PM, Shiroshica Kulatilake <shiro@wso2.com> wrote:
This was actually an effort from many contributers - so should thank everyone ! :)

We still have to do some more work to make this perfect
1. Make the responses also consistent - https://issues.apache.org/jira/browse/STRATOS-1028
2. We also should consider what to do with the v4.0 REST api - most of the operations are not valid anymore
3. CLI needs to be updated

On Thu, Dec 11, 2014 at 12:14 PM, Lakmal Warusawithana <lakmal@wso2.com> wrote:
Yes, this is great, very clear now. Thanks Shiro.

On Thu, Dec 11, 2014 at 11:54 AM, Reka Thirunavukkarasu <reka@wso2.com> wrote:
Great work Shiro..!!! The paths are very consistent now..


On Thu, Dec 11, 2014 at 11:37 AM, Mariangela Hills <mariangela@wso2.com> wrote:
I will update the wiki!



Mariangela Hills
Senior Technical Writer
WSO2, Inc.

On Thu, Dec 11, 2014 at 10:59 AM, Imesh Gunaratne <imesh@apache.org> wrote:
Great work Shiro! We might need to update the Wiki with this.


On Wed, Dec 10, 2014 at 4:29 PM, Nirmal Fernando <nirmal070125@gmail.com> wrote:
Great work Shiro on seeing this through !! 

On Wed, Dec 10, 2014 at 3:14 PM, Shiroshica Kulatilake <shiro@wso2.com> wrote:

The Stratos REST api has been modified as follows.

1. Autoscaling Policies

Resource pathDescription
POST/autoscalingPoliciesCreates a new autoscaling policy
GET/autoscalingPoliciesGets all created autoscaling policies
GET/autoscalingPolicies/{autoscalePolicyId}Gets a specific autoscaling policy
PUT/autoscalingPoliciesUpdates an existing autoscaling policy

2. Cartridges

Resource pathDescription
POST/cartridgesCreate a new cartridge definition
GET/cartridgesGet all available cartridges
GET/cartridges/{filter}?criteria=criteriaGet all available cartridges for a particular filter value
GET/cartridges/{filter}/{cartrdigeType}Get a specific cartridge within a filter value
DELETE/cartridges/{cartridgeType}Delete a specific cartridge definition

- The filter methods in cartridge are to filter cartridges by specifc values.
   e.g. /cartridges/multiTenant would give a list of all multitenant cartridges
   Similar values which can be used are - "singleTenant", "loadBalancer" and "provider"
- In the case of filtering cartridges by provider it is also needed to specify the provider name - so in this case you would need to specify that using the query parameter criteria
  e.g. /cartridges/provider?criteria=<value>

3. Groups

Resource pathDescription
POST/groupsCreate a new group definition
GET/groupsGet all created group definitions
GET/groups/{groupDefinitionName}Gets a specific group definition
DELETE/groups/{groupDefinitionName}Delete a group definition

4. Applications

Resource pathDescription
GET/applicationsGets all applications created
GET/applications/{applicationId}Gets a specific application
POST/applicationsCreate an application definition
DELETE/applications/{applicationId}Delete an application definition

5. Application Deployments

Resource pathDescription
POST/applicationDeploymentsDeploys an application for a deployment policy
DELETE/applicationDeployments/{applicationId}Undeploys a specific application based on application id

- The resource ApplicationDeployments were introduced to identify the deployment of a particular application according to a deployment policy
- The deplolyment policy json is sent with the POST command

6. Deployment Policies

Resource pathDescription
GET/deploymentPoliciesGet all deployment policies
GET/deploymentPolicies/{deploymentPolicyId}Gets a specific deployment policy
GET/deploymentPolicies/{deploymentPolicyId}/partitionGroupGets partition groups for a specific deployment policy

- Deployment policies are not created separately - instead when a POST /applicationDepoyment with the deployment policy json is sent that deployment policy is created.

7. Subscriptions

Resource pathDescription
GET/subscriptions/{applicationId}Gets subscriptions for an application
GET/subscriptions/cartridges/groups/{serviceGroupId}Gets subscribed cartridges for a service group

8. Clusters

Resource pathDescription
GET/clustersGet Clusters for a tenant
GET/clusters/{cartridgeType}Get clusters for a specific cartridge type
GET/clusters/{clusterId}Get a specifc cluster

9. Kubernetes clusters

Resource pathDescription
POST/kubernetesClustersDeploy a Kubernetes cluster group
PUT/kubernetesClusters/{kubernetesClusterId}/minionDeploy a Kubernetes Host within a cluster group
PUT/kubernetesClusters/{kubernetesClusterId}/masterDeploy a Kubernetes Master within a cluster group
GET/kubernetesClustersGets all Kubernetes cluster groups created
GET/kubernetesClusters/{kubernetesClusterId}Gets a specific Kubernetes cluster
GET/kubernetesClusters/{kubernetesClusterId}/hostsGets hosts of a specific Kubernetes cluster
GET/kubernetesClusters/{kubernetesClusterId}/masterGet master of a specific Kubernetes cluster
DELETE/kubernetesClusters/{kubernetesClusterId}Undeploy a kubernetes cluster group
DELETE/kubernetesClusters/{kubernetesClusterId}/hosts/{hostId}Undeploy a specific host within a Kubernetes cluster group

- the PATCH command is still in discussion hence it has not been changed yet. It is still the old path "/kubernetes/update/host" - a TODO.

10. Tenants

Resource pathDescription
POST/tenantsAdd a new tenant
GET/tenantsGet all tenants
GET/tenants/{tenantDomain}Get a specific tenant
GET/tenants/search/{tenantDomain}Search for a tenants
PUT/tenantsUpdate a tenant
PUT/tenants/activate/{tenantDomain}Activate a tenant
PUT/tenants/deactivate/{tenantDomain}Deactivate a tenant
DELETE/tenants/{tenantDomain}Delete a tenant

11. Users

Resource pathDescription
POST/usersAdd a new user
GET/usersGet all users
PUT/usersUpdate a user
DELETE/users/{userName}Delete a user

Example : To create a single group application where the cartridges are vms (I'm reusing the script used to test grouping) using the rest api is as follows.

1. Create an autoscaling policy
   - curl -X POST -H "Content-Type: application/json" -d @<AS policy json file> -k -v -u admin:admin https://localhost:9443/api/autoscalingPolicies
2. Create cartridges
   - curl -X POST -H "Content-Type: application/json" -d @<cartridge json file> -k -v -u admin:admin https://localhost:9443/api/cartridges
3. Create group
   - curl -X POST -H "Content-Type: application/json" -d @<group json file> -k -v -u admin:admin https://localhost:9443/api/groups
4. Create application
  - curl -X POST -H "Content-Type: application/json" -d @<application json file> -k -v -u admin:admin https://localhost:9443/api/applications
5. Deploy the application
  - curl -X POST -H "Content-Type: application/json" -d@<deployment policy json file> -k -v -u admin:admin https://localhost:9443/api/applicationDeployments

Please note :- Referring to the above email The separation between creation of a deployment policy and deployment of an application is not available in the alpha version of Stratos 4.1.0.

Thank you,

On Tue, Dec 9, 2014 at 1:29 AM, Shiroshica Kulatilake <shiro@wso2.com> wrote:

In order to create a flow and to figure out the required minimal set of REST apis for application handling thought of breaking down the actions up to deploying and undeploying an application in Stratos as follows.

1. Create cartridges needed
    - POST /cartridges with cartridgeDefinition.json
2. View created cartridges or a specific cartridge
    - GET /cartridges, /cartridges/{category}/{criteria}, /cartridges/{category}/{cartrdigeType}
3. Create an autoscaling policy
   - POST /autoscalingPolicies with autoscalingPolicyDefinition.json
4. Viewing created Autoscaling policies
  - GET /autoscalingPolicies, /autoscalingPolicies/{autoscalePolicyId}
5. Create a service group definition
  - POST /groups with groupDefinition.json
6. View created groups
  - GET /groups, /groups/{groupDefinitionName}
7. Create an application
  - POST /applications
8. Viewing created application
  - GET /applications/, /applications/{applicationId}
9. Create a deployment policy for an application
10. View deployment policy
  - GET /deploymentPolicies/{deploymentPolicyId}
11. Deploy an application with the deployment policy
12. Undeploy an application
13. Delete deploymentPolicyDefinition
14. Delete an applicationDefinition

Currently what's missing from the above is another entity which depicts an applicationDeployment.

Then /applications will simply handle the definitions and /applicationDeployments should handle the actual deploy and undeployment of an application based on a deployment policy.

Since a deployment policy is directly linked to an application it should be possible to get all deployment policies defined for a specific application and then pick one of these for the actual application deployment.

Most of this is already there in the current rest api with different naming. I am working on getting the terminology correct and also add the few missing bits.

Thank you,

On Mon, Dec 8, 2014 at 7:08 PM, Imesh Gunaratne <imesh@apache.org> wrote:
+1 We might need to clarify how we connect a deployment policy to an application according to this model.

On Mon, Dec 8, 2014 at 5:40 PM, Lakmal Warusawithana <lakmal@wso2.com> wrote:

On Mon, Dec 8, 2014 at 4:55 PM, Shiroshica Kulatilake <shiro@wso2.com> wrote:
Hi All,

While cleaning up the REST API I noticed that we have used the word "deploy" instead of 'create' in some places.

We need to use these terms consistently IMO

As a first start thought of renaming the api methods in the rest api to reflect this.

Policies = create/delete instead of deploy/undelpoy
Cartridges = create/delete instead of deploy /undeploy
Groups = create/delete instead of deploy/undelpoy
Applications = create, deploy, undeploy and delete



Thank you,

Lakmal Warusawithana
Vice President, Apache Stratos
Director - Cloud Architecture; WSO2 Inc.
Mobile : +94714289692

Imesh Gunaratne

Technical Lead, WSO2
Committer & PMC Member, Apache Stratos

Shiroshica Kulatilake

WSO2, Inc. http://wso2.com/
Phone: +94 776523867

Shiroshica Kulatilake

WSO2, Inc. http://wso2.com/
Phone: +94 776523867

Best Regards,

Nirmal Fernando.
PPMC Member & Committer of Apache Stratos,
Senior Software Engineer, WSO2 Inc.

Imesh Gunaratne

Technical Lead, WSO2
Committer & PMC Member, Apache Stratos

Reka Thirunavukkarasu
Senior Software Engineer,
WSO2, Inc.:http://wso2.com,
Mobile: +94776442007

Lakmal Warusawithana
Vice President, Apache Stratos
Director - Cloud Architecture; WSO2 Inc.
Mobile : +94714289692

Shiroshica Kulatilake

WSO2, Inc. http://wso2.com/
Phone: +94 776523867

Imesh Gunaratne

Technical Lead, WSO2
Committer & PMC Member, Apache Stratos