api

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package api provides shared API infrastructure (errors, validation interface) used across all API versions. Version-specific types live in sub-packages (e.g. api/v1).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmptyReq

type EmptyReq struct{}

EmptyReq is used for endpoints that take no request body.

func (EmptyReq) Validate

func (EmptyReq) Validate() error

Validate is a no-op for empty requests.

type Error

type Error struct {
	// Status is the HTTP status code.
	Status int
	// Code is the machine-readable error code.
	Code ErrorCode
	// Message is the client-facing error message.
	Message string
	// Details holds optional unstructured diagnostics.
	Details map[string]any
	// Cause is the optional underlying error.
	Cause error
}

Error is a concrete error type with status code, error code, optional details, and optional wrapped error.

func (*Error) Error

func (e *Error) Error() string

Error returns the error message, including any wrapped error.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the wrapped error.

type ErrorCode

type ErrorCode string

ErrorCode is a machine-readable error identifier.

const (
	CodeBadRequest               ErrorCode = "BAD_REQUEST"
	CodeUnknownHarness           ErrorCode = "UNKNOWN_HARNESS"
	CodeUnknownRepository        ErrorCode = "UNKNOWN_REPOSITORY"
	CodeUnsupportedModel         ErrorCode = "UNSUPPORTED_MODEL"
	CodeInvalidOAuthState        ErrorCode = "INVALID_OAUTH_STATE"
	CodeOAuthGrantNotFound       ErrorCode = "OAUTH_GRANT_NOT_FOUND"
	CodeOAuthProviderUnavailable ErrorCode = "OAUTH_PROVIDER_UNAVAILABLE"
	CodeRepositoryPathConflict   ErrorCode = "REPOSITORY_PATH_CONFLICT"
	CodeUnknownCache             ErrorCode = "UNKNOWN_CACHE"
	CodeUnknownRuntime           ErrorCode = "UNKNOWN_RUNTIME"
	CodeUpdateCheckFailed        ErrorCode = "UPDATE_CHECK_FAILED"
	CodeUpdateUnavailable        ErrorCode = "UPDATE_UNAVAILABLE"
	CodeUnauthorized             ErrorCode = "UNAUTHORIZED"
	CodeForbidden                ErrorCode = "FORBIDDEN"
	CodeNotFound                 ErrorCode = "NOT_FOUND"
	CodeConflict                 ErrorCode = "CONFLICT"
	CodeInternalError            ErrorCode = "INTERNAL_ERROR"
)

Error codes.

type ErrorDetails

type ErrorDetails struct {
	Code    ErrorCode `json:"code"`
	Message string    `json:"message"`
}

ErrorDetails holds the code and message within an error response.

type ErrorResponse

type ErrorResponse struct {
	Error   ErrorDetails   `json:"error"`
	Details map[string]any `json:"details,omitempty"`
}

ErrorResponse is the JSON envelope for error responses.

type Validatable

type Validatable interface {
	Validate() error
}

Validatable is implemented by request types that can validate their fields.

Directories

Path Synopsis
Package v1 defines SSE event types and API data transfer objects for the caic API.
Package v1 defines SSE event types and API data transfer objects for the caic API.

Jump to

Keyboard shortcuts

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