Updated on 2026-09-01 GMT+08:00

Retry an Instance Task

Function

This API is used to retry a failed instance task.

Debugging

You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    iotda:instance:restart

    Write

    instance *

    • g:EnterpriseProjectId

    • g:ResourceTag/<tag-key>

    -

    -

URI

POST /v5/iot/{project_id}/iotda-instances/{instance_id}/tasks/{task_id}/retry

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Parameter description : project ID. For details, see Obtaining a Project ID.

instance_id

Yes

String

Parameter description: instance ID.

Value: Enter up to 36 characters, including lowercase letters (a to f), digits, and hyphens (-).

task_id

Yes

String

Parameter description: instance task ID.

Value: Enter up to 64 characters, including lowercase letters (a to f), digits, and hyphens (-).

Request Parameters

None

Response Parameters

Status code: 200

Table 2 Response body parameters

Parameter

Type

Description

task_id

String

Parameter description: instance task ID.

Value: Enter up to 64 characters, including lowercase letters (a to f), digits, and hyphens (-).

type

String

Parameter description: instance task type.

Range:

  • CREATE: instance creation task

  • MODIFY: task for changing instance specifications

  • DELETE: instance deletion task

  • FREEZE: instance freezing task

  • UNFREEZE: instance unfreezing task

  • UPDATE_ACCESS_CONFIG: task for modifying instance access information

  • UPDATE_ALLOW_LISTS: task for modifying the instance access whitelist

  • OPEN_SNAT: task for enabling SNAT configuration of an instance

status

String

Parameter description: task status.

Range:

  • PENDING: The task is waiting to be executed.

  • RUNNING: The task is being executed.

  • SUCCESS: The task is executed successfully.

  • FAILED: The task fails to be executed.

status_detail

String

Parameter description: task status description.

create_time

String

Parameter description: time when the instance task is created. Format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'

start_time

String

Parameter description: time when the instance task starts. Format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'

end_time

String

Parameter description: time when the instance task ends. Format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'

target_config

TargetConfig object

The target specification of the instance.

operate_window

OperateWindow object

Instance maintenance time window. You can specify the time window during which the specifications are modified.

progress

Integer

Parameter description: task progress.

Table 3 TargetConfig

Parameter

Type

Description

flavor

Flavor object

Parameter description: specifications of an IoTDA instance.

charge_mode

String

Parameter description: payment mode of the instance.

Range:

  • prePaid: yearly/monthly

  • postPaid: pay-per-use

Table 4 Flavor

Parameter

Type

Description

type

String

Parameter description : specification name of the IoTDA instance to create. For details, see Specifications.

size

Integer

Parameter description : unit number of the standard IoTDA instances to create. For details, see Specifications. This parameter is mandatory when instance_type is set to standard.

Table 5 OperateWindow

Parameter

Type

Description

start_time

String

Parameter description: start time of the change time window. The value is UTC time in HH:mm format.

end_time

String

Parameter description: end time of the change time window. The value is UTC time in HH:mm format.

Example Requests

Retries instance task details.

GET https://{endpoint}/v5/iot/{project_id}/iotda-instances/{instance_id}/tasks/{task_id}/retry

Example Responses

Status code: 200

OK

{
  "task_id" : "075f413d-a3bb-4243-974d-8eb9221c1234",
  "type" : "MODIFY",
  "status" : "RUNNING",
  "create_time" : "2021-08-19T01:52:49.493Z",
  "start_time" : "2021-08-19T01:52:49.492Z",
  "end_time" : "2021-08-19T01:52:49.492Z",
  "target_config" : {
    "flavor" : {
      "type" : "iotda.enterprise.1000tps.10wonlinedevice",
      "size" : null
    }
  },
  "operate_window" : {
    "start_time" : "18:00",
    "end_time" : "22:00"
  },
  "progress" : 80
}

SDK Sample Code

The SDK sample code is as follows.

Java

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.iotdm.v5.region.IoTDMRegion;
import com.huaweicloud.sdk.iotdm.v5.*;
import com.huaweicloud.sdk.iotdm.v5.model.*;


public class RetryInstanceTaskSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        IoTDMClient client = IoTDMClient.newBuilder()
                .withCredential(auth)
                .withRegion(IoTDMRegion.valueOf("<YOUR REGION>"))
                .build();
        RetryInstanceTaskRequest request = new RetryInstanceTaskRequest();
        request.withInstanceId("{instance_id}");
        request.withTaskId("{task_id}");
        try {
            RetryInstanceTaskResponse response = client.retryInstanceTask(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}

Python

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkiotdm.v5.region.iotdm_region import IoTDMRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkiotdm.v5 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = IoTDMClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(IoTDMRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = RetryInstanceTaskRequest()
        request.instance_id = "{instance_id}"
        request.task_id = "{task_id}"
        response = client.retry_instance_task(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Go

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    iotdm "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iotdm/v5"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iotdm/v5/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iotdm/v5/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    projectId := "{project_id}"

    auth, err := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        SafeBuild()

    if err != nil {
        fmt.Println(err)
        return
    }

    hcClient, err := iotdm.IoTDMClientBuilder().
         WithRegion(region.ValueOf("<YOUR REGION>")).
         WithCredential(auth).
         SafeBuild()


    if err != nil {
        fmt.Println(err)
        return
    }

    client := iotdm.NewIoTDMClient(hcClient)

    request := &model.RetryInstanceTaskRequest{}
	request.InstanceId = "{instance_id}"
	request.TaskId = "{task_id}"
	response, err := client.RetryInstanceTask(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

More

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

200

OK

400

Bad Request

401

Unauthorized

403

Forbidden

Error Codes

See Error Codes.