更改采集通道 - UpdateCollectorChannel
功能介绍
更改采集通道
调用方法
请参见如何调用API。
授权信息
账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限,具体权限要求请参见权限和授权项。
URI
PUT /v1/{project_id}/workspaces/{workspace_id}/collector/channels/{channel_id}
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
project_id |
是 |
String |
参数解释: 项目ID,用于明确项目归属,配置后可通过该ID查询项目下资产,可以通过调用API获取,也可以从控制台获取。获取项目ID 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
|
workspace_id |
是 |
String |
工作空间ID |
|
channel_id |
是 |
String |
采集通道ID |
请求参数
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
X-Auth-Token |
是 |
String |
参数解释: 用户Token,通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。获取用户Token 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
action |
否 |
String |
参数解释: 节点运行状态的监控 约束限制 不涉及 取值范围: 默认值 不涉及 |
|
description |
否 |
String |
描述信息 |
|
group_id |
是 |
String |
UUID |
|
input |
是 |
Array of CreateModuleVo objects |
相关描述信息 |
|
nodes |
是 |
Array of NodeVo objects |
相关描述信息 |
|
output |
是 |
Array of CreateModuleVo objects |
相关描述信息 |
|
parser_id |
是 |
String |
UUID |
|
title |
是 |
String |
相关标题 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
args |
否 |
Array of ArgsVo objects |
相关描述信息 |
|
node_id |
否 |
String |
UUID |
|
node_status |
否 |
String |
参数解释: 节点状态 约束限制 不涉及 取值范围: 默认值 不涉及 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
children |
否 |
Array of CreateModuleVo objects |
相关描述信息 |
|
connection_module_id |
否 |
String |
UUID |
|
fields |
否 |
Array of ModuleFieldVo objects |
相关描述信息 |
|
name |
否 |
String |
名称 |
|
template_id |
否 |
String |
UUID |
响应参数
状态码:200
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
success |
Boolean |
创建成功 |
请求示例
https://{endpoint}/v1/{project_id}/workspaces/{workspace_id}/collector/channels/{channel_id}
{
"title" : "honneypot-channel",
"group_id" : "94e44a23-2673-4779-9517-f3b1ee451e7c",
"description" : "",
"input" : [ {
"name" : "tcp",
"template_id" : "d51164ad-40a4-4b26-9b9d-d454da34adec",
"connection_module_id" : "8e70986f-9a4f-4aef-a693-ec50747a8bf4",
"fields" : [ {
"template_field_id" : "926867ed-e31f-4766-911b-bad57f0c436a",
"name" : "mode",
"type" : "string",
"value" : "server"
}, {
"template_field_id" : "a784d1d7-e049-4602-a7a8-c8cc1bff8c65",
"name" : "port",
"type" : "number",
"value" : "6666"
}, {
"template_field_id" : "4d839ce2-485c-4a93-b778-fd02b6ad308e",
"name" : "codec",
"type" : "string",
"value" : "json"
}, {
"template_field_id" : "774ce36f-6a46-4114-9d9f-6fba83590fd7",
"name" : "type",
"type" : "string",
"value" : "tcp"
} ]
} ],
"output" : [ {
"name" : "pulsar",
"template_id" : "c4618e27-5c9c-45fc-9a70-e5c5a7ce49d8",
"connection_module_id" : "2dcaadc1-83a1-442f-bbd2-7e88d0b05c69",
"fields" : [ {
"template_field_id" : "8a767f76-9009-4197-8b34-341c81eaca44",
"name" : "type",
"type" : "string",
"value" : "tenant"
}, {
"template_field_id" : "8a767f76-9009-4197-8b44-341c80eaca44",
"name" : "pipeId",
"type" : "string",
"value" : "fa4dad11-ed76-4fff-911d-7bedfe80ce03"
}, {
"template_field_id" : "2d5dfaed-c9d5-4e9b-b7a6-244001c3b3ee",
"name" : "domain_name",
"type" : "string",
"value" : "hwstaff_p_SecCMCC"
}, {
"template_field_id" : "35c79e3b-595c-4328-927d-e181d9367393",
"name" : "user_name",
"type" : "string",
"value" : "deploy"
}, {
"template_field_id" : "35c79e3b-595c-4328-927d-e181d9367394",
"name" : "user_password",
"type" : "string",
"value" : ""
} ]
} ],
"parser_id" : "a009aa99-3521-4ec0-8827-811e277515b1",
"nodes" : [ {
"node_id" : "95cf3f44fd144595b84c5957fde4d739",
"args" : [ {
"key" : "#service_url",
"value" : "192.168.0.49"
} ]
} ],
"action" : "INSTALL"
}
响应示例
状态码:200
成功
{
"success" : true
}
SDK代码示例
SDK代码示例如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
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.secmaster.v1.region.SecMasterRegion; import com.huaweicloud.sdk.secmaster.v1.*; import com.huaweicloud.sdk.secmaster.v1.model.*; import java.util.List; import java.util.ArrayList; public class UpdateCollectorChannelSolution { 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); SecMasterClient client = SecMasterClient.newBuilder() .withCredential(auth) .withRegion(SecMasterRegion.valueOf("<YOUR REGION>")) .build(); UpdateCollectorChannelRequest request = new UpdateCollectorChannelRequest(); request.withWorkspaceId("{workspace_id}"); request.withChannelId("{channel_id}"); CreateChannelDto body = new CreateChannelDto(); List<ModuleFieldVo> listOutputFields = new ArrayList<>(); listOutputFields.add( new ModuleFieldVo() .withName("type") .withTemplateFieldId("8a767f76-9009-4197-8b34-341c81eaca44") .withType("string") .withValue("tenant") ); listOutputFields.add( new ModuleFieldVo() .withName("pipeId") .withTemplateFieldId("8a767f76-9009-4197-8b44-341c80eaca44") .withType("string") .withValue("fa4dad11-ed76-4fff-911d-7bedfe80ce03") ); listOutputFields.add( new ModuleFieldVo() .withName("domain_name") .withTemplateFieldId("2d5dfaed-c9d5-4e9b-b7a6-244001c3b3ee") .withType("string") .withValue("hwstaff_p_SecCMCC") ); listOutputFields.add( new ModuleFieldVo() .withName("user_name") .withTemplateFieldId("35c79e3b-595c-4328-927d-e181d9367393") .withType("string") .withValue("deploy") ); listOutputFields.add( new ModuleFieldVo() .withName("user_password") .withTemplateFieldId("35c79e3b-595c-4328-927d-e181d9367394") .withType("string") .withValue("") ); List<CreateModuleVo> listbodyOutput = new ArrayList<>(); listbodyOutput.add( new CreateModuleVo() .withConnectionModuleId("2dcaadc1-83a1-442f-bbd2-7e88d0b05c69") .withFields(listOutputFields) .withName("pulsar") .withTemplateId("c4618e27-5c9c-45fc-9a70-e5c5a7ce49d8") ); List<ArgsVo> listNodesArgs = new ArrayList<>(); listNodesArgs.add( new ArgsVo() .withKey("#service_url") .withValue("192.168.0.49") ); List<NodeVo> listbodyNodes = new ArrayList<>(); listbodyNodes.add( new NodeVo() .withArgs(listNodesArgs) .withNodeId("95cf3f44fd144595b84c5957fde4d739") ); List<ModuleFieldVo> listInputFields = new ArrayList<>(); listInputFields.add( new ModuleFieldVo() .withName("mode") .withTemplateFieldId("926867ed-e31f-4766-911b-bad57f0c436a") .withType("string") .withValue("server") ); listInputFields.add( new ModuleFieldVo() .withName("port") .withTemplateFieldId("a784d1d7-e049-4602-a7a8-c8cc1bff8c65") .withType("number") .withValue("6666") ); listInputFields.add( new ModuleFieldVo() .withName("codec") .withTemplateFieldId("4d839ce2-485c-4a93-b778-fd02b6ad308e") .withType("string") .withValue("json") ); listInputFields.add( new ModuleFieldVo() .withName("type") .withTemplateFieldId("774ce36f-6a46-4114-9d9f-6fba83590fd7") .withType("string") .withValue("tcp") ); List<CreateModuleVo> listbodyInput = new ArrayList<>(); listbodyInput.add( new CreateModuleVo() .withConnectionModuleId("8e70986f-9a4f-4aef-a693-ec50747a8bf4") .withFields(listInputFields) .withName("tcp") .withTemplateId("d51164ad-40a4-4b26-9b9d-d454da34adec") ); body.withTitle("honneypot-channel"); body.withParserId("a009aa99-3521-4ec0-8827-811e277515b1"); body.withOutput(listbodyOutput); body.withNodes(listbodyNodes); body.withInput(listbodyInput); body.withGroupId("94e44a23-2673-4779-9517-f3b1ee451e7c"); body.withDescription(""); body.withAction(CreateChannelDto.ActionEnum.fromValue("INSTALL")); request.withBody(body); try { UpdateCollectorChannelResponse response = client.updateCollectorChannel(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdksecmaster.v1.region.secmaster_region import SecMasterRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdksecmaster.v1 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = SecMasterClient.new_builder() \ .with_credentials(credentials) \ .with_region(SecMasterRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateCollectorChannelRequest() request.workspace_id = "{workspace_id}" request.channel_id = "{channel_id}" listFieldsOutput = [ ModuleFieldVo( name="type", template_field_id="8a767f76-9009-4197-8b34-341c81eaca44", type="string", value="tenant" ), ModuleFieldVo( name="pipeId", template_field_id="8a767f76-9009-4197-8b44-341c80eaca44", type="string", value="fa4dad11-ed76-4fff-911d-7bedfe80ce03" ), ModuleFieldVo( name="domain_name", template_field_id="2d5dfaed-c9d5-4e9b-b7a6-244001c3b3ee", type="string", value="hwstaff_p_SecCMCC" ), ModuleFieldVo( name="user_name", template_field_id="35c79e3b-595c-4328-927d-e181d9367393", type="string", value="deploy" ), ModuleFieldVo( name="user_password", template_field_id="35c79e3b-595c-4328-927d-e181d9367394", type="string", value="" ) ] listOutputbody = [ CreateModuleVo( connection_module_id="2dcaadc1-83a1-442f-bbd2-7e88d0b05c69", fields=listFieldsOutput, name="pulsar", template_id="c4618e27-5c9c-45fc-9a70-e5c5a7ce49d8" ) ] listArgsNodes = [ ArgsVo( key="#service_url", value="192.168.0.49" ) ] listNodesbody = [ NodeVo( args=listArgsNodes, node_id="95cf3f44fd144595b84c5957fde4d739" ) ] listFieldsInput = [ ModuleFieldVo( name="mode", template_field_id="926867ed-e31f-4766-911b-bad57f0c436a", type="string", value="server" ), ModuleFieldVo( name="port", template_field_id="a784d1d7-e049-4602-a7a8-c8cc1bff8c65", type="number", value="6666" ), ModuleFieldVo( name="codec", template_field_id="4d839ce2-485c-4a93-b778-fd02b6ad308e", type="string", value="json" ), ModuleFieldVo( name="type", template_field_id="774ce36f-6a46-4114-9d9f-6fba83590fd7", type="string", value="tcp" ) ] listInputbody = [ CreateModuleVo( connection_module_id="8e70986f-9a4f-4aef-a693-ec50747a8bf4", fields=listFieldsInput, name="tcp", template_id="d51164ad-40a4-4b26-9b9d-d454da34adec" ) ] request.body = CreateChannelDto( title="honneypot-channel", parser_id="a009aa99-3521-4ec0-8827-811e277515b1", output=listOutputbody, nodes=listNodesbody, input=listInputbody, group_id="94e44a23-2673-4779-9517-f3b1ee451e7c", description="", action="INSTALL" ) response = client.update_collector_channel(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" secmaster "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := secmaster.NewSecMasterClient( secmaster.SecMasterClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.UpdateCollectorChannelRequest{} request.WorkspaceId = "{workspace_id}" request.ChannelId = "{channel_id}" nameFields:= "type" templateFieldIdFields:= "8a767f76-9009-4197-8b34-341c81eaca44" typeFields:= "string" valueFields:= "tenant" nameFields1:= "pipeId" templateFieldIdFields1:= "8a767f76-9009-4197-8b44-341c80eaca44" typeFields1:= "string" valueFields1:= "fa4dad11-ed76-4fff-911d-7bedfe80ce03" nameFields2:= "domain_name" templateFieldIdFields2:= "2d5dfaed-c9d5-4e9b-b7a6-244001c3b3ee" typeFields2:= "string" valueFields2:= "hwstaff_p_SecCMCC" nameFields3:= "user_name" templateFieldIdFields3:= "35c79e3b-595c-4328-927d-e181d9367393" typeFields3:= "string" valueFields3:= "deploy" nameFields4:= "user_password" templateFieldIdFields4:= "35c79e3b-595c-4328-927d-e181d9367394" typeFields4:= "string" valueFields4:= "" var listFieldsOutput = []model.ModuleFieldVo{ { Name: &nameFields, TemplateFieldId: &templateFieldIdFields, Type: &typeFields, Value: &valueFields, }, { Name: &nameFields1, TemplateFieldId: &templateFieldIdFields1, Type: &typeFields1, Value: &valueFields1, }, { Name: &nameFields2, TemplateFieldId: &templateFieldIdFields2, Type: &typeFields2, Value: &valueFields2, }, { Name: &nameFields3, TemplateFieldId: &templateFieldIdFields3, Type: &typeFields3, Value: &valueFields3, }, { Name: &nameFields4, TemplateFieldId: &templateFieldIdFields4, Type: &typeFields4, Value: &valueFields4, }, } connectionModuleIdOutput:= "2dcaadc1-83a1-442f-bbd2-7e88d0b05c69" nameOutput:= "pulsar" templateIdOutput:= "c4618e27-5c9c-45fc-9a70-e5c5a7ce49d8" var listOutputbody = []model.CreateModuleVo{ { ConnectionModuleId: &connectionModuleIdOutput, Fields: &listFieldsOutput, Name: &nameOutput, TemplateId: &templateIdOutput, }, } keyArgs:= "#service_url" valueArgs:= "192.168.0.49" var listArgsNodes = []model.ArgsVo{ { Key: &keyArgs, Value: &valueArgs, }, } nodeIdNodes:= "95cf3f44fd144595b84c5957fde4d739" var listNodesbody = []model.NodeVo{ { Args: &listArgsNodes, NodeId: &nodeIdNodes, }, } nameFields5:= "mode" templateFieldIdFields5:= "926867ed-e31f-4766-911b-bad57f0c436a" typeFields5:= "string" valueFields5:= "server" nameFields6:= "port" templateFieldIdFields6:= "a784d1d7-e049-4602-a7a8-c8cc1bff8c65" typeFields6:= "number" valueFields6:= "6666" nameFields7:= "codec" templateFieldIdFields7:= "4d839ce2-485c-4a93-b778-fd02b6ad308e" typeFields7:= "string" valueFields7:= "json" nameFields8:= "type" templateFieldIdFields8:= "774ce36f-6a46-4114-9d9f-6fba83590fd7" typeFields8:= "string" valueFields8:= "tcp" var listFieldsInput = []model.ModuleFieldVo{ { Name: &nameFields5, TemplateFieldId: &templateFieldIdFields5, Type: &typeFields5, Value: &valueFields5, }, { Name: &nameFields6, TemplateFieldId: &templateFieldIdFields6, Type: &typeFields6, Value: &valueFields6, }, { Name: &nameFields7, TemplateFieldId: &templateFieldIdFields7, Type: &typeFields7, Value: &valueFields7, }, { Name: &nameFields8, TemplateFieldId: &templateFieldIdFields8, Type: &typeFields8, Value: &valueFields8, }, } connectionModuleIdInput:= "8e70986f-9a4f-4aef-a693-ec50747a8bf4" nameInput:= "tcp" templateIdInput:= "d51164ad-40a4-4b26-9b9d-d454da34adec" var listInputbody = []model.CreateModuleVo{ { ConnectionModuleId: &connectionModuleIdInput, Fields: &listFieldsInput, Name: &nameInput, TemplateId: &templateIdInput, }, } descriptionCreateChannelDto:= "" actionAction:= model.GetChannelActionActionEnum().INSTALL request.Body = &model.CreateChannelDto{ Title: "honneypot-channel", ParserId: "a009aa99-3521-4ec0-8827-811e277515b1", Output: listOutputbody, Nodes: listNodesbody, Input: listInputbody, GroupId: "94e44a23-2673-4779-9517-f3b1ee451e7c", Description: &descriptionCreateChannelDto, Action: &actionAction, } response, err := client.UpdateCollectorChannel(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
|
状态码 |
描述 |
|---|---|
|
200 |
成功 |
错误码
请参见错误码。