reporting

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package reporting is the demo console's read client for the Reporting API. It follows cmd/tally-vertical-slice/client.go: the same bearer header on every call, the same bounded body, and the same reading of a refused answer as the problem document the API answered with.

The client issues nothing but GET. The console shows what the API already holds, so no call of this package can change a project, a resource, or an event.

Every method returns the Request it made next to the model it decoded, which is what lets a page list where its numbers came from.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client reads the Reporting API for the console. It is deliberately minimal: no retries, and one flat timeout rather than a policy, because a demo page that fails is reloaded by the reader looking at it.

func New

func New(baseURL, token, caFile string) (*Client, error)

New builds the read client. The base URL is the API's root without the /api/v1 suffix; one trailing slash is trimmed, so the two forms an operator writes address the same routes.

The URL is taken as given. Whether it may carry the token is decided at startup by internal/console/config, which refuses one that is neither https nor loopback.

An empty caFile trusts the system store. A named one is trusted instead of it, which is what reaches a dev cluster whose certificates come from a CA the host does not know.

func (*Client) EventStats

func (c *Client) EventStats(
	ctx context.Context, groupBy []string, interval string, from, to time.Time,
) (httpapi.EventStatsList, Request, error)

EventStats counts the stored events of the half-open window [from, to) per bucket of the given interval. The route requires all four parameters.

func (*Client) GetLifecycle

func (c *Client) GetLifecycle(
	ctx context.Context, cloud, resourceType, resourceID string,
) (httpapi.Lifecycle, Request, error)

GetLifecycle reads one resource, its event history, and the billable intervals that history folds into.

func (*Client) GetProject

func (c *Client) GetProject(ctx context.Context, id uuid.UUID) (httpapi.Project, Request, error)

GetProject reads one project's registry row.

func (*Client) GetProjectSummary

func (c *Client) GetProjectSummary(
	ctx context.Context, id uuid.UUID, from, to time.Time,
) (httpapi.ProjectSummary, Request, error)

GetProjectSummary reads what one project ran inside the half-open window [from, to). Both bounds are required by the route and travel as UTC.

func (*Client) ListProjectRelations

func (c *Client) ListProjectRelations(
	ctx context.Context, id uuid.UUID, q RelationsQuery,
) (httpapi.RelationList, Request, error)

ListProjectRelations reads the relations one project has at one instant, narrowed by q. A zero query reads them as they stand now, in both directions and of every type.

func (*Client) ListProjects

func (c *Client) ListProjects(ctx context.Context, q ProjectsQuery) (httpapi.ProjectList, Request, error)

ListProjects reads one page of the registered projects. The page's NextCursor is returned as the API served it and never followed: one call answers one page, and asking for the next one is the caller's move.

func (*Client) ListRejectedEvents

func (c *Client) ListRejectedEvents(ctx context.Context, limit int) (httpapi.DeadLetterList, Request, error)

ListRejectedEvents reads the ingest items the API refused. A limit of zero or less is left out, which leaves the page size the API decides in place.

func (*Client) ListRelatedProjects

func (c *Client) ListRelatedProjects(ctx context.Context, id uuid.UUID) (httpapi.RelatedProjectList, Request, error)

ListRelatedProjects reads the projects a traversal from one project reaches.

func (*Client) ListResources

func (c *Client) ListResources(ctx context.Context, q ResourcesQuery) (httpapi.ResourceList, Request, error)

ListResources reads one page of the current resources. As with ListProjects, the cursor is returned rather than followed.

func (*Client) ResourceStats

func (c *Client) ResourceStats(
	ctx context.Context, groupBy []string, status string,
) (httpapi.ResourceStatsList, Request, error)

ResourceStats counts the current resources along the dimensions groupBy names. An empty status leaves the API's own default in place.

The at parameter of the route is never sent: the API answers 501 to a grouping asked for at an instant, so what the console shows is always the count the projection holds now.

type ProblemError

type ProblemError struct {
	Status int
	Type   string
	Title  string
	Detail string
}

ProblemError is an answer the API refused, as its problem document diagnosed it. The problem type is what a reader recognizes the case by, so it is kept next to the status code rather than dropped for it.

func (*ProblemError) Error

func (e *ProblemError) Error() string

Error reports the status the API answered with and its own diagnosis. A problem document without a detail carries the title alone.

type ProjectsQuery

type ProjectsQuery struct {
	Platform   string
	Cloud      string
	ExternalID string
	Cursor     string
}

ProjectsQuery narrows a project list. Every field is optional, and an empty one filters nothing.

type RelationsQuery

type RelationsQuery struct {
	// Direction is incoming, outgoing or both, the values the route takes.
	Direction    string
	RelationType string
	At           time.Time
}

RelationsQuery narrows a relation list. Every field is optional: an empty Direction or RelationType filters nothing, and a zero At is now.

type Request

type Request struct {
	Method string
	Path   string
}

Request is one call the client made: the method and the path, including the query string when one was sent. A page lists these as its provenance.

type ResourcesQuery

type ResourcesQuery struct {
	Cloud        string
	ProjectID    string
	ResourceType string
	State        string
	Status       string
	Cursor       string
	// Limit is how many rows one page carries at most, within the API's
	// bounds. Zero leaves the API's default.
	Limit int
}

ResourcesQuery narrows a resource list. Every field is optional, and an empty one filters nothing.

Jump to

Keyboard shortcuts

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