更新日志转储
功能介绍
该接口用于更新OBS转储,DIS转储,DMS转储。
调用方法
请参见如何调用API。
URI
PUT /v2/{project_id}/transfers
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
项目ID,获取方式请参见:获取项目ID,获取账号ID,日志组ID、日志流ID 最小长度:32 最大长度:32 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
从IAM服务获取的用户Token,获取方式请参见:获取用户Token 最小长度:1000 最大长度:2000 |
Content-Type |
是 |
String |
该字段填为:application/json;charset=UTF-8。 最小长度:30 最大长度:30 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
log_transfer_id |
是 |
String |
日志转储ID 最小长度:36 最大长度:36 |
log_transfer_info |
是 |
update_log_transfer_info object |
日志转储信息 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
log_storage_format |
是 |
String |
日志转储格式。只支持"RAW", "JSON"。RAW是指原始日志格式,JSON是指JSON日志格式。 |
log_transfer_status |
是 |
String |
日志转储状态,ENABLE是指日志转储开启状态,DISABLE是指日志转储关闭状态,EXCEPTION是指日志转储异常状态 |
log_transfer_detail |
是 |
log_transfer_detail object |
日志转储详细信息 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
obs_period |
是 |
Integer |
OBS转储时间。当创建OBS转储时,必填此参数。与obs_period_unit组合,即"obs_period"+"obs_period_unit",必须是"2min", "5min", "30min", "1hour", "3hour", "6hour","12hour"。 |
obs_period_unit |
是 |
String |
OBS转储单位。当创建OBS转储时,必填此参数。与obs_period组合,即"obs_period"+"obs_period_unit",必须是"2min", "5min", "30min", "1hour", "3hour", "6hour","12hour"。 |
obs_bucket_name |
是 |
String |
OBS转储日志桶名称。当创建OBS转储时,必填此参数。 最小长度:3 最大长度:63 |
obs_encrypted_id |
否 |
String |
OBS转储KMS密钥ID。根据OBS转储日志桶是否加密判断,若OBS转储日志加密桶则必须填写该参数,若OBS转储日志桶则不需要此参数 最小长度:36 最大长度:36 |
obs_dir_pre_fix_name |
否 |
String |
OBS转储自定义转储路径。当创建OBS转储时,根据需要选填此参数。 最小长度:1 最大长度:64 |
obs_prefix_name |
否 |
String |
OBS转储日志文件前缀。当创建OBS转储时,根据需要选填此参数。 最小长度:1 最大长度:64 |
obs_time_zone |
否 |
String |
OBS转储时区。参数选择参考OBS转储时区表。如果选择该参数,则必须选择obs_time_zone_id。 |
obs_time_zone_id |
否 |
String |
OBS转储时区ID。参数选择参考OBS转储时区表。如果选择该参数,则必须选择obs_time_zone。 |
dis_id |
否 |
String |
DIS转储通道ID。当创建DIS转储时,必填此参数。 最小长度:1 最大长度:128 |
dis_name |
否 |
String |
DIS转储通道名称。当创建DIS转储时,必填此参数。 最小长度:1 最大长度:64 |
kafka_id |
否 |
String |
DMS转储kafka ID。当创建DMS转储时,必填此参数。创建DMS转储前,需要使用kafka ID以及kafka Topic进行实例注册。详情见接口注册DMSkafka实例 |
kafka_topic |
否 |
String |
DMS转储kafka topic。当创建DMS转储时,必填此参数。创建DMS转储前,需要使用kafka ID以及kafka Topic进行实例注册。详情见接口注册DMSkafka实例 |
obs_transfer_path |
否 |
String |
OBS转储路径,指OBS日志桶中的路径。 |
obs_eps_id |
否 |
String |
OBS企业项目ID。 |
obs_encrypted_enable |
否 |
Boolean |
OBS是否开启加密。 |
tags |
否 |
Array of strings |
若开启tag投递,该字段必须包含主机信息:hostIP、hostId、hostName、pathFile、collectTime; 公共字段有:logStreamName、regionName、logGroupName、projectId,为可选填;开启转储标签:streamTag,可选填 |
lts_tags |
否 |
Array of strings |
dms转储JSON格式选填,可以转储tag字段 |
stream_tags |
否 |
Array of strings |
dms转储JSON格式选填,可以转储日志流标签字段 |
struct_fields |
否 |
Array of strings |
dms转储JSON格式选填,可以转储结构化字段 |
invalid_field_value |
否 |
String |
dms转储JSON格式选填,无效字段填充 |
响应参数
状态码: 200
参数 |
参数类型 |
描述 |
---|---|---|
log_group_id |
String |
日志组ID 最小长度:36 最大长度:36 |
log_group_name |
String |
日志组名称 最小长度:1 最大长度:64 |
log_streams |
Array of log_streams objects |
日志流集合 |
log_transfer_id |
String |
日志转储ID 最小长度:36 最大长度:36 |
log_transfer_info |
log_transfer_info_RespBody object |
日志转储信息 |
参数 |
参数类型 |
描述 |
---|---|---|
log_stream_id |
String |
日志流ID 最小长度:36 最大长度:36 |
log_stream_name |
String |
日志流名称 最小长度:1 最大长度:64 |
参数 |
参数类型 |
描述 |
---|---|---|
log_agency_transfer |
log_agency_transfer object |
委托转储信息。若转储为委托转储,则会返回该参数 |
log_create_time |
Integer |
日志转储创建时间 最小值:0 最大值:2147483647 |
log_storage_format |
String |
日志转储格式。只支持"RAW", "JSON"。RAW是指原始日志格式,JSON是指JSON日志格式。OBS转储和DIS转储支持JSON和RAW,DMS转储仅支持RAW |
log_transfer_detail |
TransferDetail object |
日志转储详细信息 |
log_transfer_mode |
String |
日志转储方式。cycle是指周期性转储,realTime是指实时转储。OBS转储只支持"cycle",DIS转储和DMS转储只支持"realTime"。 |
log_transfer_status |
String |
日志转储状态,ENABLE是指日志转储开启状态,DISABLE是指日志转储关闭状态,EXCEPTION是指日志转储异常状态 |
log_transfer_type |
String |
日志转储类型。OBS指OBS日志转储,DIS指DIS日志转储,DMS指DMS日志转储。 |
参数 |
参数类型 |
描述 |
---|---|---|
agency_domain_id |
String |
委托方账号ID 最小长度:1 最大长度:128 |
agency_domain_name |
String |
委托方账号名称 最小长度:1 最大长度:128 |
agency_name |
String |
委托方配置的委托名称 最小长度:1 最大长度:128 |
agency_project_id |
String |
委托方项目ID 最小长度:32 最大长度:32 |
be_agency_domain_id |
String |
被委托方账号ID,实际配置转储的账号ID 最小长度:1 最大长度:128 |
be_agency_project_id |
String |
被委托方项目ID,实际配置转储的账号的项目ID 最小长度:32 最大长度:32 |
参数 |
参数类型 |
描述 |
---|---|---|
obs_period |
Integer |
OBS转储时间。当创建OBS转储时,必填此参数。与obs_period_unit组合,即"obs_period"+"obs_period_unit",必须是"2min", "5min", "30min", "1hour", "3hour", "6hour","12hour"。 |
obs_period_unit |
String |
OBS转储单位。当创建OBS转储时,必填此参数。与obs_period_unit组合,即"obs_period"+"obs_period_unit",必须是"2min", "5min", "30min", "1hour", "3hour", "6hour","12hour"。 |
obs_bucket_name |
String |
OBS日志桶名称。当创建OBS转储时,必填此参数。 最小长度:3 最大长度:63 最小长度:3 最大长度:63 |
obs_encrypted_id |
String |
OBS转储KMS密钥ID。根据OBS转储日志桶是否加密判断,若OBS转储日志桶加密则必须填写该参数,若OBS转储日志桶则不需要此参数。 最小长度:36 最大长度:36 最小长度:36 最大长度:36 |
obs_dir_pre_fix_name |
String |
OBS转储自定义转储路径。当创建OBS转储时,根据需要选填此参数。 正则约束: ^(/)?([a-zA-Z0-9.-]+)(/[a-zA-Z0-9.-]+)*(/)?$ 最小长度:1 最大长度:64 最小长度:1 最大长度:64 |
obs_prefix_name |
String |
OBS转储日志文件前缀。当创建OBS转储时,根据需要选填此参数。 正则约束: ^[a-zA-Z0-9._-]*$ 最小长度:1 最大长度:64 最小长度:1 最大长度:64 |
obs_time_zone |
String |
OBS转储时区,参数选择请参考OBS转储时区表。如果选择该参数,则必须选择obs_time_zone_id。 |
obs_time_zone_id |
String |
OBS转储时区ID,参数选择请参考OBS转储时区表。如果选择该参数,则必须选择obs_time_zone。 |
dis_id |
String |
DIS转储通道ID。当创建DIS转储时,必填此参数。 最小长度:1 最大长度:128 最小长度:1 最大长度:128 |
dis_name |
String |
DIS转储通道名称。当创建DIS转储时,必填此参数。 最小长度:1 最大长度:128 最小长度:1 最大长度:128 |
kafka_id |
String |
DMS转储kafka ID。当创建DMS转储时,必填此参数。 创建DMS转储前,需要使用kafka ID以及kafka Topic进行实例注册。详情见接口注册DMSkafka实例 最小长度:36 最大长度:36 |
kafka_topic |
String |
DMS转储kafka topic。 创建DMS转储前,需要使用kafka ID以及kafka Topic进行实例注册。详情见接口注册DMSkafka实例 最小长度:1 最大长度:128 |
obs_transfer_path |
String |
OBS转储路径,指OBS日志桶中的路径。 最小长度:0 最大长度:256 |
obs_eps_id |
String |
OBS企业项目ID。 最小长度:0 最大长度:128 |
obs_encrypted_enable |
Boolean |
OBS是否开启加密。 |
tags |
Array of strings |
若开启tag投递,该字段必须包含主机信息:hostIP、hostId、hostName、pathFile、collectTime; 公共字段有:logStreamName、regionName、logGroupName、projectId,为可选填; 开启转储标签:streamTag,可选填 |
状态码: 400
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
错误码。 最小长度:8 最大长度:8 |
error_msg |
String |
调用失败响应信息描述。 |
状态码: 500
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
错误码。 最小长度:8 最大长度:8 |
error_msg |
String |
调用失败响应信息描述。 |
请求示例
-
更新OBS转储
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" } } }
-
更新DIS转储
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" } } }
-
更新DMS转储
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" } } }
响应示例
状态码: 200
更新转储请求响应成功。
-
当创建OBS转储时,会返回如下参数
{ "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" } }
-
当创建DIS转储时,会返回如下参数
{ "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" } }
-
当创建DMS转储时,会返回如下参数
{ "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" } }
状态码: 400
BadRequest 非法请求 建议根据error_msg直接修改该请求。
{ "error_code" : "LTS.0009", "error_msg" : "The Field transfer id is invalid or missing." }
状态码: 500
表明服务端能被请求访问到,但是服务内部出错。
{ "error_code" : "LTS.0010", "error_msg" : "The system encountered an internal error" }
SDK代码示例
SDK代码示例如下。
-
更新OBS转储
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()); } } }
-
更新DIS转储
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()); } } }
-
更新DMS转储
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()); } } }
-
更新OBS转储
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)
-
更新DIS转储
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)
-
更新DMS转储
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)
-
更新OBS转储
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) } }
-
更新DIS转储
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) } }
-
更新DMS转储
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) } }
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
更新转储请求响应成功。 |
400 |
BadRequest 非法请求 建议根据error_msg直接修改该请求。 |
500 |
表明服务端能被请求访问到,但是服务内部出错。 |
错误码
请参见错误码。