Brief Introduction
Overview
Baidu AI Cloud Automatic Scaling (Auto Scaling) is a kind of management service of automatically scaling the user cloud resources. When the cloud resource consumption required by your business changes frequently, the AS can be an ideal method for you to use the cloud resource.
Interface Use Specification
Normalized String
Generally, one string can include any Unicode character. In programming, this kind of flexibility will bring about numerous troubles. Therefore, the concept of "Normalized String" is introduced. One normalized string only includes the percent-encoding characters and URI (Uniform Resource Identifier) unreserved characters. RFC 3986 stipulates that "URI non-reserved characters" include the following characters: Letters (A-Z, a-z), numbers (0-9), hyphen (-), dot mark (.), underline (_), tilde (~). The method to change any string into a normalized string is:
- To convert strings into UTF-8 encoded byte stream.
- To keep all "URI non-reserved characters" unchanged.
- To make the Percent-encoding specified in RFC 3986 once for the rest bytes, namely, two sexadecimal strings representing the byte value are behind one "%". All the letters are in upper case. Example:
Original string:
This is an example for test
, Corresponding specification string:this%20is%20an%20example%20for%20%E6%B5%8B%E8%AF%95
。
Coding Specification
- The parsable contents and all request/response body contents are currently encoded with UTF-8, and more encoding types will be supported in the future.
-
At request, we should make UrlEncode for the following:
- Objectname, and "/" should be ignored when UrlEncode is made for Resource.
- Value of Querystring.
- x-bce-copy-source ("/" ignored).
- User-defined Meta: Meta Value only supports visible ASCII characters. If other characters are required, it is recommended to use UrlEncode for processing.
Transmission Specification for Password Encryption
All password-involved interface parameters should be encrypted, and forbidden to be transmitted in clear text. All passwords utilize the AES 128-bit encryption algorithm for encryption, and the first 16 bits of SK are utilized as the key. The binary byte streams generated after encryption should be converted into the sexadecimal byte streams, and transmitted to the service side in the form of strings. The specific procedures are as follows:
- byte[]bCiphertext= AES(clear text, SK)
- String strHex = HexStr(bCiphertext)
Date and Time
There are various methods to express date and time. For the purpose of unification, unless there are conventions or corresponding specifications, all fields expressing date and time specified in the HTTP standard utilize GMT, and UTC time for other places expressing date and time. The users should follow ISO 8601, and the following restrictions are made:
- Fields expressing the date all utilize the
YYYY-MM-DD
format, e.g.2014-06-01
which means June 1, 2014. - Fields expressing time all utilize the
hh:mm:ss
format, with the capital letter Z added at the end, which means UTC time. E.g.23:00:10Z
means UTC time: 23:0:10. - When the date and time is combined, the capital letter T is added between the two items, e.g.
2014-06-01T23:00:10z
means UTC time: 23:00:10 on June 1, 2014.
Standard of Request Response Format
- HTTP request, Key of parameter in Querystring, in lower camel case. E.g. upLoadId, partNumber, etc.
- All user-defined metas are put in the Header in the form of
x-bce-meta-*
. The total size of user-defined Metas shouldn't exceed 2K. The Key ofx-bce-meta-*
is in lower case at the Server side.
E.g.: When the user uses the PutObject interface to upload x-bce-meta-DeMo:value
, the Server side uses x-bce-meta-demo:value
in lower case. When the user uses the GetObject interface, the return value of the Sever side is x-bce-meta-demo:value
.
- Other Headers are defined in the form of x-bce-*except the standard Headers specified by RFC2616.
- Keys all utilize the lower camel case in all JSONs.
- Each request response contains the two Headers of
x-bce-request-id
andx-bce-debug-id
. - Related fields such as Date, Content-MD5, Content-Type, Content-Length in Headers should be subject to the restrictions of RFC 2616.
-
According to the stipulations in the HTTP protocol, both MD5 and Base64 encoding should be performed for Content-MD5. The computation method of Content-MD5 is as follows:
Content-MD5 = "Content-MD5" ":" md5-digest md5-digest = <base64 of 128 bit MD5 digest as per RFC 1864>
Service Domain Name
Service domain names of AS API:
Region | Service endpoint | Protocol |
---|---|---|
Beijing | as.bj.baidubce.com | HTTP and HTTPS |
Guangzhou | as.gz.baidubce.com | HTTP and HTTPS |
Suzhou | as.su.baidubce.com | HTTP and HTTPS |
Public Request Header
Header | Description | Required or not |
---|---|---|
Authorization | Including Access Key and request signature. | Required |
x-bce-date | The time of creating the request, and the fields expressing the date all utilize the YYYY-MM-DD format, e.g.2014-06-01 which means June 1, 2014. If the user uses the standard Date domain, the header can be left blank. When the two exist simultaneously, x-bce-date shall prevail. | Optional |
x-bce-content-sha256 | It represents the hexadecimal strings of SHA256 signature of the content part. The content refers to HTTP Request Payload Body, namely, the original data of the Content part before HTTP encode. | Optional |
Public Response Header
Header | Description |
---|---|
Content-Length | Type of HTTP request content defined in RFC2616. |
x-bce-request-id | The requestId of the corresponding request |
Error Code
The error message except for the HTTP status code should simultaneously include the parameters in the Table below in the HTTP body. The contents are as follows:
Parameter name | Type | Description |
---|---|---|
requestId | String | RequestId causing the error. |
code | String | It means a specific error type. |
message | String | Detailed description on the error. |
E.g.:
{
"code":"IllegalRequestUrl",
"message":"The requested url belongs to domain which is not under acceleration",
"requestId":" 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7"
}
Public Error Code
Error code | Message | HTTP status code | Semantics |
---|---|---|---|
AccessDenied | Access denied. | 403 Forbidden | No permission to access the 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 doesn't meet the requirements semantically, such as lack of one necessary item or value type mismatch. For consideration of compatibility, all unrecognizable items should be ignored directly, and this error should not be returned. |
InternalError | We encountered an internal error. Please try again. | 500Internal Server Error | All other undefined errors should not be utilized when there are specific corresponding other types of errors (including generic and service customized errors). |
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 | The format of Authorization header is wrong. |
InvalidHTTPRequest | There was an error in the body of your HTTP request. | 400 Bad Request | The HTTP body format is wrong. E.g. inconformity with the designated Encoding, etc. |
InvalidURI | Could not parse the specified URI. | 400 Bad Request | The URI format is incorrect, such as mismatch of some service-defined keywords. For ID mismatch and other problems, a more specific error code should be defined, such as NoSuchKey. |
MalformedJSON | The JSON you provided was not well-formed. | 400 Bad Request | The JSON format is invalid. |
InvalidVersion | The API version specified was invalid. | 404 Not Found | The version number of URI is invalid. |
OptInRequired | A subscription for the service is required. | 403 Forbidden | The corresponding service is not subscribed. |
PreconditionFailed | The specified If-Match header doesn't match the ETag header. | 412 Precondition Failed | Refer to ETag for details. |
RequestExpired | Request has expired. Timestamp date is XXX. | 400 Bad Request | The request has timed out. XXX should be changed to the value of x-bce-date. If there is only Date in the request, the Date should be changed 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 non-identical. |
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 attached in the Authorization header is inconsistent with the server authentication. |