-
Notifications
You must be signed in to change notification settings - Fork 443
Expand file tree
/
Copy pathsandbox_metadata_patch.go
More file actions
48 lines (36 loc) · 1.23 KB
/
Copy pathsandbox_metadata_patch.go
File metadata and controls
48 lines (36 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package handlers
import (
"fmt"
"net/http"
"github.com/gin-gonic/gin"
"github.com/e2b-dev/infra/packages/api/internal/api"
"github.com/e2b-dev/infra/packages/api/internal/utils"
"github.com/e2b-dev/infra/packages/auth/pkg/auth"
"github.com/e2b-dev/infra/packages/shared/pkg/ginutils"
"github.com/e2b-dev/infra/packages/shared/pkg/telemetry"
)
func (a *APIStore) PatchSandboxesSandboxIDMetadata(
c *gin.Context,
sandboxID string,
) {
ctx := c.Request.Context()
var err error
sandboxID, err = utils.ShortID(sandboxID)
if err != nil {
a.sendAPIStoreError(c, http.StatusBadRequest, "Invalid sandbox ID")
return
}
team := auth.MustGetTeamInfo(c)
body, err := ginutils.ParseBody[api.PatchSandboxesSandboxIDMetadataJSONRequestBody](ctx, c)
if err != nil {
a.sendAPIStoreError(c, http.StatusBadRequest, fmt.Sprintf("Error when parsing request: %s", err))
telemetry.ReportCriticalError(ctx, "error when parsing request", err)
return
}
if apiErr := a.orchestrator.PatchSandboxMetadata(ctx, team.ID, sandboxID, body); apiErr != nil {
telemetry.ReportErrorByCode(ctx, apiErr.Code, "error patching sandbox metadata", apiErr.Err)
a.sendAPIStoreError(c, apiErr.Code, apiErr.ClientMsg)
return
}
c.Status(http.StatusNoContent)
}