Documentation
¶
Overview ¶
Package api wraps the generated OpenAPI client for the finna backend.
Index ¶
- func CheckServerVersion(ctx context.Context, c *Client, w io.Writer)
- func FetchAll[T any](ctx context.Context, limit int, ...) ([]T, error)
- func IsTerminalScanStatus(status string) bool
- func IsTerminalStatus(status string) bool
- type APIError
- type ActiveAlertItem
- type AlertAckResponse
- type AlertListResponse
- type AlertQuery
- type AlertResponse
- type AlertStats
- type AlertStatsResponse
- type AuthProviderConfig
- type AuthProviderInput
- type AuthProviderResponse
- type AzureRegisterRequest
- type BreakdownItem
- type CLIConfigCreate
- type CLIConfigsListResponse
- type Client
- func (c *Client) AckWastageFinding(ctx context.Context, findingID string) (map[string]any, error)
- func (c *Client) AcknowledgeAlert(ctx context.Context, alertID string) (*AlertAckResponse, error)
- func (c *Client) AcknowledgeAllAlerts(ctx context.Context) (*AlertAckResponse, error)
- func (c *Client) AdminCreateProvider(ctx context.Context, req AuthProviderInput) (*AuthProviderResponse, error)
- func (c *Client) AdminDeleteProvider(ctx context.Context, id string) (*map[string]string, error)
- func (c *Client) AdminGetProvider(ctx context.Context, id string) (*AuthProviderResponse, error)
- func (c *Client) AdminListProviders(ctx context.Context) ([]AuthProviderResponse, error)
- func (c *Client) AdminTestProvider(ctx context.Context, id string) (*map[string]any, error)
- func (c *Client) AdminUpdateProvider(ctx context.Context, id string, req AuthProviderInput) (*AuthProviderResponse, error)
- func (c *Client) CancelRun(ctx context.Context, runID string) (map[string]any, error)
- func (c *Client) CreateConfig(ctx context.Context, req CloudConfigCreate) (*CloudConfigResponse, error)
- func (c *Client) CreateProject(ctx context.Context, req ProjectCreate) (*ProjectResponse, error)
- func (c *Client) DBStats(ctx context.Context) (map[string]any, error)
- func (c *Client) DeleteConfig(ctx context.Context, id string) error
- func (c *Client) DeleteExtractor(ctx context.Context, id string) error
- func (c *Client) DeleteProject(ctx context.Context, slug string) error
- func (c *Client) Do(ctx context.Context, method, path string, body io.Reader, ...) (*http.Response, error)
- func (c *Client) ExportCosts(ctx context.Context, q costQuery, w io.Writer) (int64, error)
- func (c *Client) GetActiveAlerts(ctx context.Context, limit int) ([]ActiveAlertItem, error)
- func (c *Client) GetAlertStats(ctx context.Context) (*AlertStatsResponse, error)
- func (c *Client) GetConfig(ctx context.Context, id string) (*CloudConfigResponse, error)
- func (c *Client) GetCostBreakdown(ctx context.Context, q costQuery) ([]BreakdownItem, error)
- func (c *Client) GetCostSummary(ctx context.Context, q costQuery) (*CostSummaryResponse, error)
- func (c *Client) GetCostTotals(ctx context.Context, q costQuery) (*CostTotalsResponse, error)
- func (c *Client) GetCostsBySKU(ctx context.Context, q costQuery) ([]SKUItem, error)
- func (c *Client) GetDailyCosts(ctx context.Context, q costQuery) ([]DailyEntry, error)
- func (c *Client) GetDashboardStats(ctx context.Context, window string) (*DashboardStats, error)
- func (c *Client) GetExtractor(ctx context.Context, id string) (*ExtractorResponse, error)
- func (c *Client) GetJSON(ctx context.Context, path string, out any) error
- func (c *Client) GetProject(ctx context.Context, slug, window string) (*ProjectResponse, error)
- func (c *Client) GetRun(ctx context.Context, runID string) (*RunResponse, error)
- func (c *Client) GetRunLogs(ctx context.Context, runID string) (*LogsResponse, error)
- func (c *Client) GetSKUs(ctx context.Context, provider string) ([]string, error)
- func (c *Client) GetWastageFinding(ctx context.Context, findingID string) (*WastageFinding, error)
- func (c *Client) GetWastageSummary(ctx context.Context) ([]WastageSummaryItem, error)
- func (c *Client) GitHubCallback(ctx context.Context, code string) (*GitHubCallbackResponse, error)
- func (c *Client) GitHubRedirectURL(ctx context.Context) (*GitHubRedirectResponse, error)
- func (c *Client) Health(ctx context.Context) (*HealthInfo, error)
- func (c *Client) Healthz(ctx context.Context) (*HealthzInfo, error)
- func (c *Client) IgnoreWastageFinding(ctx context.Context, findingID, reason string) (map[string]any, error)
- func (c *Client) ListActiveAlerts(ctx context.Context) (*AlertListResponse, error)
- func (c *Client) ListAlerts(ctx context.Context, q AlertQuery) (*AlertListResponse, error)
- func (c *Client) ListConfigs(ctx context.Context) ([]CloudConfigResponse, error)
- func (c *Client) ListCosts(ctx context.Context, q costQuery) (*CostListResponse, error)
- func (c *Client) ListExtractors(ctx context.Context, provider string, limit int) ([]ExtractorResponse, error)
- func (c *Client) ListProjects(ctx context.Context, window string) ([]ProjectResponse, error)
- func (c *Client) ListRuns(ctx context.Context, extractorID, status string, limit int) ([]RunResponse, error)
- func (c *Client) ListWastageFindings(ctx context.Context, q WastageFindingQuery) (*WastageFindingListResponse, error)
- func (c *Client) ListWastageRules(ctx context.Context) ([]WastageRule, error)
- func (c *Client) ListWastageScans(ctx context.Context, limit int) ([]WastageScan, error)
- func (c *Client) Login(ctx context.Context, req LoginRequest) (*LoginResponse, error)
- func (c *Client) OIDCCallback(ctx context.Context, req OIDCCallbackRequest) (*OIDCCallbackResponse, error)
- func (c *Client) OIDCLogin(ctx context.Context, providerID string) (*OIDCLoginResponse, error)
- func (c *Client) OIDCProviders(ctx context.Context) ([]OIDCProviderPublic, error)
- func (c *Client) RegisterAzure(ctx context.Context, req AzureRegisterRequest) (*map[string]any, error)
- func (c *Client) RegisterExtractor(ctx context.Context, req ExtractorCreate) (*ExtractorResponse, error)
- func (c *Client) RegisterGCP(ctx context.Context, req GCPRegisterRequest) (*map[string]any, error)
- func (c *Client) ResolveWastageFinding(ctx context.Context, findingID string) (map[string]any, error)
- func (c *Client) Server() string
- func (c *Client) TestConfig(ctx context.Context, id string) (map[string]any, error)
- func (c *Client) TriggerRun(ctx context.Context, req TriggerRequest) (*TriggerResponse, error)
- func (c *Client) TriggerWastageScan(ctx context.Context, provider string) (*WastageScanTriggerResponse, error)
- func (c *Client) UpdateConfig(ctx context.Context, id string, req CloudConfigUpdate) (*CloudConfigResponse, error)
- type CloudConfigCreate
- type CloudConfigResponse
- type CloudConfigUpdate
- type CostListResponse
- type CostQuery
- type CostRecord
- type CostSummaryResponse
- type CostTotalsResponse
- type DailyEntry
- type DashboardStats
- type ExtractorCreate
- type ExtractorListResponse
- type ExtractorResponse
- type GCPRegisterRequest
- type GitHubCallbackRequest
- type GitHubCallbackResponse
- type GitHubRedirectResponse
- type HealthInfo
- type HealthzInfo
- type LogEntry
- type LoginRequest
- type LoginResponse
- type LogsResponse
- type OIDCCallbackRequest
- type OIDCCallbackResponse
- type OIDCLoginRequest
- type OIDCLoginResponse
- type OIDCProviderPublic
- type Option
- type Page
- type ProjectCreate
- type ProjectResponse
- type ProviderTotals
- type RunListResponse
- type RunResponse
- type SKUItem
- type TokenProvider
- type TriggerRequest
- type TriggerResponse
- type ValidationItem
- type WastageFinding
- type WastageFindingListResponse
- type WastageFindingQuery
- type WastageRule
- type WastageScan
- type WastageScanTriggerResponse
- type WastageSummaryItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckServerVersion ¶
CheckServerVersion calls /api/v1/health and warns to w on major version drift between the CLI and the backend. It is safe to call from every networked command; the underlying probe runs at most once per process. A 1-second timeout prevents slow servers from blocking the user.
Errors are intentionally swallowed: the health check is best-effort and must never break a normal command invocation.
func FetchAll ¶
func FetchAll[T any](ctx context.Context, limit int, fetch func(ctx context.Context, offset, limit int) ([]T, error)) ([]T, error)
FetchAll loops with limit+offset until the page is empty, collecting all items. It is generic and relies on the caller-supplied fetch function. limit controls the page size; use 0 to let the server decide.
func IsTerminalScanStatus ¶
IsTerminalScanStatus returns true when the scan status is a terminal state.
func IsTerminalStatus ¶
IsTerminalStatus returns true when the run status is a terminal state.
Types ¶
type APIError ¶
type APIError struct {
StatusCode int
// Message is the plain-string detail (empty for 422 validation errors).
Message string
// Validation is populated only for 422 responses.
Validation []ValidationItem
// Raw is the original response body, kept for --debug surfaces.
Raw []byte
}
APIError is the decoded shape of a non-2xx response from the finna API. FastAPI returns either {"detail": "string"} for ordinary errors or {"detail": [{"loc": [...], "msg": "...", "type": "..."}, ...]} for 422 validation errors. Both shapes are normalised here.
func DecodeError ¶
DecodeError reads an HTTP response body and constructs an APIError. The body is consumed; callers should not read resp.Body afterwards.
type ActiveAlertItem ¶
type ActiveAlertItem struct {
ID string `json:"id"`
Status string `json:"status"`
Severity string `json:"severity"`
Description string `json:"description"`
Rule string `json:"rule"`
Project string `json:"project"`
CostImpact float64 `json:"cost_impact"`
Provider string `json:"provider"`
TriggeredAt string `json:"triggered_at"`
}
ActiveAlertItem is one entry from GET /api/v1/alerts/active. (AlertStats is defined in alerts.go; WastageSummaryItem in wastage.go)
type AlertAckResponse ¶
AlertAckResponse is the body returned by acknowledge endpoints.
type AlertListResponse ¶
type AlertListResponse struct {
Alerts []AlertResponse
Count int
Total int
Page int
PageSize int
HasNext bool
HasPrev bool
}
AlertListResponse is the paginated wrapper returned by GET /api/v1/alerts.
type AlertQuery ¶
AlertQuery holds optional filters for listing alerts.
type AlertResponse ¶
type AlertResponse struct {
ID string `json:"id"`
Status string `json:"status"`
Severity string `json:"severity"`
Description string `json:"description"`
Rule string `json:"rule"`
Project string `json:"project"`
CostImpact float64 `json:"cost_impact"`
Provider string `json:"provider"`
IsAcknowledged bool `json:"is_acknowledged"`
TriggeredAt string `json:"triggered_at"`
FirstSeen string `json:"first_seen"`
LastSeen string `json:"last_seen"`
Raw map[string]any
}
AlertResponse represents a single alert record from the list/active endpoints.
type AlertStats ¶
type AlertStats struct {
Firing int `json:"firing"`
Ack int `json:"ack"`
Resolved int `json:"resolved"`
BySeverity map[string]int `json:"by_severity"`
}
AlertStats holds counts from the alertStats block. AlertStatsResponse (in alerts.go) embeds this type.
type AlertStatsResponse ¶
type AlertStatsResponse struct {
AlertStats // embedded: Firing, Ack, Resolved, BySeverity
Total int
Active int
Raw map[string]any
}
AlertStatsResponse holds the counts returned by GET /api/v1/alerts/stats. It extends the embedded AlertStats (from dashboard.go) with additional fields.
type AuthProviderConfig ¶
type AuthProviderConfig struct {
Issuer string `json:"issuer,omitempty"`
ClientID string `json:"client_id,omitempty"`
ClientSecret string `json:"client_secret,omitempty"`
// Additional fields passed through.
Extra map[string]any `json:"-"`
}
AuthProviderConfig is the nested config block for AuthProviderInput.
type AuthProviderInput ¶
type AuthProviderInput struct {
Name string `json:"name"`
Kind string `json:"kind,omitempty"`
Enabled bool `json:"enabled"`
Config AuthProviderConfig `json:"config"`
}
AuthProviderInput matches AuthProviderInput schema.
type AuthProviderResponse ¶
type AuthProviderResponse struct {
ID string `json:"id"`
Name string `json:"name"`
Kind string `json:"kind"`
Enabled bool `json:"enabled"`
Config map[string]any `json:"config"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
CreatedBy string `json:"created_by,omitempty"`
LastTestAt string `json:"last_test_at,omitempty"`
LastTestOK *bool `json:"last_test_ok"`
}
AuthProviderResponse matches AuthProviderResponse schema.
type AzureRegisterRequest ¶
type AzureRegisterRequest struct {
TenantID string `json:"tenant_id"`
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret,omitempty"`
SubscriptionID string `json:"subscription_id,omitempty"`
}
AzureRegisterRequest matches AzureServiceAccountRegisterRequest schema.
type BreakdownItem ¶
type BreakdownItem struct {
SKU string `json:"service_name"`
Provider string `json:"provider"`
Total float64 `json:"total"`
}
BreakdownItem is one SKU entry from GET /api/v1/costs/breakdown.
type CLIConfigCreate ¶
type CLIConfigCreate struct {
Provider string `json:"provider"`
CloudConfig string `json:"cloud_config,omitempty"`
ServiceCategory string `json:"service_category,omitempty"`
Region string `json:"region,omitempty"`
}
CLIConfigCreate matches the _ConfigCreate schema used by /api/v1/configs.
type CLIConfigsListResponse ¶
type CLIConfigsListResponse struct {
Data []CloudConfigResponse `json:"data"`
Total int `json:"total"`
Page int `json:"page"`
}
CLIConfigsListResponse is the paginated wrapper returned by GET /api/v1/configs.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the thin wrapper around the generated OpenAPI client. It is the only type CLI commands should depend on.
func New ¶
func New(server string, token TokenProvider, opts ...Option) *Client
New constructs a Client. server must be a base URL like "https://api.host".
func (*Client) AckWastageFinding ¶
AckWastageFinding transitions a finding to acked.
func (*Client) AcknowledgeAlert ¶
AcknowledgeAlert POSTs to /api/v1/alerts/{alert_id}/acknowledge.
func (*Client) AcknowledgeAllAlerts ¶
func (c *Client) AcknowledgeAllAlerts(ctx context.Context) (*AlertAckResponse, error)
AcknowledgeAllAlerts POSTs to /api/v1/alerts/acknowledge-all.
func (*Client) AdminCreateProvider ¶
func (c *Client) AdminCreateProvider(ctx context.Context, req AuthProviderInput) (*AuthProviderResponse, error)
AdminCreateProvider creates a new OIDC provider (admin).
func (*Client) AdminDeleteProvider ¶
AdminDeleteProvider deletes a provider (admin).
func (*Client) AdminGetProvider ¶
AdminGetProvider fetches a single OIDC provider by ID (admin).
func (*Client) AdminListProviders ¶
func (c *Client) AdminListProviders(ctx context.Context) ([]AuthProviderResponse, error)
AdminListProviders lists all OIDC providers (admin).
func (*Client) AdminTestProvider ¶
AdminTestProvider tests OIDC provider connectivity (admin).
func (*Client) AdminUpdateProvider ¶
func (c *Client) AdminUpdateProvider(ctx context.Context, id string, req AuthProviderInput) (*AuthProviderResponse, error)
AdminUpdateProvider replaces an OIDC provider configuration (admin).
func (*Client) CreateConfig ¶
func (c *Client) CreateConfig(ctx context.Context, req CloudConfigCreate) (*CloudConfigResponse, error)
CreateConfig posts to /api/v1/configs (CLI-compatible endpoint).
func (*Client) CreateProject ¶
func (c *Client) CreateProject(ctx context.Context, req ProjectCreate) (*ProjectResponse, error)
CreateProject posts to /api/v1/config/projects.
func (*Client) DBStats ¶
DBStats queries /api/v1/db/stats and returns the raw map returned by the server. The schema is open (additionalProperties) so we return map[string]any.
func (*Client) DeleteConfig ¶
DeleteConfig deletes via DELETE /api/v1/configs/{id}. Returns nil on 204.
func (*Client) DeleteExtractor ¶
DeleteExtractor removes an extractor. Returns nil on 204.
func (*Client) DeleteProject ¶
DeleteProject deletes via DELETE /api/v1/config/projects/{slug}. Returns nil on 204.
func (*Client) Do ¶
func (c *Client) Do(ctx context.Context, method, path string, body io.Reader, headers map[string]string) (*http.Response, error)
Do issues an HTTP request with auth, retry, and error decoding. On a non-2xx response it returns a typed *APIError (and resp will be nil). On success the caller owns resp.Body and must close it.
func (*Client) ExportCosts ¶
ExportCosts streams the CSV export to w and returns byte count.
func (*Client) GetActiveAlerts ¶
GetActiveAlerts calls GET /api/v1/alerts/active.
func (*Client) GetAlertStats ¶
func (c *Client) GetAlertStats(ctx context.Context) (*AlertStatsResponse, error)
GetAlertStats returns alert counts by status and severity.
func (*Client) GetCostBreakdown ¶
func (c *Client) GetCostBreakdown(ctx context.Context, q costQuery) ([]BreakdownItem, error)
GetCostBreakdown calls GET /api/v1/costs/breakdown.
func (*Client) GetCostSummary ¶
func (c *Client) GetCostSummary(ctx context.Context, q costQuery) (*CostSummaryResponse, error)
GetCostSummary calls GET /api/v1/costs/summary.
func (*Client) GetCostTotals ¶
func (c *Client) GetCostTotals(ctx context.Context, q costQuery) (*CostTotalsResponse, error)
GetCostTotals calls GET /api/v1/costs/totals.
func (*Client) GetCostsBySKU ¶
GetCostsBySKU calls GET /api/v1/costs/by-sku.
func (*Client) GetDailyCosts ¶
func (c *Client) GetDailyCosts(ctx context.Context, q costQuery) ([]DailyEntry, error)
GetDailyCosts calls GET /api/v1/costs/daily.
func (*Client) GetDashboardStats ¶
GetDashboardStats calls GET /api/v1/dashboard/stats.
func (*Client) GetExtractor ¶
GetExtractor fetches a single extractor by ID.
func (*Client) GetProject ¶
GetProject fetches a single project by slug.
func (*Client) GetRunLogs ¶
GetRunLogs returns the log output for a run. The server schema is additionalProperties:true; we handle both string-array and object-array shapes.
func (*Client) GetWastageFinding ¶
GetWastageFinding fetches a single finding by ID.
func (*Client) GetWastageSummary ¶
func (c *Client) GetWastageSummary(ctx context.Context) ([]WastageSummaryItem, error)
GetWastageSummary calls GET /api/v1/wastage/summary.
func (*Client) GitHubCallback ¶
GitHubCallback exchanges an OAuth code for a JWT.
func (*Client) GitHubRedirectURL ¶
func (c *Client) GitHubRedirectURL(ctx context.Context) (*GitHubRedirectResponse, error)
GitHubRedirectURL fetches the GitHub OAuth authorization URL.
func (*Client) Health ¶
func (c *Client) Health(ctx context.Context) (*HealthInfo, error)
Health queries /api/v1/health. The endpoint is unauthenticated.
func (*Client) Healthz ¶
func (c *Client) Healthz(ctx context.Context) (*HealthzInfo, error)
Healthz queries /healthz (Kubernetes liveness probe style).
func (*Client) IgnoreWastageFinding ¶
func (c *Client) IgnoreWastageFinding(ctx context.Context, findingID, reason string) (map[string]any, error)
IgnoreWastageFinding transitions a finding to ignored with an optional reason.
func (*Client) ListActiveAlerts ¶
func (c *Client) ListActiveAlerts(ctx context.Context) (*AlertListResponse, error)
ListActiveAlerts returns only firing/unacknowledged alerts.
func (*Client) ListAlerts ¶
func (c *Client) ListAlerts(ctx context.Context, q AlertQuery) (*AlertListResponse, error)
ListAlerts returns alerts, optionally filtered.
func (*Client) ListConfigs ¶
func (c *Client) ListConfigs(ctx context.Context) ([]CloudConfigResponse, error)
ListConfigs returns all configs via the CLI-compatible /api/v1/configs endpoint. Falls back to /api/v1/config if the wrapper endpoint returns unexpected shape.
func (*Client) ListCosts ¶
func (c *Client) ListCosts(ctx context.Context, q costQuery) (*CostListResponse, error)
ListCosts returns paginated cost records.
func (*Client) ListExtractors ¶
func (c *Client) ListExtractors(ctx context.Context, provider string, limit int) ([]ExtractorResponse, error)
ListExtractors returns extractors, optionally filtered by provider.
func (*Client) ListProjects ¶
ListProjects returns all projects, optionally for a time window.
func (*Client) ListRuns ¶
func (c *Client) ListRuns(ctx context.Context, extractorID, status string, limit int) ([]RunResponse, error)
ListRuns returns extractor runs, optionally filtered.
func (*Client) ListWastageFindings ¶
func (c *Client) ListWastageFindings(ctx context.Context, q WastageFindingQuery) (*WastageFindingListResponse, error)
ListWastageFindings returns wastage findings, optionally filtered.
func (*Client) ListWastageRules ¶
func (c *Client) ListWastageRules(ctx context.Context) ([]WastageRule, error)
ListWastageRules returns the rule catalog.
func (*Client) ListWastageScans ¶
ListWastageScans returns recent scan run records.
func (*Client) Login ¶
func (c *Client) Login(ctx context.Context, req LoginRequest) (*LoginResponse, error)
Login posts credentials to /api/v1/auth/login and returns the JWT.
func (*Client) OIDCCallback ¶
func (c *Client) OIDCCallback(ctx context.Context, req OIDCCallbackRequest) (*OIDCCallbackResponse, error)
OIDCCallback completes the PKCE callback and returns a Finna JWT.
func (*Client) OIDCLogin ¶
OIDCLogin initiates the PKCE flow and returns the authorization URL + state.
func (*Client) OIDCProviders ¶
func (c *Client) OIDCProviders(ctx context.Context) ([]OIDCProviderPublic, error)
OIDCProviders lists enabled public OIDC providers (unauthenticated).
func (*Client) RegisterAzure ¶
func (c *Client) RegisterAzure(ctx context.Context, req AzureRegisterRequest) (*map[string]any, error)
RegisterAzure sends Azure service principal credentials.
func (*Client) RegisterExtractor ¶
func (c *Client) RegisterExtractor(ctx context.Context, req ExtractorCreate) (*ExtractorResponse, error)
RegisterExtractor creates a new extractor.
func (*Client) RegisterGCP ¶
RegisterGCP sends GCP service account credentials.
func (*Client) ResolveWastageFinding ¶
func (c *Client) ResolveWastageFinding(ctx context.Context, findingID string) (map[string]any, error)
ResolveWastageFinding transitions a finding to resolved.
func (*Client) TestConfig ¶
TestConfig calls POST /api/v1/config/{id}/test (note: /config not /configs).
func (*Client) TriggerRun ¶
func (c *Client) TriggerRun(ctx context.Context, req TriggerRequest) (*TriggerResponse, error)
TriggerRun triggers an extractor run via POST /api/v1/extractors/run.
func (*Client) TriggerWastageScan ¶
func (c *Client) TriggerWastageScan(ctx context.Context, provider string) (*WastageScanTriggerResponse, error)
TriggerWastageScan POSTs to /api/v1/wastage/scan.
func (*Client) UpdateConfig ¶
func (c *Client) UpdateConfig(ctx context.Context, id string, req CloudConfigUpdate) (*CloudConfigResponse, error)
UpdateConfig sends a partial update to /api/v1/configs/{id}.
type CloudConfigCreate ¶
type CloudConfigCreate struct {
Provider string `json:"provider"`
Name string `json:"name"`
CredentialType string `json:"credential_type,omitempty"`
Config map[string]any `json:"config"`
}
CloudConfigCreate matches the CloudConfigCreate schema.
type CloudConfigResponse ¶
type CloudConfigResponse struct {
ID string `json:"id"`
Provider string `json:"provider"`
Name string `json:"name"`
CredentialType string `json:"credential_type"`
Config map[string]any `json:"config"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
LastTest string `json:"last_test,omitempty"`
LastTestAt string `json:"last_test_at,omitempty"`
TenantID string `json:"tenant_id,omitempty"`
SubscriptionID string `json:"subscription_id,omitempty"`
ProjectID string `json:"project_id,omitempty"`
Err string `json:"err,omitempty"`
}
CloudConfigResponse matches the CloudConfigResponse schema.
type CloudConfigUpdate ¶
type CloudConfigUpdate struct {
Name *string `json:"name,omitempty"`
CredentialType *string `json:"credential_type,omitempty"`
Config map[string]any `json:"config,omitempty"`
}
CloudConfigUpdate matches the CloudConfigUpdate schema (all fields optional).
type CostListResponse ¶
type CostListResponse struct {
Costs []CostRecord `json:"costs"`
Totals map[string]float64 `json:"totals"`
Total int `json:"total"`
Page int `json:"page"`
PageSize int `json:"page_size"`
HasNext bool `json:"has_next"`
HasPrev bool `json:"has_prev"`
Window string `json:"window"`
}
CostListResponse is the paginated shape returned by GET /api/v1/costs.
type CostRecord ¶
type CostRecord struct {
ID string `json:"id"`
Provider string `json:"prov"`
ProjectID string `json:"project_id"`
Name string `json:"name"`
SKU string `json:"sku"`
MTD float64 `json:"mtd"`
Delta float64 `json:"delta"`
Prev float64 `json:"prev"`
Date string `json:"date"`
Tags map[string]any `json:"tags"`
}
CostRecord is a single cost entry from GET /api/v1/costs.
type CostSummaryResponse ¶
type CostSummaryResponse struct {
ByProvider map[string]float64 `json:"by_provider"`
ByService map[string]float64 `json:"by_service"`
Total float64 `json:"total"`
Window string `json:"window"`
Raw map[string]any
}
CostSummaryResponse is the shape from GET /api/v1/costs/summary. The server returns additionalProperties:true; we capture key fields.
type CostTotalsResponse ¶
type CostTotalsResponse struct {
Totals map[string]ProviderTotals `json:"totals"`
Window string `json:"window"`
StartDate string `json:"startDate"`
EndDate string `json:"endDate"`
Raw map[string]any
}
CostTotalsResponse is the shape from GET /api/v1/costs/totals.
type DailyEntry ¶
type DailyEntry struct {
Date string `json:"date"`
Azure float64 `json:"azure"`
GCP float64 `json:"gcp"`
LLM float64 `json:"llm"`
Total float64 `json:"total"`
Extra map[string]float64 // catches any other provider keys
}
DailyEntry is one date row from GET /api/v1/costs/daily.
type DashboardStats ¶
type DashboardStats struct {
Totals map[string]float64 `json:"totals"`
Daily []DailyEntry `json:"-"` // parsed from raw
AlertStats AlertStats `json:"-"` // parsed from raw
Raw map[string]any
}
DashboardStats is the shape returned by GET /api/v1/dashboard/stats.
type ExtractorCreate ¶
type ExtractorCreate struct {
Name string `json:"name"`
Provider string `json:"provider"`
ExtractorType string `json:"extractor_type,omitempty"`
ConfigID string `json:"config_id"`
Schedule string `json:"schedule,omitempty"`
Config map[string]any `json:"config,omitempty"`
}
ExtractorCreate is the body for POST /api/v1/extractors.
type ExtractorListResponse ¶
type ExtractorListResponse struct {
Data []map[string]any `json:"data"`
Count int `json:"count"`
Total int `json:"total"`
Page int `json:"page"`
PageSize int `json:"page_size"`
HasNext bool `json:"has_next"`
HasPrev bool `json:"has_prev"`
}
ExtractorListResponse is the paginated wrapper returned by GET /api/v1/extractors.
type ExtractorResponse ¶
type ExtractorResponse struct {
ID string `json:"id"`
Name string `json:"name"`
Provider string `json:"provider"`
ConfigID string `json:"config_id"`
ConfigName string `json:"config_name"`
Enabled bool `json:"enabled"`
Schedule string `json:"schedule"` // cron string or empty
LastRun string `json:"last_run"`
Status string `json:"status"`
Raw map[string]any
}
ExtractorResponse mirrors the shape in the example from GET /api/v1/extractors. The server uses additionalProperties:true so we keep a Raw map for forward-compat.
type GCPRegisterRequest ¶
type GCPRegisterRequest struct {
ProjectID string `json:"project_id"`
KeyFileContent string `json:"key_file_content,omitempty"`
}
GCPRegisterRequest matches GCPRegisterRequest schema.
type GitHubCallbackRequest ¶
type GitHubCallbackRequest struct {
Code string `json:"code"`
}
GitHubCallbackRequest matches the GitHubCallbackRequest schema.
type GitHubCallbackResponse ¶
type GitHubCallbackResponse struct {
Token string `json:"token"`
}
GitHubCallbackResponse is the shape returned by POST /api/v1/auth/github/callback.
type GitHubRedirectResponse ¶
type GitHubRedirectResponse struct {
URL string `json:"url"`
}
GitHubRedirectResponse is returned by GET /api/v1/auth/github.
type HealthInfo ¶
HealthInfo is the minimal shape we read from /api/v1/health for version drift checks. The backend may return additional fields which we ignore.
type HealthzInfo ¶
type HealthzInfo struct {
// The /healthz endpoint returns a free-form object; we capture the
// commonly-used fields and store the rest in Extra.
Status string `json:"status"`
DB string `json:"db"`
Extra map[string]any `json:"-"`
}
HealthzInfo is the minimal shape returned by /healthz.
type LogEntry ¶
type LogEntry struct {
Timestamp string `json:"timestamp"`
Level string `json:"level"`
Message string `json:"message"`
}
LogEntry is a single structured log line.
type LoginRequest ¶
LoginRequest matches /api/v1/auth/login (TokenRequest schema).
type LoginResponse ¶
type LoginResponse struct {
AccessToken string `json:"access_token"`
Token string `json:"token"` // /api/v1/auth/token uses "token"
TokenType string `json:"token_type"`
}
LoginResponse is the shape returned by /api/v1/auth/login.
func (*LoginResponse) AccessTokenValue ¶
func (r *LoginResponse) AccessTokenValue() string
AccessTokenValue returns whichever token field is populated.
type LogsResponse ¶
type LogsResponse struct {
// Lines contains log lines if the server returns a string array.
Lines []string
// Entries contains structured log entries if the server returns objects.
Entries []LogEntry
}
LogsResponse is the body returned by GET /api/v1/extractors/runs/{run_id}/logs. The schema is additionalProperties:true; we handle both array-of-strings and array-of-objects shapes.
type OIDCCallbackRequest ¶
type OIDCCallbackRequest struct {
ProviderID string `json:"provider_id"`
Code string `json:"code"`
State string `json:"state"`
}
OIDCCallbackRequest matches OIDCCallbackRequest schema.
type OIDCCallbackResponse ¶
type OIDCCallbackResponse struct {
Token string `json:"token"`
UserID int `json:"user_id"`
Username string `json:"username"`
}
OIDCCallbackResponse matches OIDCCallbackResponse schema.
type OIDCLoginRequest ¶
type OIDCLoginRequest struct {
ProviderID string `json:"provider_id"`
}
OIDCLoginRequest matches OIDCLoginRequest schema.
type OIDCLoginResponse ¶
type OIDCLoginResponse struct {
AuthorizationURL string `json:"authorization_url"`
State string `json:"state"`
}
OIDCLoginResponse matches OIDCLoginResponse schema.
type OIDCProviderPublic ¶
type OIDCProviderPublic struct {
ID string `json:"id"`
Name string `json:"name"`
Issuer string `json:"issuer"`
Enabled bool `json:"enabled"`
}
OIDCProviderPublic matches ProviderPublic schema.
type Option ¶
type Option func(*Client)
Option mutates a Client during construction.
func WithHTTPClient ¶
WithHTTPClient overrides the default http.Client (useful in tests).
func WithMaxRetries ¶
WithMaxRetries sets the maximum retry attempts for transient 5xx errors. Default is 3 (i.e. up to 4 total requests).
func WithUserAgent ¶
WithUserAgent overrides the default User-Agent string.
type Page ¶
Page is the generic page envelope expected by FetchAll. Implementations are expected to satisfy this by wrapping API responses.
type ProjectCreate ¶
ProjectCreate is the body for POST /api/v1/config/projects.
type ProjectResponse ¶
type ProjectResponse struct {
Slug string `json:"slug"`
Name string `json:"name"`
MTD float64 `json:"mtd"`
// Raw holds the full decoded payload for forward-compat display.
Raw map[string]any
}
ProjectResponse is the shape returned by /api/v1/config/projects endpoints. The server returns additionalProperties:true so we use a flexible map with well-known top-level fields extracted for convenience.
type ProviderTotals ¶
type ProviderTotals struct {
MTD float64 `json:"mtd"`
Prev float64 `json:"prev"`
Delta float64 `json:"delta"`
}
ProviderTotals holds current/prev/delta for one provider (from /costs/totals).
type RunListResponse ¶
type RunListResponse struct {
Data []map[string]any `json:"data"`
Total int `json:"total"`
Page int `json:"page"`
PageSize int `json:"page_size"`
HasNext bool `json:"has_next"`
}
RunListResponse is the paginated wrapper returned by GET /api/v1/extractors/runs.
type RunResponse ¶
type RunResponse struct {
ID string `json:"id"`
ExtractorID string `json:"extractor_id"`
ExtractorName string `json:"extractor_name"`
Provider string `json:"provider"`
Status string `json:"status"`
StartedAt string `json:"started_at"`
CompletedAt string `json:"completed_at"`
DurationSecs float64 `json:"duration_secs"`
Params map[string]any `json:"params"`
Error string `json:"error"`
Raw map[string]any
}
RunResponse mirrors the shape of individual run records.
type TokenProvider ¶
TokenProvider returns a Bearer token for the current request. Returning an empty string (and nil error) means "no auth header" — endpoints that require auth will then reject with 401.
type TriggerRequest ¶
type TriggerRequest struct {
ExtractorID string `json:"extractor_id"`
Params map[string]any `json:"params,omitempty"`
}
TriggerRequest is the body for POST /api/v1/extractors/run.
type TriggerResponse ¶
type TriggerResponse struct {
RunID string `json:"run_id"`
Status string `json:"status"`
// Some server versions return the full run object.
ID string `json:"id"`
}
TriggerResponse holds the run_id returned by the trigger endpoint.
func (*TriggerResponse) RunID_ ¶
func (r *TriggerResponse) RunID_() string
RunID_ returns the non-empty run identifier, checking both RunID and ID fields. The trailing underscore distinguishes the method from the RunID field.
type ValidationItem ¶
type ValidationItem struct {
Loc []string `json:"loc"`
Msg string `json:"msg"`
Type string `json:"type"`
}
ValidationItem mirrors one entry of FastAPI's 422 detail array.
type WastageFinding ¶
type WastageFinding struct {
ID string `json:"id"`
Provider string `json:"provider"`
RuleID string `json:"rule_id"`
RuleName string `json:"rule_name"`
Severity string `json:"severity"`
Status string `json:"status"`
EstimatedMonthlySavings float64 `json:"estimated_monthly_usd"`
ResourceID string `json:"resource_id"`
Category string `json:"category"`
AccountID string `json:"account_id"`
FirstSeenAt string `json:"first_seen_at"`
LastSeenAt string `json:"last_seen_at"`
DetectedAt string `json:"detected_at"`
Raw map[string]any
}
WastageFinding represents a single resource wastage finding.
type WastageFindingListResponse ¶
type WastageFindingListResponse struct {
Data []WastageFinding
Total int
Limit int
Offset int
HasNext bool
HasPrev bool
}
WastageFindingListResponse is the wrapper returned by GET /api/v1/wastage.
type WastageFindingQuery ¶
type WastageFindingQuery struct {
Provider string
Severity string
RuleID string
Status string
AccountID string
Limit int
Offset int
}
WastageFindingQuery holds optional filters for listing wastage findings.
type WastageRule ¶
type WastageRule struct {
ID string `json:"id"`
Name string `json:"name"`
Provider string `json:"provider"`
Severity string `json:"severity"`
Category string `json:"category"`
Description string `json:"description"`
Enabled bool `json:"enabled"`
Raw map[string]any
}
WastageRule is a single entry from the rule catalog.
type WastageScan ¶
type WastageScan struct {
ID string `json:"id"`
ScanID string `json:"scan_id"`
Status string `json:"status"`
Provider string `json:"provider"`
StartedAt string `json:"started_at"`
FinishedAt string `json:"finished_at"`
FindingCount int `json:"finding_count"`
DurationSecs float64 `json:"duration_secs"`
Raw map[string]any
}
WastageScan is a single scan run record.
type WastageScanTriggerResponse ¶
type WastageScanTriggerResponse struct {
ScanID string `json:"scan_id"`
ID string `json:"id"`
Status string `json:"status"`
Raw map[string]any
}
WastageScanTriggerResponse is returned by POST /api/v1/wastage/scan.
func (*WastageScanTriggerResponse) ScanID_ ¶
func (r *WastageScanTriggerResponse) ScanID_() string
ScanID_ returns the non-empty scan identifier.
type WastageSummaryItem ¶
type WastageSummaryItem struct {
Category string `json:"category"`
EstimatedSavings float64 `json:"estimated_savings"`
Count int `json:"count"`
}
WastageSummaryItem is one entry from the wastage summary by category. It is also used by dashboard.go.