ByteDCCloud APIPreview

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:

WhatWhere 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 IDIn the console, open My Settings → Resource Spaces. The ID is a 32-character string. Each resource space is a separate project.
PermissionsThe 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.
Treat the secret key like a password. Do not put it in source code, chat or tickets. If you think a key has leaked, delete it in the console and create a new one.

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.

A token works for one project only. If you have several resource spaces, get one token per project.

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.

StepCallYou get
1. Pick a size, image and zoneflavors, images, zonesflavorRef, imageRef, availability_zone
2. Create a networkVPC, then subnetvpc_id, subnet id
3. Open the ports you needsecurity group, then rulessecurity group id
4. Create the servercreate server, then job statusserver id
5. Give it a public addresspublic IP, bound to the server's port from interfacespublic 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

LimitValueWhen you go over
Calls per token600 per minute429 Too Many Requests. Wait and retry.
Token requests per client IP20 per minute429. Reuse your token instead of asking for a new one.
Request body size64 KB413. Mostly relevant for large user_data scripts.
Resource quotasSet per accountThe call fails with a quota error. Check your quota or ask us to raise it.

Errors

StatusMeaning
400The request is not valid. The body has a code and a message that say why.
401The token is missing, wrong or expired. Get a new one.
403Your user does not have permission for this action in this project.
404The resource does not exist, or the endpoint is not part of this API. Only the endpoints listed in the reference below are available.
409Conflict 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.
429Too many calls. See Limits.
5xxSomething 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.

POST/hcs/iam/v3/auth/tokensVerified

Get 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.

GET/hcs/ecs/v2.1/{p}/flavors/detailVerified

List server sizes (flavors) with vCPU and memory.

GET/hcs/ims/v2/cloudimagesVerified

List operating system images you can use.

GET/hcs/ecs/v2/{p}/os-availability-zoneVerified

List availability zones.

GET/hcs/evs/v2/{p}/typesVerified

List disk types.

GET/hcs/ecs/v1/{p}/cloudservers/limitsVerified

Show your server quota and how much is used.

Cloud servers

Create, change and remove servers. Creating, resizing and deleting run as background jobs.

POST/hcs/ecs/v1/{p}/cloudserversVerified

Create one or more servers.

Success

200 · runs as a background job, see job status

GET/hcs/ecs/v1/{p}/cloudservers/detailVerified

List your servers with details.

Paging starts at offset=1. offset=0 returns an empty list.

GET/hcs/ecs/v1/{p}/cloudservers/{id}Verified

Get 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.

PUT/hcs/ecs/v1/{p}/cloudservers/{id}Verified

Rename a server.

Success

200

POST/hcs/ecs/v1/{p}/cloudservers/actionVerified

Start, stop or reboot several servers at once.

Success

200 · runs as a background job, see job status

POST/hcs/ecs/v1/{p}/cloudservers/deleteVerified

Delete servers.

Success

200 · runs as a background job, see job status

POST/hcs/ecs/v1/{p}/cloudservers/{id}/resizeVerified

Change 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.

PUT/hcs/ecs/v1/{p}/cloudservers/{id}/os-reset-passwordVerified

Reset the password of a server.

Success

200

POST/hcs/ecs/v2/{p}/cloudservers/{id}/reinstallosPreview

Reinstall 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.

POST/hcs/ecs/v2/{p}/cloudservers/{id}/changeosPreview

Change 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.

GET/hcs/ecs/v1/{p}/cloudservers/{id}/os-interfaceVerified

List the network interfaces of a server.

Success

200

POST/hcs/ecs/v1/{p}/cloudservers/{id}/nicsVerified

Add network interfaces to a server.

Success

200 · runs as a background job, see job status

POST/hcs/ecs/v1/{p}/cloudservers/{id}/nics/deleteVerified

Remove network interfaces from a server.

Success

200 · runs as a background job, see job status

POST/hcs/ecs/v1/{p}/cloudservers/{id}/attachvolumeVerified

Attach 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.

DELETE/hcs/ecs/v1/{p}/cloudservers/{id}/detachvolume/{vid}Verified

Detach a disk from a server.

Success

200 · runs as a background job, see job status

GET/hcs/ecs/v1/{p}/cloudservers/{id}/block_deviceVerified

List the disks attached to a server.

Success

200

GET/hcs/ecs/v1/{p}/jobs/{jid}Verified

Check the status of a background job.

Success

200

GET/hcs/ecs/v2.1/{p}/os-keypairsVerified

List SSH key pairs.

POST/hcs/ecs/v2.1/{p}/os-keypairsVerified

Create or import an SSH key pair.

Success

200

DELETE/hcs/ecs/v2.1/{p}/os-keypairs/{name}Verified

Delete an SSH key pair.

Success

202

Disks

Block storage volumes you can attach to a server.

POST/hcs/evs/v2.1/{p}/cloudvolumesVerified

Create a disk.

Success

200

GET/hcs/evs/v2/{p}/cloudvolumes/detailVerified

List your disks with details.

GET/hcs/evs/v2/{p}/cloudvolumes/{id}Verified

Get one disk.

Success

200

POST/hcs/evs/v2/{p}/volumes/{id}/actionVerified

Expand a disk.

Success

202

Only expanding is allowed (os-extend). Disks cannot be shrunk.

DELETE/hcs/evs/v2/{p}/cloudvolumes/{id}Verified

Delete a disk.

Success

202

Snapshots and images

Point-in-time copies of a disk, and full images made from a server.

POST/hcs/evs/v2/{p}/snapshotsVerified

Take a snapshot of a disk.

Success

202

GET/hcs/evs/v2/{p}/snapshots/detailVerified

List snapshots.

GET/hcs/evs/v2/{p}/snapshots/{id}Verified

Get one snapshot.

Success

200

DELETE/hcs/evs/v2/{p}/snapshots/{id}Verified

Delete a snapshot.

Success

202

POST/hcs/evs/v2/{p}/os-vendor-snapshots/{id}/rollbackVerified

Roll a disk back to a snapshot.

Success

202

POST/hcs/ims/v2/cloudimages/actionVerified

Create 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.

DELETE/hcs/ims/v2/cloudimagesVerified

Delete 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.

POST/hcs/vpc/v1/{p}/vpcsVerified

Create a VPC.

Success

200

GET/hcs/vpc/v1/{p}/vpcsVerified

List VPCs.

GET/hcs/vpc/v1/{p}/vpcs/{id}Verified

Get one VPC.

Success

200

PUT/hcs/vpc/v1/{p}/vpcs/{id}Verified

Update a VPC.

Success

200

DELETE/hcs/vpc/v1/{p}/vpcs/{id}Verified

Delete a VPC.

Success

204

POST/hcs/vpc/v1/{p}/subnetsVerified

Create a subnet.

Success

200

GET/hcs/vpc/v1/{p}/subnetsVerified

List subnets.

GET/hcs/vpc/v1/{p}/subnets/{id}Verified

Get one subnet.

Success

200

PUT/hcs/vpc/v1/{p}/vpcs/{vid}/subnets/{id}Verified

Update a subnet.

Success

200

DELETE/hcs/vpc/v1/{p}/vpcs/{vid}/subnets/{id}Verified

Delete a subnet.

Success

204

GET/hcs/vpc/v1/{p}/routetablesVerified

List 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.

PUT/hcs/vpc/v1/{p}/routetables/{id}Verified

Add or remove routes in a route table.

Success

200

POST/hcs/vpc/v1/{p}/portsVerified

Create a network port, for example a private or virtual IP.

Success

201

GET/hcs/vpc/v1/{p}/ports/{id}Verified

Get one port.

Success

200

PUT/hcs/vpc/v1/{p}/ports/{id}Verified

Update a port: security groups or allowed address pairs.

Success

200

DELETE/hcs/vpc/v1/{p}/ports/{id}Verified

Delete a port.

Success

204

GET/hcs/vpc/v2.0/network-ip-availabilities/{id}Verified

Show 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.

POST/hcs/vpc/v1/{p}/security-groupsVerified

Create a security group.

Success

200

GET/hcs/vpc/v1/{p}/security-groupsVerified

List security groups.

GET/hcs/vpc/v1/{p}/security-groups/{id}Verified

Get one security group with its rules.

Success

200

DELETE/hcs/vpc/v1/{p}/security-groups/{id}Verified

Delete a security group.

Success

204

POST/hcs/vpc/v1/{p}/security-group-rulesVerified

Add a rule to a security group.

Success

201

GET/hcs/vpc/v1/{p}/security-group-rulesVerified

List security group rules.

DELETE/hcs/vpc/v1/{p}/security-group-rules/{id}Verified

Delete a security group rule.

Success

204

Public IPs and bandwidth

Internet-facing addresses and the bandwidth behind them.

POST/hcs/vpc/v1/{p}/publicipsVerified

Allocate 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.

GET/hcs/vpc/v1/{p}/publicipsVerified

List public IPs.

GET/hcs/vpc/v1/{p}/publicips/{id}Verified

Get one public IP.

Success

200

PUT/hcs/vpc/v1/{p}/publicips/{id}Verified

Bind a public IP to a port, or unbind it.

Success

200

DELETE/hcs/vpc/v1/{p}/publicips/{id}Verified

Release a public IP.

Success

204

GET/hcs/vpc/v1/{p}/bandwidthsVerified

List bandwidths.

GET/hcs/vpc/v1/{p}/bandwidths/{id}Verified

Get one bandwidth.

Success

200

PUT/hcs/vpc/v1/{p}/bandwidths/{id}Verified

Change the size of a bandwidth.

Success

200

POST/hcs/vpc/v2.0/{p}/bandwidthsVerified

Create a shared bandwidth.

Success

200

POST/hcs/vpc/v2.0/{p}/bandwidths/{id}/insertVerified

Add public IPs to a shared bandwidth.

Success

200

POST/hcs/vpc/v2.0/{p}/bandwidths/{id}/removeVerified

Remove public IPs from a shared bandwidth.

Success

200

DELETE/hcs/vpc/v2.0/{p}/bandwidths/{id}Verified

Delete a shared bandwidth.

Success

204

Private DNS

DNS zones that resolve only inside the networks you attach them to.

POST/hcs/clouddns/v2/zonesVerified

Create a private DNS zone.

Success

202

GET/hcs/clouddns/v2/zonesVerified

List DNS zones (use type=private).

GET/hcs/clouddns/v2/zones/{zid}Verified

Get one zone.

Success

200

PATCH/hcs/clouddns/v2/zones/{zid}Verified

Update a zone.

Success

202

DELETE/hcs/clouddns/v2/zones/{zid}Verified

Delete a zone.

Success

202

POST/hcs/clouddns/v2/zones/{zid}/associaterouterVerified

Attach a zone to a VPC.

Success

202

POST/hcs/clouddns/v2/zones/{zid}/disassociaterouterVerified

Detach a zone from a VPC.

Success

202

POST/hcs/clouddns/v2/zones/{zid}/recordsetsVerified

Create a record set.

Success

202

GET/hcs/clouddns/v2/zones/{zid}/recordsetsVerified

List the record sets in a zone.

GET/hcs/clouddns/v2/zones/{zid}/recordsets/{rid}Verified

Get one record set.

Success

200

PUT/hcs/clouddns/v2/zones/{zid}/recordsets/{rid}Verified

Update a record set.

Success

202

DELETE/hcs/clouddns/v2/zones/{zid}/recordsets/{rid}Verified

Delete a record set.

Success

202