Help Center/ TaurusDB/ API Reference/ APIs (Recommended)/ Instance Management/ Querying Whether an Instance Has Scheduled Tasks of the Same Type
Updated on 2026-07-16 GMT+08:00

Querying Whether an Instance Has Scheduled Tasks of the Same Type

Function

This API is used to check whether an instance has any scheduled tasks of the same type in the task center.

Calling Method

For details, see Calling APIs.

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 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

    Dependency

    gaussdbformysql:instance:getScheduleTask

    Read

    instance *

    • g:EnterpriseProjectId

    • g:ResourceTag/<tag-key>

    gaussdb:instance:list

    -

URI

POST /v3/{project_id}/instances/{instance_id}/schedule-tasks/exist

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID of a tenant in a region.

To obtain this value, see Obtaining a Project ID.

Constraints

N/A

Range

The value contains 32 characters. Only letters and digits are allowed.

Default Value

N/A

instance_id

Yes

String

Definition

Instance ID, which uniquely identifies an instance.

To obtain this value, see Querying DB Instances.

Constraints

N/A

Range

The value contains 36 characters with a suffix of in07. Only letters and digits are allowed.

Default Value

N/A

Request Parameters

Table 2 Request header parameter

Parameter

Mandatory

Type

Description

X-Language

No

String

Definition

Request language type.

Constraints

N/A

Range

  • en-us: English

  • zh-cn: Chinese

Default Value

en-us

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

schedule_type

Yes

String

Definition

Type of a scheduled task.

Constraints

N/A

Range

  • PROXY_VERSION_UPGRADE: upgrading the minor version of a proxy instance

  • VERSION_UPGRADE: upgrading the minor version of a DB instance

  • RESIZE_FLAVOR: changing instance specifications

  • REBOOT_NODE: rebooting a node

  • REBOOT_INSTANCE: rebooting a DB instance

Default Value

N/A

proxy_id

No

String

Definition

Proxy instance ID.

To obtain this value, see Querying Proxy Instances.

Constraints

N/A

Range

N/A

Default Value

N/A

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

exist

Boolean

Definition

Whether the scheduled task type exists.

Range

  • true: The specified scheduled task type already exists.

  • false: The specified scheduled task type does not exist.

scheduled_tasks

Array of ScheduledTaskV3 objects

Definition

List of scheduled task details. When exist is true, this list contains information about existing tasks.

Range

N/A

Table 5 ScheduledTaskV3

Parameter

Type

Description

create_time

Long

Definition

Time when a task was created.

Range

N/A

datastore_type

String

Definition

Database type.

Range

Only gaussdb-mysql is supported.

end_time

Long

Definition

Task end time.

Range

N/A

instance_id

String

Definition

ID of the instance associated with the task.

Range

N/A

instance_name

String

Definition

Name of the instance associated with the task.

Range

N/A

instance_status

String

Definition

Status of the instance associated with the task.

Range

  • NORMAL: The instance is normal.

  • BACKING_UP: The instance is being backed up.

  • MODIFYING: The instance is being modified.

  • REBUILDING: The instance is being rebuilt.

  • RESTORING: The instance is being restored.

  • FROZEN: The instance is frozen.

  • FAILED: The instance is abnormal.

  • DELETING: The instance is being deleted.

  • CREATE_FAILED: The instance failed to be created.

project_id

String

Definition

Tenant project ID.

Range

N/A

proxy_id

String

Definition

ID of the proxy instance used by the task.

Range

N/A

proxy_name

String

Definition

Name of the proxy instance used by the task.

Range

N/A

start_time

Long

Definition

Task start time.

Range

N/A

target_config

Map<String,String>

Definition

Target configuration information of the task, which is stored in key-value pairs.

Range

N/A

task_id

String

Definition

Task ID, which uniquely identifies a task.

Range

N/A

task_name

String

Definition

Task name.

Range

N/A

task_order

Integer

Definition

Task execution order.

Range

N/A

task_status

String

Definition

Task status.

Range

  • Running: The task is being executed.

  • Failed: The task failed to be executed.

  • Canceled: The task is canceled.

  • Pending: The task is waiting for execution.

Status code: 400

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 500

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Request

Checking whether an instance has any scheduled REBOOT_NODE tasks in the task center

POST https://{endpoint}/v3/619d3e78f61b4be68bc5aa0b59edcf7b/instances/61a4ea66210545909d74a05c27a7179ein07/schedule-tasks/exist

{
  "schedule_type" : "REBOOT_NODE"
}

Example Response

Status code: 200

Success.

{
  "exist" : true,
  "scheduled_tasks" : [ {
    "task_id" : "1d19619a68b047b08c82b2d57dfb907b",
    "instance_id" : "61a4ea66210545909d74a05c27a7179ein07",
    "instance_name" : null,
    "instance_status" : null,
    "project_id" : "619d3e78f61b4be68bc5aa0b59edcf7b",
    "task_name" : "REBOOT_NODE",
    "create_time" : 1779955044142,
    "start_time" : 1779991200000,
    "end_time" : 1780005600000,
    "task_order" : null,
    "task_status" : "Pending",
    "datastore_type" : null,
    "target_config" : null,
    "proxy_id" : null,
    "proxy_name" : null
  } ]
}

SDK Sample Code

The SDK sample code is as follows.

Checking whether an instance has any scheduled REBOOT_NODE tasks in the task center

 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 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.gaussdb.v3.region.GaussDBRegion;
import com.huaweicloud.sdk.gaussdb.v3.*;
import com.huaweicloud.sdk.gaussdb.v3.model.*;


public class CheckScheduleTaskExistSolution {

    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);

        GaussDBClient client = GaussDBClient.newBuilder()
                .withCredential(auth)
                .withRegion(GaussDBRegion.valueOf("<YOUR REGION>"))
                .build();
        CheckScheduleTaskExistRequest request = new CheckScheduleTaskExistRequest();
        request.withInstanceId("{instance_id}");
        CheckScheduleTaskExistRequestBody body = new CheckScheduleTaskExistRequestBody();
        body.withScheduleType("REBOOT_NODE");
        request.withBody(body);
        try {
            CheckScheduleTaskExistResponse response = client.checkScheduleTaskExist(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());
        }
    }
}

Checking whether an instance has any scheduled REBOOT_NODE tasks in the task center

 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
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkgaussdb.v3.region.gaussdb_region import GaussDBRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkgaussdb.v3 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 = GaussDBClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(GaussDBRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = CheckScheduleTaskExistRequest()
        request.instance_id = "{instance_id}"
        request.body = CheckScheduleTaskExistRequestBody(
            schedule_type="REBOOT_NODE"
        )
        response = client.check_schedule_task_exist(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Checking whether an instance has any scheduled REBOOT_NODE tasks in the task center

 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
52
53
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    gaussdb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdb/v3"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdb/v3/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdb/v3/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 := gaussdb.GaussDBClientBuilder().
         WithRegion(region.ValueOf("<YOUR REGION>")).
         WithCredential(auth).
         SafeBuild()


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

    client := gaussdb.NewGaussDBClient(hcClient)

    request := &model.CheckScheduleTaskExistRequest{}
	request.InstanceId = "{instance_id}"
	request.Body = &model.CheckScheduleTaskExistRequestBody{
		ScheduleType: "REBOOT_NODE",
	}
	response, err := client.CheckScheduleTaskExist(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

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

Status Code

For details, see Status Codes.

Error Code

For details, see Error Codes.