CreateProjectFromEnvironment
client.Projects.NewFromEnvironment(ctx, body) (*ProjectNewFromEnvironmentResponse, error)
POST/gitpod.v1.ProjectService/CreateProjectFromEnvironment
Creates a new project using an existing environment as a template.
Use this method to:
- Clone environment configurations
- Create projects from templates
- Share environment setups
Examples
-
Create from environment:
Creates a project based on existing environment.
name: "Frontend Project" environmentId: "07e03a28-65a5-4d98-b532-8ea67b188048"
CreateProjectFromEnvironment
package main
import (
"context"
"fmt"
"github.com/gitpod-io/gitpod-sdk-go"
"github.com/gitpod-io/gitpod-sdk-go/option"
)
func main() {
client := gitpod.NewClient(
option.WithBearerToken("My Bearer Token"),
)
response, err := client.Projects.NewFromEnvironment(context.TODO(), gitpod.ProjectNewFromEnvironmentParams{
EnvironmentID: gitpod.F("07e03a28-65a5-4d98-b532-8ea67b188048"),
Name: gitpod.F("Frontend Project"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Project)
}
{
"project": {
"environmentClass": {
"environmentClassId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"localRunner": true,
"order": 0
},
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"automationsFilePath": "automationsFilePath",
"desiredPhase": "PROJECT_PHASE_UNSPECIFIED",
"devcontainerFilePath": "devcontainerFilePath",
"environmentClasses": [
{
"environmentClassId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"localRunner": true,
"order": 0
}
],
"initializer": {
"specs": [
{
"contextUrl": {
"url": "https://example.com"
},
"git": {
"checkoutLocation": "checkoutLocation",
"cloneTarget": "cloneTarget",
"remoteUri": "remoteUri",
"targetMode": "CLONE_TARGET_MODE_UNSPECIFIED",
"upstreamRemoteUri": "upstreamRemoteUri"
}
}
]
},
"metadata": {
"createdAt": "2019-12-27T18:11:19.117Z",
"creator": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"principal": "PRINCIPAL_UNSPECIFIED"
},
"name": "x",
"organizationId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"updatedAt": "2019-12-27T18:11:19.117Z"
},
"prebuildConfiguration": {
"enabled": true,
"enableJetbrainsWarmup": true,
"environmentClassIds": [
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
],
"executor": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"principal": "PRINCIPAL_UNSPECIFIED"
},
"timeout": "+9125115.360s",
"trigger": {
"dailySchedule": {
"hourUtc": 23
}
}
},
"recommendedEditors": {
"editors": {
"foo": {
"versions": [
"string"
]
}
}
},
"technicalDescription": "technicalDescription",
"usedBy": {
"subjects": [
{
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"principal": "PRINCIPAL_UNSPECIFIED"
}
],
"totalSubjects": 0
}
}
}Returns Examples
{
"project": {
"environmentClass": {
"environmentClassId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"localRunner": true,
"order": 0
},
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"automationsFilePath": "automationsFilePath",
"desiredPhase": "PROJECT_PHASE_UNSPECIFIED",
"devcontainerFilePath": "devcontainerFilePath",
"environmentClasses": [
{
"environmentClassId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"localRunner": true,
"order": 0
}
],
"initializer": {
"specs": [
{
"contextUrl": {
"url": "https://example.com"
},
"git": {
"checkoutLocation": "checkoutLocation",
"cloneTarget": "cloneTarget",
"remoteUri": "remoteUri",
"targetMode": "CLONE_TARGET_MODE_UNSPECIFIED",
"upstreamRemoteUri": "upstreamRemoteUri"
}
}
]
},
"metadata": {
"createdAt": "2019-12-27T18:11:19.117Z",
"creator": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"principal": "PRINCIPAL_UNSPECIFIED"
},
"name": "x",
"organizationId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"updatedAt": "2019-12-27T18:11:19.117Z"
},
"prebuildConfiguration": {
"enabled": true,
"enableJetbrainsWarmup": true,
"environmentClassIds": [
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
],
"executor": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"principal": "PRINCIPAL_UNSPECIFIED"
},
"timeout": "+9125115.360s",
"trigger": {
"dailySchedule": {
"hourUtc": 23
}
}
},
"recommendedEditors": {
"editors": {
"foo": {
"versions": [
"string"
]
}
}
},
"technicalDescription": "technicalDescription",
"usedBy": {
"subjects": [
{
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"principal": "PRINCIPAL_UNSPECIFIED"
}
],
"totalSubjects": 0
}
}
}