Help Center/ MapReduce Service/ API Reference/ API V2/ Data Connection Management/ Querying the Data Connection List - ListDataConnector
Updated on 2026-09-15 GMT+08:00

Querying the Data Connection List - ListDataConnector

Function

This API is used to query the data connection list of a specified MRS cluster, including information such as the data connection name, type, and connection status, for managing and viewing the external data source connections configured for the cluster.

Constraints

None

Debugging

You can debug this API in API Explorer, which supports automatic authentication and authorization. API Explorer can automatically generate sample SDK code and supports sample SDK code debugging.

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

    Dependency

    mrs:dataConnector:listInstance

    List

    -

    -

    -

    -

URI

GET /v2/{project_id}/data-connectors

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

Constraints

N/A

Range

The value must consist of 1 to 64 characters. Only letters and digits are allowed.

Default Value

N/A

Table 2 Query parameters

Parameter

Mandatory

Type

Description

connector_id

No

String

Definition

Connection ID.

Constraints

N/A

Range

The value can contain 1 to 64 characters, including only letters, digits, underscores (_), and hyphens (-).

Default Value

N/A

source_type

No

String

Definition

Data source type.

Constraints

N/A

Range

  • RDS_POSTGRES: RDS PostgreSQL database.
  • RDS_MYSQL: RDS MySQL database.
  • gaussdb-mysql: TaurusDB.
  • LAKEFORMATION: LakeFormation instance.

Default Value

N/A

connector_name

No

String

Definition

Data connection name.

Constraints

N/A

Range

N/A

Default Value

N/A

limit

No

Integer

Definition

Number of resources on each page.

Constraints

N/A

Range

1-1000

Default Value

N/A

offset

No

Integer

Definition

Start offset of the pagination query.

Constraints

N/A

Range

≥0

Default Value

N/A

available

No

Boolean

Definition

Whether the data connection is valid.

Constraints

N/A

Range

true: The connection is valid.

false: The connection is invalid.

Default Value

N/A

Request Parameters

None

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

total_count

Integer

Definition

Total number of data connections

Range

N/A

data_connectors

Array of DataConnectorDetail objects

Definition

Data connection details list. For details, see Table 4.

Range

N/A

Table 4 DataConnectorDetail

Parameter

Type

Description

connector_name

String

Definition

Data connection name.

Range

N/A

source_type

String

Definition

Data connection type.

Range

  • RDS_POSTGRES: RDS PostgreSQL database
  • RDS_MYSQL: RDS MySQL database
  • gaussdb-mysql: TaurusDB
  • LAKEFORMATION: LakeFormation instance.

source_info

String

Definition

Data source information, which is in JSON format.

Range

N/A

connector_id

String

Definition

Data connection ID.

Range

N/A

create_time

Long

Definition

Creation time of the data connection, in seconds accumulated from 1970-01-01 00:00:00 UTC, for example, 1773216988.

Range

N/A

last_update_time

Long

Definition

Last update time, in seconds accumulated from 1970-01-01 00:00:00 UTC, for example, 1773216988.

Range

N/A

create_by

String

Definition

Creator ID.

Range

N/A

create_user

String

Definition

Creator username.

Range

N/A

tenant_id

String

Definition

Tenant ID.

Range

N/A

last_update_by

String

Definition

ID of the user who last updated the information.

Range

N/A

status

Integer

Definition

Data connection status.

Range

  • -1: deleted
  • 0: normal
  • -2: abnormal
  • 1: in use

used_clusters

String

Definition

Clusters using the connection.

Range

N/A

encrypt_type

Integer

Definition

Encryption type

Range

  • 1: International cryptographic algorithm generalCipher.

  • 2: Chinese cryptographic algorithm SMCompatible.

Example Request

None

Example Response

Status code: 200

Successful query of the data connection list

{
  "total_count" : 1,
  "data_connectors" : [ {
    "connector_id" : "7d169c6c-ab50-4a56-a5d2-240ca20aabda",
    "connector_name" : "test",
    "create_time" : 1681270961,
    "source_type" : "RDS_MYSQL",
    "source_info" : "{\"rds_instance_id\":\"3ce1ae8af8cd43b2bcbd18b7541bb8b0in01\",\"jdbc_url\":\"jdbc:mysql://192.XXX.XXX.XXX:3306/test?socketTimeout=60000\",\"db_name\":\"test\",\"user_name\":\"root\",\"driver_path\":\"mrs-public/drivers/mysql-connector-java-5.1.47.jar\"}",
    "last_update_time" : 1681270961,
    "create_by" : "148c89d603e048b291f5940935b38f46",
    "create_user" : "xxx",
    "tenant_id" : "xxxxe662a7e24cc99bfc858c4558dbf6",
    "last_update_by" : "148c89d603e048b291f5940935b38f46",
    "status" : 0,
    "encrypt_type" : 2
  } ]
}

SDK Sample Code

The SDK sample code is as follows.

 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
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.mrs.v2.region.MrsRegion;
import com.huaweicloud.sdk.mrs.v2.*;
import com.huaweicloud.sdk.mrs.v2.model.*;


public class ListDataConnectorSolution {

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

        MrsClient client = MrsClient.newBuilder()
                .withCredential(auth)
                .withRegion(MrsRegion.valueOf("<YOUR REGION>"))
                .build();
        ListDataConnectorRequest request = new ListDataConnectorRequest();
        try {
            ListDataConnectorResponse response = client.listDataConnector(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());
        }
    }
}
 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
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkmrs.v2.region.mrs_region import MrsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkmrs.v2 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 = MrsClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(MrsRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ListDataConnectorRequest()
        response = client.list_data_connector(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 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 main

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


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

    client := mrs.NewMrsClient(hcClient)

    request := &model.ListDataConnectorRequest{}
	response, err := client.ListDataConnector(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 Codes

See Status Codes.

Error Codes

See Error Codes.