Skip to content

Commit 57d669d

Browse files
committed
Stabilize storage and notification contracts
Server and dashboard features now need shared models for bucketed storage, host bindings, storage tokens, and notification routing rules. Keeping these in the SDK prevents each repository from inventing local JSON shapes. Constraint: lattice-server and lattice-dashboard consume these contracts from split repositories Rejected: Keep duplicated local DTOs only | downstream repos would drift and standalone server builds would depend on unpublished shapes Confidence: high Scope-risk: moderate Tested: go test ./...
1 parent ea3afc0 commit 57d669d

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

model/model.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,51 @@ type StaticObject struct {
590590
UpdatedAt time.Time `json:"updated_at"`
591591
}
592592

593+
const (
594+
StorageKindKV = "kv"
595+
StorageKindStatic = "static"
596+
597+
StorageAccessAdmin = "admin"
598+
StorageAccessRead = "read"
599+
StorageAccessWrite = "write"
600+
)
601+
602+
type StorageBucket struct {
603+
ID string `json:"id"`
604+
Kind string `json:"kind"`
605+
Name string `json:"name"`
606+
DisplayName string `json:"display_name,omitempty"`
607+
Description string `json:"description,omitempty"`
608+
IndexDocument string `json:"index_document,omitempty"`
609+
NotFoundDocument string `json:"not_found_document,omitempty"`
610+
CreatedAt time.Time `json:"created_at"`
611+
UpdatedAt time.Time `json:"updated_at"`
612+
}
613+
614+
type StorageBinding struct {
615+
ID string `json:"id"`
616+
Kind string `json:"kind"`
617+
Bucket string `json:"bucket"`
618+
Hostname string `json:"hostname"`
619+
PathPrefix string `json:"path_prefix,omitempty"`
620+
Enabled bool `json:"enabled"`
621+
CreatedAt time.Time `json:"created_at"`
622+
UpdatedAt time.Time `json:"updated_at"`
623+
}
624+
625+
type StorageAccessToken struct {
626+
ID string `json:"id"`
627+
Name string `json:"name"`
628+
TokenHash string `json:"token_hash,omitempty"`
629+
Kind string `json:"kind"`
630+
Access string `json:"access"`
631+
Buckets []string `json:"buckets,omitempty"`
632+
RevokedAt time.Time `json:"revoked_at,omitempty"`
633+
LastUsedAt time.Time `json:"last_used_at,omitempty"`
634+
CreatedAt time.Time `json:"created_at"`
635+
UpdatedAt time.Time `json:"updated_at"`
636+
}
637+
593638
type WorkerScript struct {
594639
ID string `json:"id"`
595640
Name string `json:"name"`
@@ -760,6 +805,22 @@ type NotifyChannel struct {
760805
UpdatedAt time.Time `json:"updated_at"`
761806
}
762807

808+
// NotifyRule routes notification events to one or more destinations. EventTypes
809+
// uses stable server event ids such as monitor.down or ssh.login; "*" matches
810+
// all notification events. Templates are intentionally small string templates
811+
// expanded by the server with event_type, title, and body variables.
812+
type NotifyRule struct {
813+
ID string `json:"id"`
814+
Name string `json:"name"`
815+
EventTypes []string `json:"event_types,omitempty"`
816+
ChannelIDs []string `json:"channel_ids,omitempty"`
817+
TitleTemplate string `json:"title_template,omitempty"`
818+
BodyTemplate string `json:"body_template,omitempty"`
819+
Enabled bool `json:"enabled"`
820+
CreatedAt time.Time `json:"created_at"`
821+
UpdatedAt time.Time `json:"updated_at"`
822+
}
823+
763824
// TunnelIngress maps a public hostname to a node-local service for a Cloudflare
764825
// Tunnel. Service is a cloudflared service URL, e.g. http://localhost:8088,
765826
// ssh://localhost:22, or the literal http_status:404.

0 commit comments

Comments
 (0)