Documentation
¶
Overview ¶
Package cliclient provides a lightweight HTTP client for the Nebi API.
Index ¶
- func IsForbidden(err error) bool
- func IsNotFound(err error) bool
- func IsOIDCRedirect(err error) bool
- func IsUnauthorized(err error) bool
- type APIError
- type AuditLog
- type Client
- func (c *Client) CreateRegistry(ctx context.Context, req CreateRegistryRequest) (*Registry, error)
- func (c *Client) CreateWorkspace(ctx context.Context, req CreateWorkspaceRequest) (*Workspace, error)
- func (c *Client) Delete(ctx context.Context, path string) (*http.Response, error)
- func (c *Client) DeleteRegistry(ctx context.Context, id string) error
- func (c *Client) DeleteWorkspace(ctx context.Context, id string) error
- func (c *Client) ExchangeDeviceToken(ctx context.Context, idToken string) (*DeviceTokenResponse, error)
- func (c *Client) Get(ctx context.Context, path string, result interface{}) (*http.Response, error)
- func (c *Client) GetCurrentUser(ctx context.Context) (*User, error)
- func (c *Client) GetDashboardStats(ctx context.Context) (*DashboardStats, error)
- func (c *Client) GetDeviceConfig(ctx context.Context) (*DeviceConfigResponse, error)
- func (c *Client) GetPublishDefaults(ctx context.Context, wsID string) (*PublishDefaults, error)
- func (c *Client) GetServerVersion(ctx context.Context) (*ServerVersion, error)
- func (c *Client) GetText(ctx context.Context, path string) (string, *http.Response, error)
- func (c *Client) GetVersionPixiLock(ctx context.Context, wsID string, version int32) (string, error)
- func (c *Client) GetVersionPixiToml(ctx context.Context, wsID string, version int32) (string, error)
- func (c *Client) GetWorkspace(ctx context.Context, id string) (*Workspace, error)
- func (c *Client) GetWorkspacePackages(ctx context.Context, wsID string) ([]Package, error)
- func (c *Client) GetWorkspacePublications(ctx context.Context, wsID string) ([]Publication, error)
- func (c *Client) GetWorkspaceTags(ctx context.Context, wsID string) ([]WorkspaceTag, error)
- func (c *Client) GetWorkspaceVersions(ctx context.Context, wsID string) ([]WorkspaceVersion, error)
- func (c *Client) ListAuditLogs(ctx context.Context, userID, action string) ([]AuditLog, error)
- func (c *Client) ListJobs(ctx context.Context) ([]Job, error)
- func (c *Client) ListRegistries(ctx context.Context) ([]Registry, error)
- func (c *Client) ListRegistriesAdmin(ctx context.Context) ([]Registry, error)
- func (c *Client) ListRegistriesPublic(ctx context.Context) ([]Registry, error)
- func (c *Client) ListUsers(ctx context.Context) ([]User, error)
- func (c *Client) ListWorkspaces(ctx context.Context) ([]Workspace, error)
- func (c *Client) Login(ctx context.Context, username, password string) (*LoginResponse, error)
- func (c *Client) PollDeviceCode(ctx context.Context, code string) (*DevicePollResponse, error)
- func (c *Client) Post(ctx context.Context, path string, body, result interface{}) (*http.Response, error)
- func (c *Client) PublishWorkspace(ctx context.Context, wsID string, req PublishRequest) (*PublishResponse, error)
- func (c *Client) PushVersion(ctx context.Context, wsID string, req PushRequest) (*PushResponse, error)
- func (c *Client) Put(ctx context.Context, path string, body, result interface{}) (*http.Response, error)
- func (c *Client) RequestDeviceCode(ctx context.Context) (*DeviceCodeResponse, error)
- func (c *Client) UpdateRegistry(ctx context.Context, id string, req UpdateRegistryRequest) (*Registry, error)
- type CreateRegistryRequest
- type CreateWorkspaceRequest
- type DashboardStats
- type DeviceCodeResponse
- type DeviceConfigResponse
- type DevicePollResponse
- type DeviceTokenResponse
- type Job
- type LoginRequest
- type LoginResponse
- type Package
- type Publication
- type PublishDefaults
- type PublishRequest
- type PublishResponse
- type PushRequest
- type PushResponse
- type Registry
- type ServerVersion
- type UpdateRegistryRequest
- type User
- type Workspace
- type WorkspaceTag
- type WorkspaceVersion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsForbidden ¶
IsForbidden returns true if the error is a 403 Forbidden error.
func IsNotFound ¶
IsNotFound returns true if the error is a 404 Not Found error.
func IsOIDCRedirect ¶
IsOIDCRedirect returns true if the error indicates the server is behind an OIDC proxy that redirected to a login page instead of returning JSON. This typically manifests as a JSON decode error when the response body starts with '<' (HTML) instead of '{' (JSON).
func IsUnauthorized ¶
IsUnauthorized returns true if the error is a 401 Unauthorized error.
Types ¶
type AuditLog ¶
type AuditLog struct {
ID int `json:"id"`
UserID string `json:"user_id"`
Action string `json:"action"`
Resource string `json:"resource"`
ResourceID string `json:"resource_id,omitempty"`
DetailsJSON interface{} `json:"details_json,omitempty"`
Timestamp string `json:"timestamp"`
User *User `json:"user,omitempty"`
}
AuditLog represents an audit log entry.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a lightweight HTTP client for the Nebi API.
func NewWithoutAuth ¶
NewWithoutAuth creates a new API client without authentication (for login).
func (*Client) CreateRegistry ¶
CreateRegistry creates a new registry.
func (*Client) CreateWorkspace ¶
func (c *Client) CreateWorkspace(ctx context.Context, req CreateWorkspaceRequest) (*Workspace, error)
CreateWorkspace creates a new workspace.
func (*Client) DeleteRegistry ¶
DeleteRegistry deletes a registry by ID.
func (*Client) DeleteWorkspace ¶
DeleteWorkspace deletes a workspace by ID.
func (*Client) ExchangeDeviceToken ¶ added in v0.10.1
func (c *Client) ExchangeDeviceToken(ctx context.Context, idToken string) (*DeviceTokenResponse, error)
ExchangeDeviceToken exchanges a Keycloak ID token for a Nebi JWT.
func (*Client) GetCurrentUser ¶
GetCurrentUser calls GET /auth/me to get the authenticated user.
func (*Client) GetDashboardStats ¶
func (c *Client) GetDashboardStats(ctx context.Context) (*DashboardStats, error)
GetDashboardStats returns admin dashboard statistics (admin only).
func (*Client) GetDeviceConfig ¶ added in v0.10.1
func (c *Client) GetDeviceConfig(ctx context.Context) (*DeviceConfigResponse, error)
GetDeviceConfig fetches the OIDC device flow configuration from the server.
func (*Client) GetPublishDefaults ¶
GetPublishDefaults returns suggested defaults for publishing a workspace.
func (*Client) GetServerVersion ¶
func (c *Client) GetServerVersion(ctx context.Context) (*ServerVersion, error)
GetServerVersion calls GET /version (public, no auth required).
func (*Client) GetVersionPixiLock ¶
func (c *Client) GetVersionPixiLock(ctx context.Context, wsID string, version int32) (string, error)
GetVersionPixiLock returns the pixi.lock for a specific version.
func (*Client) GetVersionPixiToml ¶
func (c *Client) GetVersionPixiToml(ctx context.Context, wsID string, version int32) (string, error)
GetVersionPixiToml returns the pixi.toml for a specific version.
func (*Client) GetWorkspace ¶
GetWorkspace returns a workspace by ID.
func (*Client) GetWorkspacePackages ¶
GetWorkspacePackages returns packages for a workspace.
func (*Client) GetWorkspacePublications ¶
GetWorkspacePublications returns publications for a workspace.
func (*Client) GetWorkspaceTags ¶
GetWorkspaceTags returns server-side tags for a workspace.
func (*Client) GetWorkspaceVersions ¶
GetWorkspaceVersions returns versions for a workspace.
func (*Client) ListAuditLogs ¶
ListAuditLogs returns audit logs with optional filters (admin only).
func (*Client) ListRegistries ¶
ListRegistries returns all registries (tries admin endpoint first, then public).
func (*Client) ListRegistriesAdmin ¶
ListRegistriesAdmin returns all registries (admin endpoint only).
func (*Client) ListRegistriesPublic ¶
ListRegistriesPublic returns all registries (public endpoint only).
func (*Client) ListWorkspaces ¶
ListWorkspaces returns all workspaces.
func (*Client) PollDeviceCode ¶
PollDeviceCode checks whether the device code has been completed.
func (*Client) Post ¶
func (c *Client) Post(ctx context.Context, path string, body, result interface{}) (*http.Response, error)
Post performs a POST request.
func (*Client) PublishWorkspace ¶
func (c *Client) PublishWorkspace(ctx context.Context, wsID string, req PublishRequest) (*PublishResponse, error)
PublishWorkspace publishes a workspace to a registry.
func (*Client) PushVersion ¶
func (c *Client) PushVersion(ctx context.Context, wsID string, req PushRequest) (*PushResponse, error)
PushVersion pushes a new version to the server with a tag.
func (*Client) Put ¶
func (c *Client) Put(ctx context.Context, path string, body, result interface{}) (*http.Response, error)
Put performs a PUT request.
func (*Client) RequestDeviceCode ¶
func (c *Client) RequestDeviceCode(ctx context.Context) (*DeviceCodeResponse, error)
RequestDeviceCode requests a new device code for browser-based CLI login.
func (*Client) UpdateRegistry ¶
func (c *Client) UpdateRegistry(ctx context.Context, id string, req UpdateRegistryRequest) (*Registry, error)
UpdateRegistry updates a registry.
type CreateRegistryRequest ¶
type CreateRegistryRequest struct {
Name string `json:"name"`
URL string `json:"url"`
Username *string `json:"username,omitempty"`
Password *string `json:"password,omitempty"`
IsDefault *bool `json:"is_default,omitempty"`
Namespace *string `json:"namespace,omitempty"`
}
CreateRegistryRequest represents a request to create a registry.
type CreateWorkspaceRequest ¶
type CreateWorkspaceRequest struct {
Name string `json:"name"`
PackageManager *string `json:"package_manager,omitempty"`
PixiToml *string `json:"pixi_toml,omitempty"`
}
CreateWorkspaceRequest represents a request to create a workspace.
type DashboardStats ¶
type DashboardStats struct {
TotalDiskUsageBytes int64 `json:"total_disk_usage_bytes"`
TotalDiskUsageFormatted string `json:"total_disk_usage_formatted"`
}
DashboardStats represents admin dashboard statistics.
type DeviceCodeResponse ¶
DeviceCodeResponse is the response from POST /auth/cli-login/code.
type DeviceConfigResponse ¶ added in v0.10.1
type DeviceConfigResponse struct {
Enabled bool `json:"enabled"`
IssuerURL string `json:"issuer_url,omitempty"`
ClientID string `json:"client_id,omitempty"`
}
DeviceConfigResponse is the response from GET /auth/device-config.
type DevicePollResponse ¶
type DevicePollResponse struct {
Status string `json:"status"`
Token string `json:"token,omitempty"`
Username string `json:"username,omitempty"`
}
DevicePollResponse is the response from GET /auth/cli-login/poll.
type DeviceTokenResponse ¶ added in v0.10.1
DeviceTokenResponse is the response from POST /auth/device-token.
type Job ¶
type Job struct {
ID string `json:"id"`
WorkspaceID string `json:"workspace_id"`
Type string `json:"type"`
Status string `json:"status"`
Logs string `json:"logs,omitempty"`
Error string `json:"error,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
CreatedAt string `json:"created_at"`
StartedAt *string `json:"started_at,omitempty"`
CompletedAt *string `json:"completed_at,omitempty"`
}
Job represents a background job on the server.
type LoginRequest ¶
LoginRequest represents a login request.
type LoginResponse ¶
LoginResponse represents a login response.
type Package ¶
type Package struct {
ID string `json:"id"`
Name string `json:"name"`
Version string `json:"version,omitempty"`
Channel string `json:"channel,omitempty"`
Source string `json:"source,omitempty"`
WsID string `json:"workspace_id"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
Package represents a package in a workspace.
type Publication ¶
type Publication struct {
ID string `json:"id"`
WsID string `json:"workspace_id"`
VersionNumber int `json:"version_number"`
RegistryID string `json:"registry_id"`
RegistryName string `json:"registry_name"`
Repository string `json:"repository"`
Tag string `json:"tag"`
Digest string `json:"digest"`
PublishedAt string `json:"published_at"`
}
Publication represents a published version of a workspace.
type PublishDefaults ¶
type PublishDefaults struct {
RegistryID string `json:"registry_id"`
RegistryName string `json:"registry_name"`
Namespace string `json:"namespace"`
Repository string `json:"repository"`
Tag string `json:"tag"`
}
PublishDefaults represents suggested defaults for publishing a workspace.
type PublishRequest ¶
type PublishRequest struct {
RegistryID string `json:"registry_id"`
Repository string `json:"repository"`
Tag string `json:"tag"`
}
PublishRequest represents a request to publish a workspace.
type PublishResponse ¶
type PublishResponse struct {
Digest string `json:"digest"`
Repository string `json:"repository"`
Tag string `json:"tag"`
}
PublishResponse represents the response from publishing a workspace.
type PushRequest ¶
type PushRequest struct {
Tag string `json:"tag"`
PixiToml string `json:"pixi_toml"`
PixiLock string `json:"pixi_lock,omitempty"`
Force bool `json:"force,omitempty"`
}
PushRequest represents a request to push a version to the server.
type PushResponse ¶
type PushResponse struct {
VersionNumber int `json:"version_number"`
Tags []string `json:"tags"`
ContentHash string `json:"content_hash"`
Deduplicated bool `json:"deduplicated"`
Tag string `json:"tag"`
}
PushResponse represents the response from pushing a version.
type Registry ¶
type Registry struct {
ID string `json:"id"`
Name string `json:"name"`
URL string `json:"url"`
Username string `json:"username,omitempty"`
IsDefault bool `json:"is_default"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
Registry represents an OCI registry.
type ServerVersion ¶
type ServerVersion struct {
Version string `json:"version"`
Commit string `json:"commit"`
GoVersion string `json:"go_version"`
OS string `json:"os"`
Arch string `json:"arch"`
Mode string `json:"mode"`
Features map[string]bool `json:"features"`
}
ServerVersion represents the response from GET /version.
type UpdateRegistryRequest ¶
type UpdateRegistryRequest struct {
Name *string `json:"name,omitempty"`
URL *string `json:"url,omitempty"`
Username *string `json:"username,omitempty"`
Password *string `json:"password,omitempty"`
IsDefault *bool `json:"is_default,omitempty"`
Namespace *string `json:"namespace,omitempty"`
}
UpdateRegistryRequest represents a request to update a registry.
type User ¶
type User struct {
ID string `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
IsAdmin bool `json:"is_admin"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
User represents a user.
type Workspace ¶
type Workspace struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
PackageManager string `json:"package_manager"`
SizeBytes int64 `json:"size_bytes"`
Owner *User `json:"owner,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Workspace represents a workspace.