Ucloud Api Skill
by @mingming-cn
Invoke UCloud APIs through the official Python SDK. Use when an AI agent needs to inspect, create, update, or delete UCloud resources by calling real UCloud...
clawhub install ucloudπ About This Skill
name: ucloud-api description: Invoke UCloud APIs through the official Python SDK. Use when an AI agent needs to inspect, create, update, or delete UCloud resources by calling real UCloud OpenAPI actions such as UHost (CVM cloud host), ULB, VPC, EIP, UDB, or other services, especially when the user wants the agent to execute cloud operations instead of only describing them.
UCloud API
Use the bundled script to call UCloud OpenAPI through ucloud-sdk-python3. Prefer this skill when the user wants actual cloud operations, resource inspection, or parameterized automation against a UCloud account.
Preconditions
ucloud SDK package to be installed in the execution environment.UCLOUD_PUBLIC_KEY
- UCLOUD_PRIVATE_KEY
UCLOUD_PROJECT_ID
- UCLOUD_REGION
- UCLOUD_ZONE
- UCLOUD_BASE_URLIf the SDK is missing, stop and either install it with user approval or explain that the environment is not ready for live API calls. If credentials, target identifiers, region, zone, project, or action-specific parameters are missing, ask the user for the exact missing items, parse the reply into the request payload, and then continue the execution flow.
Source Priority
Use sources in this order when deciding how to invoke an API:
1. SDK code and examples in ucloud-sdk-python3
2. UCloud API documentation for action names, required parameters, and response fields
3. UCloud product documentation for product semantics, region or deployment constraints, and resource concepts
4. UCloud tools documentation for cross-checking SDK or CLI naming and usage patterns
If the SDK does not expose enough information to choose the correct action, required fields, or resource scope, consult the official docs before asking the user or executing a request.
Product Naming
UHost as the UCloud cloud host product.CVM, ECS, EC2, VM, δΊδΈ»ζΊ, δΊζε‘ε¨, or similar cloud VM wording as requests for UHost unless the context clearly points to another product.UHost actions and product documentation for these cloud host requests.Invocation Flow
1. Translate the user request into either:
- a service and SDK method pair such as ulb + describe_ulb
- a raw OpenAPI action such as DescribeULB
2. Check the SDK and, if needed, official UCloud docs to determine the correct action, required parameters, and whether ProjectId, Region, or Zone are needed.
3. Check whether credentials, target resource identifiers, and action-specific required fields are present.
4. If any required information is missing, ask the user a concise follow-up question that lists only the missing fields.
5. Parse the user reply into structured values and merge them into the JSON payload.
6. Add ProjectId, Region, or Zone only when the API needs them and the user or environment provides them.
7. Run scripts/invoke_ucloud.py.
8. Review the JSON response before taking a follow-up destructive action.
Choose the Call Mode
Use SDK method mode first when the service client and method are obvious from the SDK naming:
python ./scripts/invoke_ucloud.py \
--service ulb \
--method describe_ulb \
--data '{"ULBId":"ulb-xxxx"}'
Use raw action mode when the SDK helper is unclear or absent:
python ./scripts/invoke_ucloud.py \
--action DescribeULB \
--data '{"ULBId":"ulb-xxxx"}'
Working Rules
Region, ProjectId, ULBId.--data-file instead of long inline JSON when the payload is large.Region, ProjectId, ULBId, or credentials.Creation Defaults
ubuntu for Ubuntu images. Use root for Debian, RedHat, and Rocky images unless the image metadata or product docs state otherwise.Missing Information Handling
UCLOUD_PUBLIC_KEY and UCLOUD_PRIVATE_KEY, unless the user prefers to set them as environment variables directly.
ProjectId, Region, or Zone only if the chosen action requires them and they are not already available from the environment.
ULBId, EIPId, VPCId, InstanceId, or another action-specific ID.
Error Handling
ProjectId, or switching from unclear SDK helper mode to raw action mode after verification.299 IAM permission error, first check the API definition to determine whether ProjectId is a required parameter.ProjectId and the request did not include it, treat 299 as a likely missing-ProjectId problem. Resolve or ask for ProjectId, then retry.ProjectId and the request already included it, or if the API does not require ProjectId, treat 299 as a real permission problem.Common Lookup APIs
When common parameters are missing, use these APIs for discovery before asking the user:
ListRegions: query available regions when Region is missing or the user gives only a city or product name.ListZones: query available zones when Zone is missing and the chosen region is known or can be inferred.GetProjectList: query accessible projects when ProjectId is missing.GetBalance: query account balance before create flows when quota or billing readiness may matter.Use these lookup APIs to narrow the missing values first. If multiple valid options remain after lookup, present the short list to the user and ask them to choose.
Use scripts/resolve_common_params.py to automate these lookups before asking the user.
Script Usage
Inline JSON
python ./scripts/invoke_ucloud.py \
--action DescribeInstance \
--data '{"Region":"cn-bj2"}'
JSON file
python ./scripts/invoke_ucloud.py \
--service cvm \
--method describe_instance \
--data-file ./request.json
Override credentials or endpoint
python ./scripts/invoke_ucloud.py \
--action DescribeULB \
--public-key "$UCLOUD_PUBLIC_KEY" \
--private-key "$UCLOUD_PRIVATE_KEY" \
--base-url https://api.ucloud.cn \
--data '{"ProjectId":"org-xxx"}'
Generate an alphanumeric password
python ./scripts/generate_password.py --length 20
Resolve common parameters
python ./scripts/resolve_common_params.py \
--need region \
--need zone \
--need project \
--region-hint beijing
Resolve balance only
python ./scripts/resolve_common_params.py --need balance
References
references/sdk-usage.md for the SDK calling pattern and environment conventions.references/doc-sources.md for the documentation lookup order and URL entry points.references/common-lookups.md for the shared discovery APIs used to fill missing public parameters.references/error-handling.md for the 299 IAM permission error decision rule.