api

package
v0.1.47 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultBaseURL is the default Tusk Cloud API URL
	DefaultBaseURL = "https://api.usetusk.ai"

	TestRunServiceAPIPath    = "/api/drift/test_run_service"
	ClientServiceAPIPath     = "/api/drift/client_service"
	SpanExportServiceAPIPath = "/api/drift/tusk.drift.backend.v1.SpanExportService"
)

Variables

This section is empty.

Functions

func FetchAllTraceTests added in v0.1.43

func FetchAllTraceTests(
	ctx context.Context,
	client *TuskClient,
	auth AuthOptions,
	serviceID string,
	opts *FetchAllTraceTestsOptions,
) ([]*backend.TraceTest, error)

FetchAllTraceTests fetches all trace tests from the cloud with a progress bar. This is the shared implementation used by both `tusk list -c` and `tusk run -c`.

func FetchDriftRunTraceTests added in v0.1.43

func FetchDriftRunTraceTests(
	ctx context.Context,
	client *TuskClient,
	auth AuthOptions,
	driftRunID string,
	opts *FetchAllTraceTestsOptions,
) ([]*backend.TraceTest, error)

FetchDriftRunTraceTests fetches trace tests for a specific drift run with a progress bar.

func GetBaseURL added in v0.1.23

func GetBaseURL() string

GetBaseURL returns the API base URL with the following priority: 1. TUSK_CLOUD_API_URL environment variable 2. tusk_api.url from .tusk/config.yaml 3. Default URL (https://api.usetusk.ai)

func IsNoSeatError added in v0.1.47

func IsNoSeatError(err error) bool

IsNoSeatError checks if an error is a NoSeatError

func SetupCloud

func SetupCloud(ctx context.Context, requireServiceID bool) (*TuskClient, AuthOptions, *config.Config, error)

Types

type AuthOptions

type AuthOptions struct {
	APIKey       string
	BearerToken  string
	TuskClientID string
}

type Deviation

type Deviation struct {
	Type        string `json:"type"`
	Field       string `json:"field"`
	Expected    any    `json:"expected"`
	Actual      any    `json:"actual"`
	Description string `json:"description"`
	Severity    string `json:"severity"`
}

type FetchAllTraceTestsOptions added in v0.1.43

type FetchAllTraceTestsOptions struct {
	// Message to show in the progress bar
	Message string
	// PageSize for pagination (default 25)
	PageSize int32
}

FetchAllTraceTestsOptions configures the fetch behavior

type MockInteraction

type MockInteraction struct {
	Service   string           `json:"service"`
	Request   RecordedRequest  `json:"request"`
	Response  RecordedResponse `json:"response"`
	Order     int              `json:"order"`
	Timestamp time.Time        `json:"timestamp"`
}

type NoSeatError added in v0.1.47

type NoSeatError struct {
	Message string
}

NoSeatError is returned when the PR creator doesn't have a Tusk Cloud seat

func (*NoSeatError) Error added in v0.1.47

func (e *NoSeatError) Error() string

type RecordedRequest

type RecordedRequest struct {
	Method  string              `json:"method"`
	Path    string              `json:"path"`
	Headers map[string][]string `json:"headers"`
	Body    any                 `json:"body,omitempty"`
	Query   map[string][]string `json:"query,omitempty"`
}

type RecordedResponse

type RecordedResponse struct {
	Status  int                 `json:"status"`
	Headers map[string][]string `json:"headers"`
	Body    any                 `json:"body,omitempty"`
}

type RetryConfig added in v0.1.14

type RetryConfig struct {
	MaxRetries  int
	BaseBackoff time.Duration
	MaxBackoff  time.Duration
	JitterMin   float64
	JitterMax   float64
}

func DefaultRetryConfig added in v0.1.14

func DefaultRetryConfig(maxRetries int) RetryConfig

DefaultRetryConfig returns normal retry configuration

func FastRetryConfig added in v0.1.14

func FastRetryConfig(maxRetries int) RetryConfig

FastRetryConfig returns retry configuration for testing

type TestRecording

type TestRecording struct {
	ID        string            `json:"id"`
	ServiceID string            `json:"service_id"`
	TraceID   string            `json:"trace_id"`
	Method    string            `json:"method"`
	Path      string            `json:"path"`
	Request   RecordedRequest   `json:"request"`
	Response  RecordedResponse  `json:"response"`
	Mocks     []MockInteraction `json:"mocks"`
	Timestamp time.Time         `json:"timestamp"`
	Metadata  map[string]any    `json:"metadata"`
}

type TestResult

type TestResult struct {
	TestID      string      `json:"test_id"`
	ServiceID   string      `json:"service_id"`
	Passed      bool        `json:"passed"`
	Duration    int         `json:"duration_ms"`
	Deviations  []Deviation `json:"deviations,omitempty"`
	Error       string      `json:"error,omitempty"`
	ExecutedAt  time.Time   `json:"executed_at"`
	Environment string      `json:"environment"`
}

type TuskClient

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

func NewClient

func NewClient(baseURL, apiKey string) *TuskClient

func (*TuskClient) CreateApiKey added in v0.1.19

func (*TuskClient) CreateDriftRun

func (c *TuskClient) CreateDriftRun(ctx context.Context, in *backend.CreateDriftRunRequest, auth AuthOptions) (string, error)

func (*TuskClient) CreateObservableService added in v0.1.19

func (*TuskClient) ExportSpans added in v0.1.46

ExportSpans uploads spans to Tusk Cloud

func (*TuskClient) GetAuthInfo added in v0.1.17

func (*TuskClient) GetObservableServiceInfo added in v0.1.31

GetObservableServiceInfo fetches observable service info including default branch

func (*TuskClient) GetValidationTraceTests added in v0.1.31

GetValidationTraceTests fetches traces for validation (both DRAFT and IN_SUITE)

func (*TuskClient) UpdateDriftRunCIStatus

func (c *TuskClient) UpdateDriftRunCIStatus(ctx context.Context, in *backend.UpdateDriftRunCIStatusRequest, auth AuthOptions) error

func (*TuskClient) UploadTraceTestResults

func (c *TuskClient) UploadTraceTestResults(ctx context.Context, in *backend.UploadTraceTestResultsRequest, auth AuthOptions) error

func (*TuskClient) VerifyRepoAccess added in v0.1.19

Jump to

Keyboard shortcuts

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