context.Context as the first parameter and return Go-idiomatic (result, error) pairs.
ProvisionCVM
POST /cvms/provision
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.
Returns:
*ProvisionCVMResponse with AppID, ComposeHash, AppEnvEncryptPubkey, and other provisioning details.
Example:
CommitCVMProvision
POST /cvms
Commits a provisioned CVM, triggering the actual deployment. You must pass the AppID and ComposeHash from the provision step.
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.
