Modifying a Link
Function
This API is used to modify a link.
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 Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, no identity policy-based permission required for calling this API.
URI
PUT /v1.1/{project_id}/clusters/{cluster_id}/cdm/link/{link_name}
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Project ID. For details about how to obtain it, see Project ID and Account ID. |
| cluster_id | Yes | String | Cluster ID. For details about how to obtain this ID, see Querying the Cluster List. |
| link_name | Yes | String | Link name |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Auth-Token | Yes | String | User token. This parameter is mandatory when Token Authentication is used. You can obtain it from the X-Subject-Token header in the response of the "Obtaining a User Token" API provided by IAM. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| links | Yes | Array of links objects | Link list. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| link-config-values | Yes | link-config-values object | Link parameter configuration. |
| creation-user | No | String | User who created a link |
| name | Yes | String | Link name. The value can contain a maximum of 240 characters. Only digits, letters, hyphens (-), and underscores (_) are allowed. The value cannot start with a hyphen (-). |
| id | No | Integer | Link ID |
| creation-date | No | Long | Time when the link was created, in milliseconds. |
| connector-name | Yes | String | Connector name. The corresponding link parameter is generic-jdbc-connector, which indicates a relational database link. obs-connector: link to OBS hdfs-connector: link to HDFS hbase-connector: link to HBase and link to CloudTable hive-connector: link to Hive ftp-connector/sftp-connector: link to an FTP or SFTP server mongodb-connector: link to MongoDB redis-connector: link to Redis/DCS kafka-connector: link to Kafka dis-connector: link to DIS elasticsearch-connector: link to Elasticsearch/Cloud Search Service (CSS) dli-connector: link to DLIhttp-connector: link to HTTP/HTTPS (No link parameters are required.) dms-kafka-connector: link to DMSKafka |
| update-date | No | Long | Time when a link was updated |
| enabled | No | Boolean | Whether to activate the link. The default value is true. |
| update-user | No | String | User who updated a link |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| configs | Yes | Array of configs objects | Link configuration parameter data structure. |
| extended-configs | No | extended-configs object | Extended configuration. This field is not open to external users and does not need to be specified. |
| validators | No | Array of strings | Validator. The validator configuration is not open to external users and does not need to be specified. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| inputs | Yes | Array of Input objects | Input parameter list. Each parameter in the list is in the name,value format. In the from-config-values data structure, the value of this parameter varies with the source link type. For details, see Source Job Parameters. In the to-config-values data structure, the value of this parameter varies with the destination link type. For details, see Destination Job Parameters. For details about the inputs parameter in the driver-config-values data structure, see Job Parameter Description. |
| name | Yes | String | Configuration name. The value is fromJobConfig for a source job, toJobConfig for a destination job, and linkConfig for a link. |
| id | No | Integer | Configuration ID, which is generated by the system. You do not need to set this parameter. |
| type | No | String | Configuration type, which is generated by the system. You do not need to set this parameter. The value can be LINK (for link management APIs) or JOB (for job management APIs). |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | Yes | String | Parameter name.
|
| value | Yes | Object | Parameter value, which must be a string. |
| type | No | String | Value type, such as STRING and INTEGER. The value is set by the system. |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| validation-result | Array of validationResult objects | Link verification result list. If the link fails to be updated, the failure cause is returned. If the link is updated successfully, an empty object list is returned. |
| Parameter | Type | Description |
|---|---|---|
| linkConfig | Array of validationLinkConfig objects | Verification result for creating or updating a link. |
| Parameter | Type | Description |
|---|---|---|
| message | String | Error message |
| status | String | Error level, for example, ERROR or WARNING |
Status code: 500
| Parameter | Type | Description |
|---|---|---|
| message | String | Error message |
| status | String | Error level, for example, ERROR or WARNING |
Example Requests
Modifying a link named mysql_link
PUT /v1.1/1551c7f6c808414d8e9f3c514a170f2e/clusters/6ec9a0a4-76be-4262-8697-e7af1fac7920/cdm/link/rdb_link
{
"links" : [ {
"link-config-values" : {
"configs" : [ {
"inputs" : [ {
"name" : "linkConfig.databaseType",
"value" : "MYSQL"
}, {
"name" : "linkConfig.host",
"value" : "100.94.8.163"
}, {
"name" : "linkConfig.port",
"value" : "3306"
}, {
"name" : "linkConfig.database",
"value" : "DB_name"
}, {
"name" : "linkConfig.username",
"value" : "username"
}, {
"name" : "linkConfig.password",
"value" : "DB_password"
}, {
"name" : "linkConfig.fetchSize",
"value" : "100000"
}, {
"name" : "linkConfig.usingNative",
"value" : "false"
} ],
"name" : "linkConfig"
} ]
},
"name" : "mysql_link",
"creation-date" : 1496654788622,
"connector-name" : "generic-jdbc-connector",
"update-date" : 1496654788622,
"enabled" : true
} ]
} Example Responses
Status code: 200
Request succeeded.
{
"validation-result" : [ { } ]
} Status code: 500
Internal service error. For details about the returned error code, see Error Codes.
{
"validation-result" : [ {
"linkConfig" : [ {
"message" : "Can''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''t connect to the database with given credentials: The authentication type 12 is not supported. Check that you have configured the pg_hba.conf file to include the client''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''s IP address or subnet, and that it is using an authentication scheme supported by the driver.",
"status" : "ERROR"
} ]
} ]
} SDK Sample Code
The SDK sample code is as follows.
Modifying a link named mysql_link
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | 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.*; import java.util.List; import java.util.ArrayList; public class UpdateLinkSolution { 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(); UpdateLinkRequest request = new UpdateLinkRequest(); request.withClusterId("{cluster_id}"); request.withLinkName("{link_name}"); CdmCreateAndUpdateLinkReq body = new CdmCreateAndUpdateLinkReq(); List<Input> listConfigsInputs = new ArrayList<>(); listConfigsInputs.add( new Input() .withName("linkConfig.databaseType") .withValue("MYSQL") ); listConfigsInputs.add( new Input() .withName("linkConfig.host") .withValue("100.94.8.163") ); listConfigsInputs.add( new Input() .withName("linkConfig.port") .withValue("3306") ); listConfigsInputs.add( new Input() .withName("linkConfig.database") .withValue("DB_name") ); listConfigsInputs.add( new Input() .withName("linkConfig.username") .withValue("username") ); listConfigsInputs.add( new Input() .withName("linkConfig.password") .withValue("DB_password") ); listConfigsInputs.add( new Input() .withName("linkConfig.fetchSize") .withValue("100000") ); listConfigsInputs.add( new Input() .withName("linkConfig.usingNative") .withValue("false") ); List<Configs> listLinkConfigValuesConfigs = new ArrayList<>(); listLinkConfigValuesConfigs.add( new Configs() .withInputs(listConfigsInputs) .withName("linkConfig") ); LinksLinkconfigvalues linkConfigValuesLinks = new LinksLinkconfigvalues(); linkConfigValuesLinks.withConfigs(listLinkConfigValuesConfigs); List<Links> listbodyLinks = new ArrayList<>(); listbodyLinks.add( new Links() .withLinkConfigValues(linkConfigValuesLinks) .withName("mysql_link") .withCreationDate(1496654788622L) .withConnectorName("generic-jdbc-connector") .withUpdateDate(1496654788622L) .withEnabled(true) ); body.withLinks(listbodyLinks); request.withBody(body); try { UpdateLinkResponse response = client.updateLink(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()); } } } |
Modifying a link named mysql_link
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | # 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 = UpdateLinkRequest() request.cluster_id = "{cluster_id}" request.link_name = "{link_name}" listInputsConfigs = [ Input( name="linkConfig.databaseType", value="MYSQL" ), Input( name="linkConfig.host", value="100.94.8.163" ), Input( name="linkConfig.port", value="3306" ), Input( name="linkConfig.database", value="DB_name" ), Input( name="linkConfig.username", value="username" ), Input( name="linkConfig.password", value="DB_password" ), Input( name="linkConfig.fetchSize", value="100000" ), Input( name="linkConfig.usingNative", value="false" ) ] listConfigsLinkConfigValues = [ Configs( inputs=listInputsConfigs, name="linkConfig" ) ] linkConfigValuesLinks = LinksLinkconfigvalues( configs=listConfigsLinkConfigValues ) listLinksbody = [ Links( link_config_values=linkConfigValuesLinks, name="mysql_link", creation_date=1496654788622, connector_name="generic-jdbc-connector", update_date=1496654788622, enabled=True ) ] request.body = CdmCreateAndUpdateLinkReq( links=listLinksbody ) response = client.update_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) |
Modifying a link named mysql_link
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | 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, err := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). SafeBuild() if err != nil { fmt.Println(err) return } hcClient, err := cdm.CdmClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). SafeBuild() if err != nil { fmt.Println(err) return } client := cdm.NewCdmClient(hcClient) request := &model.UpdateLinkRequest{} request.ClusterId = "{cluster_id}" request.LinkName = "{link_name}" valueInputs:= "MYSQL" var valueInputsInterface interface{} = valueInputs valueInputs1:= "100.94.8.163" var valueInputsInterface1 interface{} = valueInputs1 valueInputs2:= "3306" var valueInputsInterface2 interface{} = valueInputs2 valueInputs3:= "DB_name" var valueInputsInterface3 interface{} = valueInputs3 valueInputs4:= "username" var valueInputsInterface4 interface{} = valueInputs4 valueInputs5:= "DB_password" var valueInputsInterface5 interface{} = valueInputs5 valueInputs6:= "100000" var valueInputsInterface6 interface{} = valueInputs6 valueInputs7:= "false" var valueInputsInterface7 interface{} = valueInputs7 var listInputsConfigs = []model.Input{ { Name: "linkConfig.databaseType", Value: &valueInputsInterface, }, { Name: "linkConfig.host", Value: &valueInputsInterface1, }, { Name: "linkConfig.port", Value: &valueInputsInterface2, }, { Name: "linkConfig.database", Value: &valueInputsInterface3, }, { Name: "linkConfig.username", Value: &valueInputsInterface4, }, { Name: "linkConfig.password", Value: &valueInputsInterface5, }, { Name: "linkConfig.fetchSize", Value: &valueInputsInterface6, }, { Name: "linkConfig.usingNative", Value: &valueInputsInterface7, }, } var listConfigsLinkConfigValues = []model.Configs{ { Inputs: listInputsConfigs, Name: "linkConfig", }, } linkConfigValuesLinks := &model.LinksLinkconfigvalues{ Configs: listConfigsLinkConfigValues, } creationDateLinks:= int64(1496654788622) updateDateLinks:= int64(1496654788622) enabledLinks:= true var listLinksbody = []model.Links{ { LinkConfigValues: linkConfigValuesLinks, Name: "mysql_link", CreationDate: &creationDateLinks, ConnectorName: "generic-jdbc-connector", UpdateDate: &updateDateLinks, Enabled: &enabledLinks, }, } request.Body = &model.CdmCreateAndUpdateLinkReq{ Links: listLinksbody, } response, err := client.UpdateLink(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
| Status Code | Description |
|---|---|
| 200 | Request succeeded. |
| 400 | Request error. |
| 401 | Authentication failed. |
| 403 | No operation permissions. |
| 404 | No resources found. |
| 500 | Internal service error. For details about the returned error code, see Error Codes. |
| 503 | Service unavailable. |
Error Codes
See Error Codes.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot