Documentation
¶
Overview ¶
Package integration is the machine API for ticket trackers (Tracklines): a flag per ticket that is created in the first environment, toggled, promoted along the environment chain, and archived when done. The tracker decides which board column triggers which call; every call here is idempotent.
Index ¶
- Variables
- type AgentEnvironment
- type AgentFlag
- type AgentFlags
- type AgentInfo
- type EnvironmentState
- type FlagState
- type System
- func (s *System) AgentFlagsHandler(w http.ResponseWriter, r *http.Request)
- func (s *System) ArchiveAgentFlag(ctx context.Context, companyId, agentId, name string) error
- func (s *System) ArchiveAgentFlagHandler(w http.ResponseWriter, r *http.Request)
- func (s *System) ArchiveFlag(w http.ResponseWriter, r *http.Request)
- func (s *System) ArchiveTicketFlag(ctx context.Context, companyId, ticket string) error
- func (s *System) CompanyForToken(ctx context.Context, raw string) (string, error)
- func (s *System) CreateFlag(w http.ResponseWriter, r *http.Request)
- func (s *System) CreateTicketFlag(ctx context.Context, companyId, ticket, agentId, name string) (*TicketFlag, bool, error)
- func (s *System) CreateToken(ctx context.Context, companyId, name string) (string, error)
- func (s *System) CreateTokenHandler(w http.ResponseWriter, r *http.Request)
- func (s *System) DeleteToken(ctx context.Context, companyId, tokenId string) error
- func (s *System) DeleteTokenHandler(w http.ResponseWriter, r *http.Request)
- func (s *System) GetAgentFlags(ctx context.Context, companyId, agentId string) (*AgentFlags, error)
- func (s *System) GetFlag(w http.ResponseWriter, r *http.Request)
- func (s *System) GetTicketFlag(ctx context.Context, companyId, ticket string) (*TicketFlag, error)
- func (s *System) ListAgents(ctx context.Context, companyId string) ([]AgentInfo, error)
- func (s *System) ListAgentsHandler(w http.ResponseWriter, r *http.Request)
- func (s *System) ListTokens(ctx context.Context, companyId string) ([]Token, error)
- func (s *System) ListTokensHandler(w http.ResponseWriter, r *http.Request)
- func (s *System) MCPHandler() http.Handler
- func (s *System) PromoteFlag(w http.ResponseWriter, r *http.Request)
- func (s *System) PromoteTicketFlag(ctx context.Context, companyId, ticket string, toProduction bool) (*TicketFlag, error)
- func (s *System) SetFlag(w http.ResponseWriter, r *http.Request)
- func (s *System) SetTicketFlag(ctx context.Context, companyId, ticket, environmentId string, enabled bool) error
- type TicketFlag
- type Token
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type AgentEnvironment ¶
type AgentFlag ¶
type AgentFlag struct {
Name string `json:"name"`
Ticket string `json:"ticket,omitempty"`
States []FlagState `json:"states"`
}
AgentFlag is one flag across the agent's environments; States only lists environments it is in.
type AgentFlags ¶
type AgentFlags struct {
AgentId string `json:"agent_id"`
Environments []AgentEnvironment `json:"environments"`
Flags []AgentFlag `json:"flags"`
}
type AgentInfo ¶
type AgentInfo struct {
ProjectId string `json:"project_id"`
ProjectName string `json:"project_name"`
AgentId string `json:"agent_id"`
AgentName string `json:"agent_name"`
Environments []AgentEnvironment `json:"environments"`
}
type EnvironmentState ¶
type FlagState ¶
type FlagState struct {
EnvironmentId string `json:"environment_id"`
FlagId string `json:"flag_id"`
Enabled bool `json:"enabled"`
Rollout int `json:"rollout"`
Rules []flags.Rule `json:"rules"`
// users served the flag on/off in the last 7 days (the server's own decisions)
ServedOn int `json:"served_on"`
ServedOff int `json:"served_off"`
}
FlagState is one flag in one environment; FlagId is what the per-flag dashboard routes take.
type System ¶
type System struct {
Config *ConfigBuilder.Config
}
func NewSystem ¶
func NewSystem(cfg *ConfigBuilder.Config) *System
func (*System) AgentFlagsHandler ¶
func (s *System) AgentFlagsHandler(w http.ResponseWriter, r *http.Request)
AgentFlagsHandler: GET /agent/{agentId}/flags (dashboard user), the flag-first view of an agent.
func (*System) ArchiveAgentFlag ¶
ArchiveAgentFlag archives the agent's flag with this name in every environment.
func (*System) ArchiveAgentFlagHandler ¶
func (s *System) ArchiveAgentFlagHandler(w http.ResponseWriter, r *http.Request)
ArchiveAgentFlagHandler: DELETE /agent/{agentId}/flags/{name} (dashboard user), removes a flag from every environment.
func (*System) ArchiveFlag ¶
func (s *System) ArchiveFlag(w http.ResponseWriter, r *http.Request)
ArchiveFlag: DELETE /integration/tickets/{ticket}/flag; 204 even when there was nothing to archive.
func (*System) ArchiveTicketFlag ¶
ArchiveTicketFlag archives the ticket's flag in every environment; nothing to archive is not an error.
func (*System) CompanyForToken ¶
CompanyForToken returns the public company id for a raw token, or "" when it is unknown.
func (*System) CreateFlag ¶
func (s *System) CreateFlag(w http.ResponseWriter, r *http.Request)
CreateFlag: PUT /integration/tickets/{ticket}/flag {"agent_id","name"}; 201 when created, 200 when it already existed.
func (*System) CreateTicketFlag ¶
func (s *System) CreateTicketFlag(ctx context.Context, companyId, ticket, agentId, name string) (*TicketFlag, bool, error)
CreateTicketFlag creates the flag, off, in the agent's first environment. If the ticket already has a flag it is returned unchanged (created=false), so retries are safe.
func (*System) CreateToken ¶
CreateToken returns the raw token; only its hash is stored, so it cannot be shown again.
func (*System) CreateTokenHandler ¶
func (s *System) CreateTokenHandler(w http.ResponseWriter, r *http.Request)
CreateTokenHandler: POST /company/integration-token {"name"} (dashboard user); the token is only returned here.
func (*System) DeleteToken ¶
func (*System) DeleteTokenHandler ¶
func (s *System) DeleteTokenHandler(w http.ResponseWriter, r *http.Request)
DeleteTokenHandler: DELETE /company/integration-token/{tokenId}
func (*System) GetAgentFlags ¶
GetAgentFlags returns every flag of the agent grouped by name, with its state per environment.
func (*System) GetFlag ¶
func (s *System) GetFlag(w http.ResponseWriter, r *http.Request)
GetFlag: GET /integration/tickets/{ticket}/flag
func (*System) GetTicketFlag ¶
func (*System) ListAgents ¶
func (*System) ListAgentsHandler ¶
func (s *System) ListAgentsHandler(w http.ResponseWriter, r *http.Request)
ListAgentsHandler: GET /integration/agents, for a tracker's settings picker.
func (*System) ListTokens ¶
func (*System) ListTokensHandler ¶
func (s *System) ListTokensHandler(w http.ResponseWriter, r *http.Request)
ListTokensHandler: GET /company/integration-tokens
func (*System) MCPHandler ¶
MCPHandler serves /mcp (streamable HTTP, stateless) for the integration token's company.
func (*System) PromoteFlag ¶
func (s *System) PromoteFlag(w http.ResponseWriter, r *http.Request)
PromoteFlag: POST /integration/tickets/{ticket}/flag/promote[?to=production]
func (*System) PromoteTicketFlag ¶
func (s *System) PromoteTicketFlag(ctx context.Context, companyId, ticket string, toProduction bool) (*TicketFlag, error)
PromoteTicketFlag adds the flag, off, to the next environment after the deepest one it is in, or to every remaining environment when toProduction is set. Already at production is a no-op.
type TicketFlag ¶
type TicketFlag struct {
Ticket string `json:"ticket"`
Name string `json:"name"`
AgentId string `json:"agent_id"`
Environments []EnvironmentState `json:"environments"`
// contains filtered or unexported fields
}