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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
ServerVersion fetches the server version (GET /server/version, getServerVersion).