Documentation
¶
Overview ¶
Package devlake provides an HTTP client for the DevLake REST API.
Index ¶
- func PrintState(state *State)
- func SaveState(path string, state *State) error
- func UpdateConnections(path string, state *State, connections []StateConnection) error
- type Blueprint
- type BlueprintConnection
- type BlueprintPatch
- type BlueprintScope
- type Client
- func (c *Client) CreateConnection(plugin string, req *ConnectionCreateRequest) (*Connection, error)
- func (c *Client) CreateProject(project *Project) (*Project, error)
- func (c *Client) CreateScopeConfig(plugin string, connID int, cfg *ScopeConfig) (*ScopeConfig, error)
- func (c *Client) FindConnectionByName(plugin, name string) (*Connection, error)
- func (c *Client) GetPipeline(id int) (*Pipeline, error)
- func (c *Client) GetProject(name string) (*Project, error)
- func (c *Client) Health() (*HealthStatus, error)
- func (c *Client) ListConnections(plugin string) ([]Connection, error)
- func (c *Client) ListScopeConfigs(plugin string, connID int) ([]ScopeConfig, error)
- func (c *Client) PatchBlueprint(id int, patch *BlueprintPatch) (*Blueprint, error)
- func (c *Client) Ping() error
- func (c *Client) PutScopes(plugin string, connID int, req *ScopeBatchRequest) error
- func (c *Client) TestConnection(plugin string, req *ConnectionTestRequest) (*ConnectionTestResult, error)
- func (c *Client) TestSavedConnection(plugin string, connID int) (*ConnectionTestResult, error)
- func (c *Client) TriggerBlueprint(id int) (*Pipeline, error)
- func (c *Client) TriggerMigration() error
- type Connection
- type ConnectionCreateRequest
- type ConnectionTestRequest
- type ConnectionTestResult
- type CopilotScope
- type DiscoveryResult
- type GitHubRepoScope
- type HealthStatus
- type Pipeline
- type Project
- type ProjectMetric
- type RefdiffConfig
- type ScopeBatchRequest
- type ScopeConfig
- type State
- type StateConnection
- type StateEndpoints
- type StateProject
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrintState ¶
func PrintState(state *State)
PrintState prints a human-readable summary of the state.
func UpdateConnections ¶
func UpdateConnections(path string, state *State, connections []StateConnection) error
UpdateConnections updates the connections in the state and saves to disk.
Types ¶
type Blueprint ¶
type Blueprint struct {
ID int `json:"id"`
Name string `json:"name,omitempty"`
Enable bool `json:"enable,omitempty"`
CronConfig string `json:"cronConfig,omitempty"`
TimeAfter string `json:"timeAfter,omitempty"`
Connections []BlueprintConnection `json:"connections,omitempty"`
}
Blueprint represents a DevLake blueprint (returned from project creation or GET).
type BlueprintConnection ¶
type BlueprintConnection struct {
PluginName string `json:"pluginName"`
ConnectionID int `json:"connectionId"`
Scopes []BlueprintScope `json:"scopes"`
}
BlueprintConnection associates a plugin connection with scopes in a blueprint.
type BlueprintPatch ¶
type BlueprintPatch struct {
Enable *bool `json:"enable,omitempty"`
CronConfig string `json:"cronConfig,omitempty"`
TimeAfter string `json:"timeAfter,omitempty"`
Connections []BlueprintConnection `json:"connections,omitempty"`
}
BlueprintPatch is the payload for PATCH /blueprints/:id.
type BlueprintScope ¶
BlueprintScope identifies a single scope within a blueprint connection.
type Client ¶
Client wraps HTTP calls to the DevLake backend API.
func (*Client) CreateConnection ¶
func (c *Client) CreateConnection(plugin string, req *ConnectionCreateRequest) (*Connection, error)
CreateConnection creates a new connection for the given plugin.
func (*Client) CreateProject ¶
CreateProject creates a new DevLake project.
func (*Client) CreateScopeConfig ¶
func (c *Client) CreateScopeConfig(plugin string, connID int, cfg *ScopeConfig) (*ScopeConfig, error)
CreateScopeConfig creates a scope config for a plugin connection.
func (*Client) FindConnectionByName ¶
func (c *Client) FindConnectionByName(plugin, name string) (*Connection, error)
FindConnectionByName returns the first connection matching the given name, or nil.
func (*Client) GetPipeline ¶
GetPipeline retrieves a pipeline by ID.
func (*Client) GetProject ¶
GetProject retrieves a project by name.
func (*Client) Health ¶
func (c *Client) Health() (*HealthStatus, error)
Health returns the DevLake health status.
func (*Client) ListConnections ¶
func (c *Client) ListConnections(plugin string) ([]Connection, error)
ListConnections returns all connections for a plugin (e.g. "github", "gh-copilot").
func (*Client) ListScopeConfigs ¶
func (c *Client) ListScopeConfigs(plugin string, connID int) ([]ScopeConfig, error)
ListScopeConfigs returns all scope configs for a plugin connection.
func (*Client) PatchBlueprint ¶
func (c *Client) PatchBlueprint(id int, patch *BlueprintPatch) (*Blueprint, error)
PatchBlueprint updates a blueprint by ID.
func (*Client) PutScopes ¶
func (c *Client) PutScopes(plugin string, connID int, req *ScopeBatchRequest) error
PutScopes batch-upserts scopes for a plugin connection.
func (*Client) TestConnection ¶
func (c *Client) TestConnection(plugin string, req *ConnectionTestRequest) (*ConnectionTestResult, error)
TestConnection tests connection parameters before creating.
func (*Client) TestSavedConnection ¶
func (c *Client) TestSavedConnection(plugin string, connID int) (*ConnectionTestResult, error)
TestSavedConnection tests an already-created connection by ID.
func (*Client) TriggerBlueprint ¶
TriggerBlueprint triggers a blueprint to run and returns the pipeline.
func (*Client) TriggerMigration ¶ added in v0.2.0
TriggerMigration triggers the DevLake database migration endpoint.
type Connection ¶
Connection represents a DevLake plugin connection.
type ConnectionCreateRequest ¶
type ConnectionCreateRequest struct {
Name string `json:"name"`
Endpoint string `json:"endpoint"`
Proxy string `json:"proxy,omitempty"`
AuthMethod string `json:"authMethod"`
Token string `json:"token"`
EnableGraphql bool `json:"enableGraphql,omitempty"`
RateLimitPerHour int `json:"rateLimitPerHour"`
Organization string `json:"organization,omitempty"`
Enterprise string `json:"enterprise,omitempty"`
TokenExpiresAt string `json:"tokenExpiresAt,omitempty"`
RefreshTokenExpiresAt string `json:"refreshTokenExpiresAt,omitempty"`
}
ConnectionCreateRequest is the payload for creating a GitHub or Copilot connection.
type ConnectionTestRequest ¶
type ConnectionTestRequest struct {
Endpoint string `json:"endpoint"`
AuthMethod string `json:"authMethod"`
Token string `json:"token"`
EnableGraphql bool `json:"enableGraphql,omitempty"`
RateLimitPerHour int `json:"rateLimitPerHour"`
Proxy string `json:"proxy"`
}
ConnectionTestRequest is the payload for testing a connection before creating.
type ConnectionTestResult ¶
ConnectionTestResult is the response from testing a connection.
type CopilotScope ¶
type CopilotScope struct {
ID string `json:"id"`
ConnectionID int `json:"connectionId"`
Organization string `json:"organization"`
Name string `json:"name"`
FullName string `json:"fullName"`
}
CopilotScope represents a Copilot organization scope entry.
type DiscoveryResult ¶
type DiscoveryResult struct {
URL string
GrafanaURL string
Source string // "parameter", "statefile", "localhost"
}
DiscoveryResult contains the discovered DevLake instance details.
func Discover ¶
func Discover(explicitURL string) (*DiscoveryResult, error)
Discover finds a running DevLake instance by checking multiple sources. Priority: explicit URL → state files → well-known localhost ports.
type GitHubRepoScope ¶
type GitHubRepoScope struct {
GithubID int `json:"githubId"`
ConnectionID int `json:"connectionId"`
Name string `json:"name"`
FullName string `json:"fullName"`
HTMLURL string `json:"htmlUrl"`
CloneURL string `json:"cloneUrl"`
ScopeConfigID int `json:"scopeConfigId,omitempty"`
}
GitHubRepoScope represents a GitHub repository scope entry for PUT /scopes.
type HealthStatus ¶
type HealthStatus struct {
Status string `json:"status"`
}
HealthStatus represents the response from /health or /ping.
type Pipeline ¶
type Pipeline struct {
ID int `json:"id"`
Status string `json:"status"`
FinishedTasks int `json:"finishedTasks"`
TotalTasks int `json:"totalTasks"`
}
Pipeline represents a DevLake pipeline (returned from trigger or GET).
type Project ¶
type Project struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Metrics []ProjectMetric `json:"metrics,omitempty"`
Blueprint *Blueprint `json:"blueprint,omitempty"`
}
Project represents a DevLake project.
type ProjectMetric ¶
ProjectMetric enables a metric plugin for a project.
type RefdiffConfig ¶
type RefdiffConfig struct {
TagsPattern string `json:"tagsPattern"`
TagsLimit int `json:"tagsLimit"`
TagsOrder string `json:"tagsOrder"`
}
RefdiffConfig holds refdiff tag-matching settings.
type ScopeBatchRequest ¶
type ScopeBatchRequest struct {
Data []any `json:"data"`
}
ScopeBatchRequest is the payload for PUT /scopes (batch upsert).
type ScopeConfig ¶
type ScopeConfig struct {
ID int `json:"id,omitempty"`
Name string `json:"name"`
ConnectionID int `json:"connectionId"`
DeploymentPattern string `json:"deploymentPattern,omitempty"`
ProductionPattern string `json:"productionPattern,omitempty"`
IssueTypeIncident string `json:"issueTypeIncident,omitempty"`
Refdiff *RefdiffConfig `json:"refdiff,omitempty"`
}
ScopeConfig represents a DevLake scope configuration (e.g., DORA settings).
type State ¶
type State struct {
DeployedAt string `json:"deployedAt"`
Method string `json:"method"`
Endpoints StateEndpoints `json:"endpoints"`
Connections []StateConnection `json:"connections,omitempty"`
ConnectionsConfiguredAt string `json:"connectionsConfiguredAt,omitempty"`
Project *StateProject `json:"project,omitempty"`
ScopesConfiguredAt string `json:"scopesConfiguredAt,omitempty"`
}
State represents the persisted deployment/connection state.
func FindStateFile ¶
FindStateFile finds the first existing state file in the working directory. Returns the path and loaded state, or creates a new local state.
type StateConnection ¶
type StateConnection struct {
Plugin string `json:"plugin"`
ConnectionID int `json:"connectionId"`
Name string `json:"name"`
Organization string `json:"organization,omitempty"`
Enterprise string `json:"enterprise,omitempty"`
}
StateConnection records a created connection.
type StateEndpoints ¶
type StateEndpoints struct {
Backend string `json:"backend"`
Grafana string `json:"grafana,omitempty"`
ConfigUI string `json:"configUi,omitempty"`
}
StateEndpoints contains service URLs.