client

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package client provides an HTTP client for the ToolHive Plugins API.

Index

Constants

This section is empty.

Variables

View Source
var ErrServerUnreachable = errors.New("could not reach ToolHive API server — is 'thv serve' running?")

ErrServerUnreachable is returned when the client cannot connect to the ToolHive API server. The most common cause is that "thv serve" is not running.

Functions

This section is empty.

Types

type Client

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

Client is an HTTP client for the ToolHive Plugins API.

func NewClient

func NewClient(baseURL string, opts ...Option) *Client

NewClient creates a new Plugins API client with the given base URL.

func NewDefaultClient

func NewDefaultClient(ctx context.Context, opts ...Option) *Client

NewDefaultClient creates a Plugins API client by trying, in order:

  1. The TOOLHIVE_API_URL environment variable (explicit override)
  2. The server discovery file (auto-detected running server)
  3. The default URL http://127.0.0.1:8080

The context is used for the server discovery health check; it is not stored.

func (*Client) Build

Build builds a plugin from a local directory into an OCI artifact.

func (*Client) DeleteBuild

func (c *Client) DeleteBuild(ctx context.Context, tag string) error

DeleteBuild removes a locally-built OCI plugin artifact from the local store.

func (*Client) GetContent

func (c *Client) GetContent(ctx context.Context, opts plugins.ContentOptions) (*plugins.PluginContent, error)

GetContent retrieves the plugin.json body and file listing from an OCI artifact without installing it.

func (*Client) Info

Info returns detailed information about a plugin.

func (*Client) Install

Install installs a plugin from a remote source.

func (*Client) List

List returns all installed plugins matching the given options.

func (*Client) ListBuilds

func (c *Client) ListBuilds(ctx context.Context) ([]plugins.LocalBuild, error)

ListBuilds returns all locally-built OCI plugin artifacts in the local store.

func (*Client) Push

func (c *Client) Push(ctx context.Context, opts plugins.PushOptions) error

Push pushes a built plugin artifact to a remote registry.

func (*Client) Uninstall

func (c *Client) Uninstall(ctx context.Context, opts plugins.UninstallOptions) error

Uninstall removes an installed plugin.

func (*Client) Validate

func (c *Client) Validate(ctx context.Context, path string) (*plugins.ValidationResult, error)

Validate checks whether a plugin definition is valid.

type Option

type Option func(*Client)

Option configures a Client.

func WithHTTPClient

func WithHTTPClient(hc *http.Client) Option

WithHTTPClient replaces the underlying *http.Client entirely. This overrides any previously applied options such as WithTimeout.

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout sets the HTTP client timeout.

Jump to

Keyboard shortcuts

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