Create a Custom Image
Last Updated:2020-07-20
- This API is used to create the custom image. The created image can be used to create the instance. Each user can create up to 20 image at the same time.
- It supports to create the custom image through the instance or the snapshot.
- When you create a custome image through the instance, the custom image can be created successfully only when the instance is in the Running or Stopped status. Otherwise, it prompts an error 409.
- It is only limited to create a custom mirror through the system disk snapshot:
- When you create a custome image through the snapshot, the custom image can be created successfully only when the snapshot is in the Available status. Otherwise, it prompts an error 409.
Request Structure
POST /v{version}/image?clientToken={clientToken} HTTP/1.1
Host: bcc.bj.baidubce.com
Authorization: authorization string
{
"imageName" : imageName,
"instanceId" : instanceId,
"snapshotId" : snapshotId
}
Request Header Field
There are no other special header fields except the public header field.
Request Parameters
Parameter Name | Type | Required? | Parameter Position | Description |
---|---|---|---|---|
version | String | Yes | URL parameter | API version number |
clientToken | String | Yes | Query Parameter | The idempotent Token is an ASCII string with a length not exceeding 64 bits. For more information, please see the Idempotent. |
imageName | String | Yes | Request Body Parameter | Custom image name to create, which supports uppercase and lowercase letters, numbers, Chinese, -,,_ , /and. Special character with length 1-65, it must begin with the letter. |
instanceId | String | No | Request Body Parameter | This parameter refers to the instance ID to create the mirror during the creation of mirror from the instance. Optional parameters, which do not coexist with snapshotId. Otherwise, the instanceId is taken only. |
snapshotId | String | No | Request Body Parameter | This parameter refers to the snapshot ID to create the mirror when the image is created from the snapshot. Optional parameters, which do not exist as instanceId at the same time. Otherwise, instanceId is taken only. |
Return Header Field
There are no other special header fields except the common header field.
Return Parameter
Parameter Name | Type | Description |
---|---|---|
imageId | String | Image ID be created |
Error Code
Error Code | Error Description | HTTP Status Code | Explanations |
---|---|---|---|
Image.ImageNameInvalid | Image name is invalid. | 400 | The image name is invalid. |
Image.ImageIdIsEmpty | Image ID cannot be empty | 400 | The image ID can not be empty. |
Image.ImageQuotaExceedLimit | Image number exceeds the limit. | 413 | The number of images exceeds the limit. |
Image.InstanceStatusForbidden | Instance not in running or stopped status. | 409 | The instance is not in Running or Stopped status. Confirm and retry. |
Image.SnapshotStatusForbidden | Snapshot status is not Available, please confirm and retry. | 409 | The snapshot is in the Unvailable status. Confirm and retry. |
Image.NonSystemSnapshotForbidden | Non system snapshot can not used to create image, please confirm and retry. | 403 | The non-system snapshot can not be used to create a image. |
Request Instance
POST /v2/image?clientToken=1849ef6b-f73c-4f5d-b88b-259ca47af849 HTTP/1.1
Host: bcc.bj.baidubce.com
Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2015-08-11T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
{
"imageName" : "template_example_001",
"instanceId":"i-1849ef6b"
}
Return Instance
HTTP/1.1 200 OK
x-bce-request-id: 1214cca7-4ad5-451d-9215-71cb844c0a50
Date: Wed, 03 Dec 2014 06:42:19 GMT
Content-Type: application/json;charset=UTF-8
Server: BWS
{
"imageId" : "m-nky7qeom"
}