{"modulePath":"github.com/launchdarkly/ldcli","version":"v1.18.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package model\n\nPackage model provides dev projects and flag override data models for the api handler to use. It exists so that it can also notify observers to support streaming updates\n\n## Functions\n\n```go\nfunc ContextWithEventStore(ctx context.Context, store EventStore) context.Context\n```\n\n```go\nfunc ContextWithStore(ctx context.Context, store Store) context.Context\n```\n\n```go\nfunc CreateOrSyncProject(ctx context.Context, settings InitialProjectSettings) error\n```\n\n```go\nfunc DeleteOverride(ctx context.Context, projectKey, flagKey string) error\n```\n\n```go\nfunc DeleteOverrides(ctx context.Context, projectKey string) error\n```\n\n```go\nfunc EventStoreMiddleware(store EventStore) mux.MiddlewareFunc\n```\n\n```go\nfunc ObserversMiddleware(observers *Observers) func(handler http.Handler) http.Handler\n```\n\n```go\nfunc RestoreDb(ctx context.Context, stream io.Reader) error\n```\n\n```go\nfunc SetObserversOnContext(ctx context.Context, observers *Observers) context.Context\n```\n\n```go\nfunc StoreMiddleware(store Store) mux.MiddlewareFunc\n```\n\n## Types\n\n```go\ntype DebugSession struct {\n\tKey        string    `json:\"key\"`\n\tWrittenAt  time.Time `json:\"written_at\"`\n\tEventCount int64     `json:\"event_count\"`\n}\n```\nDebugSession represents a debug session with metadata\n\n```go\ntype DebugSessionsPage struct {\n\tSessions   []DebugSession `json:\"sessions\"`\n\tTotalCount int64          `json:\"total_count\"`\n\tHasMore    bool           `json:\"has_more\"`\n}\n```\nDebugSessionsPage represents a paginated response of debug sessions\n\n```go\ntype Environment struct {\n\tKey  string\n\tName string\n}\n```\n\n```go\nfunc GetEnvironmentsForProject(ctx context.Context, projectKey string, query string, limit *int) ([]Environment, error)\n```\n\n```go\ntype ErrAlreadyExists struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewErrAlreadyExists(kind, key string) ErrAlreadyExists\n```\n\n```go\nfunc (e ErrAlreadyExists) Error() string\n```\n\n```go\ntype ErrNotFound struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewErrNotFound(kind, key string) ErrNotFound\n```\n\n```go\nfunc (e ErrNotFound) Error() string\n```\n\n```go\ntype Event struct {\n\tID        int64           `json:\"id\"`\n\tWrittenAt time.Time       `json:\"written_at\"`\n\tKind      string          `json:\"kind\"`\n\tData      json.RawMessage `json:\"data\"`\n}\n```\nEvent represents a stored event with metadata\n\n```go\ntype EventStore interface {\n\tCreateDebugSession(ctx context.Context, debugSessionKey string) error\n\tWriteEvent(ctx context.Context, debugSessionKey string, kind string, data json.RawMessage) error\n\tQueryEvents(ctx context.Context, debugSessionKey string, kind *string, limit int, offset int) (*EventsPage, error)\n\tQueryDebugSessions(ctx context.Context, limit int, offset int) (*DebugSessionsPage, error)\n\tDeleteDebugSession(ctx context.Context, debugSessionKey string) error\n}\n```\n\n```go\nfunc EventStoreFromContext(ctx context.Context) EventStore\n```\n\n```go\ntype EventsPage struct {\n\tEvents     []Event `json:\"events\"`\n\tTotalCount int64   `json:\"total_count\"`\n\tHasMore    bool    `json:\"has_more\"`\n}\n```\nEventsPage represents a paginated response of events\n\n```go\ntype FlagState struct {\n\tValue       ldvalue.Value `json:\"value\"`\n\tVersion     int           `json:\"version\"`\n\tTrackEvents bool          `json:\"trackEvents\"`\n}\n```\n\n```go\ntype FlagValue = ldvalue.Value\n```\n\n```go\ntype FlagVariation struct {\n\tFlagKey string\n\tVariation\n}\n```\n\n```go\ntype FlagsState map[string]FlagState\n```\n\n```go\nfunc FromAllFlags(sdkFlags flagstate.AllFlags) FlagsState\n```\n\n```go\ntype InitialProjectSettings struct {\n\tEnabled    bool\n\tProjectKey string\n\tEnvKey     string\n\tContext    *ldcontext.Context   `json:\"context,omitempty\"`\n\tOverrides  map[string]FlagValue `json:\"overrides,omitempty\"`\n\tSyncOnce   bool\n}\n```\n\n```go\ntype Observer interface {\n\tHandle(interface{})\n}\n```\n\n```go\ntype Observers struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc GetObserversFromContext(ctx context.Context) *Observers\n```\n\n```go\nfunc NewObservers() *Observers\n```\n\n```go\nfunc (o *Observers) DeregisterObserver(observerId uuid.UUID) bool\n```\n\n```go\nfunc (o *Observers) Notify(event interface{})\n```\n\n```go\nfunc (o *Observers) RegisterObserver(observer Observer) uuid.UUID\n```\n\n```go\ntype Override struct {\n\tProjectKey string\n\tFlagKey    string\n\tValue      ldvalue.Value\n\tActive     bool\n\tVersion    int\n}\n```\n\n```go\nfunc UpsertOverride(ctx context.Context, projectKey, flagKey string, value ldvalue.Value) (Override, error)\n```\n\n```go\nfunc (o Override) Apply(state FlagState) FlagState\n```\n\n```go\ntype OverrideEvent struct {\n\tFlagKey    string\n\tProjectKey string\n\tFlagState  FlagState\n}\n```\nEvent for individual flag overrides\n\n```go\ntype Overrides []Override\n```\n\n```go\nfunc (o Overrides) GetFlag(key string) (Override, bool)\n```\n\n```go\ntype Project struct {\n\tKey                  string\n\tSourceEnvironmentKey string\n\tContext              ldcontext.Context\n\tLastSyncTime         time.Time\n\tAllFlagsState        FlagsState\n\tAvailableVariations  []FlagVariation\n}\n```\n\n```go\nfunc CreateProject(ctx context.Context, projectKey, sourceEnvironmentKey string, ldCtx *ldcontext.Context) (Project, error)\n```\nCreateProject creates a project and adds it to the database.\n\n```go\nfunc UpdateProject(ctx context.Context, projectKey string, context *ldcontext.Context, sourceEnvironmentKey *string) (Project, error)\n```\n\n```go\nfunc (project Project) GetFlagStateWithOverridesForProject(ctx context.Context) (FlagsState, error)\n```\n\n```go\ntype Store interface {\n\t// DeactivateOverride deactivates the override for the flag, returning the updated version of the override.\n\t// ErrNotFound is returned if there isn't an override for the flag.\n\tDeactivateOverride(ctx context.Context, projectKey, flagKey string) (int, error)\n\tGetDevProjectKeys(ctx context.Context) ([]string, error)\n\t// GetDevProject fetches the project based on the projectKey. If it doesn't exist, ErrNotFound is returned\n\tGetDevProject(ctx context.Context, projectKey string) (*Project, error)\n\tUpdateProject(ctx context.Context, project Project) (bool, error)\n\tDeleteDevProject(ctx context.Context, projectKey string) (bool, error)\n\t// InsertProject inserts the project. If it already exists, ErrAlreadyExists is returned\n\tInsertProject(ctx context.Context, project Project) error\n\tUpsertOverride(ctx context.Context, override Override) (Override, error)\n\tGetOverridesForProject(ctx context.Context, projectKey string) (Overrides, error)\n\tGetAvailableVariationsForProject(ctx context.Context, projectKey string) (map[string][]Variation, error)\n\n\tCreateBackup(ctx context.Context) (io.ReadCloser, int64, error)\n\tRestoreBackup(ctx context.Context, stream io.Reader) (string, error)\n}\n```\n\n```go\nfunc StoreFromContext(ctx context.Context) Store\n```\n\n```go\ntype SyncEvent struct {\n\tProjectKey    string\n\tAllFlagsState FlagsState\n}\n```\nEvent for full project sync\n\n```go\ntype Variation struct {\n\tId          string\n\tDescription *string\n\tName        *string\n\tValue       ldvalue.Value\n}\n```\n\n","path":"github.com/launchdarkly/ldcli/internal/dev_server/model","name":"model","synopsis":"Package model provides dev projects and flag override data models for the api handler to use.","isRedistributable":true}
