context.Context as the first parameter and return Go-idiomatic (result, error) pairs.
ProvisionCVM
POST /cvms
Provisions a new CVM by reserving resources and generating a compose hash. This is the first step of the two-phase deployment flow. The returned AppID and ComposeHash are needed to commit the provision.
Additional typed fields include
KMSContractID, AppID, EnvKeys, Ports, GPUs, EncryptedEnv, and UserConfig. ComposeFile also supports fields such as Runner, BashScript, AllowedEnvs, Requirements, and PortPolicy.
ProvisionCVMRequest.KMSType and ProvisionCVMRequest.SSHAuthorizedKeys remain in the Go type, but the current backend ignores these top-level fields. Use KMS to select the KMS type and SSHKeyIDs to authorize registered SSH keys.
For slice fields with omitzero, a nil slice is omitted and an explicitly empty slice is sent as [].
ComposeFile.EncryptedEnv has been removed. For creation, set ProvisionCVMRequest.EncryptedEnv instead. For changes to a CVM’s encrypted environment, use UpdateCVMEnvs.
ComposeFile.InitScript uses ComposeInitScripts, a string slice. It decodes historical single-string and array responses and encodes as an array. The server ignores compose_file.init_script during creation; use ProvisionCVMRequest.InitScripts to select platform-owned scripts.
Returns: *ProvisionCVMResponse with AppID, ComposeHash, AppEnvEncryptPubkey, and other provisioning details.
Example:
CommitCVMProvision
POST /cvms
Commits a provisioned CVM, triggering deployment. Pass the provision response’s Token, or supply its AppID and ComposeHash.
Returns:
*CommitCVMProvisionResponse with ID, Name, and Status. Use the CvmID() helper method to get the ID as a string.
Example — full two-phase deploy:
StartCVM
POST /cvms/{cvmId}/start
Starts a stopped CVM. This method retries automatically on transient errors.
Returns:
*CVMActionResponse with ID, Name, and Status.
StopCVM
POST /cvms/{cvmId}/stop
Force-stops a CVM immediately. Use ShutdownCVM if you need a graceful stop.
Returns:
*CVMActionResponse
ShutdownCVM
POST /cvms/{cvmId}/shutdown
Gracefully shuts down a CVM, allowing containers to stop cleanly before powering off.
Returns:
*CVMActionResponse
RestartCVM
POST /cvms/{cvmId}/restart
Restarts a CVM. By default, the restart is graceful. Set Force: true to skip the graceful shutdown phase.
RestartCVMOptions fields:
DeleteCVM
DELETE /cvms/{cvmId}
Permanently deletes a CVM and all its data. Returns only an error (no response body).
ReplicateCVM
POST /cvms/{cvmId}/replicas
Creates a replica of an existing CVM. You can optionally target a specific node. The new CVM inherits the source’s configuration.
ReplicateCVMOptions fields:
You can also replicate a CVM within an app context using
ReplicateAppCVM(ctx, appID, vmUUID, opts), which ensures the replica is associated with the correct application.
