api

package
v1.2.23 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: Apache-2.0 Imports: 16 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"
)

Variables

This section is empty.

Functions

func GetBaseURL added in v0.1.23

func GetBaseURL() string

GetBaseURL returns the API base URL, allowing override via TUSK_CLOUD_API_URL env var

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 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 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) GetAuthInfo added in v0.1.17

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