Che: Is there REST API provided from eclipse che latest version?

Created on 8 Feb 2020  ·  5Comments  ·  Source: eclipse/che

Problem

I'm using eclipse che on kubernetes using docker desktop for windows
I want to create or stop(or delete) workspace through HTTP REST API
Is there REST API provided from eclipse che?
I searched on the internet, but the most of them are not found since they been shown “404 error page” and some seems to be deprecated(For example, swagger.. )

My service flow is as below:

  1. Click the button in my website
    (the button has project's information. For example, git url, project name, ...)
  2. Using the project's information, request to create workspace through REST API
  3. Open eclipse IDE in new window while creating the workplace.

Summary

Is there REST API provided from eclipse che latest version?

Relevant information

I have using eclipse che latest version

kinquestion

All 5 comments

@leehyeongrak
Try this

To create a workspace

curl 'https://che-che.apps-crc.testing/api/workspace/devfile?attribute=stackName:NodeJS+Angular+Web+Application&infrastructure-namespace=skabashn-che&namespace=skabashn' -H 'Authorization: Bearer ${KEYCLOAK_TOKEN}' --data-binary '{"apiVersion":"1.0.0","metadata":{"generateName":"angular-","name":"wksp-uu57"},"projects":[{"name":"angular-realworld-example-app","source":{"type":"git","location":"https://github.com/gothinkster/angular-realworld-example-app"}}],"components":[{"type":"chePlugin","id":"che-incubator/typescript/latest"},{"type":"dockerimage","alias":"nodejs","image":"quay.io/eclipse/che-nodejs10-community:nightly","memoryLimit":"1Gi","endpoints":[{"name":"angular","port":4200}],"mountSources":true}],"commands":[{"name":"yarn install","actions":[{"type":"exec","component":"nodejs","command":"yarn install","workdir":"${CHE_PROJECTS_ROOT}/angular-realworld-example-app"}]},{"name":"build","actions":[{"type":"exec","component":"nodejs","command":"yarn run build","workdir":"${CHE_PROJECTS_ROOT}/angular-realworld-example-app"}]},{"name":"start","actions":[{"type":"exec","component":"nodejs","command":"yarn run start --host 0.0.0.0 --disableHostCheck true","workdir":"${CHE_PROJECTS_ROOT}/angular-realworld-example-app"}]},{"name":"lint","actions":[{"type":"exec","component":"nodejs","command":"yarn run lint","workdir":"${CHE_PROJECTS_ROOT}/angular-realworld-example-app"}]}]}'

To start workspace

curl 'https://che-che.apps-crc.testing/api/workspace/${workspaceID}/runtime' -X POST  -H 'Authorization: Bearer ${KEYCLOAK_TOKEN}' 

Also, you might want to consider to use factories https://www.eclipse.org/che/docs/che-7/configuring-a-workspace-using-a-devfile/#creating-a-workspace-from-the-default-branch-of-a-git-repository_configuring-a-workspace-using-a-devfile
It is a much easier way to embed Eclipse Che functionality to your site.

@skabashnyuk we do not generate openapi shema / swagger URL anymore?

@skabashnyuk
Thanks for the answer!
I have another question about it
Is there a way to create workspace from a private git repository when creating a workspace using the REST API?
I sent a request with private git repository URL as above but git clone failed..
Is there a safe way to create a workspace with private git project using a personal access token or something else?

Thank you for your help.

@leehyeongrak in theory it should be possible with ssh keys.
@ibuziuk we do generate swagger.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sleshchenko picture sleshchenko  ·  3Comments

JamesDrummond picture JamesDrummond  ·  3Comments

skabashnyuk picture skabashnyuk  ·  3Comments

vanzhiganov picture vanzhiganov  ·  3Comments

sudheerherle picture sudheerherle  ·  3Comments