Skip to content

Commit 7e2ac1f

Browse files
committed
Revert
1 parent f53589c commit 7e2ac1f

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package event
2+
3+
import (
4+
"time"
5+
6+
"github.com/google/uuid"
7+
)
8+
9+
type SandboxEvent struct {
10+
Timestamp time.Time `json:"timestamp"`
11+
SandboxID string `json:"sandbox_id"`
12+
SandboxExecutionID string `json:"sandbox_execution_id"`
13+
SandboxTemplateID string `json:"sandbox_template_id"`
14+
SandboxBuildID string `json:"sandbox_build_id"`
15+
SandboxTeamID uuid.UUID `json:"sandbox_team_id"`
16+
EventCategory string `json:"event_category"`
17+
EventLabel string `json:"event_label"`
18+
EventData string `json:"event_data,omitempty"`
19+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package webhooks
2+
3+
import (
4+
"fmt"
5+
"slices"
6+
7+
"github.com/google/uuid"
8+
)
9+
10+
const WebhookKeyPrefix = "wh"
11+
12+
const WebhooksChannel = "sandbox-webhooks"
13+
14+
func DeriveKey(teamID uuid.UUID) string {
15+
return fmt.Sprintf("%s:%s", WebhookKeyPrefix, teamID.String())
16+
}
17+
18+
type SandboxLifecycleEvent string
19+
20+
const (
21+
SandboxLifecycleEventCreate SandboxLifecycleEvent = "create"
22+
SandboxLifecycleEventKill SandboxLifecycleEvent = "kill"
23+
SandboxLifecycleEventPause SandboxLifecycleEvent = "pause"
24+
SandboxLifecycleEventResume SandboxLifecycleEvent = "resume"
25+
SandboxLifecycleEventUpdate SandboxLifecycleEvent = "update"
26+
)
27+
28+
var AllowedLifecycleEvents = []string{
29+
string(SandboxLifecycleEventCreate),
30+
string(SandboxLifecycleEventKill),
31+
string(SandboxLifecycleEventPause),
32+
string(SandboxLifecycleEventResume),
33+
string(SandboxLifecycleEventUpdate),
34+
}
35+
36+
func IsLifecycleEvent(event string) bool {
37+
return slices.Contains(AllowedLifecycleEvents, event)
38+
}
39+
40+
type SandboxWebhooksMetaData struct {
41+
Events []SandboxLifecycleEvent `json:"events"`
42+
URL string `json:"url"`
43+
}

0 commit comments

Comments
 (0)