api

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package api provides client functionality for the Agent-as-Code Binary API

Package api provides binary download functionality

Package api provides binary upload functionality

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetUploadSummary

func GetUploadSummary(results []*UploadResult) string

GetUploadSummary returns a summary of upload results

func SaveBinaryToFile

func SaveBinaryToFile(data []byte, filePath string) error

SaveBinaryToFile saves binary data to a file

Types

type BinaryInfo

type BinaryInfo struct {
	Filename     string `json:"filename"`
	Version      string `json:"version"`
	Platform     string `json:"platform"`
	Architecture string `json:"architecture"`
	Size         int64  `json:"size"`
	LastModified string `json:"last_modified"`
	DownloadURL  string `json:"download_url"`
}

BinaryInfo represents metadata about a binary release

type Client

type Client struct {
	BaseURL    string
	HTTPClient *http.Client
	AuthToken  string
}

Client represents the Binary API client

func NewClient

func NewClient(baseURL string) *Client

NewClient creates a new Binary API client

func (*Client) DownloadBinary

func (c *Client) DownloadBinary(version, platform, arch string) ([]byte, error)

DownloadBinary downloads a specific binary release

func (*Client) GetLatestBinary

func (c *Client) GetLatestBinary() (*BinaryInfo, error)

GetLatestBinary gets the latest binary for the current platform

func (*Client) ListFiles

func (c *Client) ListFiles(major, minor int) (*FilesResponse, error)

ListFiles lists all files for a specific major.minor version

func (*Client) ListVersions

func (c *Client) ListVersions() (*VersionsResponse, error)

ListVersions lists all available binary versions

func (*Client) SetAuthToken

func (c *Client) SetAuthToken(token string)

SetAuthToken sets the authentication token for API requests

func (*Client) UploadBinary

func (c *Client) UploadBinary(filePath, version, platform, arch string) (*UploadResponse, error)

UploadBinary uploads a binary release

type DownloadOptions

type DownloadOptions struct {
	Version      string
	Platform     string
	Architecture string
	OutputDir    string
	OutputFile   string
}

DownloadOptions represents options for binary download

type DownloadResult

type DownloadResult struct {
	Success      bool
	Platform     string
	Architecture string
	Version      string
	FilePath     string
	Size         int64
	Error        error
}

DownloadResult represents the result of a binary download

type Downloader

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

Downloader handles binary downloads from the API

func NewDownloader

func NewDownloader(baseURL string) *Downloader

NewDownloader creates a new binary downloader

func (*Downloader) DownloadAllPlatforms

func (d *Downloader) DownloadAllPlatforms(version, outputDir string) []*DownloadResult

DownloadAllPlatforms downloads binaries for all supported platforms

func (*Downloader) DownloadBinary

func (d *Downloader) DownloadBinary(opts DownloadOptions) *DownloadResult

DownloadBinary downloads a specific binary version

func (*Downloader) DownloadLatest

func (d *Downloader) DownloadLatest(outputDir string) *DownloadResult

DownloadLatest downloads the latest binary for current platform

func (*Downloader) GetBinaryInfo

func (d *Downloader) GetBinaryInfo(version, platform, arch string) (*BinaryInfo, error)

GetBinaryInfo gets information about a specific binary

func (*Downloader) InstallBinary

func (d *Downloader) InstallBinary(version, installDir string) *DownloadResult

InstallBinary downloads and installs a binary to the system

func (*Downloader) ListAvailableBinaries

func (d *Downloader) ListAvailableBinaries(version string) ([]BinaryInfo, error)

ListAvailableBinaries lists all available binaries for a version

func (*Downloader) ListAvailableVersions

func (d *Downloader) ListAvailableVersions() ([]string, error)

ListAvailableVersions lists all available versions

type ErrorResponse

type ErrorResponse struct {
	Error   string `json:"error"`
	Message string `json:"message"`
}

ErrorResponse represents an API error response

type FilesResponse

type FilesResponse struct {
	Success bool         `json:"success"`
	Major   int          `json:"major"`
	Minor   int          `json:"minor"`
	Files   []BinaryInfo `json:"files"`
	Count   int          `json:"count"`
}

FilesResponse represents the response from the files endpoint

type Release

type Release struct {
	Version      string `json:"version"`
	Major        int    `json:"major"`
	Minor        int    `json:"minor"`
	Patch        int    `json:"patch"`
	Platform     string `json:"platform"`
	Architecture string `json:"architecture"`
	Filename     string `json:"filename"`
	S3Key        string `json:"s3_key"`
	FileSize     int64  `json:"file_size"`
	ContentType  string `json:"content_type"`
	UploadedAt   string `json:"uploaded_at"`
	Checksum     string `json:"checksum"`
	DownloadURL  string `json:"download_url"`
}

Release represents a binary release

type UploadOptions

type UploadOptions struct {
	Platform     string
	Architecture string
	FilePath     string
	Force        bool // Overwrite existing binary
}

UploadOptions represents options for binary upload

type UploadRequest

type UploadRequest struct {
	Version      string `json:"version"`
	Platform     string `json:"platform"`
	Architecture string `json:"architecture"`
	FileData     string `json:"file_data"` // Base64 encoded
	Filename     string `json:"filename"`  // Optional
	Checksum     string `json:"checksum"`  // Optional
}

UploadRequest represents a binary upload request

type UploadResponse

type UploadResponse struct {
	Success bool    `json:"success"`
	Message string  `json:"message"`
	Release Release `json:"release"`
}

UploadResponse represents the response from binary upload

type UploadResult

type UploadResult struct {
	Success      bool
	Platform     string
	Architecture string
	Version      string
	DownloadURL  string
	Error        error
}

UploadResult represents the result of a binary upload

type Uploader

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

Uploader handles binary uploads to the API

func NewUploader

func NewUploader(baseURL, authToken, version string) *Uploader

NewUploader creates a new binary uploader

func (*Uploader) UploadAllPlatforms

func (u *Uploader) UploadAllPlatforms(binDir string) []*UploadResult

UploadAllPlatforms uploads binaries for all supported platforms

func (*Uploader) UploadBinary

func (u *Uploader) UploadBinary(opts UploadOptions) *UploadResult

UploadBinary uploads a single binary

func (*Uploader) UploadCurrentPlatform

func (u *Uploader) UploadCurrentPlatform(binaryPath string) *UploadResult

UploadCurrentPlatform uploads binary for current platform only

func (*Uploader) ValidateUpload

func (u *Uploader) ValidateUpload(platform, arch string) error

ValidateUpload validates a binary upload by downloading and comparing

type VersionsResponse

type VersionsResponse struct {
	Success  bool     `json:"success"`
	Versions []string `json:"versions"`
	Count    int      `json:"count"`
}

VersionsResponse represents the response from the versions endpoint

Jump to

Keyboard shortcuts

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