Introduction
Overview
BBC (Baidu Baremetal Compute) is the high-performance baremetal compute that users can exclusively enjoy in the cloud environment. Users have full management privilege of the physical device, and can combine with EIP and BLB for the flexible networking and inteconnect with the BCC private network, to flexibly deal with the user’s business requirements in various complex scenarios, and readily build a private network hybrid cloud.
Before you use the API document, make sure you have some basic knowledge about BBC, includingProduct Description and Pricing。
If you are calling the API of Baidu AI Cloud product for the first time, you can watch theAPI Getting Started Video Guide to quickly capacity the method of calling the API.
Interface Use Specification
Normalized String
In general, a string can contain any Unicode character.This flexibility can bring a lot of a hassle in programming.Hence the concept of "canonical strings” is introduced.A specification string contains only percent coded Characters and URI (Uniform Resource Identifier) non-reserved Characters. RFC 3986 specifies that non-reserved URI characters include the following: letters (S-z, a-z), digits (0-9), hyphens (-), dot (.), underscores (_), tilde (~) The way to convert any string to a canonical string is:
- Converts the string to the byte string coded by UTF-8.
- Leave all URI non-reserved characters as the same.
- Perform Percent-Encoding on the rest of the bytes according to RFC 3986, that means a % is followed by two hexadecimal letters representing the byte value. All letters are capitalized. Example:
The original string:
this is an example for test
, the corresponding normal string:this%20is%20an%20example%20for%20%E6%B5%8B%E8%AF%95
。
Encoding Specification
- Resolvable content, and UTF-8 encoding is adopted for all request/response body contents at present. More encoding types will be supported later.
-
When requesting, UrlEncode is required for the following:
- Objectname, where "/" needs to be ignored when Resource is doing URLEncode.
- Querystring的Value。
- x-bce-copy-source(ignore“/”)。
- Custom Meta:Meta Value only supports visible ASCII characters. If other characters are needed, UrlEncode processing is recommended.
Password Encryption and Transmission Specification
All interface parameters involving password need to be encrypted and plaintext transmission is prohibited. All passwords is encrypted with AES 128-bit encryption algorithm, and with the first 16 bits of SK as the key. The binary byte stream generated after encryption is converted to the hexadecimal and transmitted to the server in the form of string. The specific steps are as follows:
- byte[] bCiphertext= AES(Plaintext,SK)
- String strHex = HexStr(bCiphertext)
Date and Time
Date and time can be represented in many ways. For unification, unless it is established by convention or has corresponding specifications, all the date and time fields specified in the HTTP standard are expressed in GMT, and all other date and time fields are expressed in UTC time, following ISO 8601 and subject to the following restrictions:
- All dates should adopt the form of
YYYY-MM-DD
, for example,2014-06-01
is represented as 1 June, 2014. - All time should adopt the form of
hh:mm:ss
and add a capital Z at the end to indicate UTC time. For example,23:00:10Z
indicates that UTC time is 23:0:10 - As to the combination of date and time, add the letter T between the two. For example
2014-06-01T23:00:10Z
indicate UTC time is 23:0:10 on 1 June, 2014.
Request Response Format Standard
- HTTP request, Key of the parameter in querystring, is camel case. Such as upLoadId, partNumber, etc.
- All user-defined Meta are placed in the Header in the form of
x-bce-meta-*
, The total size of the custom meta shall not exceed 2K.x-bce-meta-*
key of will be processed by Server side in lowercase.
For example: if the user uploadsx-bce-meta-DeMo:value
using the Putobject interface, the Server will uniformly handle it in lowercasex-bce-meta-demo:value
, When the user uses the GetObject interface, the return value of the Sever side isx-bce-meta-demo:value
。
- In addition to the standard Header specified in RFC2616, other Headers are defined in the form of
x-bce-*
. - In all JSON, Key is the camel mode with lowercase initial.
- Each request response has
x-bce-request-id
andx-bce-debug-id
. - Relevant fields such as Date, Content-MD5, Content-Type, Content-Length in Header comply with RFC 2616.
-
According to the HTTP protocol, Content-MD5 must be MD5 and Base64 encoded. The calculation method is as follows:
Content-MD5 = "Content-MD5" ":" md5-digest md5-digest = <base64 of 128 bit MD5 digest as per RFC 1864>
Service domain Name
The domain names of BCC API service are as follows:
Region | Service endpoint Endpoint | Protocol |
---|---|---|
Beijing | bbc.bj.baidubce.com | HTTP and HTTPS |
Guangzhou | bbc.gz.baidubce.com | HTTP and HTTPS |
Suzhou | bbc.su.baidubce.com | HTTP and HTTPS |
Baoding | bbc.bd.baidubce.com | HTTP and HTTPS |
Wuhan | bbc.fwh.baidubce.com | HTTP and HTTPS |
Shanghai | bbc.fsh.baidubce.com | HTTP and HTTPS |
Public Request Header
Header field | Description | Required? |
---|---|---|
Authorization | Include the Access Key and Request Signature.。 | Required |
x-bce-date | Means the time of creating the request. The date is represented in the form of YYYY-MM-DD. For example, 2014-06-01 represents June 1, 2014.If the user uses the standard Date field, the header field can be left blank.When both exist, the x-bce-date prevails. | Optional |
x-bce-content-sha256 | The hexadecimal string representing the SHA256 signature of the Content part, where the content refers to HTTP Request Payload Body, that is, the original data of the content part before being HTTP encode. | Optional |
x-bce-if-match | Same semantics as If-Match. | Optional |
x-bce-if-none-match | Same semantics as If-None-Match. | Optional |
Public Response Header
Header field | Description |
---|---|
Content-Length | The type of HTTP request content defined in RFC2616. |
x-bce-request-id | Means the requestId corresponding to the request |
Error Code
In addition to the HTTP status code, the error information should also include the parameters in the following table in the HTTP body, as follows:
Parameter Name | Type | Description |
---|---|---|
requestId | String | Means the requestId causing the error |
code | String | It indicates the specific error type. |
message | String | Detailed description on this error. |
For example:
{
"code":"IllegalRequestUrl",
"message":"The requested url belongs to domain which is not under acceleration",
"requestId":" 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7"
}
Common Error Code
Error code | Message | HTTP status code | Semantics |
---|---|---|---|
AccessDenied | Access denied. | 403 Forbidden | You’ve no permission to access corresponding resources. |
InappropriateJSON | The JSON you provided was well-formed and valid, but not appropriate for this operation. | 400 Bad Request | The JSON format in the request is correct, but its semantics does not meet the requirements. For example, a required item is missing, or the value type does not match. Considering compatibility, all unrecognized items shall be directly ignored and this error shall not be returned. |
InternalError | We encountered an internal error. Please try again. | 500Internal Server Error | Means all other undefined errors. When other types of corresponding errors (including common and service-customized errors) are available, this type of error needs to be avoided. |
InvalidAccessKeyId | The Access Key ID you provided does not exist in our records. | 403 Forbidden | The Access Key ID does not exist. |
InvalidHTTPAuthHeader | The HTTP authorization header is invalid. Consult the service documentation for details. | 400 Bad Request | Means an error in the Authorization header field format. |
InvalidHTTPRequest | There was an error in the body of your HTTP request. | 400 Bad Request | The format of the HTTP body is incorrect. For example, it does not conform to the specified Encoding. |
InvalidURI | Could not parse the specified URI. | 400 Bad Request | The URI form is incorrect. For example, the keywords defined by some services are not matched. For problems such as ID mismatch, more specific error codes should be defined, such as NoSuchKey. |
MalformedJSON | The JSON you provided was not well-formed. | 400 Bad Request | The JSON format is illegal. |
InvalidVersion | The API version specified was invalid. | 404 Not Found | The URI version number is invalid. |
OptInRequired | A subscription for the service is required. | 403 Forbidden | No corresponding service has been opened. |
PreconditionFailed | The specified If-Match header doesn't match the ETag header. | 412 Precondition Failed | For more information, please see Etag. |
RequestExpired | Request has expired. Timestamp date is XXX. | 400 Bad Request | Means the request timeout. XXX must be changed to an x-bce-date value. If there is only Date in the request, you need to change Date to datetime. |
IdempotentParameterMismatch | The request uses the same client token as a previous, but non-identical request. | 403 Forbidden | The API parameters corresponding to clientToken are different. |
SignatureDoesNotMatch | The request signature we calculated does not match the signature you provided. Check your Secret Access Key and signing method. Consult the service documentation for details. | 400 Bad Request | The signature contained in the Authorization header field is inconsistent with the server verification. |
BBC Business Error Code
Error code | Message | HTTP status code | Semantics |
---|---|---|---|
InstanceNotFound | The specified CFS instance does not exist. | 404 | The specified DRDS instance does not exist. |
SubnetTypeInvalid | Bbc instance can only use bbc type subnet. | 400 | The specified subnet is not of a BBC subnet type. |
InternalException | Order extra to json failed. | 400 | The JSON format of order extra field is incorrect. |
InstancetypeInvalid | Only Bbc instance is available to renew in this method. | 400 | The renew CVM server is not of a BBC type. |
ProductTypeInvalid | Only prepay Bbc instance is available to create. | 400 | You can only create the prepaid BBC instance. |
Instance.BbcQuotaLimitExceeded | The number of bbc will exceed the limit. | 413 | The number of BBC instances created exceeds the quota |
InvalidParameter | Invalid Parameter. | 400 | Request Parameter Error |
InvalidParameter | Only postpay or expired bbc can be deleted | 400 | You can only delete expired or postpaid BBC instances |
OPERATION_DENY | Operation deny for current user | 403 | The current user is not authorized to carry out this operation |
InternalException | DiskInfo read failed from db | 400 | diskInfo configuration error |
Bbc.UserPriceConfigurationNotExist | user's price configuration for postpay does not exist. | 400 | The BBC configuration pricing information does not exist |
Instance.BbcTagQuotaLimitExceeded | The number of bbc tag will exceed the limit. | 413 | The number of tag created exceeds the quota |
Instance.RaidDoNotExist | Raid requested do not exist. | 403 | The requested raid does not exist |
Image.ImageTypeInvaild | Image type is invaild for this instance. | 400 | Invalid image type |
Instance.BbcCreateDeny | BBC create deny. | 403 | No right to purchase a BBC instance |
Instance.PasswordInvalid | Password format is invalid. | 400 | The password format is error |
Instance.NameInvalid | Instance name is invalid. | 400 | BBC instance name is invalid |
Instance.BalanceNotEnough | the balance is less than 100, please recharge. | 403 | Insufficient balance |
Instance.TemplateQuotaLimitExceeded | Custom image quota exceeds limit. | 413 | The number of custom images exceeds the quota limit. |
Instance.AdminPassDecryptionException | Invalid encryption code found for the admin password. | 400 | The decrypted password is incorrect. |
FlavorNotSupport | Flavor type is not supported | 400 | Invalid package type |
RaidTypeNotSupport | Raid type is not supported | 400 | Invalid raid type |
SysDiskSizeSupportInvalid | Sys disk size should between [20,100] | 400 | The system disk size should be within 20 GB and 100 GB. |
ImageTypeInvalid | image type invalid | 400 | Invalid image type |
FlavorImageIncompatible | the flavor specified is not compatible with the image | 400 | The specified package is not compatible with the image. |
Instance.MKTImageInstanceNotSupportChangeImageException | Instance with mkt image not support change image. | 403 | The cloud market image does not support the replacement of image reload. |
Instance.MKTImageInstanceNotSupportCreateTemplateException | Instance with mkt image not support create template. | 403 | The cloud market image does not support the creation of system image. |
Instance.KeepDataRebuildNotSupportChangeImageException | BBC Instance not support change image when keep data rebuild. | 403 | BBC does not support the replacement of image during the reload of reserved data. |
Instance.CumulativeRenewTimeException | The cumulative renewal time should not longer than ten years. | 403 | The renew time can not be greater than 10 years. |
Instance.SubnetDoNotExist | Subnet requested do not exist. | 403 | The requested subnet does not exist. |
Instance.DifferentZoneSubnetException | new subnet should be same zone. | 400 | Migration subnet, the destination subnet and the source subnet must be of the same availability zone. |
Instance.InstanceBindedEipCanNotChangeSubnetException | instance with eip can't change to NAT subnet. | 400 | The EIP server can not be changed to the NAT subnet. |
Instance.NotSupportSubnetTypeException | not support subnet type. | 400 | The subnet type is error |
Instance.InstanceBatchRebuildOutOfMaxSizeException | Target servers size exceeds maximum allowed | 400 | Batch installation of BBC, whose number exceeds the limit |
Instance.InstanceBatchRebuildException | Batch rebuild bbc partly failed. The instance ids are as follows. | 400 | Batch installation of BBC, which partially fails and returns the failed instance ID |
OperationLog.DateInvalid | *** is invalid. | 400 | Invalid date |
Vpc.NetworkParamError | vpcId or subnetId info error | 400 | vpcId or subnetId in the request parameter is incorrect. |
Vpc.NewFixIpNotInSubnet | new private ip is not in the subnet. | 400 | The original and new private network IPs are not of the same subnet IP address range. |
Vpc.IpInSubnetNotEnoughExceptions | The ip left in the subnet is not enouth for this create | 400 | The number of IPs in the subnet is insufficient. |