Documentation
¶
Overview ¶
Package sweb is a Go client for the SpaceWeb (sweb.ru) hosting API.
The API speaks JSON-RPC 2.0 over HTTPS POST. A Client wraps the transport (envelope, auth, error handling); typed operations are grouped into services (e.g. Client.VPS) in the spirit of the kubectl/yc clients.
SpaceWeb issues short-lived session tokens and has no refresh-token flow. Use WithCredentials so the client transparently re-exchanges login+password for a fresh token when the session expires.
Index ¶
- Constants
- type AvailableConfig
- type Backup
- type BackupService
- func (s *BackupService) Attach(ctx context.Context, billingID, name string) error
- func (s *BackupService) Create(ctx context.Context, billingID string) error
- func (s *BackupService) Detach(ctx context.Context, billingID, name string) error
- func (s *BackupService) List(ctx context.Context, billingID string) ([]Backup, error)
- func (s *BackupService) Remove(ctx context.Context, billingID, name string) error
- func (s *BackupService) Restore(ctx context.Context, billingID, name string) error
- func (s *BackupService) SaveSettings(ctx context.Context, billingID, mode string, frequency, backupTime int) error
- func (s *BackupService) Settings(ctx context.Context, billingID string) (*BackupSettings, error)
- type BackupSettings
- type Category
- type Client
- type CreateVPSRequest
- type DNSAction
- type DNSRecord
- type DNSService
- func (s *DNSService) EditMX(ctx context.Context, domain string, action DNSAction, r MXRecord) error
- func (s *DNSService) EditMain(ctx context.Context, domain string, action DNSAction, r MainRecord) error
- func (s *DNSService) EditNS(ctx context.Context, domain string, action DNSAction, index int, ...) error
- func (s *DNSService) EditSRV(ctx context.Context, domain string, action DNSAction, r SRVRecord) error
- func (s *DNSService) EditTXT(ctx context.Context, domain string, action DNSAction, index int, ...) error
- func (s *DNSService) GetFile(ctx context.Context, domain string) (*ZoneFile, error)
- func (s *DNSService) Records(ctx context.Context, domain string) ([]DNSRecord, error)
- type Datacenter
- type Domain
- type DomainInfo
- type DomainListOptions
- type DomainPackage
- type DomainsService
- func (s *DomainsService) AvailablePackages(ctx context.Context, domains ...string) ([]DomainPackage, error)
- func (s *DomainsService) ChangeProlong(ctx context.Context, domain, prolongType string) error
- func (s *DomainsService) ChangeProlongList(ctx context.Context, items ...ProlongItem) error
- func (s *DomainsService) CreateSubdomain(ctx context.Context, domain, machine, dir string) error
- func (s *DomainsService) Info(ctx context.Context, domain string) (*DomainInfo, error)
- func (s *DomainsService) List(ctx context.Context, opts *DomainListOptions) ([]Domain, error)
- func (s *DomainsService) Move(ctx context.Context, domain, prolongType, dir string) error
- func (s *DomainsService) MoveList(ctx context.Context, items ...MoveItem) error
- func (s *DomainsService) Prolong(ctx context.Context, domain, payType string) error
- func (s *DomainsService) ProlongList(ctx context.Context, domains ...string) (*ExtendedResult, error)
- func (s *DomainsService) Redirect(ctx context.Context, domain string) (string, error)
- func (s *DomainsService) RegAvailable(ctx context.Context, domain, payType string) (bool, error)
- func (s *DomainsService) Register(ctx context.Context, o RegisterOptions) error
- func (s *DomainsService) RegisterList(ctx context.Context, domains ...string) error
- func (s *DomainsService) RegistrationPrice(ctx context.Context, domain string) (float64, error)
- func (s *DomainsService) Remove(ctx context.Context, domain string) error
- func (s *DomainsService) RemoveList(ctx context.Context, domains ...string) error
- func (s *DomainsService) RemoveSubdomain(ctx context.Context, domain, machine string) error
- func (s *DomainsService) SetRedirect(ctx context.Context, domain, redirect string) error
- func (s *DomainsService) Subdomains(ctx context.Context, domain string) ([]SubdomainRef, error)
- func (s *DomainsService) TransferAvailable(ctx context.Context, domain string) (bool, error)
- type Error
- type ExtendedResult
- type FirstOrderInfo
- type FlexFloat
- type FlexInt
- type IPAddress
- type IPAddressList
- type IPInfo
- type IPService
- func (s *IPService) Add(ctx context.Context, billingID string, number int) (json.RawMessage, error)
- func (s *IPService) AddLocal(ctx context.Context, billingID string) error
- func (s *IPService) EditPtr(ctx context.Context, ip, ptr string) error
- func (s *IPService) GetPtr(ctx context.Context, ip string) (string, error)
- func (s *IPService) Info(ctx context.Context, billingID string) (*IPInfo, error)
- func (s *IPService) Move(ctx context.Context, ip, billingID string) error
- func (s *IPService) Remove(ctx context.Context, billingID, ip string) error
- func (s *IPService) RemoveLocal(ctx context.Context, billingID string) error
- func (s *IPService) WaitForLocalIP(ctx context.Context, billingID string, interval time.Duration) (LocalIP, error)
- type IPVPSInfo
- type ISPInfo
- type LocalIP
- type LocalIPList
- type MXRecord
- type MainRecord
- type MoveItem
- type OSOption
- type OSPanel
- type Option
- type PackageDomain
- type ProlongConfirm
- type ProlongItem
- type RegisterOptions
- type RemoteBackup
- type RemoteBackupService
- func (s *RemoteBackupService) Create(ctx context.Context, billingID, name, comment string) (json.RawMessage, error)
- func (s *RemoteBackupService) EditComment(ctx context.Context, remoteBackupID int, comment string) error
- func (s *RemoteBackupService) List(ctx context.Context) ([]RemoteBackup, error)
- func (s *RemoteBackupService) Remove(ctx context.Context, remoteBackupID int) error
- func (s *RemoteBackupService) Restore(ctx context.Context, remoteBackupID int) error
- func (s *RemoteBackupService) RestoreInto(ctx context.Context, remoteBackupID int, billingID string) error
- type SRVRecord
- type SSHKeyRef
- type Subdomain
- type SubdomainRef
- type VPS
- type VPSFeatures
- type VPSLogEntry
- type VPSPlan
- type VPSService
- func (s *VPSService) AvailableConfig(ctx context.Context) (*AvailableConfig, error)
- func (s *VPSService) ChangePlan(ctx context.Context, billingID string, vpsPlanID int) error
- func (s *VPSService) Copy(ctx context.Context, billingID string, vpsPlanID int) (json.RawMessage, error)
- func (s *VPSService) Create(ctx context.Context, req CreateVPSRequest) (json.RawMessage, error)
- func (s *VPSService) GetConstructorPlanID(ctx context.Context, cpuCores, ramGB, diskGB, categoryID int) (int, error)
- func (s *VPSService) GetFirstOrderInfo(ctx context.Context) (*FirstOrderInfo, error)
- func (s *VPSService) IsRunning(ctx context.Context, billingID string) (bool, error)
- func (s *VPSService) List(ctx context.Context) ([]VPS, error)
- func (s *VPSService) Logs(ctx context.Context, billingID string) ([]VPSLogEntry, error)
- func (s *VPSService) PowerOff(ctx context.Context, billingID string) error
- func (s *VPSService) PowerOn(ctx context.Context, billingID string) error
- func (s *VPSService) Reboot(ctx context.Context, billingID string) error
- func (s *VPSService) ReinstallOS(ctx context.Context, billingID string, distributiveID int, keepDisk bool) error
- func (s *VPSService) Remove(ctx context.Context, billingID string) (json.RawMessage, error)
- func (s *VPSService) Rename(ctx context.Context, billingID, alias string) error
- func (s *VPSService) WaitForIdle(ctx context.Context, billingID string, poll time.Duration, ...) (*VPS, error)
- type ZoneFile
Constants ¶
const ( PayBalance = "balance" // charge the account's money balance PayBonus = "bonus" // charge bonus points )
Payment sources for paid operations (reg, prolong).
const ( ProlongNone = "none" // reg, changeProlong: do not auto-prolong ProlongNo = "no" // move, moveList: do not auto-prolong ProlongManual = "manual" // prolong manually (client-initiated) ProlongBonusMoney = "bonus_money" // auto-prolong from the bonus balance )
Auto-prolongation modes. The API is inconsistent about the "do not prolong" token: reg/changeProlong/changeProlongList use "none", move/moveList use "no". Both spellings are provided; pick the one the target method documents.
const DefaultBaseURL = "https://api.sweb.ru"
DefaultBaseURL is the production SpaceWeb API root.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AvailableConfig ¶
type AvailableConfig struct {
VPSPlans []VPSPlan `json:"vpsPlans"`
SelectOS []OSOption `json:"selectOs"`
OSPanel []OSPanel `json:"osPanel"`
Datacenters []Datacenter `json:"datacenters"`
Categories []Category `json:"categories"`
}
AvailableConfig is the catalog of selectable options for creating a VPS (method "getAvailableConfig"). Shapes confirmed against a real response. selectPanel and the kit{} configurator ranges are omitted for now — add them when the CLI/provider need the custom-configurator flow.
type Backup ¶ added in v0.12.0
type Backup struct {
Name string `json:"name"`
PrettyName string `json:"prettyName"`
UnicID string `json:"unic_id"`
AttachType string `json:"attach_type"`
UpdatedAt string `json:"updatedAt"`
}
Backup is one local backup of a VPS, as returned by List. name is the key the restore/attach/detach/remove methods take.
type BackupService ¶ added in v0.12.0
type BackupService struct {
// contains filtered or unexported fields
}
BackupService groups local (on-node) backup operations (endpoint /vps/backup): list/create/restore/remove, attach/detach a backup as a disk, and the auto-backup schedule.
func (*BackupService) Attach ¶ added in v0.12.0
func (s *BackupService) Attach(ctx context.Context, billingID, name string) error
Attach mounts a backup on the VPS as an extra disk (method "attach"). Action 1/0.
func (*BackupService) Create ¶ added in v0.12.0
func (s *BackupService) Create(ctx context.Context, billingID string) error
Create takes a new local backup of a VPS (method "create"). Action 1/0 result.
func (*BackupService) Detach ¶ added in v0.12.0
func (s *BackupService) Detach(ctx context.Context, billingID, name string) error
Detach unmounts a previously attached backup disk (method "detach"). Action 1/0.
func (*BackupService) List ¶ added in v0.12.0
List returns a VPS's local backups (method "index"). Read-only.
func (*BackupService) Remove ¶ added in v0.12.0
func (s *BackupService) Remove(ctx context.Context, billingID, name string) error
Remove deletes a local backup (method "remove"). Action 1/0.
func (*BackupService) Restore ¶ added in v0.12.0
func (s *BackupService) Restore(ctx context.Context, billingID, name string) error
Restore restores a VPS from a local backup (method "restore"). DESTRUCTIVE — overwrites the current disk. name is a Backup.Name from List. Action 1/0.
func (*BackupService) SaveSettings ¶ added in v0.12.0
func (s *BackupService) SaveSettings(ctx context.Context, billingID, mode string, frequency, backupTime int) error
SaveSettings sets the auto-backup schedule (method "saveSettings"). mode is "manual" or "auto"; frequency and time are the schedule knobs (ignored in manual mode). Action 1/0 result.
func (*BackupService) Settings ¶ added in v0.12.0
func (s *BackupService) Settings(ctx context.Context, billingID string) (*BackupSettings, error)
Settings returns a VPS's auto-backup schedule (method "getSettings"). The API wraps it in a one-element array; this unwraps it (nil if empty). Read-only.
type BackupSettings ¶ added in v0.12.0
type BackupSettings struct {
Mode string `json:"mode"`
Frequency FlexInt `json:"frequency"`
Time FlexInt `json:"time"`
NextDataBackup string `json:"next_data_backup"`
}
BackupSettings is the auto-backup schedule (getSettings/saveSettings). mode is "manual" or "auto"; frequency/time are null in manual mode (FlexInt → 0).
type Client ¶
type Client struct {
// VPS groups VPS operations (endpoint /vps).
VPS *VPSService
// IP groups IP operations (endpoint /vps/ip): local network + public IPs.
IP *IPService
// Backup groups local backup operations (endpoint /vps/backup).
Backup *BackupService
// RemoteBackup groups cloud backup operations (endpoint /vps/remoteBackup).
RemoteBackup *RemoteBackupService
// DNS groups DNS-zone operations (endpoint /domains/dns).
DNS *DNSService
// Domains groups domain/subdomain operations (endpoint /domains).
Domains *DomainsService
// contains filtered or unexported fields
}
Client talks to the SpaceWeb JSON-RPC API. Construct it with New.
func New ¶
New builds a Client. A token (WithToken) and/or credentials (WithCredentials) are optional but required for authenticated endpoints.
func (*Client) CreateToken ¶
CreateToken exchanges a login + password for a personal access token via the unauthenticated endpoint (/notAuthorized/, method getToken). The returned token is then supplied via WithToken for authenticated calls.
type CreateVPSRequest ¶
type CreateVPSRequest struct {
DistributiveID int `json:"distributiveId"`
VPSPlanID int `json:"vpsPlanId"`
Datacenter int `json:"datacenter"`
Alias string `json:"alias"`
SSHKey string `json:"sshKey"`
MonitoringPlanID int `json:"monitoringPlanId,omitempty"`
MonitoringContactID int `json:"monitoringContactId,omitempty"`
IPCount int `json:"ipCount,omitempty"`
ProtectedIPs []int `json:"protectedIps,omitempty"`
}
CreateVPSRequest holds the parameters for Create (method "create"). Use AvailableConfig to resolve the numeric IDs (plan, distributive, datacenter).
type DNSAction ¶ added in v0.13.0
type DNSAction string
DNSAction is the operation an edit method performs on a record — the add/edit/remove discriminator. This is the SDK's logical token; the wire "action" value can differ (remove is sent as "del", see editDelete).
add and edit are confirmed against live responses (add via a live editTxt probe, edit via the apidoc examples). remove is routed through editDelete, whose wire shape ("del" + a "type" discriminator, no subDomain/value) was observed live for editTxt; the same shape is applied to the other record types by inference.
type DNSRecord ¶ added in v0.13.0
type DNSRecord struct {
Index FlexInt `json:"index"` // record id for edit/remove; per-category, not globally unique
Type string `json:"type"` // A, AAAA, CNAME, MX, SRV, TXT, NS
Category string `json:"category"` // zoneMain, subdom, mx, srv, mainTxt, …
Name string `json:"name"`
Value string `json:"value"`
// MX, SRV
Priority FlexInt `json:"priority"`
// SRV
Service string `json:"service"`
Protocol string `json:"protocol"`
TTL FlexInt `json:"ttl"`
Weight FlexInt `json:"weight"`
Port FlexInt `json:"port"`
Target string `json:"target"`
// A ("A"/… selector and a stringified bool for whether it may change)
Sel string `json:"sel"`
CanChange string `json:"canChange"` // "true"/"false" (stringified bool)
// TXT
Domain string `json:"domain"` // "@" for the apex
Main FlexInt `json:"main"`
}
DNSRecord is one record in a zone as returned by the "info" method. The API returns a heterogeneous list — a single struct carries every type's fields, with only the relevant ones populated per Type. Numeric fields (Priority, TTL, Weight, Port, Index, Main) arrive as quoted strings on some record types and bare numbers on others, so all decode through FlexInt.
type DNSService ¶ added in v0.13.0
type DNSService struct {
// contains filtered or unexported fields
}
DNSService groups DNS-zone operations (endpoint /domains/dns): read the zone (Records, ZoneFile) and edit records by type (Main/MX/SRV/NS/TXT).
func (*DNSService) EditMX ¶ added in v0.13.0
EditMX adds/edits/removes an MX record (method "editMx", 1=success).
func (*DNSService) EditMain ¶ added in v0.13.0
func (s *DNSService) EditMain(ctx context.Context, domain string, action DNSAction, r MainRecord) error
EditMain adds/edits/removes a general zone record (method "editMain", true=success). Covers the record types without a dedicated method (A, AAAA, CNAME, …).
func (*DNSService) EditNS ¶ added in v0.13.0
func (s *DNSService) EditNS(ctx context.Context, domain string, action DNSAction, index int, subDomain, value string) error
EditNS adds/edits/removes an NS record (method "editNS", true=success).
func (*DNSService) EditSRV ¶ added in v0.13.0
func (s *DNSService) EditSRV(ctx context.Context, domain string, action DNSAction, r SRVRecord) error
EditSRV adds/edits/removes an SRV record (method "editSrv", true=success).
func (*DNSService) EditTXT ¶ added in v0.13.0
func (s *DNSService) EditTXT(ctx context.Context, domain string, action DNSAction, index int, subDomain, value string) error
EditTXT adds/edits/removes a TXT record (method "editTxt", true=success).
type Datacenter ¶
type Datacenter struct {
ID string `json:"id"`
Name string `json:"name"`
Location string `json:"location"`
SiteName string `json:"site_name"`
}
Datacenter is a location a VPS can be placed in.
type Domain ¶ added in v0.14.0
type Domain struct {
FQDN string `json:"fqdn"` // encoded name
FQDNReadable string `json:"fqdn_readable"` // human-readable name
FQDNTech string `json:"fqdn_tech"` // technical domain
Docroot string `json:"docroot"` // home directory
SiteAlias string `json:"siteAlias"` // site name in the control panel
// Package-only fields.
FQDNList []string `json:"fqdnList"` // encoded member domains
FQDNReadableList []string `json:"fqdnReadableList"` // readable member domains
FQDNTechList []string `json:"fqdnTechList"` // technical domains of the package
IsAvailable FlexInt `json:"is_available"` // 1 if the package can be registered
InQueue FlexInt `json:"in_queue"` // 1 while an operation is running
OrderPackageID FlexInt `json:"order_package_id"` // order id for the package
RegPrice FlexFloat `json:"reg_price"` // registration price
BonusAvailable bool `json:"bonus_available"` // registrable for bonus points
Subdomains []Subdomain `json:"subdomains"`
}
Domain is one entry from the account's domain list ("index"). A single struct carries both a plain domain and a domain package; the *List / is_available / order_package_id fields are populated only for packages (showPackages=true).
type DomainInfo ¶ added in v0.14.0
type DomainInfo struct {
IsActiveTask FlexInt `json:"is_active_task"` // an operation is running
Autoreg FlexInt `json:"autoreg"` // auto-registration enabled
IsTaken FlexInt `json:"is_taken"` // domain is taken
Registrar string `json:"registrar"` // null → ""
IsOur FlexInt `json:"is_our"` // 1 if under our management
Expired string `json:"expired"` // registration expiry date, "" if unknown
CanProlong FlexInt `json:"can_prolong"` // 1 if prolongable now
ProlongPrice FlexInt `json:"prolong_price"` // prolongation price
ProlongByBonus bool `json:"prolong_by_bonus"` // prolongable for bonus points
ProlongConfirm *ProlongConfirm `json:"prolong_confirm"` // null when no confirmation dialog
RegPrice FlexInt `json:"reg_price"` // registration price
TransferPrice FlexInt `json:"transfer_price"` // -1 when transfer not offered
Autoprolong string `json:"autoprolong"` // "no", "manual", "bonus_money"
DocRoot string `json:"docRoot"` // doc says int; live is a path string
SiteAlias string `json:"siteAlias"` // site name in the control panel
BonusAvailable bool `json:"bonus_available"` // registrable for bonus points
TransferLink string `json:"transferLink"` // null → ""
RedirectURL string `json:"redirectUrl"` // configured redirect, null → ""
}
DomainInfo is the full per-domain record returned by "getDomainInfo".
type DomainListOptions ¶ added in v0.14.0
type DomainListOptions struct {
OrderField string // sort field (e.g. "fqdn_readable")
OrderDirect string // sort direction ("ASC"/"DESC")
Type string // "all", "sweb", "free", "other"
Filter string // substring filter on the domain name
Page int
PerPage int
ShowPackages bool // include domain packages in the result
}
DomainListOptions filters and paginates List ("index"). All fields are optional.
type DomainPackage ¶ added in v0.14.0
type DomainPackage struct {
ID FlexInt `json:"id"`
NameReadable string `json:"name_readable"`
Price FlexFloat `json:"price"` // promotional price
Price2 FlexFloat `json:"price2"` // regular price
Priority FlexInt `json:"priority"`
Available bool `json:"available"`
OrderPackageID FlexInt `json:"order_package_id"`
Domains []PackageDomain `json:"domains"`
}
DomainPackage is one discounted registration package from "getAvailablePackages".
type DomainsService ¶ added in v0.14.0
type DomainsService struct {
// contains filtered or unexported fields
}
DomainsService groups domain and subdomain operations (endpoint /domains): read the account's domains (List, Info, Subdomains), check/price registration and transfer, and mutate the domain lifecycle (register, move-in, prolong, remove, redirect, subdomain CRUD).
func (*DomainsService) AvailablePackages ¶ added in v0.14.0
func (s *DomainsService) AvailablePackages(ctx context.Context, domains ...string) ([]DomainPackage, error)
AvailablePackages checks whether the given domains form a discounted package and returns the matching packages with an order_package_id ("getAvailablePackages").
SIDE EFFECT: despite the "get" name, on a hit the API ADDS the package to the account (per the apidoc). Not a pure read — do not call it speculatively.
func (*DomainsService) ChangeProlong ¶ added in v0.14.0
func (s *DomainsService) ChangeProlong(ctx context.Context, domain, prolongType string) error
ChangeProlong changes a domain's auto-prolongation setting ("changeProlong", 1=success).
func (*DomainsService) ChangeProlongList ¶ added in v0.14.0
func (s *DomainsService) ChangeProlongList(ctx context.Context, items ...ProlongItem) error
ChangeProlongList changes auto-prolongation for several domains at once ("changeProlongList", 1=success).
func (*DomainsService) CreateSubdomain ¶ added in v0.14.0
func (s *DomainsService) CreateSubdomain(ctx context.Context, domain, machine, dir string) error
CreateSubdomain adds a subdomain ("createSubdomain", 1=success).
func (*DomainsService) Info ¶ added in v0.14.0
func (s *DomainsService) Info(ctx context.Context, domain string) (*DomainInfo, error)
Info returns the full record for one domain ("getDomainInfo"). Read-only.
func (*DomainsService) List ¶ added in v0.14.0
func (s *DomainsService) List(ctx context.Context, opts *DomainListOptions) ([]Domain, error)
List returns the account's domains ("index"). Read-only.
func (*DomainsService) Move ¶ added in v0.14.0
func (s *DomainsService) Move(ctx context.Context, domain, prolongType, dir string) error
Move adds an existing domain to the account ("move"). On success the API answers 1; on failure it answers an ExtendedResult carrying per-domain errors, surfaced here as an error.
func (*DomainsService) MoveList ¶ added in v0.14.0
func (s *DomainsService) MoveList(ctx context.Context, items ...MoveItem) error
MoveList adds several existing domains to the account ("moveList"). Same success/ExtendedResult contract as Move.
func (*DomainsService) Prolong ¶ added in v0.14.0
func (s *DomainsService) Prolong(ctx context.Context, domain, payType string) error
Prolong prolongs a domain's registration ("prolong", 1=success). Bills the account.
func (*DomainsService) ProlongList ¶ added in v0.14.0
func (s *DomainsService) ProlongList(ctx context.Context, domains ...string) (*ExtendedResult, error)
ProlongList prolongs several domains at once ("prolongList"). Unlike the other batch methods it always answers an ExtendedResult envelope; it is returned to the caller (with the success message) and, on a non-1 code, also as an error.
func (*DomainsService) Redirect ¶ added in v0.14.0
Redirect returns a domain's configured redirect URL ("getRedirectVh"). Read-only.
func (*DomainsService) RegAvailable ¶ added in v0.14.0
RegAvailable reports whether a domain can be registered ("regAvailable", 1=available). A preliminary check — read-only.
func (*DomainsService) Register ¶ added in v0.14.0
func (s *DomainsService) Register(ctx context.Context, o RegisterOptions) error
Register registers a domain on the account ("reg", 1=success). Bills the account.
func (*DomainsService) RegisterList ¶ added in v0.14.0
func (s *DomainsService) RegisterList(ctx context.Context, domains ...string) error
RegisterList registers several domains at once ("regList", 1=success). Bills the account.
func (*DomainsService) RegistrationPrice ¶ added in v0.14.0
RegistrationPrice returns a domain's registration price ("priceForRegistration"). Read-only.
func (*DomainsService) Remove ¶ added in v0.14.0
func (s *DomainsService) Remove(ctx context.Context, domain string) error
Remove deletes a domain from the account ("remove", 1=success).
func (*DomainsService) RemoveList ¶ added in v0.14.0
func (s *DomainsService) RemoveList(ctx context.Context, domains ...string) error
RemoveList deletes several domains at once ("removeList", 1=success).
func (*DomainsService) RemoveSubdomain ¶ added in v0.14.0
func (s *DomainsService) RemoveSubdomain(ctx context.Context, domain, machine string) error
RemoveSubdomain deletes a subdomain ("removeSubdomain", 1=success).
func (*DomainsService) SetRedirect ¶ added in v0.14.0
func (s *DomainsService) SetRedirect(ctx context.Context, domain, redirect string) error
SetRedirect sets a domain's redirect URL ("setRedirectVh", 1=success).
NOTE: the apidoc's request example names the URL param "setRedirectVh", but the documented parameter is "redirect"; this sends "redirect" per the parameter table. Confirm against a live response before relying on it.
func (*DomainsService) Subdomains ¶ added in v0.14.0
func (s *DomainsService) Subdomains(ctx context.Context, domain string) ([]SubdomainRef, error)
Subdomains lists a domain's subdomains ("getSubdomains"). Read-only.
func (*DomainsService) TransferAvailable ¶ added in v0.14.0
TransferAvailable reports whether a domain can be transferred in ("priceForTrasfer" — the API misspells "transfer"; the wire method keeps the typo, 1=available). Read-only.
type Error ¶
type Error struct {
Code int `json:"code"`
Message string `json:"message"`
Data any `json:"data,omitempty"`
}
Error is an API-level failure: either a JSON-RPC error object returned by the API, or a synthesized error for a non-200 HTTP response (Code = status code).
NOTE: the exact JSON-RPC error shape SpaceWeb returns is not yet confirmed against a real response (Evidence phase) — Code/Message/Data are the standard JSON-RPC fields and may need adjusting once real error payloads are recorded.
type ExtendedResult ¶ added in v0.14.0
type ExtendedResult struct {
Code FlexInt `json:"code"`
Message string `json:"message"`
Data json.RawMessage `json:"data"` // [] on success; per-domain errors otherwise
}
ExtendedResult is SpaceWeb's batch-operation envelope. move/moveList answer a bare 1 on success or this on failure (Data holds per-domain [fqdn, error] pairs); prolongList always wraps it as {"extendedResult":{…}}. Code 1 == success.
type FirstOrderInfo ¶ added in v0.4.0
type FirstOrderInfo struct {
Plan string `json:"plan"`
OS string `json:"os"`
Panel string `json:"panel"`
CPUCores FlexInt `json:"cpu_cores"`
RAM FlexInt `json:"ram"` // MB
VolumeDisk string `json:"volume_disk"` // localized, e.g. "10 ГБ"
PricePerMonth FlexFloat `json:"price_per_month"`
PayPeriod FlexInt `json:"pay_period"` // months
PriceForPeriodWithStock FlexFloat `json:"price_for_period_with_stock"`
PricePerMonthWithStock FlexFloat `json:"price_per_month_with_stock"`
Promocode string `json:"promocode"` // empty when null
ClearAvailable bool `json:"clearAvailable"`
PlanIsConstructor bool `json:"plan_is_constructor"`
IPCount FlexInt `json:"ipCount"`
ProtectedIPs []FlexInt `json:"protectedIps"`
}
FirstOrderInfo describes the account's promotional first VPS order (method "getFirstOrderInfo"), used by the onboarding / clear-first-order flow.
Doc caveats reconciled against a real response: cpu_cores/ram come as quoted strings; pay_period is a month COUNT (not a price, despite the doc); and the two *_with_stock descriptions are swapped in the docs — field names + values are authoritative.
type FlexFloat ¶ added in v0.3.0
type FlexFloat float64
FlexFloat is FlexInt's fractional sibling for money fields: decodes from a JSON number (0.9), a quoted string ("0.9"), or null (→ 0). Marshals back as a bare JSON number.
func (FlexFloat) MarshalJSON ¶ added in v0.3.0
MarshalJSON emits a bare JSON number (shortest round-trippable form).
func (*FlexFloat) UnmarshalJSON ¶ added in v0.3.0
UnmarshalJSON accepts 0.9, "0.9", "" and null.
type FlexInt ¶ added in v0.3.0
type FlexInt int64
FlexInt is an int64 that decodes from EITHER a JSON number (4) or a quoted string ("4"), and from null (→ 0). The SpaceWeb API returns many numeric fields inconsistently as one or the other across nodes/plans, so a plain int crashes on the string form (the plan_price/ram class of bug). Marshals back as a bare JSON number.
func (FlexInt) MarshalJSON ¶ added in v0.3.0
MarshalJSON emits a bare JSON number.
func (*FlexInt) UnmarshalJSON ¶ added in v0.3.0
UnmarshalJSON accepts 4, "4", "" and null.
type IPAddress ¶ added in v0.8.0
type IPAddress struct {
IP string `json:"ip"`
Gateway string `json:"gateway"`
Netmask string `json:"netmask"`
Datacenter FlexInt `json:"datacenter"`
PTR string `json:"ptr"`
Price FlexFloat `json:"price"` // money: the API returns fractional prices (e.g. 142.06)
}
IPAddress is a public IP bound to (or orderable for) a VPS.
type IPAddressList ¶ added in v0.8.2
type IPAddressList []IPAddress
IPAddressList is []IPAddress with the same array-or-object tolerance.
func (*IPAddressList) UnmarshalJSON ¶ added in v0.8.2
func (l *IPAddressList) UnmarshalJSON(b []byte) error
UnmarshalJSON accepts an array, a single object, or null.
type IPInfo ¶ added in v0.8.0
type IPInfo struct {
IPs IPAddressList `json:"ips"`
ProtectedIPs json.RawMessage `json:"protected_ips"` // raw: shape varies; decode on demand
LocalIP LocalIPList `json:"local_ip"`
VPS IPVPSInfo `json:"vps"`
}
IPInfo is the per-VPS IP inventory returned by the "index" method: public IPs, protected IPs, and the local-network attachment (if any).
type IPService ¶ added in v0.8.0
type IPService struct {
// contains filtered or unexported fields
}
IPService groups IP operations (endpoint /vps/ip): the account private (local) network and public/additional IP management.
func (*IPService) Add ¶ added in v0.11.0
Add orders number additional public IPs for a VPS (method "add"). This BILLS. Like Create, the result shape is left raw pending a recorded response — read the assigned addresses back via Info once they settle.
func (*IPService) AddLocal ¶ added in v0.8.0
AddLocal attaches the VPS to the account private (local) network. The local IP is assigned by SpaceWeb — read it back via Info or WaitForLocalIP. This is the declarative way to put an EXISTING VPS on the private network (no re-create).
func (*IPService) EditPtr ¶ added in v0.11.0
EditPtr sets the PTR (reverse-DNS) record for an IP (method "editPtr"). An empty ptr resets it to the provider default. Action 1/0 result.
func (*IPService) GetPtr ¶ added in v0.11.0
GetPtr returns the PTR (reverse-DNS) record for an IP (method "getPtr"). Read-only. Tolerates the record arriving as a bare string or a {"ptr": …} object.
func (*IPService) Info ¶ added in v0.8.0
Info returns the IP inventory for a VPS (method "index"). Read-only.
func (*IPService) Move ¶ added in v0.11.0
Move attaches an IP to a VPS, or detaches it when billingID is empty (method "move"; the API takes billingId=null to detach). Action 1/0 result.
func (*IPService) Remove ¶ added in v0.11.0
Remove releases a public IP from a VPS (method "remove"). Action 1/0 result.
func (*IPService) RemoveLocal ¶ added in v0.8.0
RemoveLocal detaches the VPS from the private (local) network.
func (*IPService) WaitForLocalIP ¶ added in v0.8.0
func (s *IPService) WaitForLocalIP(ctx context.Context, billingID string, interval time.Duration) (LocalIP, error)
WaitForLocalIP polls Info until the VPS reports a local IP (attachment can be asynchronous), returning the first one, or until ctx is done.
type IPVPSInfo ¶ added in v0.8.0
type IPVPSInfo struct {
BillingID string `json:"billingId"`
CurrentAction string `json:"currentAction"` // string|null
IsEmpty string `json:"isEmpty"` // "0" once the OS is installed
OrderedIPCount FlexInt `json:"ordered_ip_count"`
}
IPVPSInfo is the VPS summary embedded in the IP index.
type ISPInfo ¶ added in v0.3.0
type ISPInfo struct {
LicenseType string `json:"license_type"`
IP string `json:"ip"`
ActiveUntil string `json:"active_until"`
Price FlexFloat `json:"price"`
Link string `json:"link"`
IsBlocked FlexInt `json:"is_blocked"`
CreationTime string `json:"creation_time"`
}
ISPInfo is control-panel (ISP license) info attached to a VPS ("isp" in the index response).
type LocalIP ¶ added in v0.8.0
LocalIP is a VPS's attachment to the account private (local) network.
type LocalIPList ¶ added in v0.8.2
type LocalIPList []LocalIP
LocalIPList is []LocalIP that also decodes a bare object or null (SpaceWeb returns local_ip as [] when unattached, a single object when attached).
func (*LocalIPList) UnmarshalJSON ¶ added in v0.8.2
func (l *LocalIPList) UnmarshalJSON(b []byte) error
UnmarshalJSON accepts an array, a single object, or null.
type MXRecord ¶ added in v0.13.0
type MXRecord struct {
Index int
Priority int
Value string // mail server
SubDomain string // subdomain if not for the main domain
}
MXRecord addresses an MX record for editMx.
type MainRecord ¶ added in v0.13.0
type MainRecord struct {
Index int // record id for edit/remove
Name string // subdomain name, or "" for the apex
Type string // A, AAAA, CNAME, MX, TXT, …
Value string
Prefix string // "префикс или TTL записи"; the apidoc example sends a bare int
}
MainRecord addresses a general zone record (A/AAAA/CNAME/…) for editMain.
type MoveItem ¶ added in v0.14.0
type MoveItem struct {
FQDN string `json:"fqdn"`
ProlongType string `json:"prolongType"` // ProlongNo, ProlongManual, ProlongBonusMoney
Dir string `json:"dir,omitempty"`
}
MoveItem is one domain for MoveList.
type OSOption ¶
type OSOption struct {
ID string `json:"id"`
Name string `json:"name"`
Version string `json:"version"`
OSDistributionID string `json:"os_distribution_id"`
PlanID string `json:"plan_id"`
}
OSOption is a selectable OS image.
type OSPanel ¶
type OSPanel struct {
Distributive string `json:"distributive"`
OS string `json:"os"`
Panel string `json:"panel"`
AvailablePlanIDs []int `json:"availablePlanIds"`
MinRAM int `json:"minRam"`
MinStorage int `json:"minStorage"`
}
OSPanel maps a distributive/OS to the plans and minimum resources it needs.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithBaseURL ¶
WithBaseURL overrides the API root (useful for tests / staging).
func WithCredentials ¶ added in v0.1.3
WithCredentials enables transparent token refresh: when a call fails because the session token expired, the client exchanges login+password for a fresh token (getToken) and retries once. Pair with WithOnTokenRefresh to persist it.
func WithHTTPClient ¶
WithHTTPClient injects a custom *http.Client (timeouts, transport, test server).
func WithOnTokenRefresh ¶ added in v0.1.3
WithOnTokenRefresh registers a callback invoked with the new token whenever the client refreshes it — e.g. to cache it in an OS keyring.
type PackageDomain ¶ added in v0.14.0
type PackageDomain struct {
Name string `json:"name"` // encoded name
NameReadable string `json:"name_readable"` // readable name
}
PackageDomain is one member domain of a DomainPackage.
type ProlongConfirm ¶ added in v0.14.0
type ProlongConfirm struct {
Domain string `json:"domain"` // readable domain name
Confirm bool `json:"confirm"` // whether to show a confirmation dialog
Price FlexInt `json:"price"` // prolongation price
Link string `json:"link"` // extra-info URL, null → ""
}
ProlongConfirm carries the prolongation-dialog details from DomainInfo.
type ProlongItem ¶ added in v0.14.0
type ProlongItem struct {
Domain string `json:"domain"`
ProlongType string `json:"prolongType"` // ProlongNo, ProlongManual, ProlongBonusMoney
}
ProlongItem is one domain for ChangeProlongList.
type RegisterOptions ¶ added in v0.14.0
type RegisterOptions struct {
Domain string
PayType string // PayBalance or PayBonus
DomPerson int // domain-person (registrant contact) id
ProlongType string // ProlongNone, ProlongBonusMoney, ProlongManual
AutoReg int // auto-registration flag
Dir string // relative site directory
IDShield bool // hide WHOIS
}
RegisterOptions parameterizes Register ("reg").
type RemoteBackup ¶ added in v0.12.0
type RemoteBackup struct {
ID FlexInt `json:"id"`
BillingID string `json:"billing_id"`
DiskSize FlexInt `json:"disk_size"`
Size FlexInt `json:"size"`
Status string `json:"status"`
OSDistributionID string `json:"os_distribution_id"`
Price FlexFloat `json:"price"`
Name string `json:"name"`
Comment string `json:"comment"`
TSCreate string `json:"ts_create"`
}
RemoteBackup is one cloud backup, as returned by List. ID is the key the edit/restore/remove methods take.
type RemoteBackupService ¶ added in v0.12.0
type RemoteBackupService struct {
// contains filtered or unexported fields
}
RemoteBackupService groups cloud (off-node) backup operations (endpoint /vps/remoteBackup): list/create/remove, edit the comment, and restore into the source or a different VPS.
func (*RemoteBackupService) Create ¶ added in v0.12.0
func (s *RemoteBackupService) Create(ctx context.Context, billingID, name, comment string) (json.RawMessage, error)
Create takes a new cloud backup of a VPS (method "create"). Like the VPS create, the result shape is left raw pending a recorded response — read the new backup back via List.
func (*RemoteBackupService) EditComment ¶ added in v0.12.0
func (s *RemoteBackupService) EditComment(ctx context.Context, remoteBackupID int, comment string) error
EditComment updates a cloud backup's comment (method "editComment").
func (*RemoteBackupService) List ¶ added in v0.12.0
func (s *RemoteBackupService) List(ctx context.Context) ([]RemoteBackup, error)
List returns all cloud backups on the account (method "index"). Read-only.
func (*RemoteBackupService) Remove ¶ added in v0.12.0
func (s *RemoteBackupService) Remove(ctx context.Context, remoteBackupID int) error
Remove deletes a cloud backup (method "remove").
func (*RemoteBackupService) Restore ¶ added in v0.12.0
func (s *RemoteBackupService) Restore(ctx context.Context, remoteBackupID int) error
Restore restores a cloud backup into its source VPS (method "restore"). DESTRUCTIVE — overwrites the source disk.
func (*RemoteBackupService) RestoreInto ¶ added in v0.12.0
func (s *RemoteBackupService) RestoreInto(ctx context.Context, remoteBackupID int, billingID string) error
RestoreInto restores a cloud backup into a DIFFERENT VPS (method "restoreInto"). DESTRUCTIVE — overwrites the target disk.
type SRVRecord ¶ added in v0.13.0
type SRVRecord struct {
Index int
Priority int
TTL int
Weight int
Target string
Service string
Protocol string
Port int
SubDomain string
}
SRVRecord addresses an SRV record for editSrv.
type Subdomain ¶ added in v0.14.0
type Subdomain struct {
Machine string `json:"machine"` // encoded name (e.g. "*")
MachineReadable string `json:"machine_readable"` // readable name
FQDN string `json:"fqdn"` // full encoded name incl. domain
FQDNReadable string `json:"fqdn_readable"` // full readable name
ParentFQDN string `json:"parent_fqdn"` // parent domain (encoded)
ParentFQDNReadable string `json:"parent_fqdn_readable"`
Docroot string `json:"docroot"` // home directory
SiteAlias string `json:"siteAlias"` // site name in the control panel
}
Subdomain is a subdomain as nested under a Domain in the "index" result.
type SubdomainRef ¶ added in v0.14.0
type SubdomainRef struct {
Value string `json:"value"` // encoded name
Name string `json:"name"` // readable name
}
SubdomainRef is one entry from "getSubdomains": encoded value + readable name.
type VPS ¶
type VPS struct {
BillingID string `json:"billingId"`
Name string `json:"name"` // user-facing alias
UID string `json:"uid"` // stable unique id
PlanID FlexInt `json:"plan_id"`
PlanName string `json:"plan_name"`
ParentPlanID FlexInt `json:"parent_plan_id"` // nullable
PlanPrice FlexFloat `json:"plan_price"` // money, may be fractional
CPU FlexInt `json:"cpu"`
RAM FlexInt `json:"ram"` // MB; API may quote it ("1024")
Disk string `json:"disk"` // localized human size, e.g. "10 ГБ"
BlockUI FlexInt `json:"blockUi"`
Active FlexInt `json:"active"`
OSDistribution string `json:"os_distribution"`
OSDistrID FlexInt `json:"os_distr_id"`
Category string `json:"category"`
TSCreate string `json:"ts_create"`
MAC string `json:"mac"`
IP string `json:"ip"`
LocalIP string `json:"local_ip"` // nullable
LocalMAC string `json:"local_mac"` // nullable
LocalMask string `json:"local_mask"`
CurrentAction string `json:"current_action"`
IsRunning FlexInt `json:"is_running"`
ISP []ISPInfo `json:"isp"`
ExtIPs []json.RawMessage `json:"ext_ips"` // TODO: type once a populated example exists (doc: array of IP objects)
IsTest FlexInt `json:"is_test"`
IsNew bool `json:"is_new"`
Datacenter string `json:"datacenter"`
OrderedIPCount FlexInt `json:"ordered_ip_count"`
ProtectedIPs []string `json:"protected_ips"`
// Not part of the documented index response — present in an earlier recorded
// response and still consumed by the Terraform provider's computed mapping
// (disk size, datacenter id). Kept until the provider reconcile (variant B);
// index does not populate these, so they decode to zero here.
DiskGB int `json:"diskGb"`
DatacenterID string `json:"datacenter_id"`
PasswordAccess bool `json:"password_access"`
SSHKeys []SSHKeyRef `json:"ssh_keys"`
Features VPSFeatures `json:"features"`
}
VPS is a VPS instance as returned by List (method "index").
Types are reconciled against a real API response: SpaceWeb returns many numeric fields either as numbers or quoted strings (FlexInt/FlexFloat handle both), and nullable fields (parent_plan_id, local_*) as JSON null.
type VPSFeatures ¶
type VPSFeatures struct {
AllowBackups bool `json:"allowBackups"`
AllowLocalNetwork bool `json:"allowLocalNetwork"`
AllowCustomImage bool `json:"allowCustomImage"`
AllowDdosProtection bool `json:"allowDdosProtection"`
MaxIPCount int `json:"maxIpCount"`
AllowConfigurator bool `json:"allowConfigurator"`
AllowAccess bool `json:"allowAccess"`
AllowDiskConnection bool `json:"allowDiskConnection"`
AllowAutoBackups bool `json:"allowAutoBackups"`
AllowClone bool `json:"allowClone"`
}
VPSFeatures are capability flags for a VPS / plan.
type VPSLogEntry ¶ added in v0.10.0
type VPSLogEntry struct {
Type string `json:"type"`
Status string `json:"status"`
StartedAt string `json:"started_at"`
EndedAt string `json:"ended_at"`
}
VPSLogEntry is one entry of a VPS's operation log (method "logs"). Field names follow the documented shape (type/status/started_at/ended_at); the call is read-only, so the struct is reconciled from the docs pending a recorded response — unknown fields simply decode to zero.
type VPSPlan ¶
type VPSPlan struct {
ID int `json:"id"`
Name string `json:"name"`
PricePerMonth float64 `json:"price_per_month"` // money: API returns fractional prices
Category string `json:"category"`
CPUCores string `json:"cpu_cores"`
RAM string `json:"ram"`
DiskType string `json:"disk_type"`
VolumeDisk string `json:"volume_disk"`
Datacenters []int `json:"datacenters"`
SoldOut bool `json:"sold_out"`
}
VPSPlan is a purchasable VPS plan. Note SpaceWeb returns several numeric-ish fields (cpu_cores, ram, volume_disk) as strings.
type VPSService ¶
type VPSService struct {
// contains filtered or unexported fields
}
VPSService groups VPS operations. All calls hit the /vps endpoint with a JSON-RPC method.
func (*VPSService) AvailableConfig ¶
func (s *VPSService) AvailableConfig(ctx context.Context) (*AvailableConfig, error)
AvailableConfig returns the catalog of selectable VPS options (method "getAvailableConfig"): plans, OS images, datacenters, categories.
func (*VPSService) ChangePlan ¶ added in v0.5.0
ChangePlan changes a VPS's tariff plan in place (method "changePlan") — a resize without reprovisioning. billingID is the service id ("login_vps_N"); vpsPlanID is a plan id (from AvailableConfig, or GetConstructorPlanID for a custom configuration). The API returns 1 on success, 0 on failure (surfaced here as an error).
NOTE: the parameter is "planId" (per the docs' parameter table). The docs' EXAMPLE instead shows "vpsPlanId" (as in Create), but the API rejects that with -32602 "Invalid method parameter(s)" — confirmed live. NOTE: the resize is asynchronous — poll List / current_action until it settles.
func (*VPSService) Copy ¶ added in v0.10.0
func (s *VPSService) Copy(ctx context.Context, billingID string, vpsPlanID int) (json.RawMessage, error)
Copy clones a VPS into a new one on the given plan (method "copy"). billingID is the source; vpsPlanID is the new VPS's plan (from AvailableConfig, or GetConstructorPlanID for a custom configuration). Like Create, this provisions a NEW, billed VPS and runs asynchronously — the result shape is left raw pending a recorded response; find the new node via List once it settles.
func (*VPSService) Create ¶
func (s *VPSService) Create(ctx context.Context, req CreateVPSRequest) (json.RawMessage, error)
Create provisions a new VPS (method "create").
The result shape is intentionally left raw: "create" mutates (and bills), so it was not exercised during the Evidence phase. Type it once a real create response is recorded.
func (*VPSService) GetConstructorPlanID ¶ added in v0.1.4
func (s *VPSService) GetConstructorPlanID(ctx context.Context, cpuCores, ramGB, diskGB, categoryID int) (int, error)
GetConstructorPlanID resolves a custom ("configurator") plan ID for the given resources via the "getConstructorPlanId" method. ram and disk are in GB; categoryID is a catalog category id (see AvailableConfig.Categories). This is read-only — it neither creates nor bills; feed the result to Create as the VPSPlanID.
func (*VPSService) GetFirstOrderInfo ¶ added in v0.4.0
func (s *VPSService) GetFirstOrderInfo(ctx context.Context) (*FirstOrderInfo, error)
GetFirstOrderInfo returns the account's first-order info (method "getFirstOrderInfo"), or nil if there is no first order.
The API double-wraps the payload: the outer result is a one-element array whose element is itself a JSON-RPC envelope, so the object lives at result[0].result. This unwraps it.
func (*VPSService) IsRunning ¶ added in v0.9.0
IsRunning reports whether the VPS is powered on (method "isRunning"). Read-only. Note List already carries VPS.IsRunning for every node; this is the cheaper single-VPS query when only the power state is needed.
func (*VPSService) List ¶
func (s *VPSService) List(ctx context.Context) ([]VPS, error)
List returns all VPS instances (method "index").
func (*VPSService) Logs ¶ added in v0.10.0
func (s *VPSService) Logs(ctx context.Context, billingID string) ([]VPSLogEntry, error)
Logs returns the VPS's operation log (method "logs") — the record of lifecycle actions (create, reinstall, resize, …) run against the node. Read-only.
func (*VPSService) PowerOff ¶ added in v0.9.0
func (s *VPSService) PowerOff(ctx context.Context, billingID string) error
PowerOff shuts a running VPS down (method "powerOff"). Asynchronous — see PowerOn.
func (*VPSService) PowerOn ¶ added in v0.9.0
func (s *VPSService) PowerOn(ctx context.Context, billingID string) error
PowerOn boots a stopped VPS (method "powerOn"). The power change is asynchronous: the API accepts the request (returns 1) and the machine settles over the following seconds — poll IsRunning, or WaitForIdle for the current_action to clear. A JSON-RPC error (or a 0 result) surfaces as an error.
func (*VPSService) Reboot ¶ added in v0.9.0
func (s *VPSService) Reboot(ctx context.Context, billingID string) error
Reboot restarts a VPS (method "reboot"). Asynchronous — see PowerOn.
func (*VPSService) ReinstallOS ¶ added in v0.10.0
func (s *VPSService) ReinstallOS(ctx context.Context, billingID string, distributiveID int, keepDisk bool) error
ReinstallOS reinstalls the VPS's operating system (method "reinstallOs") to the given distributive (see AvailableConfig.SelectOS for the ids). This is DESTRUCTIVE — it wipes the system disk unless keepDisk is set (the API's save_disk flag). It runs asynchronously; poll WaitForIdle to await the rebuild. The API answers 1 on acceptance (0 = failure).
func (*VPSService) Remove ¶ added in v0.1.2
func (s *VPSService) Remove(ctx context.Context, billingID string) (json.RawMessage, error)
Remove deletes a VPS (method "remove"). billingID is the service identifier (format "login_vps_N"), as returned in VPS.BillingID by List.
This is destructive — it cancels the VPS. The result shape is left raw pending a recorded response.
func (*VPSService) Rename ¶ added in v0.2.0
func (s *VPSService) Rename(ctx context.Context, billingID, alias string) error
Rename changes a VPS's user-facing name/alias (method "rename"). billingID is the service identifier ("login_vps_N"); alias is the new name. This is an in-place label change — it does not reprovision or bill. The API returns 1 on success; a JSON-RPC error surfaces as *Error.
func (*VPSService) WaitForIdle ¶ added in v0.7.0
func (s *VPSService) WaitForIdle(ctx context.Context, billingID string, poll time.Duration, onPhase func(action string)) (*VPS, error)
WaitForIdle polls the VPS until its current_action is empty. SpaceWeb runs a resize / provisioning as a SEQUENCE of async actions (e.g. Modify → ExtIpAdd — an IP re-issue runs even when no extra IP was ordered), and is_running stays 1 throughout — so "settled" means current_action is idle, NOT is_running == 1.
poll is the interval between checks (default 10s). onPhase, if non-nil, is called each poll with the current action (trimmed; "" once idle) — a CLI can render it as progress. Honors ctx for cancellation / timeout; wrap ctx with a deadline to bound the wait.
type ZoneFile ¶ added in v0.13.0
type ZoneFile struct {
Mimetype string `json:"mimetype"`
Metadata json.RawMessage `json:"metadata"` // [] in observed responses; shape not yet pinned
Content string `json:"content"`
Name string `json:"name"`
}
ZoneFile is the raw BIND-style zone file returned by "getFile".