查询连接
功能介绍
查询连接接口。
调用方法
请参见如何调用API。
URI
GET /v1.1/{project_id}/clusters/{cluster_id}/cdm/link/{link_name}
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
项目ID,获取方法请参见项目ID和账号ID |
cluster_id |
是 |
String |
集群ID |
link_name |
是 |
String |
连接名称 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 |
响应参数
状态码: 200
参数 |
参数类型 |
描述 |
---|---|---|
links |
Array of links objects |
连接列表,请参见links数据结构说明 |
fromTo-unMapping |
String |
表/文件迁移不支持哪些数据源迁移到哪些数据源 |
batchFromTo-mapping |
String |
整库迁移支持哪些数据源迁移到哪些数据源 |
参数 |
参数类型 |
描述 |
---|---|---|
link-config-values |
link-config-values object |
连接参数配置,请参见link-config-values参数说明。 |
creation-user |
String |
创建连接的用户 |
name |
String |
连接名称 |
id |
Integer |
连接ID |
creation-date |
Long |
创建连接的时间 |
connector-name |
String |
连接器名称,对应的连接参数如下:generic-jdbc-connector:关系数据库连接。obs-connector:OBS连接。hdfs-connector:HDFS连接。hbase-connector:HBase连接、CloudTable连接。hive-connector:Hive连接。ftp-connector/sftp-connector:FTP/SFTP连接。mongodb-connector:MongoDB连接。redis-connector:Redis/DCS连接。kafka-connector:Kafka连接。dis-connector:DIS连接。elasticsearch-connector:Elasticsearch/云搜索服务连接。dli-connector:DLI连接。 http-connector:HTTP/HTTPS连接,该连接暂无连接参数。dms-kafka-connector:DMSKafka连接 |
update-date |
Long |
更新连接的时间 |
enabled |
Boolean |
是否激活连接,默认为“true”。 |
update-user |
String |
更新连接的用户 |
参数 |
参数类型 |
描述 |
---|---|---|
configs |
Array of configs objects |
连接配置参数数据结构,请参见configs参数说明。 |
extended-configs |
extended-configs object |
扩展配置,请参见extended-configs参数说明。 |
validators |
Array of strings |
校验器 |
参数 |
参数类型 |
描述 |
---|---|---|
inputs |
Array of Input objects |
输入参数列表,列表中的每个参数为“name,value”结构,请参考inputs数据结构参数说明。在“from-config-values”数据结构中,不同的源连接类型有不同的“inputs”参数列表,请参见源端作业参数说明下的章节。在“to-config-values”数据结构中,不同的目的连接类型有不同的“inputs”参数列表,请参见目的端作业参数说明下面的子章节。在“driver-config-values”数据结构中,“inputs”具体参数请参见作业任务参数说明。 |
name |
String |
配置名称:源端作业的配置名称为“fromJobConfig”。目的端作业的配置名称为“toJobConfig”,连接的配置名称固定为“linkConfig”。 |
id |
Integer |
配置ID,由系统生成,用户无需填写。 |
type |
String |
配置类型,由系统生成,用户无需填写。值为LINK或者JOB,如果是连接管理API,则为LINK;如果是作业管理API,则为JOB。 |
请求示例
GET /v1.1/1551c7f6c808414d8e9f3c514a170f2e/clusters/6ec9a0a4-76be-4262-8697-e7af1fac7920/cdm/link/sftplink
响应示例
状态码: 200
OK
{ "links" : [ { "link-config-values" : { "configs" : [ { "inputs" : [ { "name" : "linkConfig.server", "type" : "STRING", "value" : "100.94.8.163" }, { "name" : "linkConfig.port", "type" : "INTEGER", "value" : 22 }, { "name" : "linkConfig.username", "type" : "STRING", "value" : "root" }, { "name" : "linkConfig.password", "type" : "STRING", "value" : "Add password here" } ], "name" : "linkConfig" } ] }, "creation-user" : "cdm", "name" : "sftp_link", "creation-date" : 1516674482640, "connector-name" : "sftp-connector", "update-date" : 1516674476022, "enabled" : true, "update-user" : "cdm" } ] }
SDK代码示例
SDK代码示例如下。
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.cdm.v1.region.CdmRegion; import com.huaweicloud.sdk.cdm.v1.*; import com.huaweicloud.sdk.cdm.v1.model.*; public class ShowLinkSolution { 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); CdmClient client = CdmClient.newBuilder() .withCredential(auth) .withRegion(CdmRegion.valueOf("<YOUR REGION>")) .build(); ShowLinkRequest request = new ShowLinkRequest(); request.withClusterId("{cluster_id}"); request.withLinkName("{link_name}"); try { ShowLinkResponse response = client.showLink(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 32 33 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcdm.v1.region.cdm_region import CdmRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcdm.v1 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 = CdmClient.new_builder() \ .with_credentials(credentials) \ .with_region(CdmRegion.value_of("<YOUR REGION>")) \ .build() try: request = ShowLinkRequest() request.cluster_id = "{cluster_id}" request.link_name = "{link_name}" response = client.show_link(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 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" cdm "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdm/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdm/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdm/v1/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 := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := cdm.NewCdmClient( cdm.CdmClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ShowLinkRequest{} request.ClusterId = "{cluster_id}" request.LinkName = "{link_name}" response, err := client.ShowLink(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
OK |
400 |
请求错误 |
401 |
鉴权失败 |
403 |
没有操作权限 |
404 |
找不到资源 |
500 |
服务内部错误,具体返回错误码请参考错误码 |
503 |
服务不可用 |
错误码
请参见错误码。