client

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package client wraps the generated Immich API client with authentication and base-URL handling. All API access goes through this package; application code must not construct immichapi clients directly.

Index

Constants

View Source
const (
	MinServerMajor = 3
	MinServerMinor = 2
	MinServerPatch = 0
)

MinServerVersion is the oldest Immich server this CLI supports (3.2.0: cursor search pagination, workflow logs). Compared numerically against GET /server/version; the prerelease number is ignored.

Variables

This section is empty.

Functions

func Check

func Check(resp Response, want int) error

Check returns a descriptive error when resp does not have the wanted HTTP status. Use it right after every *WithResponse call:

resp, err := c.API.GetMyUserWithResponse(ctx)
if err != nil { ... }
if err := client.Check(resp, http.StatusOK); err != nil { return err }

func FormatServerVersion

func FormatServerVersion(v immichapi.ServerVersionResponseDto) string

FormatServerVersion renders a version DTO as "3.2.0" (with "-rc.N" suffix when the server reports a prerelease number).

func MinServerVersionString

func MinServerVersionString() string

MinServerVersionString renders the minimum supported server version for user-facing messages (e.g. "3.2.0").

func ServerTooOld

func ServerTooOld(v immichapi.ServerVersionResponseDto) bool

ServerTooOld reports whether v is below the minimum supported server version (numeric major/minor/patch comparison; prerelease ignored). Pure so the version gate is directly unit-testable.

Types

type Client

type Client struct {
	// API exposes the generated typed operations (e.g. GetMyUserWithResponse).
	API *immichapi.ClientWithResponses
	// Server is the origin of the Immich instance (e.g. https://immich.example.com/).
	Server string
}

Client is a thin wrapper around the generated OpenAPI client. Future cross-cutting concerns (error mapping, pagination helpers, rate limiting) belong here.

func New

func New(cfg *config.Config) (*Client, error)

New builds an authenticated client from the config. The spec declares servers: [{"url": "/api"}], so the base URL is the server origin + /api.

func (*Client) CheckServerVersion

func (c *Client) CheckServerVersion(ctx context.Context) error

CheckServerVersion fetches the server version and returns a descriptive error when it is below the minimum supported version. Callers decide whether that error aborts (fail fast) or just warns; every CLI command warns via newClient so the requirement stays transparent.

func (*Client) PrintIdentity

func (c *Client) PrintIdentity(ctx context.Context)

PrintIdentity fetches the current user and prints the identity line (email + server URL + server version) to stderr so users always know which account and instance — and which minimum version applies — they are operating against. A version-fetch failure degrades to "unknown" rather than hiding the identity line.

func (*Client) ServerVersion

func (c *Client) ServerVersion(ctx context.Context) (immichapi.ServerVersionResponseDto, error)

ServerVersion fetches the server version (GET /server/version, getServerVersion).

type Response

type Response interface {
	StatusCode() int
	Status() string
	GetBody() []byte
}

Response is the subset of methods every generated *WithResponse type implements, allowing one status check to serve all operations.

Jump to

Keyboard shortcuts

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