schema

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert added in v0.0.3

type Alert struct {
	ID          string    `json:"id"`
	Title       string    `json:"title"`
	Description string    `json:"description,omitempty"`
	Status      string    `json:"status"`
	Severity    string    `json:"severity"`
	Service     string    `json:"service,omitempty"`
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt"`

	// Fields is a flexible bag for commonly useful, structured attributes
	// (e.g. metric name, monitor/issue ID, hostname, region, tags).
	Fields map[string]any `json:"fields,omitempty"`

	// Metadata is for provider-specific payload fragments that don't map cleanly
	// into the normalized shape (raw JSON, rule definitions, etc.).
	Metadata map[string]any `json:"metadata,omitempty"`
}

Alert captures the normalized alert shape for the current schema revision. It is intentionally similar to Incident but represents a lower-level signal.

type AlertQuery added in v0.0.3

type AlertQuery struct {
	// Query is a free-form search string providers can map to title/message or
	// provider-specific search syntax.
	Query string `json:"query,omitempty"`

	// Statuses filters alerts by one or more normalized status values
	// (e.g. "open", "closed", "firing", "resolved").
	Statuses []string `json:"statuses,omitempty"`

	// Severities filters alerts by normalized severity values
	// (e.g. "info", "warning", "error", "critical", "P1").
	Severities []string `json:"severities,omitempty"`

	// Scope provides shared service/team/environment hints.
	Scope QueryScope `json:"scope,omitempty"`

	// Limit caps the maximum number of alerts returned.
	Limit int `json:"limit,omitempty"`

	// Metadata carries provider-specific filter hints (e.g. label selectors,
	// monitor types, project IDs).
	Metadata map[string]any `json:"metadata,omitempty"`
}

AlertQuery filters normalized alerts from the active alert provider. Providers choose how to map these hints to their upstream search/filter API.

type Block

type Block struct {
	Type   BlockType         `json:"type"`
	Text   string            `json:"text,omitempty"`
	Fields map[string]string `json:"fields,omitempty"`
}

Block represents a UI element in a message. Text fields support CommonMark Markdown. Adapters are responsible for converting this Markdown to the target platform's format (e.g., Slack mrkdwn).

type BlockType

type BlockType string

BlockType defines the type of a UI block.

const (
	BlockTypeHeader  BlockType = "header"
	BlockTypeSection BlockType = "section"
	BlockTypeDivider BlockType = "divider"
)

type CreateIncidentInput

type CreateIncidentInput struct {
	Title       string         `json:"title"`
	Description string         `json:"description,omitempty"`
	Status      string         `json:"status"`
	Severity    string         `json:"severity"`
	Service     string         `json:"service,omitempty"`
	Fields      map[string]any `json:"fields,omitempty"`
	Metadata    map[string]any `json:"metadata,omitempty"`
}

CreateIncidentInput is the provider-agnostic payload for creating an incident.

type CreateTicketInput

type CreateTicketInput struct {
	Title       string         `json:"title"`
	Description string         `json:"description,omitempty"`
	Fields      map[string]any `json:"fields,omitempty"`
	Metadata    map[string]any `json:"metadata,omitempty"`
}

CreateTicketInput defines the payload for ticket creation.

type Incident

type Incident struct {
	ID          string         `json:"id"`
	Title       string         `json:"title"`
	Description string         `json:"description,omitempty"`
	Status      string         `json:"status"`
	Severity    string         `json:"severity"`
	Service     string         `json:"service,omitempty"`
	CreatedAt   time.Time      `json:"createdAt"`
	UpdatedAt   time.Time      `json:"updatedAt"`
	Fields      map[string]any `json:"fields,omitempty"`
	Metadata    map[string]any `json:"metadata,omitempty"`
}

Incident captures the normalized incident shape for the current schema revision.

type IncidentQuery

type IncidentQuery struct {
	// Query is a free-form search string providers can map to title, summary, or
	// provider-specific search syntax.
	Query string `json:"query,omitempty"`

	// Statuses filters incidents by one or more normalized status values.
	Statuses []string `json:"statuses,omitempty"`

	// Severities filters incidents by normalized severity values.
	Severities []string `json:"severities,omitempty"`

	// Scope provides shared service/team/environment hints.
	Scope QueryScope `json:"scope,omitempty"`

	// Limit caps the maximum number of incidents returned.
	Limit int `json:"limit,omitempty"`

	// Metadata carries provider-specific filter hints.
	Metadata map[string]any `json:"metadata,omitempty"`
}

IncidentQuery filters normalized incidents from the active incident provider. Providers choose how to map these hints to their upstream search/filter API.

type LogEntry

type LogEntry struct {
	Timestamp time.Time         `json:"timestamp"`
	Message   string            `json:"message"`
	Severity  string            `json:"severity,omitempty"`
	Service   string            `json:"service,omitempty"`
	Labels    map[string]string `json:"labels,omitempty"`   // filterable
	Fields    map[string]any    `json:"fields,omitempty"`   // structured JSON
	Metadata  map[string]any    `json:"metadata,omitempty"` // provider-specific
}

LogEntry is a normalized log record.

type LogExpression

type LogExpression struct {
	Search     string      `json:"search,omitempty"`     // Full-text search term
	Filters    []LogFilter `json:"filters,omitempty"`    // Structured filters
	SeverityIn []string    `json:"severityIn,omitempty"` // Filter by severity levels
}

LogExpression defines structured log search criteria.

type LogFilter

type LogFilter struct {
	Field    string `json:"field"`    // Field name (e.g., "service", "message")
	Operator string `json:"operator"` // "=", "!=", "contains", "regex"
	Value    string `json:"value"`    // Filter value
}

LogFilter defines a field-level filter for logs.

type LogQuery

type LogQuery struct {
	Expression *LogExpression `json:"expression,omitempty"`
	Start      time.Time      `json:"start"`
	End        time.Time      `json:"end"`
	Scope      QueryScope     `json:"scope,omitempty"`
	Limit      int            `json:"limit,omitempty"`
	Metadata   map[string]any `json:"metadata,omitempty"`
	Providers  []string       `json:"providers,omitempty"`
}

LogQuery requests a slice of normalized log entries.

Example:

{
  "expression": {
    "search": "error connection",
    "filters": [
      {"field": "service", "operator": "=", "value": "api-gateway"},
      {"field": "status", "operator": "!=", "value": "200"}
    ],
    "severityIn": ["error", "critical"]
  },
  "start": "2023-10-01T00:00:00Z",
  "end": "2023-10-01T01:00:00Z"
}

type Message

type Message struct {
	Channel   string         `json:"channel"`
	Body      string         `json:"body"`
	Metadata  map[string]any `json:"metadata,omitempty"`
	ThreadRef string         `json:"threadRef,omitempty"`
	Blocks    []Block        `json:"blocks,omitempty"`
}

type MessageResult

type MessageResult struct {
	ID       string         `json:"id"`
	Channel  string         `json:"channel"`
	SentAt   time.Time      `json:"sentAt"`
	Metadata map[string]any `json:"metadata,omitempty"`
}

type MetricDescriptor

type MetricDescriptor struct {
	Name        string         `json:"name"`               // Metric name (e.g., "http_requests_total")
	Type        string         `json:"type"`               // "counter", "gauge", "histogram"
	Description string         `json:"description"`        // Human-readable description
	Labels      []string       `json:"labels"`             // Available label keys
	Unit        string         `json:"unit,omitempty"`     // "bytes", "seconds", "requests"
	Metadata    map[string]any `json:"metadata,omitempty"` // Provider-specific metadata
}

MetricDescriptor describes an available metric for discovery.

type MetricExpression

type MetricExpression struct {
	MetricName  string         `json:"metricName"`            // Required: metric name (e.g., "http_requests_total")
	Aggregation string         `json:"aggregation,omitempty"` // "avg", "sum", "max", "min", "count"
	Filters     []MetricFilter `json:"filters,omitempty"`     // Label filters
	GroupBy     []string       `json:"groupBy,omitempty"`     // Label keys to group by
}

MetricExpression defines structured metric selection criteria.

type MetricFilter

type MetricFilter struct {
	Label    string `json:"label"`    // Label key
	Operator string `json:"operator"` // "=", "!=", "=~", "!~"
	Value    string `json:"value"`    // Filter value
}

MetricFilter defines a label-based filter for metrics.

type MetricPoint

type MetricPoint struct {
	Timestamp time.Time `json:"timestamp"`
	Value     float64   `json:"value"`
}

MetricPoint represents a single value in a series.

type MetricQuery

type MetricQuery struct {
	Expression *MetricExpression `json:"expression,omitempty"`
	Start      time.Time         `json:"start"`
	End        time.Time         `json:"end"`
	Step       int               `json:"step"` // in seconds
	Scope      QueryScope        `json:"scope,omitempty"`
	Metadata   map[string]any    `json:"metadata,omitempty"`
}

MetricQuery specifies a time-series request.

Example:

{
  "expression": {
    "metricName": "http_requests_total",
    "aggregation": "sum",
    "filters": [
      {"label": "method", "operator": "=", "value": "POST"}
    ],
    "groupBy": ["service", "status"]
  },
  "start": "2023-10-01T00:00:00Z",
  "end": "2023-10-01T01:00:00Z",
  "step": 60
}

type MetricSeries

type MetricSeries struct {
	Name     string         `json:"name"`
	Service  string         `json:"service,omitempty"`
	Labels   map[string]any `json:"labels,omitempty"`
	Points   []MetricPoint  `json:"points"`
	Metadata map[string]any `json:"metadata,omitempty"`
}

MetricSeries is a normalized collection of metric points.

type QueryScope

type QueryScope struct {
	// Service is the canonical service name.
	// Providers map this to service tags, project IDs, components, etc.
	Service string `json:"service,omitempty"`

	// Team is the team owning the workload or resource.
	// Providers map this to escalation policies, Jira components, Datadog tags, etc.
	Team string `json:"team,omitempty"`

	// Environment is a simple "prod", "staging", "dev"-style filter.
	// Providers map this to labels/tags in their own systems.
	Environment string `json:"environment,omitempty"`
}

QueryScope is the minimal shared filter used across all OpsOrch queries. Providers can choose to ignore fields they don't understand.

type Service

type Service struct {
	// ID is the stable, normalized OpsOrch identifier for this service.
	// Typically derived from the provider's unique field (e.g. UID, ID, slug).
	ID string `json:"id"`

	// Name is the human-readable display name of the service.
	// Providers may map this from title, name, alias, or other upstream fields.
	Name string `json:"name"`

	// Tags contains normalized key/value tags for filtering and correlation.
	// Providers flatten their native tag/label formats into string pairs.
	Tags map[string]string `json:"tags,omitempty"`

	// Metadata stores provider-specific fields not covered by the normalized schema.
	// Providers may include raw upstream objects, attributes, or extended data here.
	Metadata map[string]any `json:"metadata,omitempty"`
}

Service represents a normalized service definition from the active service provider. OpsOrch does not create, modify, or delete services; providers own the source of truth.

type ServiceQuery

type ServiceQuery struct {
	// IDs filters services by their normalized OpsOrch ID.
	// Providers can map this to their upstream "id", "uid", or similar fields.
	IDs []string `json:"ids,omitempty"`

	// Name is a substring / fuzzy match filter for service names.
	// Providers typically match this against their display name or slug.
	Name string `json:"name,omitempty"`

	// Tags filters services by key/value tag pairs.
	// Providers may match these to labels, tags, attributes, or custom metadata.
	Tags map[string]string `json:"tags,omitempty"`

	// Limit restricts the maximum number of services returned.
	// Providers may apply this server-side or let OpsOrch slice results.
	Limit int `json:"limit,omitempty"`

	// Scope provides a shared set of filtering hints applied across providers.
	// Providers can ignore fields they do not support.
	Scope QueryScope `json:"scope,omitempty"`

	// Metadata carries provider-specific query hints.
	// This is an escape hatch: adapters may interpret these fields as needed.
	Metadata map[string]any `json:"metadata,omitempty"`
}

ServiceQuery defines filters passed to the single active service provider. Providers decide how to apply these filters (server-side or client-side).

type Ticket

type Ticket struct {
	ID          string         `json:"id"`
	Key         string         `json:"key,omitempty"`
	Title       string         `json:"title"`
	Description string         `json:"description,omitempty"`
	Status      string         `json:"status"`
	Assignees   []string       `json:"assignees,omitempty"`
	Reporter    string         `json:"reporter,omitempty"`
	CreatedAt   time.Time      `json:"createdAt"`
	UpdatedAt   time.Time      `json:"updatedAt"`
	Fields      map[string]any `json:"fields,omitempty"`
	Metadata    map[string]any `json:"metadata,omitempty"`
}

Ticket is a normalized representation of a work item.

type TicketQuery

type TicketQuery struct {
	Query     string         `json:"query,omitempty"`
	Statuses  []string       `json:"statuses,omitempty"`
	Assignees []string       `json:"assignees,omitempty"`
	Reporter  string         `json:"reporter,omitempty"`
	Scope     QueryScope     `json:"scope,omitempty"`
	Limit     int            `json:"limit,omitempty"`
	Metadata  map[string]any `json:"metadata,omitempty"`
}

TicketQuery defines filters for querying tickets. Query is a free-form search string providers can map to JQL, name, description, etc.

type TimelineAppendInput

type TimelineAppendInput struct {
	At       time.Time      `json:"at"`
	Kind     string         `json:"kind"`
	Body     string         `json:"body"`
	Actor    map[string]any `json:"actor,omitempty"`
	Metadata map[string]any `json:"metadata,omitempty"`
}

TimelineAppendInput is used to append to an incident timeline.

type TimelineEntry

type TimelineEntry struct {
	ID         string         `json:"id"`
	IncidentID string         `json:"incidentId"`
	At         time.Time      `json:"at"`
	Kind       string         `json:"kind"`
	Body       string         `json:"body"`
	Actor      map[string]any `json:"actor,omitempty"`
	Metadata   map[string]any `json:"metadata,omitempty"`
}

TimelineEntry represents a single entry on an incident timeline.

type UpdateIncidentInput

type UpdateIncidentInput struct {
	Title       *string        `json:"title,omitempty"`
	Description *string        `json:"description,omitempty"`
	Status      *string        `json:"status,omitempty"`
	Severity    *string        `json:"severity,omitempty"`
	Service     *string        `json:"service,omitempty"`
	Fields      map[string]any `json:"fields,omitempty"`
	Metadata    map[string]any `json:"metadata,omitempty"`
}

UpdateIncidentInput defines mutable fields on an incident.

type UpdateTicketInput

type UpdateTicketInput struct {
	Title       *string        `json:"title,omitempty"`
	Description *string        `json:"description,omitempty"`
	Status      *string        `json:"status,omitempty"`
	Assignees   *[]string      `json:"assignees,omitempty"`
	Fields      map[string]any `json:"fields,omitempty"`
	Metadata    map[string]any `json:"metadata,omitempty"`
}

UpdateTicketInput defines mutable fields on a ticket.

Jump to

Keyboard shortcuts

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