ByteDC Cloud API
Manage servers, disks, networks, public IPs and private DNS on ByteDC Cloud from your own code or scripts. Everything you can do here, you can also do in the console at console.bytedc.com.
86 endpoints84 verified
Base URL:
https://api.bytedc.com/hcs
Requests and responses are JSON over HTTPS. The paths and request bodies follow the Huawei Cloud Stack 8.5 APIs, so existing tools and code written for those APIs usually work after you change the base URL.
Resources you create through the API belong to your account just like resources created in the console. They are charged under your ByteDC agreement in the same way.
Before you start
You need three things from your ByteDC Cloud account:
| What | Where to find it |
|---|---|
| Access key (AK) and secret key (SK) | In the console, open My Settings → Access Keys and add a key. The key file downloads once and cannot be shown again, so keep it somewhere safe. Each user can have two keys. |
| Project ID | In the console, open My Settings → Resource Spaces. The ID is a 32-character string. Each resource space is a separate project. |
| Permissions | The API can do exactly what the user who owns the key can do in the console. Use a user with only the rights your code needs. |
Get a token
Send your access key to the token endpoint. The token comes back in the X-Subject-Token response header and is valid for 24 hours. Reuse it until it expires instead of asking for a new one on every call.
curl -si -X POST https://api.bytedc.com/hcs/iam/v3/auth/tokens \
-H 'Content-Type: application/json' \
-d '{
"auth": {
"identity": {
"methods": ["hw_ak_sk"],
"hw_ak_sk": {
"access": {"key": "YOUR_AK"},
"secret": {"key": "YOUR_SK"}
}
},
"scope": {"project": {"id": "YOUR_PROJECT_ID"}}
}
}' | grep -i x-subject-token
A successful call returns 201 Created. The response body tells you when the token expires (token.expires_at) and which project it is for (token.project.id).
The hw_ak_sk method is how ByteDC Cloud exchanges an access key for a token. It may not appear in the general Huawei Cloud Stack reference, but it is the supported way to use this API.
Making requests
Put the token in the X-Auth-Token header of every call. Paths that contain {p} need your project ID in that position, and it must match the project the token was issued for.
curl -s https://api.bytedc.com/hcs/ecs/v1/YOUR_PROJECT_ID/cloudservers/detail?offset=1&limit=50 \
-H "X-Auth-Token: $TOKEN"
Some actions take a while, for example creating, resizing or deleting a server. They answer straight away with a job_id. Check progress with GET /hcs/ecs/v1/{p}/jobs/{jid} until the status is SUCCESS or FAIL. Every response carries an X-Request-Id header. Include it when you contact us about a call.
Example: a server from scratch
A typical first build, in order. Each step uses an ID from the step before.
| Step | Call | You get |
|---|---|---|
| 1. Pick a size, image and zone | flavors, images, zones | flavorRef, imageRef, availability_zone |
| 2. Create a network | VPC, then subnet | vpc_id, subnet id |
| 3. Open the ports you need | security group, then rules | security group id |
| 4. Create the server | create server, then job status | server id |
| 5. Give it a public address | public IP, bound to the server's port from interfaces | public IP address |
A create-server body looks like this:
{
"server": {
"name": "web-01",
"imageRef": "IMAGE_ID",
"flavorRef": "FLAVOR_ID",
"vpcid": "VPC_ID",
"nics": [{"subnet_id": "SUBNET_ID"}],
"security_groups": [{"id": "SECURITY_GROUP_ID"}],
"root_volume": {"volumetype": "SSD", "size": 40},
"availability_zone": "ZONE",
"key_name": "my-key",
"count": 1
}
}
Use key_name for an SSH key pair, or adminPass for a password. To run a script at first boot, add user_data as base64.
Limits
| Limit | Value | When you go over |
|---|---|---|
| Calls per token | 600 per minute | 429 Too Many Requests. Wait and retry. |
| Token requests per client IP | 20 per minute | 429. Reuse your token instead of asking for a new one. |
| Request body size | 64 KB | 413. Mostly relevant for large user_data scripts. |
| Resource quotas | Set per account | The call fails with a quota error. Check your quota or ask us to raise it. |
Errors
| Status | Meaning |
|---|---|
| 400 | The request is not valid. The body has a code and a message that say why. |
| 401 | The token is missing, wrong or expired. Get a new one. |
| 403 | Your user does not have permission for this action in this project. |
| 404 | The resource does not exist, or the endpoint is not part of this API. Only the endpoints listed in the reference below are available. |
| 409 | Conflict with the current state, for example deleting a subnet that still has servers in it, or a public IP pool that has no free addresses. |
| 429 | Too many calls. See Limits. |
| 5xx | Something went wrong on our side. Retry with a delay. If it keeps happening, send us the X-Request-Id. |
About Preview
The API is new. Endpoints marked Verified have been run end to end on ByteDC Cloud. Endpoints marked Preview are available and follow the same rules, but we are still checking them one by one. They may change, so try them on a test project first. As each one passes, the label changes to Verified.
Authentication
Exchange your access key for a token. Every other call needs that token.
/hcs/iam/v3/auth/tokensVerifiedGet a token from your access key (AK/SK).
Success
201
Catalog
What you can build with: server sizes, operating system images, zones, disk types and your quota.
/hcs/ecs/v2.1/{p}/flavors/detailVerifiedList server sizes (flavors) with vCPU and memory.
/hcs/ims/v2/cloudimagesVerifiedList operating system images you can use.
/hcs/ecs/v2/{p}/os-availability-zoneVerifiedList availability zones.
/hcs/evs/v2/{p}/typesVerifiedList disk types.
/hcs/ecs/v1/{p}/cloudservers/limitsVerifiedShow your server quota and how much is used.
Cloud servers
Create, change and remove servers. Creating, resizing and deleting run as background jobs.
/hcs/ecs/v1/{p}/cloudserversVerifiedCreate one or more servers.
Success
200 · runs as a background job, see job status
/hcs/ecs/v1/{p}/cloudservers/detailVerifiedList your servers with details.
Paging starts at offset=1. offset=0 returns an empty list.
/hcs/ecs/v1/{p}/cloudservers/{id}VerifiedGet one server.
Success
200
A server that does not exist returns 400 with code Ecs.1000 and the text "could not be found", not 404.
/hcs/ecs/v1/{p}/cloudservers/{id}VerifiedRename a server.
Success
200
/hcs/ecs/v1/{p}/cloudservers/actionVerifiedStart, stop or reboot several servers at once.
Success
200 · runs as a background job, see job status
/hcs/ecs/v1/{p}/cloudservers/deleteVerifiedDelete servers.
Success
200 · runs as a background job, see job status
/hcs/ecs/v1/{p}/cloudservers/{id}/resizeVerifiedChange the size of a server.
Success
200 · runs as a background job, see job status
Pick a target size from the same family as the current one, for example s3.medium.2 to s3.large.2. Stop the server first.
/hcs/ecs/v1/{p}/cloudservers/{id}/os-reset-passwordVerifiedReset the password of a server.
Success
200
/hcs/ecs/v2/{p}/cloudservers/{id}/reinstallosPreviewReinstall the operating system (same image).
Not available for servers built from the Linux public images. Those images support static IP injection, and the platform does not reinstall such a server (error Ecs.0005). Windows public images are not affected.
/hcs/ecs/v2/{p}/cloudservers/{id}/changeosPreviewChange the operating system (new image).
Not available for servers built from the Linux public images. Those images support static IP injection, and the platform does not change the OS of such a server (error Ecs.0005). Windows public images are not affected.
/hcs/ecs/v1/{p}/cloudservers/{id}/os-interfaceVerifiedList the network interfaces of a server.
Success
200
/hcs/ecs/v1/{p}/cloudservers/{id}/nicsVerifiedAdd network interfaces to a server.
Success
200 · runs as a background job, see job status
/hcs/ecs/v1/{p}/cloudservers/{id}/nics/deleteVerifiedRemove network interfaces from a server.
Success
200 · runs as a background job, see job status
/hcs/ecs/v1/{p}/cloudservers/{id}/attachvolumeVerifiedAttach a disk to a server.
Success
200 · runs as a background job, see job status
device is required, for example "/dev/vdb". Without it the call fails with Ecs.0005.
/hcs/ecs/v1/{p}/cloudservers/{id}/detachvolume/{vid}VerifiedDetach a disk from a server.
Success
200 · runs as a background job, see job status
/hcs/ecs/v1/{p}/cloudservers/{id}/block_deviceVerifiedList the disks attached to a server.
Success
200
/hcs/ecs/v1/{p}/jobs/{jid}VerifiedCheck the status of a background job.
Success
200
/hcs/ecs/v2.1/{p}/os-keypairsVerifiedList SSH key pairs.
/hcs/ecs/v2.1/{p}/os-keypairsVerifiedCreate or import an SSH key pair.
Success
200
/hcs/ecs/v2.1/{p}/os-keypairs/{name}VerifiedDelete an SSH key pair.
Success
202
Disks
Block storage volumes you can attach to a server.
/hcs/evs/v2.1/{p}/cloudvolumesVerifiedCreate a disk.
Success
200
/hcs/evs/v2/{p}/cloudvolumes/detailVerifiedList your disks with details.
/hcs/evs/v2/{p}/cloudvolumes/{id}VerifiedGet one disk.
Success
200
/hcs/evs/v2/{p}/volumes/{id}/actionVerifiedExpand a disk.
Success
202
Only expanding is allowed (os-extend). Disks cannot be shrunk.
/hcs/evs/v2/{p}/cloudvolumes/{id}VerifiedDelete a disk.
Success
202
Snapshots and images
Point-in-time copies of a disk, and full images made from a server.
/hcs/evs/v2/{p}/snapshotsVerifiedTake a snapshot of a disk.
Success
202
/hcs/evs/v2/{p}/snapshots/detailVerifiedList snapshots.
/hcs/evs/v2/{p}/snapshots/{id}VerifiedGet one snapshot.
Success
200
/hcs/evs/v2/{p}/snapshots/{id}VerifiedDelete a snapshot.
Success
202
/hcs/evs/v2/{p}/os-vendor-snapshots/{id}/rollbackVerifiedRoll a disk back to a snapshot.
Success
202
/hcs/ims/v2/cloudimages/actionVerifiedCreate an image from a server.
Success
200 · runs as a background job, see job status
A new server needs a few minutes after creation before you can make an image from it. Until then the call is refused; wait and try again.
/hcs/ims/v2/cloudimagesVerifiedDelete one of your private images.
Success
200 · runs as a background job, see job status
Send the image IDs in the body: {"images": ["<image id>"]}, up to 10 per call. The delete runs as a background job; the image disappears from the list when it is done.
Networks
Virtual private clouds, subnets, route tables and network ports.
/hcs/vpc/v1/{p}/vpcsVerifiedCreate a VPC.
Success
200
/hcs/vpc/v1/{p}/vpcsVerifiedList VPCs.
/hcs/vpc/v1/{p}/vpcs/{id}VerifiedGet one VPC.
Success
200
/hcs/vpc/v1/{p}/vpcs/{id}VerifiedUpdate a VPC.
Success
200
/hcs/vpc/v1/{p}/vpcs/{id}VerifiedDelete a VPC.
Success
204
/hcs/vpc/v1/{p}/subnetsVerifiedCreate a subnet.
Success
200
/hcs/vpc/v1/{p}/subnetsVerifiedList subnets.
/hcs/vpc/v1/{p}/subnets/{id}VerifiedGet one subnet.
Success
200
/hcs/vpc/v1/{p}/vpcs/{vid}/subnets/{id}VerifiedUpdate a subnet.
Success
200
/hcs/vpc/v1/{p}/vpcs/{vid}/subnets/{id}VerifiedDelete a subnet.
Success
204
/hcs/vpc/v1/{p}/routetablesVerifiedList route tables (filter with vpc_id).
Success
200
Getting a single route table by ID is not available. List with ?vpc_id= and pick the one you need.
/hcs/vpc/v1/{p}/routetables/{id}VerifiedAdd or remove routes in a route table.
Success
200
/hcs/vpc/v1/{p}/portsVerifiedCreate a network port, for example a private or virtual IP.
Success
201
/hcs/vpc/v1/{p}/ports/{id}VerifiedGet one port.
Success
200
/hcs/vpc/v1/{p}/ports/{id}VerifiedUpdate a port: security groups or allowed address pairs.
Success
200
/hcs/vpc/v1/{p}/ports/{id}VerifiedDelete a port.
Success
204
/hcs/vpc/v2.0/network-ip-availabilities/{id}VerifiedShow how many IP addresses are free in a subnet.
Success
200
Use the subnet "id" from the subnet list. The neutron_subnet_id value is not accepted here.
Security groups
Firewall rules that apply to server network interfaces.
/hcs/vpc/v1/{p}/security-groupsVerifiedCreate a security group.
Success
200
/hcs/vpc/v1/{p}/security-groupsVerifiedList security groups.
/hcs/vpc/v1/{p}/security-groups/{id}VerifiedGet one security group with its rules.
Success
200
/hcs/vpc/v1/{p}/security-groups/{id}VerifiedDelete a security group.
Success
204
/hcs/vpc/v1/{p}/security-group-rulesVerifiedAdd a rule to a security group.
Success
201
/hcs/vpc/v1/{p}/security-group-rulesVerifiedList security group rules.
/hcs/vpc/v1/{p}/security-group-rules/{id}VerifiedDelete a security group rule.
Success
204
Public IPs and bandwidth
Internet-facing addresses and the bandwidth behind them.
/hcs/vpc/v1/{p}/publicipsVerifiedAllocate a public IP.
Success
200
publicip.type is the name of a public IP pool, for example EIP_Pool_Cambodia. Ask us which pools your account can use.
/hcs/vpc/v1/{p}/publicipsVerifiedList public IPs.
/hcs/vpc/v1/{p}/publicips/{id}VerifiedGet one public IP.
Success
200
/hcs/vpc/v1/{p}/publicips/{id}VerifiedBind a public IP to a port, or unbind it.
Success
200
/hcs/vpc/v1/{p}/publicips/{id}VerifiedRelease a public IP.
Success
204
/hcs/vpc/v1/{p}/bandwidthsVerifiedList bandwidths.
/hcs/vpc/v1/{p}/bandwidths/{id}VerifiedGet one bandwidth.
Success
200
/hcs/vpc/v1/{p}/bandwidths/{id}VerifiedChange the size of a bandwidth.
Success
200
/hcs/vpc/v2.0/{p}/bandwidthsVerifiedCreate a shared bandwidth.
Success
200
/hcs/vpc/v2.0/{p}/bandwidths/{id}/insertVerifiedAdd public IPs to a shared bandwidth.
Success
200
/hcs/vpc/v2.0/{p}/bandwidths/{id}/removeVerifiedRemove public IPs from a shared bandwidth.
Success
200
/hcs/vpc/v2.0/{p}/bandwidths/{id}VerifiedDelete a shared bandwidth.
Success
204
Private DNS
DNS zones that resolve only inside the networks you attach them to.
/hcs/clouddns/v2/zonesVerifiedCreate a private DNS zone.
Success
202
/hcs/clouddns/v2/zonesVerifiedList DNS zones (use type=private).
/hcs/clouddns/v2/zones/{zid}VerifiedGet one zone.
Success
200
/hcs/clouddns/v2/zones/{zid}VerifiedUpdate a zone.
Success
202
/hcs/clouddns/v2/zones/{zid}VerifiedDelete a zone.
Success
202
/hcs/clouddns/v2/zones/{zid}/associaterouterVerifiedAttach a zone to a VPC.
Success
202
/hcs/clouddns/v2/zones/{zid}/disassociaterouterVerifiedDetach a zone from a VPC.
Success
202
/hcs/clouddns/v2/zones/{zid}/recordsetsVerifiedCreate a record set.
Success
202
/hcs/clouddns/v2/zones/{zid}/recordsetsVerifiedList the record sets in a zone.
/hcs/clouddns/v2/zones/{zid}/recordsets/{rid}VerifiedGet one record set.
Success
200
/hcs/clouddns/v2/zones/{zid}/recordsets/{rid}VerifiedUpdate a record set.
Success
202
/hcs/clouddns/v2/zones/{zid}/recordsets/{rid}VerifiedDelete a record set.
Success
202
