Creating a Collection Channel
Function
This API is used to create a collection channel.
Calling Method
For details, see Calling APIs.
URI
POST /v1/{project_id}/workspaces/{workspace_id}/collector/channels
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
project_id |
Yes |
String |
Definition Project ID, which is used to specify the project that a resource belongs to. You can query the resources of a project by project ID. You can obtain the project ID from the API or console. Obtaining the Project ID Constraints N/A Value Range N/A Default value N/A |
|
workspace_id |
Yes |
String |
Workspace ID. |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
X-Auth-Token |
Yes |
String |
Definition User token. You can obtain it by calling the IAM API for obtaining a user token. The user token is the value of X-Subject-Token in the response header. Obtaining a User Token Constraints N/A Range N/A Default Value N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
action |
No |
String |
Definition Node running status monitoring. Constraints N/A Range Default Value N/A |
|
description |
No |
String |
Description. |
|
group_id |
Yes |
String |
UUID |
|
input |
Yes |
Array of CreateModuleVo objects |
Description. |
|
nodes |
Yes |
Array of NodeVo objects |
Description. |
|
output |
Yes |
Array of CreateModuleVo objects |
Description. |
|
parser_id |
Yes |
String |
UUID |
|
title |
Yes |
String |
Related title. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
args |
No |
Array of ArgsVo objects |
Description. |
|
node_id |
No |
String |
UUID |
|
node_status |
No |
String |
Definition Node status. Constraints N/A Range Default Value N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
children |
No |
Array of CreateModuleVo objects |
Description. |
|
connection_module_id |
No |
String |
UUID |
|
fields |
No |
Array of ModuleFieldVo objects |
Description. |
|
name |
No |
String |
Name. |
|
template_id |
No |
String |
UUID |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
success |
Boolean |
Created successfully. |
Example Requests
https://{endpoint}/v1/{project_id}/workspaces/{workspace_id}/collector/channels
{
"title" : "my channel",
"group_id" : "72ce1e35-af50-4bfc-8761-7781b75431ae",
"description" : "my channel",
"input" : [ {
"name" : "tcp",
"template_id" : "d51164ad-40a4-4b26-9b9d-d454da34adec",
"connection_module_id" : "c2ba9006-7c3e-4a9a-8645-8cb491f77145",
"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" : "1025"
}, {
"template_field_id" : "4d839ce2-485c-4a93-b778-fd02b6ad308e",
"name" : "codec",
"type" : "string",
"value" : "plain"
} ]
} ],
"output" : [ {
"name" : "pulsar",
"template_id" : "c4618e27-5c9c-45fc-9a70-e5c5a7ce49d8",
"connection_module_id" : "404ae2ec-b266-4638-9559-0b63e8a374e9",
"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" : "97bfc7e0-fb64-421c-85f0-5cec5bf96bcc"
}, {
"template_field_id" : "2d5dfaed-c9d5-4e9b-b7a6-244001c3b3ee",
"name" : "domain_name",
"type" : "string",
"value" : "test"
}, {
"template_field_id" : "35c79e3b-595c-4328-927d-e181d9367393",
"name" : "user_name",
"type" : "string",
"value" : "test"
}, {
"template_field_id" : "35c79e3b-595c-4328-927d-e181d9367394",
"name" : "user_password",
"type" : "string",
"value" : "test"
} ]
} ],
"parser_id" : "a009aa99-3521-4ec0-8827-811e277515b1",
"nodes" : [ {
"node_id" : "5b5667a2-be31-46f9-bf11-363d007bdb25",
"args" : [ {
"key" : "#service_url",
"value" : "192.168.0.151"
} ]
} ],
"action" : "INSTALL"
}
Example Responses
Status code: 200
Successful.
{
"success" : true
}
SDK Sample Code
The SDK sample code is as follows.
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 |
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 CreateCollectorChannelSolution { 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(); CreateCollectorChannelRequest request = new CreateCollectorChannelRequest(); request.withWorkspaceId("{workspace_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("97bfc7e0-fb64-421c-85f0-5cec5bf96bcc") ); 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("t30032627") ); 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("404ae2ec-b266-4638-9559-0b63e8a374e9") .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.151") ); List<NodeVo> listbodyNodes = new ArrayList<>(); listbodyNodes.add( new NodeVo() .withArgs(listNodesArgs) .withNodeId("5b5667a2-be31-46f9-bf11-363d007bdb25") ); 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("1025") ); listInputFields.add( new ModuleFieldVo() .withName("codec") .withTemplateFieldId("4d839ce2-485c-4a93-b778-fd02b6ad308e") .withType("string") .withValue("plain") ); List<CreateModuleVo> listbodyInput = new ArrayList<>(); listbodyInput.add( new CreateModuleVo() .withConnectionModuleId("c2ba9006-7c3e-4a9a-8645-8cb491f77145") .withFields(listInputFields) .withName("tcp") .withTemplateId("d51164ad-40a4-4b26-9b9d-d454da34adec") ); body.withTitle("my channel"); body.withParserId("a009aa99-3521-4ec0-8827-811e277515b1"); body.withOutput(listbodyOutput); body.withNodes(listbodyNodes); body.withInput(listbodyInput); body.withGroupId("72ce1e35-af50-4bfc-8761-7781b75431ae"); body.withDescription("my channel"); body.withAction(CreateChannelDto.ActionEnum.fromValue("INSTALL")); request.withBody(body); try { CreateCollectorChannelResponse response = client.createCollectorChannel(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 |
# 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 = CreateCollectorChannelRequest() request.workspace_id = "{workspace_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="97bfc7e0-fb64-421c-85f0-5cec5bf96bcc" ), 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="t30032627" ), ModuleFieldVo( name="user_password", template_field_id="35c79e3b-595c-4328-927d-e181d9367394", type="string", value="" ) ] listOutputbody = [ CreateModuleVo( connection_module_id="404ae2ec-b266-4638-9559-0b63e8a374e9", fields=listFieldsOutput, name="pulsar", template_id="c4618e27-5c9c-45fc-9a70-e5c5a7ce49d8" ) ] listArgsNodes = [ ArgsVo( key="#service_url", value="192.168.0.151" ) ] listNodesbody = [ NodeVo( args=listArgsNodes, node_id="5b5667a2-be31-46f9-bf11-363d007bdb25" ) ] 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="1025" ), ModuleFieldVo( name="codec", template_field_id="4d839ce2-485c-4a93-b778-fd02b6ad308e", type="string", value="plain" ) ] listInputbody = [ CreateModuleVo( connection_module_id="c2ba9006-7c3e-4a9a-8645-8cb491f77145", fields=listFieldsInput, name="tcp", template_id="d51164ad-40a4-4b26-9b9d-d454da34adec" ) ] request.body = CreateChannelDto( title="my channel", parser_id="a009aa99-3521-4ec0-8827-811e277515b1", output=listOutputbody, nodes=listNodesbody, input=listInputbody, group_id="72ce1e35-af50-4bfc-8761-7781b75431ae", description="my channel", action="INSTALL" ) response = client.create_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 |
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.CreateCollectorChannelRequest{} request.WorkspaceId = "{workspace_id}" nameFields:= "type" templateFieldIdFields:= "8a767f76-9009-4197-8b34-341c81eaca44" typeFields:= "string" valueFields:= "tenant" nameFields1:= "pipeId" templateFieldIdFields1:= "8a767f76-9009-4197-8b44-341c80eaca44" typeFields1:= "string" valueFields1:= "97bfc7e0-fb64-421c-85f0-5cec5bf96bcc" 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:= "t30032627" 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:= "404ae2ec-b266-4638-9559-0b63e8a374e9" 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.151" var listArgsNodes = []model.ArgsVo{ { Key: &keyArgs, Value: &valueArgs, }, } nodeIdNodes:= "5b5667a2-be31-46f9-bf11-363d007bdb25" 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:= "1025" nameFields7:= "codec" templateFieldIdFields7:= "4d839ce2-485c-4a93-b778-fd02b6ad308e" typeFields7:= "string" valueFields7:= "plain" 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, }, } connectionModuleIdInput:= "c2ba9006-7c3e-4a9a-8645-8cb491f77145" nameInput:= "tcp" templateIdInput:= "d51164ad-40a4-4b26-9b9d-d454da34adec" var listInputbody = []model.CreateModuleVo{ { ConnectionModuleId: &connectionModuleIdInput, Fields: &listFieldsInput, Name: &nameInput, TemplateId: &templateIdInput, }, } descriptionCreateChannelDto:= "my channel" actionAction:= model.GetChannelActionActionEnum().INSTALL request.Body = &model.CreateChannelDto{ Title: "my channel", ParserId: "a009aa99-3521-4ec0-8827-811e277515b1", Output: listOutputbody, Nodes: listNodesbody, Input: listInputbody, GroupId: "72ce1e35-af50-4bfc-8761-7781b75431ae", Description: &descriptionCreateChannelDto, Action: &actionAction, } response, err := client.CreateCollectorChannel(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
Successful. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot