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) DeleteConnection(plugin string, connID int) error
- func (c *Client) DeleteProject(name string) error
- func (c *Client) DeleteScope(plugin string, connID int, scopeID string) error
- func (c *Client) FindConnectionByName(plugin, name string) (*Connection, error)
- func (c *Client) GetConnection(plugin string, connID int) (*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) ListProjects() ([]Project, error)
- func (c *Client) ListScopeConfigs(plugin string, connID int) ([]ScopeConfig, error)
- func (c *Client) ListScopes(plugin string, connID int) (*ScopeListResponse, 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
- func (c *Client) UpdateConnection(plugin string, connID int, req *ConnectionUpdateRequest) (*Connection, error)
- type Connection
- type ConnectionCreateRequest
- type ConnectionTestRequest
- type ConnectionTestResult
- type ConnectionUpdateRequest
- type CopilotScope
- type DiscoveryResult
- type GitHubRepoScope
- type HealthStatus
- type Pipeline
- type Project
- type ProjectListResponse
- type ProjectMetric
- type RefdiffConfig
- type ScopeBatchRequest
- type ScopeConfig
- type ScopeListEntry
- type ScopeListResponse
- type ScopeListWrapper
- 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 SaveState ¶
SaveState writes state to disk, merging with any existing fields in the file (e.g. Azure deployment metadata) that the State struct doesn't model.
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"`
Mode string `json:"mode,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) DeleteConnection ¶ added in v0.3.5
DeleteConnection deletes a plugin connection by ID.
func (*Client) DeleteProject ¶ added in v0.3.10
DeleteProject deletes a project by name.
func (*Client) DeleteScope ¶ added in v0.3.10
DeleteScope removes a scope from 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) GetConnection ¶ added in v0.3.5
func (c *Client) GetConnection(plugin string, connID int) (*Connection, error)
GetConnection retrieves a single connection by plugin and ID.
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) ListProjects ¶ added in v0.3.10
ListProjects returns all DevLake projects.
func (*Client) ListScopeConfigs ¶
func (c *Client) ListScopeConfigs(plugin string, connID int) ([]ScopeConfig, error)
ListScopeConfigs returns all scope configs for a plugin connection.
func (*Client) ListScopes ¶ added in v0.3.7
func (c *Client) ListScopes(plugin string, connID int) (*ScopeListResponse, error)
ListScopes returns the scopes configured on 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.
func (*Client) UpdateConnection ¶ added in v0.3.5
func (c *Client) UpdateConnection(plugin string, connID int, req *ConnectionUpdateRequest) (*Connection, error)
UpdateConnection patches an existing connection for the given plugin.
type Connection ¶
type Connection struct {
ID int `json:"id"`
Name string `json:"name"`
Endpoint string `json:"endpoint,omitempty"`
Proxy string `json:"proxy,omitempty"`
Token string `json:"token,omitempty"`
Organization string `json:"organization,omitempty"`
Enterprise string `json:"enterprise,omitempty"`
}
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 plugin connection.
type ConnectionTestRequest ¶
type ConnectionTestRequest struct {
Name string `json:"name"`
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"`
Organization string `json:"organization,omitempty"`
Enterprise string `json:"enterprise,omitempty"`
}
ConnectionTestRequest is the payload for testing a connection before creating.
type ConnectionTestResult ¶
ConnectionTestResult is the response from testing a connection.
type ConnectionUpdateRequest ¶ added in v0.3.5
type ConnectionUpdateRequest struct {
Name string `json:"name,omitempty"`
Endpoint string `json:"endpoint,omitempty"`
Proxy string `json:"proxy,omitempty"`
AuthMethod string `json:"authMethod,omitempty"`
Token string `json:"token,omitempty"`
Organization string `json:"organization,omitempty"`
Enterprise string `json:"enterprise,omitempty"`
}
ConnectionUpdateRequest is the payload for PATCH /plugins/{plugin}/connections/{id}. Fields with omitempty are only included in the request when non-empty, enabling sparse updates (only changed fields are sent).
type CopilotScope ¶
type CopilotScope struct {
ID string `json:"id"`
ConnectionID int `json:"connectionId"`
Organization string `json:"organization"`
Enterprise string `json:"enterprise,omitempty"`
Name string `json:"name"`
FullName string `json:"fullName"`
}
CopilotScope represents a Copilot organization or enterprise scope entry.
type DiscoveryResult ¶
type DiscoveryResult struct {
URL string
GrafanaURL string
ConfigUIURL 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 ProjectListResponse ¶ added in v0.3.10
ProjectListResponse is the response from GET /projects.
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 ScopeListEntry ¶ added in v0.3.7
type ScopeListEntry struct {
GithubID int `json:"githubId,omitempty"`
ID string `json:"id,omitempty"`
Name string `json:"name"`
FullName string `json:"fullName,omitempty"`
}
ScopeListEntry represents a scope object returned inside the wrapper. ID fields vary by plugin (githubId for GitHub, id for Copilot), so we capture both and resolve in the caller.
type ScopeListResponse ¶ added in v0.3.7
type ScopeListResponse struct {
Scopes []ScopeListWrapper `json:"scopes"`
Count int `json:"count"`
}
ScopeListResponse is the response from GET /plugins/{plugin}/connections/{id}/scopes.
type ScopeListWrapper ¶ added in v0.3.7
type ScopeListWrapper struct {
Scope ScopeListEntry `json:"scope"`
}
ScopeListWrapper wraps a scope object as returned by the DevLake GET scopes API. The API nests each scope inside a "scope" key: { "scope": { ... } }.
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.
func LoadStateFromCwd ¶ added in v0.3.8
LoadStateFromCwd loads the first known state file from the current directory. Returns nil,nil when no state file exists.
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.