更新日志转储
功能介绍
该接口用于更新OBS转储,DIS转储,DMS转储。
调用方法
请参见如何调用API。
URI
PUT /v2/{project_id}/transfers
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
参数解释: 项目ID,可以从调用API处获取,也可以从控制台获取。获取方式请参见:获取项目ID。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 最小长度:32 最大长度:32 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
参数解释: 从IAM服务获取的用户Token,获取方式请参见: 获取用户Token。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 最小长度:1000 最大长度:2000 |
Content-Type |
是 |
String |
参数解释: 用于定义消息体的格式,该字段填为:application/json;charset=utf8。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 最小长度:30 最大长度:30 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
log_transfer_id |
是 |
String |
日志转储ID 最小长度:36 最大长度:36 |
log_group_id |
否 |
String |
日志组ID |
log_transfer_info |
是 |
update_log_transfer_info object |
日志转储信息 |
log_streams |
否 |
LogStreams object |
日志流信息 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
log_storage_format |
是 |
String |
参数解释: 日志转储格式。只支持"RAW", "JSON"。RAW是指原始日志格式,JSON是指JSON日志格式。 约束限制: 不涉及。 取值范围: JSON,RAW |
log_transfer_status |
是 |
String |
参数解释: 日志转储状态,ENABLE是指日志转储开启状态,DISABLE是指日志转储关闭状态,EXCEPTION是指日志转储异常状态 约束限制: 不涉及。 取值范围: 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"。 约束限制: 不涉及。 取值范围: 1,2,3,5,6,12,30 |
obs_period_unit |
是 |
String |
参数解释: OBS转储单位。当创建OBS转储时,必填此参数。与obs_period组合,即"obs_period"+"obs_period_unit",必须是"2min", "5min", "30min", "1hour", "3hour", "6hour","12hour"。 约束限制: 不涉及。 取值范围: min,hour |
obs_bucket_name |
是 |
String |
参数解释: OBS转储日志桶名称。当创建OBS转储时,必填此参数。 约束限制: 不涉及 |
obs_encrypted_id |
否 |
String |
参数解释: OBS转储KMS密钥ID。根据OBS转储日志桶是否加密判断,若OBS转储日志加密桶则必须填写该参数,若OBS转储日志桶则不需要此参数 约束限制: 不涉及 |
obs_dir_pre_fix_name |
否 |
String |
参数解释: OBS转储自定义转储路径。当创建OBS转储时,根据需要选填此参数。 约束限制: 不涉及 |
obs_prefix_name |
否 |
String |
参数解释: OBS转储日志文件前缀。当创建OBS转储时,根据需要选填此参数。 约束限制: 不涉及 |
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转储时,必填此参数。 约束限制: 不涉及 |
dis_name |
否 |
String |
参数解释: DIS转储通道名称。当创建DIS转储时,必填此参数。 约束限制: 不涉及 |
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_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。 取值范围: 不涉及。 |
log_group_name |
String |
参数解释: 已创建的日志组名称。 取值范围: 不涉及。 |
log_streams |
Array of log_streams objects |
参数解释: 日志组下的日志流详细信息。 |
log_transfer_id |
String |
参数解释: 已创建的日志转储ID。 取值范围: 不涉及 |
log_transfer_info |
log_transfer_info_RespBody object |
参数解释: 日志转储信息。 |
参数 |
参数类型 |
描述 |
---|---|---|
log_agency_transfer |
log_agency_transfer object |
参数解释: 转储委托的相关信息。 当转储的日志源为其他账号时,对委托人账号下所产生的日志进行转储,如需转储其他账号日志,需该账号使用者在IAM中创建委托。 https://support.huaweicloud.com/usermanual-iam/iam_06_0002.html |
log_create_time |
Integer |
参数解释: 日志转储的创建时间。 取值范围: 0-2147483647 |
log_storage_format |
String |
参数解释: 日志转储格式。有RAW(原始日志格式)和JSON。 不同转储对象,转储格式不同。
取值范围: RAW JSON |
log_transfer_detail |
TransferDetail object |
参数解释: 日志转储的相关信息。 |
log_transfer_mode |
String |
参数解释: 日志转储方式。有周期性转储(cycle)和实时转储(realTime)。 不同转储对象,转储方式不同。
取值范围: |
log_transfer_status |
String |
参数解释: 日志转储状态。 ENABLE:日志转储开启状态。 DISABLE:日志转储关闭状态。 EXCEPTION:日志转储异常状态。 取值范围:
|
log_transfer_type |
String |
参数解释: 日志转储类型。 OBS:日志转储至OBS。 DIS:日志转储至DIS。 DMS:日志转储至DMS。 取值范围:
|
参数 |
参数类型 |
描述 |
---|---|---|
agency_domain_id |
String |
参数解释: 委托方的账号ID。 取值范围: 不涉及。 |
agency_domain_name |
String |
参数解释: 委托方的账号名称。 取值范围: 不涉及。 |
agency_name |
String |
参数解释: 委托方配置的委托名称。 取值范围: 不涉及。 |
agency_project_id |
String |
参数解释: 委托方项目ID。 取值范围: 不涉及。 |
be_agency_domain_id |
String |
参数解释: 被委托方账号ID,实际为配置转储的账号ID。 取值范围: 不涉及。 |
be_agency_project_id |
String |
参数解释: 被委托方项目ID,实际为配置转储的项目ID。 取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
obs_period |
Integer |
参数解释: 转储至OBS的时间。当转储对象为OBS时,返回该参数。obs_period与obs_period_unit组合,即"obs_period"+"obs_period_unit",必须是"2min", "5min", "30min", "1hour", "3hour", "6hour","12hour"。 取值范围: 1、2、3、5、6、2、30 |
obs_period_unit |
String |
参数解释: 转储至OBS的时间单位。当转储对象为OBS时,返回该参数。obs_period与obs_period_unit组合,即"obs_period"+"obs_period_unit",必须是"2min", "5min", "30min", "1hour", "3hour", "6hour","12hour"。 取值范围: min hour |
obs_bucket_name |
String |
参数解释: 转储至OBS的日志桶名称。当转储对象为OBS时,返回该参数。 取值范围: 不涉及。 |
obs_encrypted_id |
String |
参数解释: 转储至OBS的KMS密钥ID。当转储对象为OBS且日志桶加密时,返回该参数。 取值范围: 不涉及。 |
obs_dir_pre_fix_name |
String |
参数解释: 转储至OBS的自定义转储路径。当转储对象为OBS时,返回该参数。将日志转储至自定义路径中,用于区分不同日志流之间的转储日志文件。 取值范围: 不涉及。 |
obs_prefix_name |
String |
参数解释: 转储至OBS桶中的日志文件前缀。 当转储对象为OBS时,返回该参数。 取值范围: 不涉及。 |
obs_time_zone |
String |
参数解释: OBS转储时区,请参考8.7 OBS转储时区表。。 https://support.huaweicloud.com/api-lts/lts_api_0111.html 取值范围: 不涉及。 |
obs_time_zone_id |
String |
参数解释: OBS转储时区ID,请参考8.7 OBS转储时区表。。 https://support.huaweicloud.com/api-lts/lts_api_0111.html 取值范围: 不涉及。 |
dis_id |
String |
参数解释: 日志转储至DIS转储通道ID。当转储至DIS时,返回该参数。 取值范围: 不涉及。 |
dis_name |
String |
参数解释: 日志转储至DIS转储通道名称。当转储至DIS时,返回该参数。 取值范围: 不涉及。 |
kafka_id |
String |
参数解释: 日志转储至DMS的kafka ID。当转储至DMS时,返回该参数。 创建DMS转储前,需要使用kafka ID以及kafka Topic进行实例注册。请参考注册DMSkafka实例。 https://support.huaweicloud.com/api-lts/RegisterDmsKafkaInstance.html 取值范围: 不涉及。 |
kafka_topic |
String |
参数解释: 日志转储至DMS的kafka topic。当转储至DMS时,返回该参数。 创建DMS转储前,需要使用kafka ID以及kafka Topic进行实例注册。请参考注册DMSkafka实例。 https://support.huaweicloud.com/api-lts/RegisterDmsKafkaInstance.html 取值范围: 不涉及。 |
obs_transfer_path |
String |
参数解释: 日志转储至OBS的路径,即OBS日志桶中的路径。 取值范围: 不涉及。 |
obs_eps_id |
String |
参数解释: OBS的企业项目ID。 取值范围: 不涉及。 |
obs_encrypted_enable |
Boolean |
参数解释: OBS是否开启加密。 取值范围: true false |
tags |
Array of strings |
参数解释: 开启tag投递。 取值范围: 不涉及。 |
状态码:400
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
参数解释: 错误码,请参见:错误码。 取值范围: 不涉及。 |
error_msg |
String |
参数解释: 调用失败响应信息描述。 取值范围: 不涉及。 |
状态码:500
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
参数解释: 错误码,请参见:错误码。 取值范围: 不涉及。 |
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
非法请求 建议根据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代码示例。
-
更新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 |
非法请求 建议根据error_msg直接修改该请求。 |
500 |
表明服务端能被请求访问到,但是服务内部出错。 |
错误码
请参见错误码。