client

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: GPL-3.0 Imports: 19 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 is a thin wrapper over the Hamravesh Darkube REST API.

Authentication is a two-part scheme discovered against the live API:

Authorization: Api-key <account-token>
X-Organization: <tenant-slug>

The account token identifies the user; X-Organization scopes every request to one tenant (organization). Requests without a valid X-Organization are rejected with 403 permission_denied even though the token itself is valid.

Index

Constants

View Source
const (
	BuildInitiated = "initiated"
	BuildRunning   = "running"
	BuildSucceeded = "succeeded"
	BuildFailed    = "failed"
	BuildCanceled  = "canceled"
)

Build statuses, as the console's build tab names them.

View Source
const (
	// CodeSameHelmReleaseName means the name is taken by a Helm release in the
	// target namespace. Deleting an app drops its record immediately but can
	// leave the release behind, so this also fires for names with no app.
	CodeSameHelmReleaseName = "SameHelmReleaseNameExists"
	// CodeTerminatingApp means an app of this name is still being deleted.
	CodeTerminatingApp = "TerminatingAppException"
	// CodeDuplicateReleaseAndNamespace means a live app of this name already
	// exists in the namespace. The API distinguishes this from
	// CodeSameHelmReleaseName, which is the orphaned-release case.
	CodeDuplicateReleaseAndNamespace = "DuplicateReleaseAndNamespaceException"
	// CodeGithubAuth and CodeGitlabAuth mean the git provider has not been
	// connected to this Hamravesh account, so Darkube cannot read the repository
	// it is being asked to build. Creating a git-backed app has an account-level
	// prerequisite that creating an image-backed one does not.
	CodeGithubAuth = "GithubAuthException"
	CodeGitlabAuth = "GitlabAuthException"
)

API error codes worth handling by name. The `detail` that accompanies them is Persian prose, so matching the code is both more robust and more readable.

View Source
const (
	CreationMethodDockerImage = "docker_image"
	CreationMethodGitRepoURL  = "git_repo_url"

	ProviderGithub = "Github"
	ProviderGitlab = "Gitlab"

	BuilderDockerfile      = "dockerfile"
	BuilderHerokuBuildpack = "heroku_buildpacks"

	BuildMethodGitlabCI = "gitlabci"
	BuildMethodWebhook  = "webhook"
)

Valid values for the enumerated build fields, as advertised by OPTIONS on /api/v1/darkube/apps/ (confirmed 2026-08-28).

View Source
const (
	InsightCPU            = "cpu_usage"       // cores
	InsightCPUThrottling  = "cpu_throttling"  // fraction of periods throttled, 0-1
	InsightRAM            = "ram_usage"       // bytes
	InsightDisk           = "disk_usage"      // bytes
	InsightNetworkReceive = "network_receive" // bytes per second
	InsightNetworkSend    = "network_send"    // bytes per second

	// AllPods scopes an insight to every pod of the app, one series each.
	AllPods = "*"
)

Insight types the console charts, with the units the console converts from.

View Source
const (
	PermView   = "view"
	PermChange = "change"
	PermDelete = "delete"
)

App permissions, as the console names them.

View Source
const (
	GCDestinationRegistry  = "registry"
	GCDestinationImageRepo = "image_repo"
	GCKeepCount            = "count"
	GCKeepDuration         = "duration"
)

GC strategy destinations and keep types, as the console sends them.

View Source
const (
	StorageRead  = "Read"
	StorageWrite = "Write"
	StorageList  = "List"
)

Storage key actions, as the API spells them.

View Source
const (
	TicketStatusAll    = "All"
	TicketStatusOpen   = "Open"
	TicketStatusClosed = "Closed"
)

Ticket status filter values, exactly as the list route's enum spells them. Note the ticket's own status reads "Close", not "Closed".

View Source
const DefaultBaseURL = "https://api.hamravesh.com"

DefaultBaseURL is the public Hamravesh API host.

View Source
const (

	// DefaultRegistryName is the registry the console's page opens on.
	DefaultRegistryName = "hamdocker"
)

The container registry: the tenant's space on registry.hamdocker.ir, where a git-backed app's builds are pushed. The routes come from the console's container-registry page (console-remote, 2026-09-30). Every registry action hangs off the registry's id, and a repository is named in the body rather than the path, because repository names contain slashes.

View Source
const KubeconfigAccessToken = "token"

KubeconfigAccessToken is the access_type the console's "Download KubeConfig" asks for: a kubeconfig carrying a bearer token for the cluster's admin.

View Source
const StaffEmailDomain = "@hamravesh.com"

StaffEmailDomain is how the console tells a support engineer's comment from a customer's: nothing in the comment says so, only the author's address.

Variables

View Source
var (
	ErrAppNotFound  = errors.New("no app named or with that id")
	ErrAppAmbiguous = errors.New("app name is ambiguous")
)

Sentinel errors returned by ResolveApp, comparable with errors.Is.

View Source
var (
	// ErrOTPRequired means the platform refused a write for want of a valid
	// two-factor code.
	ErrOTPRequired = errors.New("this change needs a valid two-factor (TOTP) code")
	// ErrBucketNameTaken means another bucket, in any tenant, has the name.
	ErrBucketNameTaken = errors.New("bucket name is already taken")
	// ErrNoStorageKeySecret means a key was made but its secret did not come back.
	ErrNoStorageKeySecret = fmt.Errorf("%w: secret_key", ErrMissingField)
)
View Source
var (
	ErrNoTicketID     = errors.New("support platform accepted the ticket but returned no id")
	ErrNoAttachmentID = errors.New("support platform accepted the upload but returned no attachment id")
)

Errors for answers the support platform accepted without the id they owe.

View Source
var AllPermissions = []string{PermView, PermChange, PermDelete}

AllPermissions is every permission an app grants, in display order.

View Source
var ErrInvalidJSON = errors.New("request body is not valid JSON")

ErrInvalidJSON reports a raw request body that is not JSON.

View Source
var ErrMissingField = errors.New("response is missing a field")

ErrMissingField means the API answered without a field it owes.

View Source
var ErrNoAPIKeyValue = fmt.Errorf("%w: value", ErrMissingField)

ErrNoAPIKeyValue means the platform created a key but did not return it.

View Source
var ErrNoOrganizationID = errors.New("could not determine the numeric organization id")

ErrNoOrganizationID is returned when the numeric org id can't be derived.

View Source
var ErrNoSuchCluster = errors.New("no such cluster")

ErrNoSuchCluster is returned when a cluster reference matches nothing the tenant can see.

View Source
var ErrNoSuchEnv = errors.New("no such environment variable")

ErrNoSuchEnv is returned when removing an environment variable that is absent.

View Source
var ErrNoSuchHost = errors.New("no such domain")

ErrNoSuchHost is returned when removing a domain the app does not serve.

View Source
var ErrNoSuchOrganization = errors.New("the account is not a member of that organization")

ErrNoSuchOrganization means the account does not belong to the organization.

View Source
var ErrWriteRedirected = errors.New("the API redirected a write request")

ErrWriteRedirected means the server answered a write with a redirect.

Functions

func ErrorCode added in v0.2.0

func ErrorCode(err error) string

ErrorCode returns the API error code carried by err, or "" if err is not an *APIError.

func ExternalHosts added in v0.4.0

func ExternalHosts(app map[string]any) []string

ExternalHosts reads the domains routed to an app. This is where custom domains actually live; custom_domain_address is a separate, usually empty field and is not the ingress host list.

func IsNotFound added in v0.5.0

func IsNotFound(err error) bool

IsNotFound reports whether err is an API 404. This is the distinction `wait --for deleted` turns on: "the app is gone" versus "the request failed".

func IsTransient added in v0.5.0

func IsTransient(err error) bool

IsTransient reports whether err is worth retrying: a transport failure, or a 5xx from the API. Polling loops use it so that a flaky minute — which this API does produce — does not abort a wait that would otherwise have succeeded.

A cancellation is not transient: the caller asked to stop, and retrying would ignore that. A deadline still counts, because a single request timing out is exactly the flakiness this exists for and looks the same as an expired caller context; a polling loop must check its own ctx, which they all do.

func NormalizeForPut added in v0.7.0

func NormalizeForPut(app map[string]any)

NormalizeForPut is normalizeForPut for callers comparing a fresh read with an object they wrote: the read nests relations the write sent as bare ids.

func ResolveCluster added in v0.7.0

func ResolveCluster(ref string, known []Namespace) (int, error)

ResolveCluster turns a cluster reference — a numeric id, or a name such as "hamravesh-c11" — into a cluster id, using the clusters the tenant's existing namespaces already sit on.

A name is worth supporting because the id is not shown anywhere a person normally looks: `get namespaces` prints the cluster's name, so asking for the id means going and finding it in JSON.

func SecretEnvNames added in v0.4.0

func SecretEnvNames(app map[string]any) []string

SecretEnvNames reads the names of an app's secret environment variables.

Only names are ever available: the API stores the values in a vault and returns them empty on every read, so there is nothing to unmask.

func SetEnvVars added in v0.4.0

func SetEnvVars(app map[string]any, envs []EnvVar)

SetEnvVars replaces an app's plain environment variables.

func SetExternalHosts added in v0.4.0

func SetExternalHosts(app map[string]any, hosts []string)

SetExternalHosts replaces the domains routed to an app.

Types

type APIError

type APIError struct {
	StatusCode int    `json:"-"`
	Detail     string `json:"detail"`
	Code       string `json:"code"`
}

APIError is a structured error returned by the API's DRF backend.

func (*APIError) Error

func (e *APIError) Error() string

type APIKeyInfo added in v0.10.0

type APIKeyInfo struct {
	ID             string `json:"id"              yaml:"id"`
	Name           string `json:"name"            yaml:"name"`
	CreationTime   string `json:"creation_time"   yaml:"creation_time"`
	ExpirationTime string `json:"expiration_time" yaml:"expiration_time"`
}

APIKeyInfo is an API key as listed; the key itself is never returned again.

type APIServerWhitelist added in v0.15.0

type APIServerWhitelist struct {
	SourceRanges []string `json:"source_ranges" yaml:"sourceRanges"`
	SyncedAt     string   `json:"synced_at"     yaml:"syncedAt"`
}

APIServerWhitelist is the set of source ranges allowed to reach a cluster's API server. SyncedAt is when the platform last pushed it to the cluster.

type Alert added in v0.4.0

type Alert struct {
	ID               string `json:"id"`
	AlertName        string `json:"alertname"`
	Status           string `json:"status"`
	Severity         string `json:"severity"`
	Instance         string `json:"instance"`
	ServiceOwner     string `json:"service_owner"`
	Condition        string `json:"condition"`
	AlertDescription string `json:"alert_description"`
	DescriptionFA    string `json:"description_fa"`
	TimeWindow       string `json:"timewindow"`
	StartsAt         string `json:"starts_at"`
	EndsAt           string `json:"ends_at"`
	ActionLink       string `json:"action_link"`
	ForMe            bool   `json:"for_me"`
}

Alert is one monitoring alert raised against the tenant's resources.

func (Alert) IsFiring added in v0.4.0

func (a Alert) IsFiring() bool

IsFiring reports whether the alert is currently active rather than resolved.

type App

type App struct {
	ID                  string    `json:"id"`
	Name                string    `json:"name"`
	Namespace           Namespace `json:"namespace"`
	State               State     `json:"state"`
	Plan                *Plan     `json:"plan"`
	Replicas            int       `json:"replicas"`
	IsEnabled           bool      `json:"is_enabled"`
	IsDeployable        bool      `json:"is_deployable"`
	IsHPAEnabled        bool      `json:"is_hpa_enabled"`
	RAMLimit            string    `json:"ram_limit"`
	CPURequest          string    `json:"cpu_request"`
	CustomDomainAddress string    `json:"custom_domain_address"`
	EnableSSL           bool      `json:"enable_SSL"`
	ImageRepo           string    `json:"image_repo"`
	ImageTag            string    `json:"image_tag"`
	CreationTime        string    `json:"creation_time"`
	UpdatedAt           string    `json:"updated_at"`

	// CreationMethod is how the app came to exist, and it is the field that
	// separates a plain workload from a managed service. There is no separate
	// "managed services" API: a oneclick Redis, Postgres, Grafana or Prometheus is
	// an ordinary app in this same list, carrying creation_method "redisnew",
	// "postgresqlnew", "grafana", "prometheus" and so on. Without surfacing it
	// there is no way to tell the two apart, which is why `get apps -o wide`
	// prints it and `--type` filters on it.
	CreationMethod string `json:"creation_method"`
}

App is a Darkube application (maps to a Kubernetes workload).

Only the commonly used fields are typed; `darkubectl describe`/`-o json` read the raw object so no data is lost to this partial view.

func (App) Image added in v0.5.0

func (a App) Image() string

Image is the container image the app runs, as repo:tag. The v2 list route returns the whole object, so this costs no extra request — which is what makes "which build is each app on?" answerable for a whole namespace at once.

func (App) IsManagedService added in v0.5.0

func (a App) IsManagedService() bool

IsManagedService reports whether the app is a marketplace/oneclick service (Redis, Postgres, Grafana, …) rather than a workload someone built.

type AppPermission added in v0.10.0

type AppPermission struct {
	User        PermissionUser `json:"user"        yaml:"user"`
	Permissions []string       `json:"permissions" yaml:"permissions"`
	// contains filtered or unexported fields
}

AppPermission is one member's access to an app.

func (AppPermission) Has added in v0.10.0

func (p AppPermission) Has(perm string) bool

Has reports whether the member holds perm.

type Auth

type Auth string

Auth is an HTTP Authorization header value. The Darkube API accepts two schemes: an account Api-key, or a Console JWT (Bearer) obtained from login.

func APIKey

func APIKey(token string) Auth

APIKey builds Api-key–scheme authorization from an account token.

func BearerToken

func BearerToken(jwt string) Auth

BearerToken builds Bearer-scheme (JWT) authorization from a login access token.

type Bucket added in v0.12.0

type Bucket struct {
	ID         string `json:"id"          yaml:"id"`
	Name       string `json:"name"        yaml:"name"`
	Status     string `json:"status"      yaml:"status"`
	Size       string `json:"size"        yaml:"size"`
	IsPublic   bool   `json:"is_public"   yaml:"isPublic"`
	CreateTime string `json:"create_time" yaml:"createTime"`
}

Bucket is one bucket on a storage. Size is a string of bytes.

type Build added in v0.10.0

type Build struct {
	ID              BuildID `json:"id"                yaml:"id"`
	Status          string  `json:"status"            yaml:"status"`
	GitBranch       string  `json:"git_branch"        yaml:"git_branch"`
	ShortCommitHash string  `json:"short_commit_hash" yaml:"short_commit_hash"`
	CommitMessage   string  `json:"commit_message"    yaml:"commit_message"`
	CreationTime    string  `json:"creation_time"     yaml:"creation_time"`
	EndTime         string  `json:"end_time"          yaml:"end_time"`
	// Errors is the platform's explanation of a failed build. The console shows
	// it as prose above the log.
	Errors any `json:"errors,omitempty" yaml:"errors,omitempty"`
	// Log is the build output with ANSI colors, present on the detail route only.
	Log string `json:"log,omitempty" yaml:"log,omitempty"`
}

Build is one image build of a git-backed app.

func (Build) InProgress added in v0.10.0

func (b Build) InProgress() bool

InProgress reports whether the build has yet to finish.

type BuildID added in v0.10.0

type BuildID = FlexID

BuildID identifies a build.

type CICDScripts added in v0.10.0

type CICDScripts struct {
	Envs          map[string]string `json:"envs"           yaml:"envs"`
	GitLabCI      string            `json:"gitlabci"       yaml:"gitlabci"`
	GitHubActions string            `json:"github_actions" yaml:"github_actions"`
	Curl          string            `json:"curl"           yaml:"curl"`
}

CICDScripts is the pipeline configuration the console's CI/CD tab generates for an app, from GET stateless_apps/<uuid>/generate_cicd_scripts (no trailing slash; confirmed 2026-10-01). The GitLab and GitHub jobs build with darkube-cli and deploy with the app's trigger deploy token, which they read from the CI variables in Envs.

Envs and Curl carry secrets: the deploy token and, in DOCKER_AUTH_CONFIG, the tenant's registry credential.

type Certificate

type Certificate struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	CommonName string `json:"common_name"`
	State      string `json:"state"`
	Domain     string `json:"domain"`
}

Certificate is a TLS certificate entry. The certificates endpoint uses a different envelope than the paginated ones: {"data":{"items":[...]}}.

type Client

type Client struct {
	BaseURL string
	Org     string
	// contains filtered or unexported fields
}

Client talks to the Darkube API for a single tenant.

func New

func New(baseURL string, auth Auth, org string) *Client

New builds a Client. baseURL may be empty to use DefaultBaseURL, and auth may be empty for the routes that authenticate otherwise.

func (*Client) APIServerWhitelist added in v0.15.0

func (c *Client) APIServerWhitelist(ctx context.Context, cluster string) (*APIServerWhitelist, error)

APIServerWhitelist reads the source ranges allowed to reach a cluster's API.

func (*Client) Alerts added in v0.4.0

func (c *Client) Alerts(ctx context.Context) ([]Alert, error)

Alerts returns the tenant's monitoring alerts, both firing and resolved.

func (*Client) AppHistory added in v0.10.0

func (c *Client) AppHistory(ctx context.Context, id string, since, until time.Time) ([]HistoryEntry, error)

AppHistory returns the writes made to an app between since and until, newest first.

func (*Client) AppLogs added in v0.2.0

func (c *Client) AppLogs(ctx context.Context, appID string, opts LogOptions) ([]LogEntry, int, error)

AppLogs returns the tail of one container's log, oldest entry first.

The endpoint is index-based rather than time-based: from_index/to_index bound a window and reference_index anchors it. Reading the tail means asking for a window past the end and letting the server clamp, which is what the console does.

func (*Client) AppManifests added in v0.10.0

func (c *Client) AppManifests(ctx context.Context, appID string) (string, error)

AppManifests returns the Kubernetes objects the platform renders for an app: the Helm output of its chart, as multi-document YAML with "# Source:" comments, from GET apps/<uuid>/manifests/ (the console downloads it as a file). Confirmed 2026-10-01. The secrets template renders empty, so secret values are not in it.

func (*Client) AppPermissions added in v0.10.0

func (c *Client) AppPermissions(ctx context.Context, appID string) ([]AppPermission, error)

AppPermissions returns every organization member's access to an app.

func (*Client) AppSuggestions added in v0.10.0

func (c *Client) AppSuggestions(ctx context.Context, appID string) ([]Suggestion, error)

AppSuggestions computes and returns the platform's advice for an app. The route is a POST (GET answers 405) with an empty body, as the console calls it; it records the suggestions it returns. Confirmed 2026-10-01.

func (*Client) BuildLatestCommit added in v0.10.0

func (c *Client) BuildLatestCommit(ctx context.Context, appID string) error

BuildLatestCommit builds the head of the app's branch and deploys the result, the console's "build and deploy the last commit" button.

func (*Client) CICDScripts added in v0.10.0

func (c *Client) CICDScripts(ctx context.Context, appID string) (*CICDScripts, error)

CICDScripts returns the generated pipeline configuration for an app.

func (*Client) CertificateStatus added in v0.10.0

func (c *Client) CertificateStatus(ctx context.Context, appID string) (map[string]*time.Time, error)

CertificateStatus returns, per host of an app, when the platform-issued certificate expires. A nil time means the platform has issued none.

func (*Client) CheckDNS added in v0.10.0

func (c *Client) CheckDNS(ctx context.Context, hosts []string) (map[string]bool, error)

CheckDNS reports, per host, whether its DNS points at the platform.

func (*Client) Close

func (c *Client) Close() error

Close releases the underlying transport (resty v3 clients are closable).

func (*Client) CloseTicket added in v0.9.0

func (c *Client) CloseTicket(ctx context.Context, id string) error

CloseTicket closes a ticket.

func (*Client) ClusterNodes added in v0.15.0

func (c *Client) ClusterNodes(ctx context.Context, cluster string) ([]ClusterNode, error)

ClusterNodes lists a cluster's nodes, flattened out of their pools.

func (*Client) ClusterUpdateStatus added in v0.15.0

func (c *Client) ClusterUpdateStatus(ctx context.Context, cluster string) (*ClusterUpdateStatus, error)

ClusterUpdateStatus reports the cluster's version and whether it is the latest.

func (*Client) CreateAPIKey added in v0.10.0

func (c *Client) CreateAPIKey(ctx context.Context, name string) (string, error)

CreateAPIKey creates a key and returns its value, which cannot be read back later. The platform decides its expiry.

func (*Client) CreateApp

func (c *Client) CreateApp(ctx context.Context, in CreateAppInput) (map[string]any, error)

CreateApp creates a Docker-image app and returns the created object. The payload mirrors the console's confirmed POST /api/v1/darkube/apps/ request.

func (*Client) CreateBucket added in v0.14.0

func (c *Client) CreateBucket(ctx context.Context, storageID, name string) (string, error)

CreateBucket creates a private bucket on a storage and returns its id. The API takes an is_public field and ignores it, so a bucket is made public afterwards, with SetBucketPublic. Names are global to the storage service, not to the tenant; a taken one is ErrBucketNameTaken.

func (*Client) CreateGCStrategy added in v0.10.0

func (c *Client) CreateGCStrategy(ctx context.Context, body map[string]any) error

CreateGCStrategy adds a retention rule. body carries destination_type, registry or image_repo, keep_type and keep_count or keep_duration.

func (*Client) CreateNamespace added in v0.7.0

func (c *Client) CreateNamespace(ctx context.Context, name string, clusterID int) (Namespace, error)

CreateNamespace creates a project (namespace) in the current tenant.

This goes to the same v1 surface as ListNamespaces and carries the same requirement: it needs the user context a Console JWT provides, and an Api-key is rejected. That is why there is no way to do this with an account token, and why it belongs in the tool rather than in a shell one-liner — the credential stays here.

The organization goes in the body as well as the X-Organization header, matching CreateApp: the API takes it from the payload on create.

Note the cluster key is "cluster_id", not "cluster" -- a namespace reads back as a nested cluster object, so the obvious guess is wrong and the API answers `400 cluster_id: این مقدار لازم است` when it is.

func (*Client) CreateStorageKey added in v0.14.0

func (c *Client) CreateStorageKey(ctx context.Context, name string, actions, bucketIDs []string, otp string) (*StorageKeySecret, error)

CreateStorageKey creates an access key limited to actions on the given buckets, and returns it with its secret.

func (*Client) CreateTicket added in v0.9.0

func (c *Client) CreateTicket(ctx context.Context, t NewTicket) (string, error)

CreateTicket files a ticket and attaches any files to it, returning its id.

The console does this in two steps and so does this: the create body's own `attachments` is always sent empty, files are uploaded to a staging area first, and a separate attachment-comment then links them to the new ticket. A failure in that second step leaves a ticket without its files, which is reported as an error alongside the id.

func (*Client) DeleteAPIKey added in v0.10.0

func (c *Client) DeleteAPIKey(ctx context.Context, id string) error

DeleteAPIKey revokes a key.

func (*Client) DeleteApp

func (c *Client) DeleteApp(ctx context.Context, id string) error

DeleteApp deletes an app by UUID.

func (*Client) DeleteBucket added in v0.14.0

func (c *Client) DeleteBucket(ctx context.Context, id, otp string) error

DeleteBucket deletes a bucket and everything in it.

func (*Client) DeleteDigests added in v0.10.0

func (c *Client) DeleteDigests(ctx context.Context, registryID FlexID, repo string, digests []string) error

DeleteDigests deletes manifests, and so every tag pointing at them.

func (*Client) DeleteGCStrategy added in v0.10.0

func (c *Client) DeleteGCStrategy(ctx context.Context, id FlexID) error

DeleteGCStrategy removes a retention rule.

func (*Client) DeleteNamespace added in v0.7.0

func (c *Client) DeleteNamespace(ctx context.Context, id int) error

DeleteNamespace removes a namespace (project) by id.

Like create, this needs a Console JWT. The API does not check whether the namespace still holds apps, so the caller must -- deleting a populated one takes its workloads with it.

func (*Client) DeleteRepository added in v0.10.0

func (c *Client) DeleteRepository(ctx context.Context, registryID FlexID, repo string) error

DeleteRepository deletes an image repository with every tag in it.

func (*Client) DeleteStorageKey added in v0.14.0

func (c *Client) DeleteStorageKey(ctx context.Context, name, otp string) error

DeleteStorageKey revokes a key.

func (*Client) DeleteTags added in v0.10.0

func (c *Client) DeleteTags(ctx context.Context, registryID FlexID, repo, digest string, tags []string) error

DeleteTags removes tags from one manifest, leaving the manifest itself.

func (*Client) DeployToken added in v0.3.0

func (c *Client) DeployToken(ctx context.Context, id string) (string, error)

DeployToken returns an app's CI trigger deploy token.

This is the credential `darkube deploy --token` wants in a pipeline, paired with the app's own id as --app-id. The console shows it on the app's CI/CD page and it is stored nowhere in the cluster, so the API is the only way to wire up CI without the web UI.

It is deliberately not a field on App: `get apps -o json` would then print every app's deploy token, which is not what asking for a list of apps means.

func (*Client) DeployWithToken added in v0.10.0

func (c *Client) DeployWithToken(ctx context.Context, in DeployInput) error

DeployWithToken sets the app's image tag using only its deploy token. The client needs no credential for this, and normally has none.

func (*Client) DownloadTicketAttachment added in v0.9.0

func (c *Client) DownloadTicketAttachment(ctx context.Context, attachmentID string) (string, []byte, error)

DownloadTicketAttachment fetches an attachment by id, returning the filename the server suggests (empty if it names none) and the file's bytes.

func (*Client) EtcdBackups added in v0.15.0

func (c *Client) EtcdBackups(ctx context.Context, cluster string) ([]EtcdBackup, error)

EtcdBackups lists a cluster's etcd snapshots, newest first.

func (*Client) GetApp

func (c *Client) GetApp(ctx context.Context, id string) (map[string]any, error)

GetApp returns the full raw app object by UUID. The result is a generic map so every field is preserved for `describe` / `-o json|yaml`.

func (*Client) GetAppTyped

func (c *Client) GetAppTyped(ctx context.Context, id string) (*App, error)

GetAppTyped returns a single app decoded into the typed App struct.

func (*Client) GetBuild added in v0.10.0

func (c *Client) GetBuild(ctx context.Context, id BuildID) (*Build, error)

GetBuild returns one build with its log.

func (*Client) GetClusterRaw added in v0.15.0

func (c *Client) GetClusterRaw(ctx context.Context, name string) (map[string]any, error)

GetClusterRaw returns one cluster as the API sends it, every field included.

func (*Client) Insight added in v0.10.0

func (c *Client) Insight(ctx context.Context, q InsightQuery) ([]Series, error)

Insight runs one resource-usage query and returns a series per pod.

func (*Client) Invoices added in v0.10.0

func (c *Client) Invoices(ctx context.Context, limit int) ([]Invoice, error)

Invoices returns the most recent invoices, newest first, up to limit.

func (*Client) IsACLEnabled added in v0.10.0

func (c *Client) IsACLEnabled(ctx context.Context, org string) (bool, error)

IsACLEnabled reports whether per-app permissions are enforced in an organization, from the account profile.

func (*Client) Kubeconfig added in v0.15.0

func (c *Client) Kubeconfig(ctx context.Context, cluster string) ([]byte, error)

Kubeconfig downloads a cluster's admin kubeconfig. The body is YAML, and it is a credential: it carries a bearer token with cluster-admin rights.

func (*Client) ListAPIKeys added in v0.10.0

func (c *Client) ListAPIKeys(ctx context.Context) ([]APIKeyInfo, error)

ListAPIKeys returns the account's API keys.

func (*Client) ListApps

func (c *Client) ListApps(ctx context.Context) ([]App, error)

ListApps returns all apps in the current tenant, following pagination.

func (*Client) ListBuilds added in v0.10.0

func (c *Client) ListBuilds(ctx context.Context, appID string, limit int) ([]Build, error)

ListBuilds returns an app's most recent builds, newest first, up to limit.

func (*Client) ListCertificates

func (c *Client) ListCertificates(ctx context.Context) ([]Certificate, error)

ListCertificates returns TLS certificates for the current tenant.

func (*Client) ListClusters added in v0.15.0

func (c *Client) ListClusters(ctx context.Context) ([]KaaSCluster, error)

ListClusters returns the tenant's KaaS clusters.

func (*Client) ListDatabases added in v0.10.0

func (c *Client) ListDatabases(ctx context.Context) ([]Database, error)

ListDatabases returns the tenant's managed databases.

func (*Client) ListDigests added in v0.10.0

func (c *Client) ListDigests(ctx context.Context, registryID FlexID, repo string) ([]Digest, error)

ListDigests returns the manifests of one repository with their tags.

func (*Client) ListGCStrategies added in v0.10.0

func (c *Client) ListGCStrategies(ctx context.Context) ([]GCStrategy, error)

ListGCStrategies returns the tenant's registry retention rules.

func (*Client) ListNamespaces added in v0.2.0

func (c *Client) ListNamespaces(ctx context.Context) ([]Namespace, error)

ListNamespaces returns every namespace (project) in the current tenant, including ones that hold no apps yet. Requires a JWT.

func (*Client) ListPVCs added in v0.10.0

func (c *Client) ListPVCs(ctx context.Context, namespace string, clusterID int) ([]PVC, error)

ListPVCs returns the claims in one namespace.

func (*Client) ListPlans

func (c *Client) ListPlans(ctx context.Context) ([]Plan, error)

ListPlans returns all resource/pricing plans (paginated DRF envelope).

func (*Client) ListRegistries added in v0.10.0

func (c *Client) ListRegistries(ctx context.Context) ([]Registry, error)

ListRegistries returns the registries the tenant can use.

func (*Client) ListRepositories added in v0.10.0

func (c *Client) ListRepositories(ctx context.Context, registryID FlexID) ([]Repository, error)

ListRepositories returns every image repository in a registry.

func (*Client) ListServices added in v0.10.0

func (c *Client) ListServices(ctx context.Context) ([]Service, error)

ListServices returns the tenant's marketplace services.

func (*Client) Members added in v0.10.0

func (c *Client) Members(ctx context.Context, orgID int) ([]Member, error)

Members returns the members of the organization with the numeric id orgID.

func (*Client) Namespaces added in v0.2.0

func (c *Client) Namespaces(ctx context.Context) ([]Namespace, error)

Namespaces returns the tenant's namespaces, preferring the dedicated endpoint and falling back to deriving them from apps.

The distinction matters: the derived list can only contain namespaces that already hold at least one app, so a freshly created, still-empty project is invisible to it — which is exactly when you need to look one up in order to create the first app in it.

func (*Client) NamespacesFromApps

func (c *Client) NamespacesFromApps(ctx context.Context) ([]Namespace, error)

NamespacesFromApps derives the set of namespaces (projects) visible in the current tenant from the app list. This is the fallback for credentials that cannot reach the dedicated endpoint; it omits namespaces with no apps.

func (*Client) NodePools added in v0.15.0

func (c *Client) NodePools(ctx context.Context, cluster string) ([]NodePool, error)

NodePools lists a cluster's node pools.

func (*Client) Notifications added in v0.4.0

func (c *Client) Notifications(ctx context.Context, limit int) ([]Notification, error)

Notifications returns the most recent notifications, newest first, following pagination up to limit entries.

func (*Client) Organization added in v0.4.0

func (c *Client) Organization(ctx context.Context) (*Organization, error)

Organization returns the current tenant's entry from the user's profile, matching on the slug carried in the X-Organization header.

func (*Client) OrganizationID

func (c *Client) OrganizationID(ctx context.Context) (int, error)

OrganizationID returns the current tenant's numeric organization id, which the create payload requires.

The user profile is the authoritative source and, crucially, works for a tenant that holds no apps yet — the case the app-detail fallback below cannot serve, which used to make it impossible to create the *first* app in a new organization.

func (*Client) PrepareAppUpdate added in v0.5.0

func (c *Client) PrepareAppUpdate(
	ctx context.Context, id string, mutate func(app map[string]any) error,
) (map[string]any, map[string]any, error)

PrepareAppUpdate performs every step of UpdateApp except the write, returning the normalized object as it stands now and as it would be sent.

This is what makes a dry run possible, and it matters more here than it would on an API with a real partial update: every write is a full-object PUT rebuilt from a read, so a mistake in the mutate step can rewrite fields nobody meant to touch, and the request body alone does not show which of its seventy fields actually changed.

func (*Client) Profile added in v0.4.0

func (c *Client) Profile(ctx context.Context) (*Profile, error)

Profile returns the signed-in user and the tenants they belong to.

func (*Client) RateTicket added in v0.9.0

func (c *Client) RateTicket(ctx context.Context, id string, stars int, comment string) error

RateTicket rates the support on a ticket, 1 to 5 stars, with an optional comment.

func (*Client) Raw added in v0.8.0

func (c *Client) Raw(ctx context.Context, method, path string, query url.Values, body []byte) ([]byte, error)

Raw sends one request to an arbitrary API path with the client's auth and X-Organization, and returns the response body. A body, when given, must be JSON and is sent as-is.

This is the escape hatch for routes darkubectl does not model yet: the API is reverse-engineered, and the fastest way to learn a route is to call it.

func (*Client) RawWithHeaders added in v0.11.0

func (c *Client) RawWithHeaders(
	ctx context.Context, method, path string, query url.Values, body []byte, header http.Header,
) ([]byte, error)

RawWithHeaders is Raw with extra request headers. Some writes need one the client does not send by default: Hamravesh object storage, for instance, demands the account's TOTP code in `x-otp` before it creates a key or makes a bucket public, and answers 500 "2-fa verification error" without it.

func (*Client) RegistryPassword added in v0.10.0

func (c *Client) RegistryPassword(ctx context.Context, registryID FlexID) (string, error)

RegistryPassword reads a registry's password out of the vault.

func (*Client) RegistryStorageUsage added in v0.10.0

func (c *Client) RegistryStorageUsage(ctx context.Context, registryID FlexID) (int64, error)

RegistryStorageUsage returns how many bytes a registry holds.

func (*Client) ReplyToTicket added in v0.9.0

func (c *Client) ReplyToTicket(ctx context.Context, id, body string, files []TicketFile) error

ReplyToTicket adds a comment to a ticket, uploading any files to it first. Unlike create, a reply's files are uploaded against the ticket itself and then referenced by id in the comment.

func (*Client) ResolveApp

func (c *Client) ResolveApp(ctx context.Context, nameOrID string) (*App, error)

ResolveApp finds an app by UUID or by exact name within the current tenant. Names are not guaranteed unique across namespaces; an ambiguous name is an error.

func (*Client) RestartApp added in v0.7.0

func (c *Client) RestartApp(ctx context.Context, id string) error

RestartApp rolls an app's pods, the platform's equivalent of `kubectl rollout restart`.

POST /api/v1/darkube/apps/<id>/restart/ answers 200 with the bare string "ok" and the Deployment moves to a new ReplicaSet — confirmed 2026-09-27 on a throwaway app in the rahacloud org, whose pod went from one ReplicaSet hash to another within seconds. The body is ignored; OPTIONS on the route describes the whole app serializer, which is a DRF artefact rather than a sign that anything in it is read.

func (*Client) RetryBuild added in v0.10.0

func (c *Client) RetryBuild(ctx context.Context, id BuildID) (*Build, error)

RetryBuild rebuilds the commit of an earlier build and returns the new build. The route is a GET even though it starts a build; that is how the console calls it. The console reads the new build out of the answer; if the answer is not a build, the retry still happened and the returned build has no ID.

func (*Client) RotateKubeconfig added in v0.15.0

func (c *Client) RotateKubeconfig(ctx context.Context, cluster string) error

RotateKubeconfig issues a new kubeconfig for a cluster and invalidates the one every existing copy carries. Taken from the console source; it has not been called against the live API, so what it answers is not known.

func (*Client) RotateStorageKey added in v0.14.0

func (c *Client) RotateStorageKey(ctx context.Context, name, otp string) (*StorageKeySecret, error)

RotateStorageKey issues a new access and secret key under the same name and grants; the old pair stops working.

func (*Client) SecretEnvs added in v0.8.0

func (c *Client) SecretEnvs(ctx context.Context, id string) ([]EnvVar, error)

SecretEnvs reads an app's secret environment variables with their values.

func (*Client) SetAPIServerWhitelist added in v0.15.0

func (c *Client) SetAPIServerWhitelist(ctx context.Context, cluster string, ranges []string) (*APIServerWhitelist, error)

SetAPIServerWhitelist replaces the whole list. There is no add or remove route: whatever is not in ranges is dropped, so a caller changing one entry must send every other one back.

func (*Client) SetAppPermissions added in v0.10.0

func (c *Client) SetAppPermissions(ctx context.Context, appID string, rows []AppPermission) error

SetAppPermissions writes an app's access list. Every row is sent, those with no permissions included: an empty list is what revokes access.

func (*Client) SetBucketPublic added in v0.14.0

func (c *Client) SetBucketPublic(ctx context.Context, id string, public bool, otp string) error

SetBucketPublic makes a bucket readable by anyone, or private again.

func (*Client) StopBuild added in v0.10.0

func (c *Client) StopBuild(ctx context.Context, id BuildID) error

StopBuild cancels a running build.

func (*Client) Storages added in v0.12.0

func (c *Client) Storages(ctx context.Context) ([]Storage, error)

Storages returns the tenant's object storages with their buckets, keys and endpoints. Four reads, because each collection is a separate route that returns the whole storage list with only its own field populated.

func (*Client) Ticket added in v0.9.0

func (c *Client) Ticket(ctx context.Context, id string) (Ticket, error)

Ticket returns one ticket.

func (*Client) TicketCategories added in v0.9.0

func (c *Client) TicketCategories(ctx context.Context) ([]TicketCategory, error)

TicketCategories returns the request types a ticket can be filed under.

func (*Client) TicketComments added in v0.9.0

func (c *Client) TicketComments(ctx context.Context, id string) ([]TicketComment, error)

TicketComments returns a ticket's public thread, oldest first, starting with the description. The route answers with {total,start,limit,values} but ignores start and limit, so there is nothing to page through.

func (*Client) TicketPriorities added in v0.9.0

func (c *Client) TicketPriorities(ctx context.Context) ([]TicketPriority, error)

TicketPriorities returns the priorities a ticket can be filed with.

func (*Client) Tickets added in v0.9.0

func (c *Client) Tickets(ctx context.Context, status, requestType string, mine bool) (TicketList, error)

Tickets lists the tenant's tickets. status is one of the TicketStatus constants ("" means all), requestType a category key ("" means all), and mine limits the list to tickets this account reported rather than every ticket in the organization.

func (*Client) UpdateApp added in v0.4.0

func (c *Client) UpdateApp(ctx context.Context, id string, mutate func(app map[string]any) error) (map[string]any, error)

UpdateApp applies mutate to an app's current state and writes it back.

The API has no partial update, so this is a read-modify-write: the current object is fetched, normalized into the shape the write serializer accepts, handed to mutate, and PUT in full. Callers therefore change one field without having to reconstruct the other seventy.

func (*Client) UpdateGCStrategy added in v0.10.0

func (c *Client) UpdateGCStrategy(ctx context.Context, id FlexID, body map[string]any) error

UpdateGCStrategy changes a rule's keep_type, keep_count and keep_duration.

The trailing slash is required. The console omits it, and without it the server redirects and a PUT replayed as a GET changes nothing (2026-09-30).

func (*Client) UpdateSecretEnvs added in v0.8.0

func (c *Client) UpdateSecretEnvs(
	ctx context.Context, id string, mutate func(secrets []EnvVar) ([]EnvVar, error),
	also ...func(app map[string]any) error,
) ([]EnvVar, error)

UpdateSecretEnvs changes an app's secret environment variables.

The PUT replaces the whole list, and an entry sent without its value is not safe to rely on, so this reads every current value first, hands the complete list to mutate, and writes back the complete result. Plain fields go through the same read-modify-write as UpdateApp, so nothing else on the app changes.

Like every PUT, this rolls the app's pods; a Secret edit made this way is also what a later deploy re-renders, which is the point of doing it here rather than in the Kubernetes Secret.

also, when given, edits the rest of the app object in the same PUT; set env --from-plain uses it to drop the plain copies of the variables it moves, so the move is one write and one restart instead of two with a gap between them.

func (*Client) UpdateStorageKey added in v0.14.0

func (c *Client) UpdateStorageKey(ctx context.Context, name string, actions, bucketIDs []string, otp string) error

UpdateStorageKey sets a key's actions and buckets, which may only grow: the platform refuses a list that drops something the key already has. The pair itself does not change.

func (*Client) Wallets added in v0.10.0

func (c *Client) Wallets(ctx context.Context) ([]Wallet, error)

Wallets returns the organization's balances.

type Cluster

type Cluster struct {
	ID              int    `json:"id"`
	Name            string `json:"name"`
	LocationCountry string `json:"location_country"`
	IsOnPremise     bool   `json:"is_on_premise"`
}

Cluster is the physical cluster an app's namespace lives on.

type ClusterDatacenter added in v0.15.0

type ClusterDatacenter struct {
	Name     string `json:"name"     yaml:"name"`
	Zone     string `json:"zone"     yaml:"zone"`
	Location string `json:"location" yaml:"location"`
}

ClusterDatacenter is where a cluster runs.

type ClusterNode added in v0.15.0

type ClusterNode struct {
	Pool   string `json:"pool"   yaml:"pool"`
	Name   string `json:"name"   yaml:"name"`
	Status string `json:"status" yaml:"status"`
	IP     string `json:"ip"     yaml:"ip"`
	CPU    int    `json:"cpu"    yaml:"cpu"`
}

ClusterNode is one node, as the nodes route lists it under its pool.

type ClusterOrg added in v0.15.0

type ClusterOrg struct {
	ID   int    `json:"id"   yaml:"id"`
	Name string `json:"name" yaml:"name"`
}

ClusterOrg is the tenant that owns a cluster.

type ClusterUpdateStatus added in v0.15.0

type ClusterUpdateStatus struct {
	Cluster        string `json:"cluster"         yaml:"cluster"`
	CurrentVersion string `json:"current_version" yaml:"currentVersion"`
	IsLatest       bool   `json:"is_latest"       yaml:"isLatest"`
}

ClusterUpdateStatus says whether a newer Kubernetes version is offered.

type CreateAppInput

type CreateAppInput struct {
	Name           string
	NamespaceID    int
	OrganizationID int
	PlanID         string
	ImageRepo      string
	ImageTag       string
	Command        string
	Args           string
	Replicas       int

	SvcType    string
	Ports      map[string]Port
	Disk       *Disk
	Envs       []EnvVar
	SecretEnvs []EnvVar

	// Git, when non-nil, switches the app from pulling a prebuilt image to being
	// built by Darkube from a repository. ImageRepo/ImageTag are then chosen by
	// the platform (it pushes to registry.hamdocker.ir/<tenant>/<app>) and must
	// be left empty.
	Git *GitSource
}

CreateAppInput describes a Docker-image app to create. Names have already been resolved to ids by the caller.

Everything below Replicas is optional. It can also be changed afterwards through UpdateApp, which PUTs the whole object back — the API has no partial update, but it is not read-only either.

type Database added in v0.10.0

type Database struct {
	ID          string         `json:"id"           yaml:"id"`
	Name        string         `json:"name"         yaml:"name"`
	Engine      string         `json:"engine"       yaml:"engine"`
	Version     string         `json:"version"      yaml:"version"`
	Plan        string         `json:"plan"         yaml:"plan"`
	IsManaged   bool           `json:"is_managed"   yaml:"is_managed"`
	NamespaceID int            `json:"namespace_id" yaml:"namespace_id"`
	ClusterID   int            `json:"cluster_id"   yaml:"cluster_id"`
	NumNodes    int            `json:"num_node"     yaml:"num_node"`
	Status      DatabaseStatus `json:"status"       yaml:"status"`
	Nodes       []DatabaseNode `json:"nodes"        yaml:"nodes"`
}

Database is a managed database instance.

type DatabaseNode added in v0.10.0

type DatabaseNode struct {
	Name   string `json:"name"   yaml:"name"`
	Status string `json:"status" yaml:"status"`
	CPU    int    `json:"cpu"    yaml:"cpu"`
	RAM    int    `json:"ram"    yaml:"ram"`
	Disk   int    `json:"disk"   yaml:"disk"`
}

DatabaseNode is one member of a database cluster. CPU is in millicores, RAM in megabytes and Disk in gigabytes.

type DatabaseStatus added in v0.10.0

type DatabaseStatus struct {
	Role   string `json:"role"   yaml:"role"`
	Status string `json:"status" yaml:"status"`
	Detail string `json:"detail" yaml:"detail"`
}

DatabaseStatus is a database's health as the platform summarizes it.

type DeployInput added in v0.10.0

type DeployInput struct {
	AppID       string
	DeployToken string
	ImageTag    string
	// JobID is the CI job, which darkube-cli reports alongside; optional.
	JobID string
}

DeployInput is one token-authenticated deploy.

type Digest added in v0.10.0

type Digest struct {
	Digest     string   `json:"digest_sha"  yaml:"digest_sha"`
	Tags       []string `json:"tags"        yaml:"tags"`
	Size       int64    `json:"size"        yaml:"size"`
	LastPushed string   `json:"last_pushed" yaml:"last_pushed"`
}

Digest is one image manifest in a repository, with the tags pointing at it.

type Disk added in v0.2.0

type Disk struct {
	Partitions       []Partition `json:"partitions"                   yaml:"partitions"`
	SizeInGi         int         `json:"size_in_Gi"                   yaml:"sizeInGi"`
	StorageClassName string      `json:"storage_class_name,omitempty" yaml:"storageClassName"`
	SetFSGroup       bool        `json:"set_fsgroup"                  yaml:"setFsGroup"`
}

Disk is the app's persistent volume. SizeInGi of 0 means "no disk".

type EnvVar added in v0.2.0

type EnvVar struct {
	Name  string `json:"name"  yaml:"name"`
	Value string `json:"value" yaml:"value"`
}

EnvVar is one entry of envs or secret_envs. The API calls the key "name".

func EnvVars added in v0.4.0

func EnvVars(app map[string]any) []EnvVar

EnvVars reads an app's plain (non-secret) environment variables.

type EtcdBackup added in v0.15.0

type EtcdBackup struct {
	ID        int    `json:"id"         yaml:"id"`
	Date      string `json:"date"       yaml:"date"`
	Status    string `json:"status"     yaml:"status"`
	SizeBytes int64  `json:"size_bytes" yaml:"sizeBytes"`
	Size      string `json:"size"       yaml:"size"`
}

EtcdBackup is one scheduled etcd snapshot of a cluster.

type FlexID added in v0.10.0

type FlexID string

FlexID is an identifier whose JSON type the API does not pin down: the same id can arrive as a string on one route and a number on another, so it decodes from either.

func (*FlexID) UnmarshalJSON added in v0.10.0

func (f *FlexID) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts a JSON string or number.

type GCStrategy added in v0.10.0

type GCStrategy struct {
	ID              FlexID       `json:"id"               yaml:"id"`
	DestinationType string       `json:"destination_type" yaml:"destination_type"`
	Registry        *RegistryRef `json:"registry"         yaml:"registry"`
	ImageRepo       string       `json:"image_repo"       yaml:"image_repo"`
	KeepType        string       `json:"keep_type"        yaml:"keep_type"`
	KeepCount       *int         `json:"keep_count"       yaml:"keep_count"`
	// KeepDuration is a Django duration, "<days> 00:00:00".
	KeepDuration *string `json:"keep_duration" yaml:"keep_duration"`
}

GCStrategy is a registry retention rule: keep the newest KeepCount images, or those pushed within KeepDuration, and let the rest be collected. It applies either to a whole registry or to one image repository.

type GitSource added in v0.5.0

type GitSource struct {
	RepoURL    string
	Branch     string
	Provider   string // Github | Gitlab
	Dockerfile string
	Context    string
	Workdir    string
	Builder    string // dockerfile | heroku_buildpacks
	// BuildMethod is gitlabci or webhook. Autodeploy has a pointer type so an
	// explicit false is distinguishable from "unset".
	BuildMethod string
	Autodeploy  *bool
}

GitSource describes a repository Darkube builds the app from, producing creation_method "git_repo_url" rather than "docker_image".

Every field maps to one the API returns on such an app; the zero values are filled from the defaults the console uses, so RepoURL alone is enough.

type HistoryChange added in v0.10.0

type HistoryChange struct {
	Field string `json:"field" yaml:"field"`
	Old   string `json:"old"   yaml:"old"`
	New   string `json:"new"   yaml:"new"`
}

HistoryChange is one field of a HistoryEntry. Old and New are the field's values JSON-encoded as strings, so a list reads back as "[\"a.example\"]".

type HistoryEntry added in v0.10.0

type HistoryEntry struct {
	Date      string          `json:"history_date" yaml:"history_date"`
	Type      string          `json:"history_type" yaml:"history_type"`
	UserEmail string          `json:"user_email"   yaml:"user_email"`
	UserID    int             `json:"user_id"      yaml:"user_id"`
	Changes   []HistoryChange `json:"changes"      yaml:"changes"`
}

HistoryEntry is one write to an app: who made it, when, and the fields it changed.

type InsightQuery added in v0.10.0

type InsightQuery struct {
	AppID string
	Type  string
	// Pod is a pod name, or AllPods.
	Pod        string
	Start, End time.Time
	Step       time.Duration
}

InsightQuery selects one metric of one app over a window.

type Invoice added in v0.10.0

type Invoice struct {
	ID            string  `json:"id"             yaml:"id"`
	Number        int64   `json:"number"         yaml:"number"`
	StartTime     string  `json:"start_time"     yaml:"start_time"`
	EndTime       string  `json:"end_time"       yaml:"end_time"`
	PaymentStatus string  `json:"payment_status" yaml:"payment_status"`
	OrdersPrice   float64 `json:"orders_price"   yaml:"orders_price"`
	DiscountPrice float64 `json:"discount_price" yaml:"discount_price"`
	TaxPrice      float64 `json:"tax_price"      yaml:"tax_price"`
	FinalPrice    float64 `json:"final_price"    yaml:"final_price"`
	Payable       float64 `json:"payable_amount" yaml:"payable_amount"`
}

Invoice is one monthly bill. The current month's is "pending" and grows until its end_time.

type KaaSCluster added in v0.15.0

type KaaSCluster struct {
	ID               int               `json:"id"                 yaml:"id"`
	Name             string            `json:"name"               yaml:"name"`
	UniqueID         int               `json:"unique_id"          yaml:"uniqueId"`
	Status           string            `json:"status"             yaml:"status"`
	Version          string            `json:"version"            yaml:"version"`
	Size             string            `json:"size"               yaml:"size"`
	Provider         string            `json:"provider"           yaml:"provider"`
	APIServerURL     string            `json:"api_server_url"     yaml:"apiServerUrl"`
	APIServerIP      string            `json:"api_server_ip"      yaml:"apiServerIp"`
	TraefikServiceIP string            `json:"traefik_service_ip" yaml:"traefikServiceIp"`
	FirewallPublicIP string            `json:"firewall_public_ip" yaml:"firewallPublicIp"`
	Datacenter       ClusterDatacenter `json:"datacenter"         yaml:"datacenter"`
	Organization     ClusterOrg        `json:"organization"       yaml:"organization"`
}

KaaSCluster is one KaaS cluster. APIServerURL is a bare hostname, not a URL.

type LogEntry added in v0.2.0

type LogEntry struct {
	Timestamp string // RFC3339 with nanoseconds, as sent by the API
	Text      string
}

LogEntry is one log record: the container's stdout/stderr at a point in time. The API returns a timestamp-keyed object, so entries carry their own key.

type LogOptions added in v0.2.0

type LogOptions struct {
	PodName   string
	Container string
	Tail      int  // number of lines back from the newest
	Previous  bool // the previous container instance, i.e. what a crashloop left behind
}

LogOptions selects which slice of an app's log to read.

type Member added in v0.10.0

type Member struct {
	ID       int      `json:"id"          yaml:"id"`
	Email    string   `json:"email"       yaml:"email"`
	FullName string   `json:"full_name"   yaml:"full_name"`
	Roles    []string `json:"roles"       yaml:"roles"`
	Verified bool     `json:"is_verified" yaml:"is_verified"`
}

Member is one member of an organization, from GET /api/v1/organizations/<numeric id>/members (a bare list; confirmed 2026-10-01). full_name falls back to the email when the account has no name. The console changes membership with a PUT of the whole list, which is not wired.

type Namespace

type Namespace struct {
	ID      int     `json:"id"`
	Name    string  `json:"name"`
	Cluster Cluster `json:"cluster"`
}

Namespace maps to a Darkube "project" (a Kubernetes namespace).

type NewTicket added in v0.9.0

type NewTicket struct {
	RequestType string
	Summary     string
	Description string
	Priority    string
	Attachments []TicketFile
}

NewTicket is the body of a ticket create. Priority is a TicketPriority ID and may be empty, in which case the platform picks its default.

type NodePool added in v0.15.0

type NodePool struct {
	ID       int     `json:"id"        yaml:"id"`
	Name     string  `json:"name"      yaml:"name"`
	CPU      float64 `json:"cpu"       yaml:"cpu"`
	RAM      float64 `json:"ram"       yaml:"ram"`
	OSDisk   float64 `json:"os_disk"   yaml:"osDisk"`
	DataDisk float64 `json:"data_disk" yaml:"dataDisk"`
	DiskType string  `json:"disk_type" yaml:"diskType"`
	TypeName string  `json:"type_name" yaml:"typeName"`
	TypeSize string  `json:"type_size" yaml:"typeSize"`
	HasTaint bool    `json:"has_taint" yaml:"hasTaint"`
}

NodePool is one pool of a cluster. CPU is in cores, RAM and disks in GB.

type Notification added in v0.4.0

type Notification struct {
	Slug        int    `json:"slug"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Timestamp   string `json:"timestamp"`
	TargetType  string `json:"target_type"`
	ActionURL   string `json:"action_url"`
	ActionLabel string `json:"action_label"`
	Unread      bool   `json:"unread"`
	Public      bool   `json:"public"`
}

Notification is one entry of the account's notification feed. Titles and descriptions are Persian prose, and the description carries HTML.

type Organization added in v0.4.0

type Organization struct {
	ID    int      `json:"id"`
	Name  string   `json:"name"`
	Roles []string `json:"current_user_roles"`
}

Organization is a tenant the signed-in user belongs to.

ID is the numeric primary key the app create/update payload calls "organization"; Name is the slug sent as the X-Organization header.

type PVC added in v0.10.0

type PVC struct {
	Name         string `json:"name"          yaml:"name"`
	Size         string `json:"size"          yaml:"size"`
	StorageClass string `json:"storage_class" yaml:"storage_class"`
	Status       string `json:"status"        yaml:"status"`
}

PVC is one persistent volume claim.

type Partition added in v0.2.0

type Partition struct {
	DisplayName string `json:"display_name" yaml:"name"`
	MountPath   string `json:"mount_path"   yaml:"mountPath"`
	SubPath     string `json:"sub_path"     yaml:"subPath"`
}

Partition is one mount inside a Disk.

type PermissionUser added in v0.10.0

type PermissionUser struct {
	ID       int    `json:"id"        yaml:"id"`
	Email    string `json:"email"     yaml:"email"`
	FullName string `json:"full_name" yaml:"full_name"`
}

PermissionUser is the member a permission row is about.

type Plan

type Plan struct {
	ID              string     `json:"id"`
	Name            string     `json:"name"`
	CodeName        string     `json:"code_name"`
	PlanType        string     `json:"plan_type"`
	CostType        string     `json:"cost_type"`
	ShowInCreateApp bool       `json:"show_in_create_app"`
	Detail          PlanDetail `json:"detail"`
	Cluster         *Cluster   `json:"cluster"`
}

Plan is a resource/pricing plan.

func (Plan) IsCreatable

func (p Plan) IsCreatable() bool

IsCreatable reports whether a plan can be picked when creating an app.

type PlanDetail

type PlanDetail struct {
	RAMLimit   int `json:"ram_limit"`
	CPURequest int `json:"cpu_request"`
}

PlanDetail holds an app plan's resource sizing (megabytes / millicores).

type Port added in v0.2.0

type Port struct {
	ContainerPort int    `json:"containerPort" yaml:"containerPort"`
	ServicePort   int    `json:"servicePort"   yaml:"servicePort"`
	Protocol      string `json:"protocol"      yaml:"protocol"`
}

Port is one entry of svc.ports, keyed by name in the API ("main", "amqp", …).

type Profile added in v0.4.0

type Profile struct {
	ID            int            `json:"id"`
	Email         string         `json:"email"`
	FullName      string         `json:"full_name"`
	Organizations []Organization `json:"organizations"`
}

Profile is the signed-in user's account.

type Registry added in v0.10.0

type Registry struct {
	ID       FlexID `json:"id"       yaml:"id"`
	Name     string `json:"name"     yaml:"name"`
	Address  string `json:"address"  yaml:"address"`
	Username string `json:"username" yaml:"username"`
	// IsProvidedAsSaaS marks the shared hamdocker registry, where the tenant's
	// images live under <address>/<username>/.
	IsProvidedAsSaaS  bool   `json:"is_provided_as_saas"           yaml:"is_provided_as_saas"`
	StorageUsageBytes *int64 `json:"storage_usage_bytes,omitempty" yaml:"storage_usage_bytes,omitempty"`
}

Registry is one container registry the tenant can push to.

func (Registry) PushPrefix added in v0.10.0

func (r Registry) PushPrefix() string

PushPrefix is the image name prefix that images in this registry take.

type RegistryRef added in v0.10.0

type RegistryRef struct {
	ID   FlexID `json:"id"   yaml:"id"`
	Name string `json:"name" yaml:"name"`
}

RegistryRef is the registry a retention rule names. A read nests the whole registry object; a write takes its bare id, and "" when the rule is on one image. It decodes from either.

func (*RegistryRef) UnmarshalJSON added in v0.10.0

func (r *RegistryRef) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts a registry object, a bare id, or an empty string.

type Repository added in v0.10.0

type Repository struct {
	Name       string `json:"name"        yaml:"name"`
	LastPushed string `json:"last_pushed" yaml:"last_pushed"`
	RecentTag  string `json:"recent_tag"  yaml:"recent_tag"`
}

Repository is one image repository in a registry.

type Sample added in v0.10.0

type Sample struct {
	Time  time.Time `json:"time"  yaml:"time"`
	Value float64   `json:"value" yaml:"value"`
}

Sample is one point of a Series.

type Series added in v0.10.0

type Series struct {
	Pod    string            `json:"pod"    yaml:"pod"`
	Labels map[string]string `json:"labels" yaml:"labels"`
	Values []Sample          `json:"values" yaml:"values"`
}

Series is one pod's samples of a metric.

func (Series) Latest added in v0.10.0

func (s Series) Latest() (Sample, bool)

Latest is the most recent sample, and whether there is one.

type Service added in v0.10.0

type Service struct {
	ID          string `json:"id"           yaml:"id"`
	Name        string `json:"name"         yaml:"name"`
	Label       string `json:"label"        yaml:"label"`
	ProductType string `json:"product_type" yaml:"product_type"`
	Cluster     string `json:"cluster"      yaml:"cluster"`
	PodStatus   string `json:"pod_status"   yaml:"pod_status"`
	IsEnabled   bool   `json:"is_enabled"   yaml:"is_enabled"`
	Deleted     bool   `json:"deleted"      yaml:"deleted"`
}

Service is a marketplace service instance (Jira, Rocket.Chat, n8n, …).

type State

type State struct {
	StateType   string `json:"state_type"`
	Text        string `json:"text"`
	Description string `json:"description"`
}

State is an app's live health, as reported by the platform.

type Storage added in v0.12.0

type Storage struct {
	ID             string          `json:"id"              yaml:"id"`
	Name           string          `json:"name"            yaml:"name"`
	StorageClass   string          `json:"storage_class"   yaml:"storageClass"`
	IsShared       bool            `json:"is_shared"       yaml:"isShared"`
	TraefikAddress string          `json:"traefik_address" yaml:"traefikAddress"`
	Buckets        []Bucket        `json:"buckets"         yaml:"buckets"`
	Keys           []StorageKey    `json:"keys"            yaml:"keys"`
	Domains        []StorageDomain `json:"domains"         yaml:"domains"`
}

Storage is one object-storage cluster the tenant can use.

func (Storage) Endpoint added in v0.12.0

func (s Storage) Endpoint() string

Endpoint returns the S3 endpoint URL to configure a client with, or "" when the storage has no domain yet. A custom domain wins over the platform one.

type StorageDomain added in v0.12.0

type StorageDomain struct {
	URL             string `json:"url"               yaml:"url"`
	Custom          bool   `json:"custom"            yaml:"custom"`
	IsDNSChallenged bool   `json:"is_dns_challenged" yaml:"isDnsChallenged"`
}

StorageDomain is the S3 endpoint a storage answers on. The non-custom one is the address to give an S3 client: a per-tenant name under hs3.ir, which cannot be derived from the tenant slug because it carries a random suffix.

type StorageKey added in v0.12.0

type StorageKey struct {
	Name    string   `json:"name"    yaml:"name"`
	Actions []string `json:"actions" yaml:"actions"`
	Buckets []string `json:"buckets" yaml:"buckets"`
}

StorageKey is an access key. The secret is returned only once, by the call that creates it, and is not readable afterwards.

type StorageKeySecret added in v0.14.0

type StorageKeySecret struct {
	StorageKey `yaml:",inline"`

	AccessKey string `json:"access_key" yaml:"accessKey"`
	SecretKey string `json:"secret_key" yaml:"secretKey"`
}

StorageKeySecret is a key as returned by the two calls that mint a secret: create and rotate. Neither value can be read again afterwards.

type Suggestion added in v0.10.0

type Suggestion struct {
	ID       string `json:"id"              yaml:"id"`
	Type     string `json:"suggestion_type" yaml:"suggestion_type"`
	Severity string `json:"severity"        yaml:"severity"`
	Title    string `json:"title"           yaml:"title"`
	Text     string `json:"text"            yaml:"text"`
	Docs     string `json:"docs_address"    yaml:"docs_address"`
}

Suggestion is a piece of configuration advice the platform derives from an app, such as a port the image exposes that the app does not. Title and Text are Persian prose.

type Ticket added in v0.9.0

type Ticket struct {
	ID           TicketID          `json:"id"`
	Summary      string            `json:"summary"`
	Description  string            `json:"description"`
	Status       string            `json:"status"`
	RequestType  TicketRequestType `json:"request_type"`
	Reporter     TicketUser        `json:"reporter"`
	Created      string            `json:"created"`
	Updated      string            `json:"updated,omitempty"`
	CommentCount int               `json:"comment_number,omitempty"`
	Rate         int               `json:"rate"`
	RateComment  string            `json:"rate_comment,omitempty"`
}

Ticket is one support ticket. Created and Updated are Jira timestamps (`2026-09-26T08:25:33.000+0000`), which are not RFC 3339.

func (Ticket) IsOpen added in v0.9.0

func (t Ticket) IsOpen() bool

IsOpen reports whether the ticket is still open.

type TicketAttachment added in v0.9.0

type TicketAttachment struct {
	ID       TicketID `json:"id"`
	Filename string   `json:"filename"`
}

TicketAttachment is a file on a comment, fetched with DownloadTicketAttachment.

type TicketCategory added in v0.9.0

type TicketCategory struct {
	ID    string `json:"id"`
	Key   string `json:"key"`
	Value string `json:"value"`
}

TicketCategory is a request type a ticket can be filed under.

type TicketComment added in v0.9.0

type TicketComment struct {
	ID          TicketID           `json:"id"`
	Body        string             `json:"body"`
	Public      bool               `json:"public"`
	Author      TicketUser         `json:"author"`
	Created     TicketTime         `json:"created"`
	Attachments []TicketAttachment `json:"attachments"`
}

TicketComment is one entry of a ticket's thread. The first is synthesized from the ticket's description with id 0. Internal Jira comments are left out, so a ticket's CommentCount can exceed the number returned.

type TicketFile added in v0.9.0

type TicketFile struct {
	Path string
}

TicketFile is a local file to attach to a ticket or reply.

type TicketID added in v0.9.0

type TicketID string

TicketID is a Jira issue number. The list sends it as a string and the detail as a number, so it decodes from either.

func (*TicketID) UnmarshalJSON added in v0.9.0

func (t *TicketID) UnmarshalJSON(b []byte) error

UnmarshalJSON accepts a JSON string or number.

type TicketList added in v0.9.0

type TicketList struct {
	Total   int      `json:"total"`
	Open    int      `json:"number_open"`
	Closed  int      `json:"number_close"`
	Tickets []Ticket `json:"tickets"`
}

TicketList is the list route's answer. Total counts every status, whatever the filter; Tickets holds only the matching ones.

type TicketPriority added in v0.9.0

type TicketPriority struct {
	ID      string `json:"id"`
	Keyword string `json:"keyword"`
}

TicketPriority is a priority a ticket can be filed with. Create takes the ID, not the keyword.

type TicketRequestType added in v0.9.0

type TicketRequestType struct {
	Key   string `json:"key"`
	Value string `json:"value,omitempty"`
}

TicketRequestType is a ticket's category. The list sends only the key as a bare string; the detail sends {key, value} with a localized value.

func (*TicketRequestType) UnmarshalJSON added in v0.9.0

func (r *TicketRequestType) UnmarshalJSON(b []byte) error

UnmarshalJSON accepts a bare key or a {key, value} object.

type TicketTime added in v0.9.0

type TicketTime string

TicketTime is a comment timestamp. Jira sends {iso8601, jira, friendly, epochMillis}; only iso8601 is always present, so that is what is kept.

func (*TicketTime) UnmarshalJSON added in v0.9.0

func (t *TicketTime) UnmarshalJSON(b []byte) error

UnmarshalJSON accepts a bare string or Jira's timestamp object.

type TicketUser added in v0.9.0

type TicketUser struct {
	Name        string `json:"name"`
	DisplayName string `json:"displayName"`
	Email       string `json:"email"`
}

TicketUser is a ticket's reporter or a comment's author. Jira calls the address `emailAddress` and the support platform's own detail calls it `email`; both land in Email.

func (TicketUser) IsStaff added in v0.9.0

func (u TicketUser) IsStaff() bool

IsStaff reports whether the user is a Hamravesh support engineer.

func (*TicketUser) UnmarshalJSON added in v0.9.0

func (u *TicketUser) UnmarshalJSON(b []byte) error

UnmarshalJSON folds `emailAddress` into Email.

type Wallet added in v0.10.0

type Wallet struct {
	ID       string  `json:"id"       yaml:"id"`
	Type     string  `json:"type"     yaml:"type"`
	Budget   float64 `json:"budget"   yaml:"budget"`
	Priority int     `json:"priority" yaml:"priority"`
}

Wallet is one balance an organization pays from: "cash" or "gift" credit. Priority is the order they are drawn down in.

Jump to

Keyboard shortcuts

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