-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Uptime is set periodically by the agent. Additionally, removed unnecessary properties from the ProjectInfo struct. Signed-off-by: Toma Puljak <[email protected]>
- Loading branch information
Showing
27 changed files
with
1,088 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2024 Daytona Platforms Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package workspace | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"time" | ||
|
||
"github.com/daytonaio/daytona/pkg/api/controllers/workspace/dto" | ||
"github.com/daytonaio/daytona/pkg/server" | ||
"github.com/daytonaio/daytona/pkg/workspace" | ||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
// SetProjectState godoc | ||
// | ||
// @Tags workspace | ||
// @Summary Set project state | ||
// @Description Set project state | ||
// @Param workspaceId path string true "Workspace ID or Name" | ||
// @Param projectId path string true "Project ID" | ||
// @Param setState body SetProjectState true "Set State" | ||
// @Success 200 | ||
// @Router /workspace/{workspaceId}/{projectId}/state [post] | ||
// | ||
// @id SetProjectState | ||
func SetProjectState(ctx *gin.Context) { | ||
workspaceId := ctx.Param("workspaceId") | ||
projectId := ctx.Param("projectId") | ||
|
||
var setProjectStateDTO dto.SetProjectState | ||
err := ctx.BindJSON(&setProjectStateDTO) | ||
if err != nil { | ||
ctx.AbortWithError(http.StatusBadRequest, fmt.Errorf("invalid request body: %s", err.Error())) | ||
return | ||
} | ||
|
||
server := server.GetInstance(nil) | ||
|
||
_, err = server.WorkspaceService.SetProjectState(workspaceId, projectId, &workspace.ProjectState{ | ||
Uptime: setProjectStateDTO.Uptime, | ||
UpdatedAt: time.Now().Format(time.RFC1123), | ||
}) | ||
if err != nil { | ||
ctx.AbortWithError(http.StatusInternalServerError, fmt.Errorf("failed to stop workspace %s: %s", workspaceId, err.Error())) | ||
return | ||
} | ||
|
||
ctx.Status(200) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.