Skip to content

Commit 7d3b28a

Browse files
committed
Update sandbox metadata
1 parent 3473acb commit 7d3b28a

File tree

13 files changed

+1329
-197
lines changed

13 files changed

+1329
-197
lines changed

packages/api/internal/api/api.gen.go

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/api/internal/api/spec.gen.go

Lines changed: 87 additions & 87 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/api/internal/api/types.gen.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package handlers
2+
3+
import (
4+
"fmt"
5+
"net/http"
6+
7+
"github.com/gin-gonic/gin"
8+
9+
"github.com/e2b-dev/infra/packages/api/internal/api"
10+
"github.com/e2b-dev/infra/packages/api/internal/utils"
11+
"github.com/e2b-dev/infra/packages/shared/pkg/telemetry"
12+
)
13+
14+
func (a *APIStore) PatchSandboxesSandboxID(
15+
c *gin.Context,
16+
sandboxID api.SandboxID,
17+
) {
18+
ctx := c.Request.Context()
19+
sandboxID = utils.ShortID(sandboxID)
20+
21+
body, err := utils.ParseBody[api.PatchSandboxesSandboxIDJSONRequestBody](ctx, c)
22+
if err != nil {
23+
a.sendAPIStoreError(c, http.StatusBadRequest, fmt.Sprintf("Error when parsing request: %s", err))
24+
25+
telemetry.ReportCriticalError(ctx, "error when parsing request", err)
26+
27+
return
28+
}
29+
30+
// Convert the api.SandboxMetadata to map[string]string if it exists
31+
var metadata map[string]string
32+
if body.Metadata != nil {
33+
metadata = *body.Metadata
34+
}
35+
36+
apiErr := a.orchestrator.UpdateSandboxMetadata(ctx, sandboxID, metadata)
37+
if apiErr != nil {
38+
telemetry.ReportError(ctx, "error when updating sandbox metadata", apiErr.Err)
39+
a.sendAPIStoreError(c, apiErr.Code, apiErr.ClientMsg)
40+
41+
return
42+
}
43+
44+
c.Status(http.StatusOK)
45+
}

0 commit comments

Comments
 (0)