flags

package
v0.14.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKeyClaims added in v0.14.7

type APIKeyClaims struct {
	ProjectID     string `json:"project_id"`
	AgentID       string `json:"agent_id"`
	EnvironmentID string `json:"environment_id,omitempty"`
	jwt.RegisteredClaims
}

APIKeyClaims represents the JWT claims for an API key

type APIKeyHTTPSystem added in v0.14.7

type APIKeyHTTPSystem struct {
	Config  *ConfigBuilder.Config
	Context context.Context
}

func NewAPIKeyHTTPSystem added in v0.14.7

func NewAPIKeyHTTPSystem(cfg *ConfigBuilder.Config) *APIKeyHTTPSystem

func (*APIKeyHTTPSystem) GenerateAPIKeyHandler added in v0.14.7

func (s *APIKeyHTTPSystem) GenerateAPIKeyHandler(w http.ResponseWriter, r *http.Request)

GenerateAPIKeyHandler handles POST /api-key/generate

func (*APIKeyHTTPSystem) SetContext added in v0.14.7

func (s *APIKeyHTTPSystem) SetContext(ctx context.Context) *APIKeyHTTPSystem

type APIKeySystem added in v0.14.7

type APIKeySystem struct {
	Config *ConfigBuilder.Config
}

APIKeySystem handles API key generation and validation

func NewAPIKeySystem added in v0.14.7

func NewAPIKeySystem(cfg *ConfigBuilder.Config) *APIKeySystem

func (*APIKeySystem) GenerateAPIKey added in v0.14.7

func (s *APIKeySystem) GenerateAPIKey(projectID, agentID, environmentID string) (string, error)

GenerateAPIKey creates a JWT-based API key with project, agent, and environment info

func (*APIKeySystem) ValidateAPIKey added in v0.14.7

func (s *APIKeySystem) ValidateAPIKey(tokenString string) (*APIKeyClaims, error)

ValidateAPIKey parses and validates a JWT-based API key

type AgentResponse

type AgentResponse struct {
	IntervalAllowed int        `json:"intervalAllowed,omitempty"`
	SecretMenu      SecretMenu `json:"secretMenu,omitempty"`
	Flags           []Flag     `json:"flags,omitempty"`
}

type BulkEvaluationRequest added in v0.14.7

type BulkEvaluationRequest struct {
	Context EvaluationContext `json:"context,omitempty"`
}

BulkEvaluationRequest is for evaluating multiple flags

type BulkEvaluationResponse added in v0.14.7

type BulkEvaluationResponse struct {
	Flags []interface{} `json:"flags"`
}

BulkEvaluationResponse wraps multiple flag evaluations

type Details

type Details struct {
	Name        string `json:"name"`
	ID          string `json:"id"`
	LastChanged string `json:"lastChanged,omitempty"`
	Promoted    bool   `json:"promoted,omitempty"`
}

type ErrorCode added in v0.14.7

type ErrorCode string

ErrorCode represents OFREP error codes

const (
	ErrorParseError          ErrorCode = "PARSE_ERROR"
	ErrorTargetingKeyMissing ErrorCode = "TARGETING_KEY_MISSING"
	ErrorInvalidContext      ErrorCode = "INVALID_CONTEXT"
	ErrorFlagNotFound        ErrorCode = "FLAG_NOT_FOUND"
	ErrorTypeMismatch        ErrorCode = "TYPE_MISMATCH"
	ErrorGeneral             ErrorCode = "GENERAL"
)

type ErrorEvaluationResponse added in v0.14.7

type ErrorEvaluationResponse struct {
	Key          string                 `json:"key"`
	ErrorCode    ErrorCode              `json:"errorCode"`
	ErrorDetails string                 `json:"errorDetails,omitempty"`
	Reason       ResolutionReason       `json:"reason"`
	Metadata     map[string]interface{} `json:"metadata,omitempty"`
}

ErrorEvaluationResponse represents a failed flag evaluation

type EvaluationContext added in v0.14.7

type EvaluationContext struct {
	TargetingKey string                 `json:"targetingKey,omitempty"`
	Context      map[string]interface{} `json:"context,omitempty"`
}

EvaluationContext represents the context for flag evaluation

type EvaluationRequest added in v0.14.7

type EvaluationRequest struct {
	Context EvaluationContext `json:"context,omitempty"`
}

EvaluationRequest is the request body for flag evaluation

type Flag

type Flag struct {
	Enabled bool    `json:"enabled"`
	Details Details `json:"details"`
}

type FlagNameChangeRequest

type FlagNameChangeRequest struct {
	Name string `json:"name"`
	ID   string `json:"id"`
}

type GenerateAPIKeyRequest added in v0.14.7

type GenerateAPIKeyRequest struct {
	ProjectID     string `json:"project_id"`
	AgentID       string `json:"agent_id"`
	EnvironmentID string `json:"environment_id,omitempty"`
}

type GenerateAPIKeyResponse added in v0.14.7

type GenerateAPIKeyResponse struct {
	APIKey    string `json:"api_key"`
	ExpiresAt string `json:"expires_at"`
}

type OFREPSystem added in v0.14.7

type OFREPSystem struct {
	Config  *ConfigBuilder.Config
	Context context.Context
}

OFREPSystem handles OFREP endpoints

func NewOFREPSystem added in v0.14.7

func NewOFREPSystem(cfg *ConfigBuilder.Config) *OFREPSystem

func (*OFREPSystem) EvaluateBulkFlags added in v0.14.7

func (s *OFREPSystem) EvaluateBulkFlags(w http.ResponseWriter, r *http.Request)

EvaluateBulkFlags handles POST /ofrep/v1/evaluate/flags

func (*OFREPSystem) EvaluateSingleFlag added in v0.14.7

func (s *OFREPSystem) EvaluateSingleFlag(w http.ResponseWriter, r *http.Request)

EvaluateSingleFlag handles POST /ofrep/v1/evaluate/flags/{key}

func (*OFREPSystem) GetSingleFlagFromDB added in v0.14.7

func (s *OFREPSystem) GetSingleFlagFromDB(projectId, agentId, environmentId, flagKey string) (*Flag, error)

func (*OFREPSystem) SetContext added in v0.14.7

func (s *OFREPSystem) SetContext(ctx context.Context) *OFREPSystem

type ResolutionReason added in v0.14.7

type ResolutionReason string

ResolutionReason represents why a flag was resolved to its value

const (
	ReasonStatic         ResolutionReason = "STATIC"
	ReasonTargetingMatch ResolutionReason = "TARGETING_MATCH"
	ReasonDefault        ResolutionReason = "DEFAULT"
	ReasonDisabled       ResolutionReason = "DISABLED"
	ReasonError          ResolutionReason = "ERROR"
	ReasonUnknown        ResolutionReason = "UNKNOWN"
)

type Response

type Response struct {
	Flags []Flag `json:"flags"`
}

type SecretMenu

type SecretMenu struct {
	Sequence []string          `json:"sequence,omitempty"`
	Styles   []SecretMenuStyle `json:"styles,omitempty"`
}

type SecretMenuStyle

type SecretMenuStyle struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type SuccessEvaluationResponse added in v0.14.7

type SuccessEvaluationResponse struct {
	Key      string                 `json:"key"`
	Reason   ResolutionReason       `json:"reason"`
	Variant  string                 `json:"variant,omitempty"`
	Value    interface{}            `json:"value"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

SuccessEvaluationResponse represents a successful flag evaluation

type System

type System struct {
	Config  *ConfigBuilder.Config
	Context context.Context
}

func NewSystem

func NewSystem(cfg *ConfigBuilder.Config) *System

func (*System) CreateFlagInDB

func (s *System) CreateFlagInDB(flag flagCreate) error

func (*System) CreateFlags

func (s *System) CreateFlags(w http.ResponseWriter, r *http.Request)

func (*System) DeleteAllFlagsForEnv

func (s *System) DeleteAllFlagsForEnv(envId string) error

func (*System) DeleteFlagFromDB

func (s *System) DeleteFlagFromDB(flag Flag) error

func (*System) DeleteFlags

func (s *System) DeleteFlags(w http.ResponseWriter, r *http.Request)

func (*System) EditFlag

func (s *System) EditFlag(w http.ResponseWriter, r *http.Request)

func (*System) EditFlagInDB

func (s *System) EditFlagInDB(cr FlagNameChangeRequest) error

func (*System) GetAgentFlags

func (s *System) GetAgentFlags(w http.ResponseWriter, r *http.Request)

func (*System) GetAgentFlagsFromDB

func (s *System) GetAgentFlagsFromDB(projectId, agentId, environmentId string) (*AgentResponse, error)

func (*System) GetClientFlags

func (s *System) GetClientFlags(w http.ResponseWriter, r *http.Request)

func (*System) GetClientFlagsFromDB

func (s *System) GetClientFlagsFromDB(environmentId string) ([]Flag, error)

func (*System) GetDefaultEnvironment

func (s *System) GetDefaultEnvironment(projectId, agentId string) (string, error)

func (*System) PromoteFlag added in v0.14.7

func (s *System) PromoteFlag(w http.ResponseWriter, r *http.Request)

func (*System) PromoteFlagInDB added in v0.14.7

func (s *System) PromoteFlagInDB(flagId string) error

func (*System) SetContext

func (s *System) SetContext(ctx context.Context) *System

func (*System) UpdateFlagInDB

func (s *System) UpdateFlagInDB(flag Flag) error

func (*System) UpdateFlags

func (s *System) UpdateFlags(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL