update_* method targets a single aspect of the CVM and calls a dedicated API endpoint. patch_cvm is the unified method that can update multiple fields in a single request. Use patch_cvm when you need to change several settings atomically; use the individual update_* methods when you only need to change one thing.
update_docker_compose
PATCH /cvms/{cvmId}/docker-compose
Updates the Docker Compose configuration for a CVM. If the CVM has on-chain hash verification enabled, you need to pass compose_hash and transaction_hash.
Parameters:
Returns:
InProgressResponse on success, or ComposeHashPreconditionResponse if on-chain verification is needed.
Example:
update_cvm_envs
PATCH /cvms/{cvmId}/envs
Updates encrypted environment variables for a CVM. Environment variables must be encrypted using the KMS public key before being sent.
Parameters:
Returns:
InProgressResponse on success, or precondition response if on-chain verification is needed.
Example:
update_pre_launch_script
PATCH /cvms/{cvmId}/pre-launch-script
Updates the pre-launch script that runs before Docker containers start.
Parameters:
Returns:
InProgressResponse on success.
get_cvm_docker_compose
GET /cvms/{cvmId}/docker-compose.yml
Retrieves the current Docker Compose YAML for a CVM as a raw string.
Parameters:
Returns:
str — Docker Compose YAML content.
Example:
get_cvm_compose_file
GET /cvms/{cvmId}/compose_file
Retrieves the compose file with metadata (including hash info and structure).
Parameters:
Returns: Compose file response with metadata.
update_cvm_resources
PATCH /cvms/{cvmId}/resources
Changes the resource allocation (CPU, memory, disk, instance type) for a CVM.
Parameters:
Returns:
None
Example:
update_cvm_visibility
PATCH /cvms/{cvmId}/visibility
Controls which CVM information is publicly accessible.
Parameters:
Returns: Visibility settings response.
Example:
update_os_image
PATCH /cvms/{cvmId}/os-image
Changes the OS image for a CVM.
Parameters:
Returns:
None
Example:
get_available_os_images
GET /cvms/{cvmId}/available-os-images
Lists OS images available for a specific CVM. The available images depend on the CVM’s node and configuration.
Parameters:
Returns: List of available OS image objects.
patch_cvm
PATCH /cvms/{cvmId}
A batch update method that can modify multiple CVM fields in a single request. This is useful when you need to change several settings atomically.
Parameters:
Returns: A dict with
requires_on_chain_hash (bool) and either correlation_id or on-chain hash details.
If the patch changes compose-hash-relevant fields, the response may include
requires_on_chain_hash: True with hash details that need on-chain verification. Use confirm_cvm_patch to complete the update.Compose File Update Flow
For updates that require on-chain hash verification, the SDK provides a two-step flow similar to CVM provisioning:provision_cvm_compose_file_update
POST /cvms/{cvmId}/compose_file/provision
Provisions a compose file update and returns the new compose hash.
commit_cvm_compose_file_update
PATCH /cvms/{cvmId}/compose_file
Commits the compose file update with the verified hash.
Related
- CVM Lifecycle — provisioning and managing CVMs
- KMS — encryption keys for environment variables

