# Creating a Data Disk Image Using an External Image File

#### Function

This API is used to create a data disk image from a data disk image file uploaded to the OBS bucket. The API is an asynchronous one. If it is successfully called, the cloud service system receives the request. However, you need to use the asynchronous job query API to query the image creation status. For details, see Asynchronous Job Query.

#### URI

POST /v1/cloudimages/dataimages/action

#### Request

- Request parameters

  Parameter | Mandatory | Type | Description
  --- | --- | --- | ---
  name | Yes | String | Specifies the image name. For detailed description, see Image Attributes.
  description | No | String | Provides supplementary information about the image. For detailed description, see Image Attributes. The value contains a maximum of 1024 characters and consists of only letters and digits. Carriage returns and angle brackets (< >) are not allowed. This parameter is left blank by default.
  os_type | Yes | String | Specifies the OS type. It can only be Windows or Linux.
  image_url | Yes | String | Specifies the URL of the external image file in the OBS bucket. The format is OBS bucket name:Image file name. NOTE: The storage class of the OBS bucket must be Standard.
  min_disk | Yes | Integer | Specifies the minimum size of the data disk. Value range: 40 GB to 2048 GB
  cmk_id | No | String | Specifies the master key used for encrypting an image. For its value, see the Key Management Service User Guide.
  tags | No | Array of strings | Specifies image tags. This parameter is left blank by default. For detailed parameter description, see Image Tag Data Formats. Use either tags or image_tags.
  image_tags | No | Array of objects | Lists the image tags. This parameter is left blank by default. For detailed parameter descriptions, see Image Tag Data Formats. Use either tags or image_tags.

- Example requests
  - Request for creating an image (tags)

        POST https://{Endpoint}/v1/cloudimages/dataimages/action

         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11

        {
          "name": "fedora-data1",
          "image_url": "image-test:fedora_data1.qcow2",
          "description":"Data disk 1 of Fedora",
          "min_disk": 40,
          "tags": [
            "aaa.111",
            "bbb.222"
          ],
          "os_type": "Linux"
        }

  - Request for creating an image (image_tags)

        POST https://{Endpoint}/v1/cloudimages/dataimages/action

        1
        2
        3
        4
        5
        6
        7
        8

        {
          "name": "fedora-data2",
          "image_url": "image-test:fedora_data1.qcow2",
          "description":"Data disk 2 of Fedora",
          "min_disk": 40,
          "image_tags": [{"key":"aaa","value":"111"},{"key":"bbb","value":"222"}],
          "os_type": "Linux"
        }

#### Response

- Response parameters

  Parameter | Type | Description
  --- | --- | ---
  job_id | String | Specifies the asynchronous job ID. For details, see Asynchronous Job Query.

- Example response

      STATUS CODE 200

      1
      2
      3

      {
          "job_id": "4010a32b5f909853015f90aaa24b0015"
      }

#### Returned Value

- Normal

  200

- Abnormal

  Returned Value | Description
  --- | ---
  400 Bad Request | Request error. For details about the returned error code, see Error Codes.
  401 Unauthorized | Authentication failed.
  403 Forbidden | You do not have the rights to perform the operation.
  404 Not Found | The requested resource was not found.
  500 Internal Server Error | Internal service error.
  503 Service Unavailable | The service is unavailable.

Parent topic: Image