Updating a Log Transfer Task
Function
This API is used to update an OBS, DIS, or DMS transfer task.
Calling Method
For details, see Calling APIs.
URI
PUT /v2/{project_id}/transfers
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID. For details about how to obtain a project ID, see Obtaining the Project ID, Account ID, Log Group ID, and Log Stream ID. Minimum: 32 Maximum: 32 |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
User token obtained from IAM. For details about how to obtain a user token, see Obtaining a User Token. Minimum: 1000 Maximum: 2000 |
Content-Type |
Yes |
String |
Set this parameter to application/json;charset=UTF-8. Minimum: 30 Maximum: 30 |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
log_transfer_id |
Yes |
String |
Log transfer task ID. Minimum: 36 Maximum: 36 |
log_transfer_info |
Yes |
update_log_transfer_info object |
Log transfer information. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
log_storage_format |
Yes |
String |
Log transfer format. The value can be RAW or JSON. RAW indicates the raw log format, and JSON indicates the JSON format. |
log_transfer_status |
Yes |
String |
Log transfer status. ENABLE indicates that log transfer is enabled, DISABLE indicates that log transfer is disabled, and EXCEPTION indicates that log transfer is abnormal. |
log_transfer_detail |
Yes |
log_transfer_detail object |
Log transfer details. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
obs_period |
Yes |
Integer |
Length of the transfer interval for an OBS transfer task. This parameter is required when you create an OBS transfer task. The log transfer interval is specified by the combination of the values of obs_period and obs_period_unit, and must be set to one of the following: 2 min, 5 min, 30 min, 1 hour, 3 hours, 6 hours, and 12 hours. |
obs_period_unit |
Yes |
String |
Unit of the transfer interval for an OBS transfer task. This parameter is required when you create an OBS transfer task. The log transfer interval is specified by the combination of the values of obs_period and obs_period_unit, and must be set to one of the following: 2 min, 5 min, 30 min, 1 hour, 3 hours, 6 hours, and 12 hours. |
obs_bucket_name |
Yes |
String |
OBS bucket name. This parameter is required when you create an OBS transfer task. Minimum: 3 Maximum: 63 |
obs_encrypted_id |
No |
String |
KMS key ID for an OBS transfer task. Required if encryption is enabled for the target OBS bucket. Minimum: 36 Maximum: 36 |
obs_dir_pre_fix_name |
No |
String |
Custom transfer path of an OBS transfer task. This parameter is optional. Minimum: 1 Maximum: 64 |
obs_prefix_name |
No |
String |
Transfer file prefix of an OBS transfer task. This parameter is optional. Minimum: 1 Maximum: 64 |
obs_time_zone |
No |
String |
Time zone for an OBS transfer task. For details, see Time Zone List for OBS Transfer. If this parameter is specified, obs_time_zone_id must also be specified. |
obs_time_zone_id |
No |
String |
ID of the time zone for an OBS transfer task. For details, see Time Zone List for OBS Transfer. If this parameter is specified, obs_time_zone must also be specified. |
dis_id |
No |
String |
DIS stream ID. This parameter is required when you create a DIS transfer task. Minimum: 1 Maximum: 128 |
dis_name |
No |
String |
DIS stream ID. This parameter is required when you create a DIS transfer task. Minimum: 1 Maximum: 64 |
kafka_id |
No |
String |
Kafka ID of a DMS transfer task. This parameter is required when you create a DMS transfer task. Before creating a DMS transfer task, register your Kafka instance with Kafka ID and Kafka topic first. For details, see Registering a DMS Kafka Instance. |
kafka_topic |
No |
String |
Kafka topic of a DMS transfer task. This parameter is required when you create a DMS transfer task. Before creating a DMS transfer task, register your Kafka instance with Kafka ID and Kafka topic first. For details, see Registering a DMS Kafka Instance. |
obs_transfer_path |
No |
String |
OBS bucket path, which is the log transfer destination. |
obs_eps_id |
No |
String |
Enterprise project ID of an OBS transfer task. |
obs_encrypted_enable |
No |
Boolean |
Whether OBS bucket encryption is enabled. |
tags |
No |
Array of strings |
If tag delivery is enabled, this field must contain the following host information: hostIP, hostId, hostName, pathFile, and collectTime. The common fields are logStreamName, regionName, logGroupName, and projectId, which are optional. The tag for enabling transfer is streamTag, which is optional. |
lts_tags |
No |
Array of strings |
Whether to transfer the tag field. This parameter is optional when the JSON format is selected for DMS transfer. |
stream_tags |
No |
Array of strings |
Whether to transfer the log stream tag field. This parameter is optional when the JSON format is selected for DMS transfer. |
struct_fields |
No |
Array of strings |
Whether to transfer the structured fields. This parameter is optional when the JSON format is selected for DMS transfer. |
invalid_field_value |
No |
String |
Whether to enable the invalid field fill function. This parameter is optional when the JSON format is selected for DMS transfer. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
log_group_id |
String |
Log group ID. Minimum: 36 Maximum: 36 |
log_group_name |
String |
Log group name. Minimum: 1 Maximum: 64 |
log_streams |
Array of log_streams objects |
Log stream list. |
log_transfer_id |
String |
Log transfer task ID. Minimum: 36 Maximum: 36 |
log_transfer_info |
log_transfer_info_RespBody object |
Log transfer information. |
Parameter |
Type |
Description |
---|---|---|
log_stream_id |
String |
Log stream ID. Minimum: 36 Maximum: 36 |
log_stream_name |
String |
Log stream name. Minimum: 1 Maximum: 64 |
Parameter |
Type |
Description |
---|---|---|
log_agency_transfer |
log_agency_transfer object |
Information about delegated log transfer. This parameter is returned for a delegated log transfer task. |
log_create_time |
Integer |
Time when the log transfer task was created. Minimum: 0 Maximum: 2147483647 |
log_storage_format |
String |
Log transfer format. The value can be RAW or JSON. RAW indicates the raw log format, and JSON indicates the JSON format. JSON and RAW are supported for OBS and DIS transfer tasks, but only RAW is supported for DMS transfer tasks. |
log_transfer_detail |
TransferDetail object |
Log transfer details. |
log_transfer_mode |
String |
Log transfer mode. cycle indicates periodical transfer, and realTime indicates real-time transfer. cycle is available to OBS transfer tasks and realTime is available to DIS and DMS transfer tasks. |
log_transfer_status |
String |
Log transfer status. ENABLE indicates that log transfer is enabled, DISABLE indicates that log transfer is disabled, and EXCEPTION indicates that log transfer is abnormal. |
log_transfer_type |
String |
Log transfer type. You can transfer logs to OBS, DIS, and DMS. |
Parameter |
Type |
Description |
---|---|---|
agency_domain_id |
String |
Delegator account ID. Minimum: 1 Maximum: 128 |
agency_domain_name |
String |
Delegator account name. Minimum: 1 Maximum: 128 |
agency_name |
String |
Name of the agency created by the delegator. Minimum: 1 Maximum: 128 |
agency_project_id |
String |
Project ID of the delegator. Minimum: 32 Maximum: 32 |
be_agency_domain_id |
String |
Account ID of the delegated party (ID of the account that created the log transfer task). Minimum: 1 Maximum: 128 |
be_agency_project_id |
String |
Project ID of the delegated party (project ID of the account that created the log transfer task). Minimum: 32 Maximum: 32 |
Parameter |
Type |
Description |
---|---|---|
obs_period |
Integer |
Length of the transfer interval for an OBS transfer task. This parameter is required when you create an OBS transfer task. The log transfer interval is specified by the combination of the values of obs_period and obs_period_unit, and must be set to one of the following: 2 min, 5 min, 30 min, 1 hour, 3 hours, 6 hours, and 12 hours. |
obs_period_unit |
String |
Unit of the transfer interval for an OBS transfer task. This parameter is required when you create an OBS transfer task. The log transfer interval is specified by the combination of the values of obs_period and obs_period_unit, and must be set to one of the following: 2 min, 5 min, 30 min, 1 hour, 3 hours, 6 hours, and 12 hours. |
obs_bucket_name |
String |
OBS log bucket name. This parameter is required when you create an OBS transfer task. Minimum length: 3 characters. Maximum length: 63 characters. Minimum: 3 Maximum: 63 |
obs_encrypted_id |
String |
KMS key ID for an OBS transfer task. Required if encryption is enabled for the target OBS bucket. Minimum length: 36 characters. Maximum length: 36 characters. Minimum: 36 Maximum: 36 |
obs_dir_pre_fix_name |
String |
Custom transfer path of an OBS transfer task. This parameter is optional. The value must match the regular expression: ^(/)?([a-zA-Z0-9.-]+)(/[a-zA-Z0-9.-]+)*(/)?$ Minimum length: 1 character. Maximum length: 64 characters. Minimum: 1 Maximum: 64 |
obs_prefix_name |
String |
Transfer file prefix of an OBS transfer task. This parameter is optional. The value must match the regular expression: ^[a-zA-Z0-9._-]*$ Minimum length: 1 character. Maximum length: 64 characters. Minimum: 1 Maximum: 64 |
obs_time_zone |
String |
Time zone for an OBS transfer task. For details, see Time Zone List for OBS Transfer. If this parameter is specified, obs_time_zone_id must also be specified. |
obs_time_zone_id |
String |
ID of the time zone for an OBS transfer task. For details, see Time Zone List for OBS Transfer. If this parameter is specified, obs_time_zone must also be specified. |
dis_id |
String |
DIS stream ID. This parameter is required when you create a DIS transfer task. Minimum length: 1 character. Maximum length: 128 characters. Minimum: 1 Maximum: 128 |
dis_name |
String |
DIS stream ID. This parameter is required when you create a DIS transfer task. Minimum length: 1 character. Maximum length: 128 characters. Minimum: 1 Maximum: 128 |
kafka_id |
String |
Kafka ID of a DMS transfer task. This parameter is required when you create a DMS transfer task. Before creating a DMS transfer task, register your Kafka instance with Kafka ID and Kafka topic first. For details, see Registering a DMS Kafka Instance. Minimum: 36 Maximum: 36 |
kafka_topic |
String |
Kafka topic of a DMS transfer task. Before creating a DMS transfer task, register your Kafka instance with Kafka ID and Kafka topic first. For details, see Registering a DMS Kafka Instance. Minimum: 1 Maximum: 128 |
obs_transfer_path |
String |
OBS bucket path, which is the log transfer destination. Minimum: 0 Maximum: 256 |
obs_eps_id |
String |
Enterprise project ID of an OBS transfer task. Minimum: 0 Maximum: 128 |
obs_encrypted_enable |
Boolean |
Whether OBS bucket encryption is enabled. |
tags |
Array of strings |
If tag delivery is enabled, this field must contain the following host information: hostIP, hostId, hostName, pathFile, and collectTime. The common fields include logStreamName, regionName, logGroupName and projectId, which are optional. The transfer tag streamTag is optional. |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. Minimum: 8 Maximum: 8 |
error_msg |
String |
Error message. |
Status code: 500
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. Minimum: 8 Maximum: 8 |
error_msg |
String |
Error message. |
Example Requests
-
Updating an OBS transfer task
PUT https://{endpoint}/v2/{project_id}/transfers { "log_transfer_id" : "9f74e101-b969-483c-a610-d3f3064xxxxx", "log_transfer_info" : { "log_storage_format" : "JSON", "log_transfer_status" : "DISABLE", "log_transfer_detail" : { "obs_period" : 3, "obs_period_unit" : "hour", "obs_bucket_name" : "0xxx", "obs_encrypted_id" : "1bd90032-1424-481f-8558-ba49854xxxxx", "obs_dir_pre_fix_name" : "/xx", "obs_prefix_name" : "xxxxx", "obs_time_zone" : "UTC+01:00", "obs_time_zone_id" : "Africa/Lagos" } } }
-
Updating a DIS transfer task
PUT https://{endpoint}/v2/{project_id}/transfers { "log_transfer_id" : "9f74e101-b969-483c-a610-d3f3064xxxxx", "log_transfer_info" : { "log_storage_format" : "JSON", "log_transfer_status" : "DISABLE", "log_transfer_detail" : { "dis_id" : "xxxxx", "dis_name" : "xxxxxx" } } }
-
Updating a DMS transfer task
PUT https://{endpoint}/v2/{project_id}/transfers { "log_transfer_id" : "9f74e101-b969-483c-a610-d3f3064xxxxx", "log_transfer_info" : { "log_storage_format" : "JSON", "log_transfer_status" : "DISABLE", "log_transfer_detail" : { "kafka_id" : "xxxxx", "kafka_topic" : "xxxxxx" } } }
Example Responses
Status code: 200
The transfer task is updated.
-
The following parameters are returned for an OBS transfer task:
{ "log_group_id" : "9a7e2183-2d6d-4732-9a9b-e897fd4e49e0", "log_group_name" : "lts-group-kafka", "log_streams" : [ { "log_stream_id" : "839dac89-35af-4db2-ab4a-a7dda0d0d3f8", "log_stream_name" : "lts-topic-kafka" } ], "log_transfer_id" : "ddced522-233a-4181-a5fc-7b458c819afc", "log_transfer_info" : { "log_create_time" : 1634802241847, "log_storage_format" : "JSON", "log_agency_transfer" : { "agency_domain_id" : "1d26cc8c86a840e28a4f8d0d078xxxxx", "agency_domain_name" : "paas_apm_z004xxxxx_xx", "agency_name" : "test20210325", "agency_project_id" : "2a473356cca5487f8373be891bfxxxxx", "be_agency_domain_id" : "1d26cc8c86a840e28a4f8d0d078xxxxx", "be_agency_project_id" : "2a473356cca5487f8373be891bfxxxxx" }, "log_transfer_detail" : { "obs_period" : 2, "obs_prefix_name" : "", "obs_period_unit" : "min", "obs_transfer_path" : "/0002/LogTanks/cn-north-7/", "obs_bucket_name" : "0002", "obs_encrypted_enable" : false, "obs_dir_pre_fix_name" : "", "obs_time_zone" : "UTC+01:00", "obs_time_zone_id" : "Africa/Lagos", "tags" : [ ] }, "log_transfer_mode" : "cycle", "log_transfer_status" : "ENABLE", "log_transfer_type" : "OBS" } }
-
The following parameters are returned for a DIS transfer task:
{ "log_group_id" : "9a7e2183-2d6d-4732-9a9b-e897fd4e49e0", "log_group_name" : "lts-group-kafka", "log_streams" : [ { "log_stream_id" : "839dac89-35af-4db2-ab4a-a7dda0d0d3f8", "log_stream_name" : "lts-topic-kafka" } ], "log_transfer_id" : "ddced522-233a-4181-a5fc-7b458c819afc", "log_transfer_info" : { "log_create_time" : 1634802241847, "log_storage_format" : "JSON", "log_agency_transfer" : { "agency_domain_id" : "1d26cc8c86a840e28a4f8d0d078xxxxx", "agency_domain_name" : "paas_apm_z004xxxxx_xx", "agency_name" : "test20210325", "agency_project_id" : "2a473356cca5487f8373be891bfxxxxx", "be_agency_domain_id" : "1d26cc8c86a840e28a4f8d0d078xxxxx", "be_agency_project_id" : "2a473356cca5487f8373be891bfxxxxx" }, "log_transfer_detail" : { "dis_id" : "xxxxx", "dis_name" : "xxxxxx", "tags" : [ ] }, "log_transfer_mode" : "cycle", "log_transfer_status" : "ENABLE", "log_transfer_type" : "OBS" } }
-
The following parameters are returned for a DMS transfer task:
{ "log_group_id" : "9a7e2183-2d6d-4732-9a9b-e897fd4e49e0", "log_group_name" : "lts-group-kafka", "log_streams" : [ { "log_stream_id" : "839dac89-35af-4db2-ab4a-a7dda0d0d3f8", "log_stream_name" : "lts-topic-kafka" } ], "log_transfer_id" : "ddced522-233a-4181-a5fc-7b458c819afc", "log_transfer_info" : { "log_create_time" : 1634802241847, "log_storage_format" : "JSON", "log_agency_transfer" : { "agency_domain_id" : "1d26cc8c86a840e28a4f8d0d078xxxxx", "agency_domain_name" : "paas_apm_z004xxxxx_xx", "agency_name" : "test20210325", "agency_project_id" : "2a473356cca5487f8373be891bfxxxxx", "be_agency_domain_id" : "1d26cc8c86a840e28a4f8d0d078xxxxx", "be_agency_project_id" : "2a473356cca5487f8373be891bfxxxxx" }, "log_transfer_detail" : { "kafka_id" : "xxxxxx", "kafka_topic" : "xxxxx", "tags" : [ ] }, "log_transfer_mode" : "cycle", "log_transfer_status" : "ENABLE", "log_transfer_type" : "OBS" } }
Status code: 400
Invalid request. Modify the request based on the description in error_msg before a retry.
{ "error_code" : "LTS.0009", "error_msg" : "The Field transfer id is invalid or missing." }
Status code: 500
The server has received the request but encountered an internal error.
{ "error_code" : "LTS.0010", "error_msg" : "The system encountered an internal error" }
SDK Sample Code
The SDK sample code is as follows.
-
Updating an OBS transfer task
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
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.lts.v2.region.LtsRegion; import com.huaweicloud.sdk.lts.v2.*; import com.huaweicloud.sdk.lts.v2.model.*; public class UpdateTransferSolution { 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); LtsClient client = LtsClient.newBuilder() .withCredential(auth) .withRegion(LtsRegion.valueOf("<YOUR REGION>")) .build(); UpdateTransferRequest request = new UpdateTransferRequest(); UpdateTransferRequestBody body = new UpdateTransferRequestBody(); TransferDetail logTransferDetailLogTransferInfo = new TransferDetail(); logTransferDetailLogTransferInfo.withObsPeriod(TransferDetail.ObsPeriodEnum.NUMBER_3) .withObsEncryptedId("1bd90032-1424-481f-8558-ba49854xxxxx") .withObsPrefixName("xxxxx") .withObsPeriodUnit("hour") .withObsBucketName("0xxx") .withObsDirPreFixName("/xx") .withObsTimeZone("UTC+01:00") .withObsTimeZoneId("Africa/Lagos"); UpdateTransferRequestBodyLogTransferInfo logTransferInfobody = new UpdateTransferRequestBodyLogTransferInfo(); logTransferInfobody.withLogStorageFormat(UpdateTransferRequestBodyLogTransferInfo.LogStorageFormatEnum.fromValue("JSON")) .withLogTransferStatus(UpdateTransferRequestBodyLogTransferInfo.LogTransferStatusEnum.fromValue("DISABLE")) .withLogTransferDetail(logTransferDetailLogTransferInfo); body.withLogTransferInfo(logTransferInfobody); body.withLogTransferId("9f74e101-b969-483c-a610-d3f3064xxxxx"); request.withBody(body); try { UpdateTransferResponse response = client.updateTransfer(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()); } } }
-
Updating a DIS transfer task
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
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.lts.v2.region.LtsRegion; import com.huaweicloud.sdk.lts.v2.*; import com.huaweicloud.sdk.lts.v2.model.*; public class UpdateTransferSolution { 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); LtsClient client = LtsClient.newBuilder() .withCredential(auth) .withRegion(LtsRegion.valueOf("<YOUR REGION>")) .build(); UpdateTransferRequest request = new UpdateTransferRequest(); UpdateTransferRequestBody body = new UpdateTransferRequestBody(); TransferDetail logTransferDetailLogTransferInfo = new TransferDetail(); logTransferDetailLogTransferInfo.withDisId("xxxxx") .withDisName("xxxxxx"); UpdateTransferRequestBodyLogTransferInfo logTransferInfobody = new UpdateTransferRequestBodyLogTransferInfo(); logTransferInfobody.withLogStorageFormat(UpdateTransferRequestBodyLogTransferInfo.LogStorageFormatEnum.fromValue("JSON")) .withLogTransferStatus(UpdateTransferRequestBodyLogTransferInfo.LogTransferStatusEnum.fromValue("DISABLE")) .withLogTransferDetail(logTransferDetailLogTransferInfo); body.withLogTransferInfo(logTransferInfobody); body.withLogTransferId("9f74e101-b969-483c-a610-d3f3064xxxxx"); request.withBody(body); try { UpdateTransferResponse response = client.updateTransfer(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()); } } }
-
Updating a DMS transfer task
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
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.lts.v2.region.LtsRegion; import com.huaweicloud.sdk.lts.v2.*; import com.huaweicloud.sdk.lts.v2.model.*; public class UpdateTransferSolution { 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); LtsClient client = LtsClient.newBuilder() .withCredential(auth) .withRegion(LtsRegion.valueOf("<YOUR REGION>")) .build(); UpdateTransferRequest request = new UpdateTransferRequest(); UpdateTransferRequestBody body = new UpdateTransferRequestBody(); TransferDetail logTransferDetailLogTransferInfo = new TransferDetail(); logTransferDetailLogTransferInfo.withKafkaId("xxxxx") .withKafkaTopic("xxxxxx"); UpdateTransferRequestBodyLogTransferInfo logTransferInfobody = new UpdateTransferRequestBodyLogTransferInfo(); logTransferInfobody.withLogStorageFormat(UpdateTransferRequestBodyLogTransferInfo.LogStorageFormatEnum.fromValue("JSON")) .withLogTransferStatus(UpdateTransferRequestBodyLogTransferInfo.LogTransferStatusEnum.fromValue("DISABLE")) .withLogTransferDetail(logTransferDetailLogTransferInfo); body.withLogTransferInfo(logTransferInfobody); body.withLogTransferId("9f74e101-b969-483c-a610-d3f3064xxxxx"); request.withBody(body); try { UpdateTransferResponse response = client.updateTransfer(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()); } } }
-
Updating an OBS transfer task
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
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdklts.v2.region.lts_region import LtsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdklts.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 = LtsClient.new_builder() \ .with_credentials(credentials) \ .with_region(LtsRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateTransferRequest() logTransferDetailLogTransferInfo = TransferDetail( obs_period=3, obs_encrypted_id="1bd90032-1424-481f-8558-ba49854xxxxx", obs_prefix_name="xxxxx", obs_period_unit="hour", obs_bucket_name="0xxx", obs_dir_pre_fix_name="/xx", obs_time_zone="UTC+01:00", obs_time_zone_id="Africa/Lagos" ) logTransferInfobody = UpdateTransferRequestBodyLogTransferInfo( log_storage_format="JSON", log_transfer_status="DISABLE", log_transfer_detail=logTransferDetailLogTransferInfo ) request.body = UpdateTransferRequestBody( log_transfer_info=logTransferInfobody, log_transfer_id="9f74e101-b969-483c-a610-d3f3064xxxxx" ) response = client.update_transfer(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
Updating a DIS transfer task
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
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdklts.v2.region.lts_region import LtsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdklts.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 = LtsClient.new_builder() \ .with_credentials(credentials) \ .with_region(LtsRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateTransferRequest() logTransferDetailLogTransferInfo = TransferDetail( dis_id="xxxxx", dis_name="xxxxxx" ) logTransferInfobody = UpdateTransferRequestBodyLogTransferInfo( log_storage_format="JSON", log_transfer_status="DISABLE", log_transfer_detail=logTransferDetailLogTransferInfo ) request.body = UpdateTransferRequestBody( log_transfer_info=logTransferInfobody, log_transfer_id="9f74e101-b969-483c-a610-d3f3064xxxxx" ) response = client.update_transfer(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
Updating a DMS transfer task
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
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdklts.v2.region.lts_region import LtsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdklts.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 = LtsClient.new_builder() \ .with_credentials(credentials) \ .with_region(LtsRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateTransferRequest() logTransferDetailLogTransferInfo = TransferDetail( kafka_id="xxxxx", kafka_topic="xxxxxx" ) logTransferInfobody = UpdateTransferRequestBodyLogTransferInfo( log_storage_format="JSON", log_transfer_status="DISABLE", log_transfer_detail=logTransferDetailLogTransferInfo ) request.body = UpdateTransferRequestBody( log_transfer_info=logTransferInfobody, log_transfer_id="9f74e101-b969-483c-a610-d3f3064xxxxx" ) response = client.update_transfer(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
Updating an OBS transfer task
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
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" lts "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/lts/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/lts/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/lts/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 := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := lts.NewLtsClient( lts.LtsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.UpdateTransferRequest{} obsEncryptedIdLogTransferDetail:= "1bd90032-1424-481f-8558-ba49854xxxxx" obsPrefixNameLogTransferDetail:= "xxxxx" obsDirPreFixNameLogTransferDetail:= "/xx" obsTimeZoneLogTransferDetail:= "UTC+01:00" obsTimeZoneIdLogTransferDetail:= "Africa/Lagos" logTransferDetailLogTransferInfo := &model.TransferDetail{ ObsPeriod: model.GetTransferDetailObsPeriodEnum().E_3, ObsEncryptedId: &obsEncryptedIdLogTransferDetail, ObsPrefixName: &obsPrefixNameLogTransferDetail, ObsPeriodUnit: "hour", ObsBucketName: "0xxx", ObsDirPreFixName: &obsDirPreFixNameLogTransferDetail, ObsTimeZone: &obsTimeZoneLogTransferDetail, ObsTimeZoneId: &obsTimeZoneIdLogTransferDetail, } logTransferInfobody := &model.UpdateTransferRequestBodyLogTransferInfo{ LogStorageFormat: model.GetUpdateTransferRequestBodyLogTransferInfoLogStorageFormatEnum().JSON, LogTransferStatus: model.GetUpdateTransferRequestBodyLogTransferInfoLogTransferStatusEnum().DISABLE, LogTransferDetail: logTransferDetailLogTransferInfo, } request.Body = &model.UpdateTransferRequestBody{ LogTransferInfo: logTransferInfobody, LogTransferId: "9f74e101-b969-483c-a610-d3f3064xxxxx", } response, err := client.UpdateTransfer(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
Updating a DIS transfer task
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
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" lts "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/lts/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/lts/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/lts/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 := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := lts.NewLtsClient( lts.LtsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.UpdateTransferRequest{} disIdLogTransferDetail:= "xxxxx" disNameLogTransferDetail:= "xxxxxx" logTransferDetailLogTransferInfo := &model.TransferDetail{ DisId: &disIdLogTransferDetail, DisName: &disNameLogTransferDetail, } logTransferInfobody := &model.UpdateTransferRequestBodyLogTransferInfo{ LogStorageFormat: model.GetUpdateTransferRequestBodyLogTransferInfoLogStorageFormatEnum().JSON, LogTransferStatus: model.GetUpdateTransferRequestBodyLogTransferInfoLogTransferStatusEnum().DISABLE, LogTransferDetail: logTransferDetailLogTransferInfo, } request.Body = &model.UpdateTransferRequestBody{ LogTransferInfo: logTransferInfobody, LogTransferId: "9f74e101-b969-483c-a610-d3f3064xxxxx", } response, err := client.UpdateTransfer(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
Updating a DMS transfer task
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
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" lts "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/lts/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/lts/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/lts/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 := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := lts.NewLtsClient( lts.LtsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.UpdateTransferRequest{} kafkaIdLogTransferDetail:= "xxxxx" kafkaTopicLogTransferDetail:= "xxxxxx" logTransferDetailLogTransferInfo := &model.TransferDetail{ KafkaId: &kafkaIdLogTransferDetail, KafkaTopic: &kafkaTopicLogTransferDetail, } logTransferInfobody := &model.UpdateTransferRequestBodyLogTransferInfo{ LogStorageFormat: model.GetUpdateTransferRequestBodyLogTransferInfoLogStorageFormatEnum().JSON, LogTransferStatus: model.GetUpdateTransferRequestBodyLogTransferInfoLogTransferStatusEnum().DISABLE, LogTransferDetail: logTransferDetailLogTransferInfo, } request.Body = &model.UpdateTransferRequestBody{ LogTransferInfo: logTransferInfobody, LogTransferId: "9f74e101-b969-483c-a610-d3f3064xxxxx", } response, err := client.UpdateTransfer(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 |
The transfer task is updated. |
400 |
Invalid request. Modify the request based on the description in error_msg before a retry. |
500 |
The server has received the request but encountered an internal error. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank 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