Documentation
¶
Overview ¶
Package api is the typed HTTP client for the loradex control-plane API. File bytes never pass through here — they move directly to/from presigned URLs.
Index ¶
- func OpenBrowser(url string) error
- func RandomState() string
- type Client
- func (c *Client) AuthorizeURL(callback, state, challenge string) string
- func (c *Client) CheckEndpoint() error
- func (c *Client) CreateRepo(ctx context.Context, owner string, body CreateRepoBody) (*Repo, error)
- func (c *Client) Download(ctx context.Context, owner, repo, version, include string) (*DownloadResp, error)
- func (c *Client) Exchange(ctx context.Context, code, verifier string) (*ExchangeResp, error)
- func (c *Client) FinalizeUpload(ctx context.Context, owner, repo string, body FinalizeBody) (*FinalizeResp, error)
- func (c *Client) GetRepo(ctx context.Context, owner, repo string) (*Repo, error)
- func (c *Client) InitiateUpload(ctx context.Context, owner, repo string, body InitiateBody) (*InitiateResp, error)
- func (c *Client) ListFiles(ctx context.Context, owner, repo, version string) (string, []File, error)
- func (c *Client) ListRepos(ctx context.Context, p ListReposParams) (*RepoList, error)
- func (c *Client) ListVersions(ctx context.Context, owner, repo string) ([]Version, error)
- func (c *Client) Me(ctx context.Context) (*Me, error)
- func (c *Client) Search(ctx context.Context, p SearchParams) (*RepoList, error)
- type CreateRepoBody
- type DownloadFile
- type DownloadResp
- type ExchangeResp
- type ExtraFile
- type File
- type FinalizeBody
- type FinalizeResp
- type InitiateBody
- type InitiateResp
- type ListReposParams
- type LoopbackServer
- type Me
- type PKCE
- type Part
- type PartETag
- type Repo
- type RepoList
- type SearchParams
- type UploadTarget
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OpenBrowser ¶
OpenBrowser best-effort opens url in the default browser.
Types ¶
type Client ¶
type Client struct {
Endpoint string // e.g. https://api.loradex.ai
Web string // e.g. https://loradex.ai
Token string // bearer token for the endpoint host (may be empty)
Insecure bool // allow http:// for loopback only
HTTP *http.Client
Log *output.Printer
}
Client talks to the loradex API.
func (*Client) AuthorizeURL ¶
AuthorizeURL builds the web authorize URL for the loopback flow.
func (*Client) CheckEndpoint ¶
CheckEndpoint enforces HTTPS unless the endpoint is a loopback host with --insecure.
func (*Client) CreateRepo ¶
CreateRepo creates a repository. 409 if it exists.
func (*Client) Download ¶
func (c *Client) Download(ctx context.Context, owner, repo, version, include string) (*DownloadResp, error)
Download requests presigned GET URLs. include = "weights" or "all" (+samples handled server-side).
func (*Client) Exchange ¶
Exchange swaps the one-time code for a CLI token (non-idempotent; no retry).
func (*Client) FinalizeUpload ¶
func (c *Client) FinalizeUpload(ctx context.Context, owner, repo string, body FinalizeBody) (*FinalizeResp, error)
FinalizeUpload commits the version. Never auto-retried.
func (*Client) InitiateUpload ¶
func (c *Client) InitiateUpload(ctx context.Context, owner, repo string, body InitiateBody) (*InitiateResp, error)
InitiateUpload requests presigned upload URLs (non-idempotent).
func (*Client) ListFiles ¶
func (c *Client) ListFiles(ctx context.Context, owner, repo, version string) (string, []File, error)
ListFiles returns the files of a version.
func (*Client) ListVersions ¶
ListVersions returns the version history.
type CreateRepoBody ¶
type CreateRepoBody struct {
Name string `json:"name"`
Description string `json:"description"`
Visibility string `json:"visibility"`
BaseModel string `json:"base_model"`
Format string `json:"format"`
License string `json:"license"`
TriggerWords []string `json:"trigger_words"`
NetworkRank int `json:"network_rank"`
NetworkDim int `json:"network_dim"`
RecommendedWeight float64 `json:"recommended_weight"`
Tags []string `json:"tags"`
}
CreateRepoBody is the metadata for creating a repo.
type DownloadFile ¶
type DownloadFile struct {
Name string `json:"name"`
URL string `json:"url"`
SHA256 string `json:"sha256"`
Size int64 `json:"size"`
}
DownloadFile is a presigned GET target with integrity metadata.
type DownloadResp ¶
type DownloadResp struct {
Version string `json:"version"`
Files []DownloadFile `json:"files"`
}
DownloadResp lists files to download for a version.
type ExchangeResp ¶
type ExchangeResp struct {
Token string `json:"token"`
Handle string `json:"handle"`
ExpiresAt string `json:"expires_at"`
}
ExchangeResp is the result of the CLI token exchange.
type ExtraFile ¶
type ExtraFile struct {
Name string `json:"name"`
Size int64 `json:"size"`
SHA256 string `json:"sha256"`
}
ExtraFile describes a non-weights file included in an upload (README, config.json, samples).
type File ¶
type File struct {
Name string `json:"name"`
Type string `json:"type"`
Size int64 `json:"size"`
SHA256 string `json:"sha256"`
}
File is an entry within a version.
type FinalizeBody ¶
type FinalizeBody struct {
UploadID string `json:"upload_id"`
SHA256 string `json:"sha256"`
Parts []PartETag `json:"parts"`
}
FinalizeBody commits the version after upload.
type FinalizeResp ¶
type FinalizeResp struct {
Version string `json:"version"`
}
FinalizeResp returns the assigned version tag.
type InitiateBody ¶
type InitiateBody struct {
SHA256 string `json:"sha256"`
Size int64 `json:"size"`
Filename string `json:"filename"`
ExplicitVersion *string `json:"explicit_version"`
ExtraFiles []ExtraFile `json:"extra_files"`
}
InitiateBody requests presigned upload targets.
type InitiateResp ¶
type InitiateResp struct {
UploadID string `json:"upload_id"`
Uploads []UploadTarget `json:"uploads"`
DuplicateOf *string `json:"duplicate_of"`
}
InitiateResp is the presigned-upload plan.
type ListReposParams ¶
type ListReposParams struct {
Owner string
Visibility string
Starred bool
Sort string
Limit int
Page int
}
ListReposParams filters the list endpoint.
type LoopbackServer ¶
type LoopbackServer struct {
// contains filtered or unexported fields
}
LoopbackServer captures the browser redirect on a random localhost port.
func StartLoopback ¶
func StartLoopback() (*LoopbackServer, error)
StartLoopback binds 127.0.0.1:0 and serves /callback.
func (*LoopbackServer) CallbackURL ¶
func (s *LoopbackServer) CallbackURL() string
CallbackURL is the redirect target the web flow must call.
func (*LoopbackServer) Shutdown ¶
func (s *LoopbackServer) Shutdown()
Shutdown stops the loopback server.
type Me ¶
type Me struct {
Handle string `json:"handle"`
Plan string `json:"plan"`
StorageUsed int64 `json:"storage_used"`
StorageQuota int64 `json:"storage_quota"`
}
Me is the authenticated identity + storage usage.
type Part ¶
type Part struct {
PartNumber int `json:"part_number"`
URL string `json:"url"`
Size int64 `json:"size"`
}
Part is one presigned part of a multipart upload.
type Repo ¶
type Repo struct {
Owner string `json:"owner"`
Name string `json:"name"`
Description string `json:"description"`
Visibility string `json:"visibility"`
BaseModel string `json:"base_model"`
Format string `json:"format"`
License string `json:"license"`
TriggerWords []string `json:"trigger_words"`
NetworkRank int `json:"network_rank"`
NetworkDim int `json:"network_dim"`
RecommendedWeight float64 `json:"recommended_weight"`
Tags []string `json:"tags"`
Downloads int64 `json:"downloads"`
Stars int64 `json:"stars"`
LatestVersion string `json:"latest_version"`
Size int64 `json:"size"`
UpdatedAt string `json:"updated_at"`
Readme string `json:"readme,omitempty"`
}
Repo is repository metadata. `readme` is present on detail responses only.
type RepoList ¶
type RepoList struct {
Items []Repo `json:"items"`
Page int `json:"page"`
Total int `json:"total"`
}
RepoList is the standard paginated envelope.
type SearchParams ¶
type SearchParams struct {
Query string
Base []string
Format []string
Tag []string
Sort string
Limit int
Page int
}
SearchParams filters the search endpoint. base/format/tag are repeatable.
type UploadTarget ¶
type UploadTarget struct {
Name string `json:"name"`
Method string `json:"method"`
URL string `json:"url"`
Headers map[string]string `json:"headers"`
Parts []Part `json:"parts"` // multipart (large files)
CompleteURL string `json:"complete_url"` // multipart completion
}
UploadTarget is a presigned destination for a single file.