api

package
v1.15.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound indicates the requested resource does not exist.
	ErrNotFound = errors.New("not found")

	// ErrAlreadyExists indicates the resource already exists.
	ErrAlreadyExists = errors.New("already exists")
)

Sentinel errors for API responses. Use errors.Is() to check for these error types.

Functions

This section is empty.

Types

type API

type API struct {
	Organizations   *OrganizationService
	Accounts        *AccountService
	DatadogAccounts *DatadogAccountService
	Services        *ServiceService
}

API bundles all control plane API services. It provides a single entry point for all API-related operations.

func New

func New(client Client, scope log.Scope) *API

New creates a new API with all services initialized. Requires an authenticated API client.

type APIServices

type APIServices struct {
	Organizations   Organizations
	Accounts        Accounts
	Workspaces      Workspaces
	DatadogAccounts DatadogAccounts
	Conversations   Conversations
	Messages        Messages
	Services        Services
	// contains filtered or unexported fields
}

APIServices aggregates all API services for easy dependency injection. This is the primary public interface for interacting with the Tero API.

func NewAPIServices

func NewAPIServices(client Client, scope log.Scope) APIServices

NewAPIServices creates all API services from the given client. Use this constructor when you need to inject a mock client for testing.

func NewServices

func NewServices(endpoint string, authService auth.Auth, scope log.Scope) APIServices

NewServices creates APIServices with an internally-managed client. This is the preferred constructor for production use.

func (APIServices) RawQuery

func (s APIServices) RawQuery(ctx context.Context, query string, variables map[string]interface{}) (map[string]interface{}, error)

RawQuery executes an arbitrary GraphQL query (for debugging).

func (APIServices) SetAccountID

func (s APIServices) SetAccountID(accountID domain.AccountID)

SetAccountID sets the account ID header for scoped requests.

type AccountService

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

AccountService handles account-related API operations.

func NewAccountService

func NewAccountService(client Client, scope log.Scope) *AccountService

NewAccountService creates a new account service.

func (*AccountService) Create

Create creates a new account with the given client-provided ID.

func (*AccountService) Get

func (s *AccountService) Get(ctx context.Context, accountID domain.AccountID) (*domain.Account, error)

Get fetches a single account by ID. Returns nil if not found.

func (*AccountService) List

func (s *AccountService) List(ctx context.Context, organizationID domain.OrganizationID) ([]domain.Account, error)

List fetches all accounts for an organization.

type Accounts

type Accounts interface {
	List(ctx context.Context, organizationID domain.OrganizationID) ([]domain.Account, error)
	Get(ctx context.Context, accountID domain.AccountID) (*domain.Account, error)
	Create(ctx context.Context, input CreateAccountInput) (*domain.Account, error)
}

Accounts provides access to accounts.

type Client

type Client interface {
	// SetAccountID sets the account ID header for scoped requests.
	SetAccountID(accountID domain.AccountID)

	// RawQuery executes an arbitrary GraphQL query (for debugging).
	RawQuery(ctx context.Context, query string, variables map[string]interface{}) (map[string]interface{}, error)

	// Organization operations
	ListOrganizations(ctx context.Context) (*gen.ListOrganizationsResponse, error)
	CreateOrganizationAndBootstrap(ctx context.Context, input gen.CreateOrganizationInput) (*gen.CreateOrganizationAndBootstrapResponse, error)

	// Account operations
	ListAccounts(ctx context.Context, organizationID string) (*gen.ListAccountsResponse, error)
	CreateAccount(ctx context.Context, input gen.CreateAccountInput) (*gen.CreateAccountResponse, error)
	GetAccount(ctx context.Context, accountID string) (*gen.GetAccountResponse, error)

	// Datadog operations
	ValidateDatadogApiKey(ctx context.Context, input gen.ValidateDatadogApiKeyInput) (*gen.ValidateDatadogApiKeyResponse, error)
	CreateDatadogAccountWithCredentials(ctx context.Context, input gen.CreateDatadogAccountWithCredentialsInput) (*gen.CreateDatadogAccountWithCredentialsResponse, error)
	GetDatadogAccountStatus(ctx context.Context, id string) (*gen.GetDatadogAccountStatusResponse, error)

	// Workspace operations
	ListWorkspaces(ctx context.Context, accountID string) (*gen.ListWorkspacesResponse, error)

	// Conversation operations
	CreateConversation(ctx context.Context, input gen.CreateConversationInput) (*gen.CreateConversationResponse, error)
	UpdateConversation(ctx context.Context, id string, input gen.UpdateConversationInput) (*gen.UpdateConversationResponse, error)
	DeleteConversation(ctx context.Context, id string) (*gen.DeleteConversationResponse, error)

	// Message operations
	CreateMessage(ctx context.Context, input gen.CreateMessageInput) (*gen.CreateMessageResponse, error)

	// Service operations
	EnableService(ctx context.Context, serviceID string) (*gen.EnableServiceResponse, error)
	DisableService(ctx context.Context, serviceID string) (*gen.DisableServiceResponse, error)
}

Client defines the interface for communicating with the Tero control plane. This allows services to be tested without real API calls.

func NewClient

func NewClient(endpoint string, authService auth.Auth) Client

NewClient creates a new GraphQL API client. - Retries transient errors (connection reset, 502/503/504) up to 3 times with backoff - Gets a fresh token via auth.GetAccessToken before each request

type ConversationService

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

ConversationService handles conversation-related API operations.

func NewConversationService

func NewConversationService(client Client, scope log.Scope) *ConversationService

NewConversationService creates a new conversation service.

func (*ConversationService) Create

Create creates a new conversation with the given client-provided ID.

func (*ConversationService) Delete

Delete deletes a conversation. Returns ErrNotFound (via errors.Is) if the conversation does not exist.

func (*ConversationService) Update

Update updates a conversation.

type Conversations

Conversations provides access to conversations.

type CreateAccountInput

type CreateAccountInput struct {
	ID             uuid.UUID
	OrganizationID domain.OrganizationID
	Name           string
}

CreateAccountInput contains the fields for creating an account.

type CreateConversationInput

type CreateConversationInput struct {
	ID          uuid.UUID
	WorkspaceID domain.WorkspaceID
	Title       string
}

CreateConversationInput contains the fields for creating a conversation.

type CreateDatadogAccountInput

type CreateDatadogAccountInput struct {
	ID        uuid.UUID
	AccountID domain.AccountID
	Name      string
	Site      string
	APIKey    string
	AppKey    string
}

CreateDatadogAccountInput contains the fields for creating a Datadog account with credentials.

type CreateOrganizationInput

type CreateOrganizationInput struct {
	ID   uuid.UUID
	Name string
}

CreateOrganizationInput contains the fields for creating an organization.

type DatadogAccount

type DatadogAccount struct {
	ID   domain.DatadogAccountID
	Name string
	Site string // GraphQL enum value (US1, US5, EU1, etc.)
}

DatadogAccount is the domain model for a Datadog account.

type DatadogAccountHealth added in v1.15.0

type DatadogAccountHealth string

DatadogAccountHealth represents the infrastructure health of a Datadog account.

const (
	DatadogAccountHealthDisabled DatadogAccountHealth = "DISABLED"
	DatadogAccountHealthInactive DatadogAccountHealth = "INACTIVE"
	DatadogAccountHealthError    DatadogAccountHealth = "ERROR"
	DatadogAccountHealthStale    DatadogAccountHealth = "STALE"
	DatadogAccountHealthOK       DatadogAccountHealth = "OK"
)

type DatadogAccountService

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

DatadogAccountService handles Datadog account operations via the control plane API.

func NewDatadogAccountService

func NewDatadogAccountService(client Client, scope log.Scope) *DatadogAccountService

NewDatadogAccountService creates a new Datadog account service.

func (*DatadogAccountService) CreateAccount

CreateAccount creates a Datadog account in the control plane with credentials. Both API key and Application key must be provided. Keys are sent to control plane and stored securely there - never stored locally. The control plane validates the credentials before creating the account.

func (*DatadogAccountService) GetAccount

func (s *DatadogAccountService) GetAccount(ctx context.Context, accountID domain.AccountID) (*DatadogAccount, error)

GetAccount retrieves the Datadog account for the given account ID, or nil if none exists

func (*DatadogAccountService) GetStatus

func (s *DatadogAccountService) GetStatus(ctx context.Context, datadogAccountID domain.DatadogAccountID) (*DatadogAccountStatus, error)

GetStatus gets the health status for a Datadog account. This is used during onboarding to track overall progress.

func (*DatadogAccountService) HasAccount

func (s *DatadogAccountService) HasAccount(ctx context.Context, accountID domain.AccountID) (bool, error)

HasAccount checks if an account has a Datadog integration configured

func (*DatadogAccountService) ValidateAPIKey

func (s *DatadogAccountService) ValidateAPIKey(ctx context.Context, input ValidateAPIKeyInput) (bool, string, error)

ValidateAPIKey validates the API key via the control plane. The control plane handles validation against Datadog's API. Returns whether the key is valid, an error message if invalid, and any system errors.

type DatadogAccountStatus

type DatadogAccountStatus struct {
	Health               DatadogAccountHealth
	ReadyForUse          bool
	ServiceCount         int
	ActiveServices       int
	OkServices           int
	ErrorServices        int
	StaleServices        int
	DisabledServices     int
	InactiveServices     int
	EventCount           int
	AnalyzedCount        int
	QuarantinedCount     int
	PendingPolicyCount   int
	ApprovedPolicyCount  int
	DismissedPolicyCount int
}

DatadogAccountStatus tracks the health and progress for a Datadog account.

type DatadogAccounts

type DatadogAccounts interface {
	HasAccount(ctx context.Context, accountID domain.AccountID) (bool, error)
	GetAccount(ctx context.Context, accountID domain.AccountID) (*DatadogAccount, error)
	ValidateAPIKey(ctx context.Context, input ValidateAPIKeyInput) (bool, string, error)
	CreateAccount(ctx context.Context, input CreateDatadogAccountInput) (*DatadogAccount, error)
	GetStatus(ctx context.Context, datadogAccountID domain.DatadogAccountID) (*DatadogAccountStatus, error)
}

DatadogAccounts provides access to Datadog account operations.

type MessageService

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

MessageService handles message persistence via GraphQL.

func NewMessageService

func NewMessageService(client Client, scope log.Scope) *MessageService

NewMessageService creates a new message service.

func (*MessageService) CreateMessage

func (s *MessageService) CreateMessage(ctx context.Context, msg *domain.Message) error

CreateMessage persists a message to the control plane.

type Messages

type Messages interface {
	CreateMessage(ctx context.Context, msg *domain.Message) error
}

Messages persists messages to the control plane for durability. This is separate from the Chat API - it only handles persistence, not inference.

type OrderDirection

type OrderDirection string

OrderDirection specifies the direction for ordering results. This is a common type used across all list operations.

const (
	OrderDirectionAsc  OrderDirection = "ASC"
	OrderDirectionDesc OrderDirection = "DESC"
)

type OrganizationBootstrapResult

type OrganizationBootstrapResult struct {
	Organization *domain.Organization
	Account      *domain.Account
	Workspace    *domain.Workspace
}

OrganizationBootstrapResult contains the organization, account, and workspace created during bootstrap.

type OrganizationService

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

OrganizationService handles organization-related API operations.

func NewOrganizationService

func NewOrganizationService(client Client, scope log.Scope) *OrganizationService

NewOrganizationService creates a new organization service.

func (*OrganizationService) Create

Create creates a new organization with bootstrapped account and workspace.

func (*OrganizationService) List

List fetches all organizations for the user.

type Organizations

type Organizations interface {
	List(ctx context.Context) ([]domain.Organization, error)
	Create(ctx context.Context, input CreateOrganizationInput) (*OrganizationBootstrapResult, error)
}

Organizations provides access to organizations.

type ServiceService

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

ServiceService handles service-related operations. Services are discovered from observability platforms (Datadog, Splunk, etc.) and represent applications/microservices generating telemetry.

func NewServiceService

func NewServiceService(client Client, scope log.Scope) *ServiceService

NewServiceService creates a new service service.

func (*ServiceService) DisableService added in v1.15.0

func (s *ServiceService) DisableService(ctx context.Context, serviceID domain.ServiceID) error

DisableService disables a service.

func (*ServiceService) EnableService added in v1.15.0

func (s *ServiceService) EnableService(ctx context.Context, serviceID domain.ServiceID) error

EnableService enables a service for analysis.

type Services

type Services interface {
	EnableService(ctx context.Context, serviceID domain.ServiceID) error
	DisableService(ctx context.Context, serviceID domain.ServiceID) error
}

Services provides access to service operations.

type UpdateConversationInput

type UpdateConversationInput struct {
	Title *string
}

UpdateConversationInput contains the fields that can be updated on a conversation. Fields are pointers — nil means "don't change", non-nil means "set to this value".

type ValidateAPIKeyInput

type ValidateAPIKeyInput struct {
	APIKey string
	Site   string
}

ValidateAPIKeyInput contains the fields for validating a Datadog API key.

type WorkspaceService

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

WorkspaceService handles workspace-related API operations.

func NewWorkspaceService

func NewWorkspaceService(client Client, scope log.Scope) *WorkspaceService

NewWorkspaceService creates a new workspace service.

func (*WorkspaceService) List

func (s *WorkspaceService) List(ctx context.Context, accountID domain.AccountID) ([]domain.Workspace, error)

List fetches all workspaces for an account.

type Workspaces

type Workspaces interface {
	List(ctx context.Context, accountID domain.AccountID) ([]domain.Workspace, error)
}

Workspaces provides access to workspaces.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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