Adding a Classification
Function
This API is used to add a classification.
Calling Method
For details, see Calling APIs.
URI
POST /v1/{project_id}/workspaces/{workspace_id}/soc/mappings/classifiers
|
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 Range N/A Default Value N/A |
|
workspace_id |
Yes |
String |
Definition Workspace ID. Range N/A |
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 |
|
Content-Type |
Yes |
String |
Definition Content type. Constraints N/A Range Default Value N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
id |
Yes |
String |
Mapping ID. |
|
name |
Yes |
String |
Name. |
|
project_id |
No |
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 Range N/A Default Value N/A |
|
workspace_id |
No |
String |
Definition Workspace ID. Range N/A |
|
dataclass_id |
Yes |
String |
Mapping ID. |
|
data_source |
Yes |
String |
Data source. |
|
description |
Yes |
String |
Description. |
|
classifier |
Yes |
DpeClassifyCreate object |
Classification creation information. |
|
mapper |
No |
CreateDpeMappingRequestBody object |
Request body for creating a categorical mapping. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
id |
Yes |
String |
Mapping ID. |
|
name |
No |
String |
Name. |
|
project_id |
No |
String |
Mapping ID. |
|
workspace_id |
No |
String |
Mapping ID. |
|
dataclass_id |
Yes |
String |
Mapping ID. |
|
data_source |
No |
String |
Data source. |
|
status |
No |
String |
Status: enabled or disabled. |
|
description |
No |
String |
Description. |
|
create_time |
No |
String |
Creation time. |
|
creator_id |
No |
String |
Creator ID. |
|
creator_name |
No |
String |
Creator name. |
|
update_time |
No |
String |
Update time. |
|
modifier_id |
No |
String |
Modifier ID. |
|
modifier_name |
No |
String |
Modifier name. |
|
mapper |
Yes |
DpeMappingDetail object |
Mapping information. |
|
classifier |
No |
DpeClassifyCreate object |
Classification creation information. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
id |
No |
String |
Mapping ID. |
|
name |
No |
String |
Name. |
|
project_id |
No |
String |
Mapping ID. |
|
workspace_id |
No |
String |
Mapping ID. |
|
dataclass_id |
No |
String |
Mapping ID. |
|
dataclass_name |
No |
String |
Data class name. |
|
mapper_type_id |
No |
String |
Mapping ID. |
|
mapping_id |
No |
String |
Mapping ID. |
|
mapping_info |
No |
DpeInfo object |
Classification information. |
|
create_time |
No |
String |
Creation time. |
|
creator_id |
No |
String |
Creator ID. |
|
creator_name |
No |
String |
Creator name. |
|
update_time |
No |
String |
Update time. |
|
modifier_id |
No |
String |
Modifier ID. |
|
modifier_name |
No |
String |
Modifier name. |
|
mapper_field_list |
No |
Array of DpeMappingFieldDetail objects |
Mapping set. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
id |
No |
String |
Mapping ID. |
|
project_id |
No |
String |
Mapping ID. |
|
workspace_id |
No |
String |
Mapping ID. |
|
dataclass_id |
No |
String |
Mapping ID. |
|
mapping_id |
No |
String |
Mapping ID. |
|
mapper_id |
No |
String |
Mapping ID. |
|
default_value |
No |
String |
Default Value |
|
target_key |
No |
String |
Target field. |
|
expression |
No |
String |
Expression. |
|
create_time |
No |
String |
Creation time. |
|
update_time |
No |
String |
Update time. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
id |
No |
String |
Mapping ID. |
|
project_id |
No |
String |
Mapping ID. |
|
workspace_id |
No |
String |
Mapping ID. |
|
dataclass_id |
No |
String |
Mapping ID. |
|
dataclass_name |
No |
String |
Data class name. |
|
mapping_id |
No |
String |
Mapping ID. |
|
direct_classifier |
No |
String |
Direct classification. |
|
direct_classifier_type_id |
No |
String |
Mapping ID. |
|
create_time |
No |
String |
Creation time. |
|
creator_id |
No |
String |
Creator ID. |
|
creator_name |
No |
String |
Creator name. |
|
update_time |
No |
String |
Update time. |
|
modifier_id |
No |
String |
Modifier ID. |
|
modifier_name |
No |
String |
Modifier name. |
|
mapping_info |
No |
DpeInfo object |
Classification information. |
|
classifier_item_list |
No |
Array of DpeClassifyItemDetail objects |
Category set element. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
id |
No |
String |
Mapping ID. |
|
name |
No |
String |
Name. |
|
project_id |
No |
String |
Mapping ID. |
|
workspace_id |
No |
String |
Mapping ID. |
|
dataclass_id |
No |
String |
Mapping ID. |
|
dataclass_name |
No |
String |
Data class name. |
|
classifier_id |
No |
String |
Associated classification ID. |
|
status |
No |
String |
Status. |
|
complete_degree |
No |
String |
Progress. |
|
instance_num |
No |
String |
The number of associated instances. |
|
built_in |
No |
String |
Whether the data is built-in. |
|
data_source |
No |
String |
Data source. |
|
description |
No |
String |
Description. |
|
update_time |
No |
String |
Update time. |
|
create_time |
No |
String |
Creation time. |
|
creator_id |
No |
String |
Creator ID. |
|
creator_name |
No |
String |
Creator name. |
|
modifier_id |
No |
String |
Modifier ID. |
|
modifier_name |
No |
String |
Modifier name. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
id |
No |
String |
Mapping ID. |
|
classifier_id |
No |
String |
Mapping ID. |
|
classifier_type_id |
No |
String |
Mapping ID. |
|
mapping_id |
No |
String |
Mapping ID. |
|
classifier_order |
No |
Integer |
Classification priority. |
|
expression |
No |
String |
Expression. |
|
create_time |
No |
String |
Creation time. |
|
update_time |
No |
String |
Update time. |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
code |
String |
Definition Error code. Range N/A |
|
message |
String |
Definition Error description. Range N/A |
|
data |
CreateDpeClassifyRequestBody object |
Request body for creating a classification mapping. |
|
Parameter |
Type |
Description |
|---|---|---|
|
id |
String |
Mapping ID. |
|
name |
String |
Name. |
|
project_id |
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 Range N/A Default Value N/A |
|
workspace_id |
String |
Definition Workspace ID. Range N/A |
|
dataclass_id |
String |
Mapping ID. |
|
data_source |
String |
Data source. |
|
description |
String |
Description. |
|
classifier |
DpeClassifyCreate object |
Classification creation information. |
|
mapper |
CreateDpeMappingRequestBody object |
Request body for creating a categorical mapping. |
|
Parameter |
Type |
Description |
|---|---|---|
|
id |
String |
Mapping ID. |
|
name |
String |
Name. |
|
project_id |
String |
Mapping ID. |
|
workspace_id |
String |
Mapping ID. |
|
dataclass_id |
String |
Mapping ID. |
|
data_source |
String |
Data source. |
|
status |
String |
Status: enabled or disabled. |
|
description |
String |
Description. |
|
create_time |
String |
Creation time. |
|
creator_id |
String |
Creator ID. |
|
creator_name |
String |
Creator name. |
|
update_time |
String |
Update time. |
|
modifier_id |
String |
Modifier ID. |
|
modifier_name |
String |
Modifier name. |
|
mapper |
DpeMappingDetail object |
Mapping information. |
|
classifier |
DpeClassifyCreate object |
Classification creation information. |
|
Parameter |
Type |
Description |
|---|---|---|
|
id |
String |
Mapping ID. |
|
name |
String |
Name. |
|
project_id |
String |
Mapping ID. |
|
workspace_id |
String |
Mapping ID. |
|
dataclass_id |
String |
Mapping ID. |
|
dataclass_name |
String |
Data class name. |
|
mapper_type_id |
String |
Mapping ID. |
|
mapping_id |
String |
Mapping ID. |
|
mapping_info |
DpeInfo object |
Classification information. |
|
create_time |
String |
Creation time. |
|
creator_id |
String |
Creator ID. |
|
creator_name |
String |
Creator name. |
|
update_time |
String |
Update time. |
|
modifier_id |
String |
Modifier ID. |
|
modifier_name |
String |
Modifier name. |
|
mapper_field_list |
Array of DpeMappingFieldDetail objects |
Mapping set. |
|
Parameter |
Type |
Description |
|---|---|---|
|
id |
String |
Mapping ID. |
|
project_id |
String |
Mapping ID. |
|
workspace_id |
String |
Mapping ID. |
|
dataclass_id |
String |
Mapping ID. |
|
mapping_id |
String |
Mapping ID. |
|
mapper_id |
String |
Mapping ID. |
|
default_value |
String |
Default Value |
|
target_key |
String |
Target field. |
|
expression |
String |
Expression. |
|
create_time |
String |
Creation time. |
|
update_time |
String |
Update time. |
|
Parameter |
Type |
Description |
|---|---|---|
|
id |
String |
Mapping ID. |
|
project_id |
String |
Mapping ID. |
|
workspace_id |
String |
Mapping ID. |
|
dataclass_id |
String |
Mapping ID. |
|
dataclass_name |
String |
Data class name. |
|
mapping_id |
String |
Mapping ID. |
|
direct_classifier |
String |
Direct classification. |
|
direct_classifier_type_id |
String |
Mapping ID. |
|
create_time |
String |
Creation time. |
|
creator_id |
String |
Creator ID. |
|
creator_name |
String |
Creator name. |
|
update_time |
String |
Update time. |
|
modifier_id |
String |
Modifier ID. |
|
modifier_name |
String |
Modifier name. |
|
mapping_info |
DpeInfo object |
Classification information. |
|
classifier_item_list |
Array of DpeClassifyItemDetail objects |
Category set element. |
|
Parameter |
Type |
Description |
|---|---|---|
|
id |
String |
Mapping ID. |
|
name |
String |
Name. |
|
project_id |
String |
Mapping ID. |
|
workspace_id |
String |
Mapping ID. |
|
dataclass_id |
String |
Mapping ID. |
|
dataclass_name |
String |
Data class name. |
|
classifier_id |
String |
Associated classification ID. |
|
status |
String |
Status. |
|
complete_degree |
String |
Progress. |
|
instance_num |
String |
The number of associated instances. |
|
built_in |
String |
Whether the data is built-in. |
|
data_source |
String |
Data source. |
|
description |
String |
Description. |
|
update_time |
String |
Update time. |
|
create_time |
String |
Creation time. |
|
creator_id |
String |
Creator ID. |
|
creator_name |
String |
Creator name. |
|
modifier_id |
String |
Modifier ID. |
|
modifier_name |
String |
Modifier name. |
|
Parameter |
Type |
Description |
|---|---|---|
|
id |
String |
Mapping ID. |
|
classifier_id |
String |
Mapping ID. |
|
classifier_type_id |
String |
Mapping ID. |
|
mapping_id |
String |
Mapping ID. |
|
classifier_order |
Integer |
Classification priority. |
|
expression |
String |
Expression. |
|
create_time |
String |
Creation time. |
|
update_time |
String |
Update time. |
Status code: 400
|
Parameter |
Type |
Description |
|---|---|---|
|
code |
String |
Definition Error code. Range N/A |
|
message |
String |
Definition Error description. Range N/A |
Example Requests
Add a category.
{
"id" : "38173e29-ba56-404e-84d7-71ca33d0e416",
"name" : "CreateClassifier",
"dataclass_id" : "38173e29-ba56-404e-84d7-71ca33d0e416",
"description" : "description",
"classifier" : {
"direct_classifier_type_id" : "38173e29-ba56-404e-84d7-71ca33d0e416",
"dataclass_name" : "Indicator",
"modifier_name" : "r00000001",
"create_time" : "2022-06-16T10:37:50Z+0800",
"dataclass_id" : "38173e29-ba56-404e-84d7-71ca33d0e416",
"workspace_id" : "38173e29-ba56-404e-84d7-71ca33d0e416",
"direct_classifier" : false,
"update_time" : "2022-06-16T10:37:50Z+0800",
"project_id" : "38173e29-ba56-404e-84d7-71ca33d0e416",
"classifier_item_list" : [ {
"classifier_id" : "38173e29-ba56-404e-84d7-71ca33d0e416",
"update_time" : "2022-06-16T10:37:50Z+0800",
"expression" : "{\"filter\":{\"conditions\":[{\"name\":\"c1\",\"data\":[\"title\",\"==\",\"xxxx\"],\"is_context\":false}],\"logics\":[\"title\"]}}javascript:void(0);",
"create_time" : "2022-06-16T10:37:50Z+0800",
"classifier_type_id" : "38173e29-ba56-404e-84d7-71ca33d0e416",
"mapping_id" : "38173e29-ba56-404e-84d7-71ca33d0e416",
"classifier_order" : 3,
"id" : "38173e29-ba56-404e-84d7-71ca33d0e416"
} ],
"mapping_id" : "38173e29-ba56-404e-84d7-71ca33d0e416",
"id" : "38173e29-ba56-404e-84d7-71ca33d0e416"
},
"mapper" : null,
"data_source" : "CFW"
}
Example Responses
Status code: 200
Response to the request for adding a classification.
{
"code" : "00000000",
"data" : {
"classifier" : {
"classifier_item_list" : [ {
"classifier_order" : "0",
"classifier_type_id" : "23f48a58c5b2fbb037c2162846076cd0",
"expression" : "{\"filter\":{\"logics\":[\"general-classify-field-0\"],\"conditions\":[{\"data\":[\"ops.csvc\",\"Equals\",\"secmaster\"],\"name\":\"general-classify-field-0\",\"is_contxt\":true}]},\"transformer\":{},\"pre_filter\":{}}"
} ],
"dataclass_id" : "",
"direct_classifier" : "false",
"direct_classifier_type_id" : "",
"id" : "4e47a0f5-60c8-4999-afc4-e595bd5de041",
"mapping_id" : "",
"project_id" : "",
"workspace_id" : ""
},
"data_source" : "CFW",
"dataclass_id" : "a5883c13-39b6-34e4-ae4f-a5256bf7e27d",
"description" : "CreateClassifier",
"id" : "33dbe0e6-f242-47a6-8ddc-eaea8f405258",
"mapper" : null,
"name" : "CreateClassifier",
"project_id" : "15645222e8744afa985c93dab6341da6",
"workspace_id" : "5e6377d9-548d-43d7-9241-fb63a75a464e"
},
"message" : ""
}
SDK Sample Code
The SDK sample code is as follows.
Add a category.
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 |
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 CreateClassifierSolution { 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(); CreateClassifierRequest request = new CreateClassifierRequest(); request.withWorkspaceId("{workspace_id}"); CreateDpeClassifyRequestBody body = new CreateDpeClassifyRequestBody(); List<DpeClassifyItemDetail> listClassifierClassifierItemList = new ArrayList<>(); listClassifierClassifierItemList.add( new DpeClassifyItemDetail() .withId("38173e29-ba56-404e-84d7-71ca33d0e416") .withClassifierId("38173e29-ba56-404e-84d7-71ca33d0e416") .withClassifierTypeId("38173e29-ba56-404e-84d7-71ca33d0e416") .withMappingId("38173e29-ba56-404e-84d7-71ca33d0e416") .withClassifierOrder(3) .withExpression("{"filter":{"conditions":[{"name":"c1","data":["title","==","xxxx"],"is_context":false}],"logics":["title"]}}javascript:void(0);") .withCreateTime("2022-06-16T10:37:50Z+0800") .withUpdateTime("2022-06-16T10:37:50Z+0800") ); DpeInfo mappingInfoClassifier = new DpeInfo(); mappingInfoClassifier.withId("38173e29-ba56-404e-84d7-71ca33d0e416") .withName("CreateClassifier") .withProjectId("38173e29-ba56-404e-84d7-71ca33d0e416") .withWorkspaceId("38173e29-ba56-404e-84d7-71ca33d0e416") .withDataclassId("38173e29-ba56-404e-84d7-71ca33d0e416") .withDataclassName("Indicator") .withClassifierId("909494e3-558e-46b6-a9eb-07a8e18ca62f") .withStatus("enabled") .withCompleteDegree("YYY") .withInstanceNum("0") .withDescription("description") .withUpdateTime("2022-06-16T10:37:50Z+0800") .withCreateTime("2022-06-16T10:37:50Z+0800") .withCreatorId("r00000001") .withCreatorName("r00000001") .withModifierId("r00000001") .withModifierName("r00000001"); DpeClassifyCreate classifierbody = new DpeClassifyCreate(); classifierbody.withId("38173e29-ba56-404e-84d7-71ca33d0e416") .withProjectId("38173e29-ba56-404e-84d7-71ca33d0e416") .withWorkspaceId("38173e29-ba56-404e-84d7-71ca33d0e416") .withDataclassId("38173e29-ba56-404e-84d7-71ca33d0e416") .withDataclassName("Indicator") .withMappingId("38173e29-ba56-404e-84d7-71ca33d0e416") .withDirectClassifier("false") .withDirectClassifierTypeId("38173e29-ba56-404e-84d7-71ca33d0e416") .withCreateTime("2022-06-16T10:37:50Z+0800") .withCreatorId("r00000001") .withCreatorName("r00000001") .withUpdateTime("2022-06-16T10:37:50Z+0800") .withModifierId("r00000001") .withModifierName("r00000001") .withMappingInfo(mappingInfoClassifier) .withClassifierItemList(listClassifierClassifierItemList); body.withClassifier(classifierbody); body.withDescription("description"); body.withDataSource("CFW"); body.withDataclassId("38173e29-ba56-404e-84d7-71ca33d0e416"); body.withName("CreateClassifier"); body.withId("38173e29-ba56-404e-84d7-71ca33d0e416"); request.withBody(body); try { CreateClassifierResponse response = client.createClassifier(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()); } } } |
Add a category.
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 |
# 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 = CreateClassifierRequest() request.workspace_id = "{workspace_id}" listClassifierItemListClassifier = [ DpeClassifyItemDetail( id="38173e29-ba56-404e-84d7-71ca33d0e416", classifier_id="38173e29-ba56-404e-84d7-71ca33d0e416", classifier_type_id="38173e29-ba56-404e-84d7-71ca33d0e416", mapping_id="38173e29-ba56-404e-84d7-71ca33d0e416", classifier_order=3, expression="{"filter":{"conditions":[{"name":"c1","data":["title","==","xxxx"],"is_context":false}],"logics":["title"]}}javascript:void(0);", create_time="2022-06-16T10:37:50Z+0800", update_time="2022-06-16T10:37:50Z+0800" ) ] mappingInfoClassifier = DpeInfo( id="38173e29-ba56-404e-84d7-71ca33d0e416", name="CreateClassifier", project_id="38173e29-ba56-404e-84d7-71ca33d0e416", workspace_id="38173e29-ba56-404e-84d7-71ca33d0e416", dataclass_id="38173e29-ba56-404e-84d7-71ca33d0e416", dataclass_name="Indicator", classifier_id="909494e3-558e-46b6-a9eb-07a8e18ca62f", status="enabled", complete_degree="YYY", instance_num="0", description="description", update_time="2022-06-16T10:37:50Z+0800", create_time="2022-06-16T10:37:50Z+0800", creator_id="r00000001", creator_name="r00000001", modifier_id="r00000001", modifier_name="r00000001" ) classifierbody = DpeClassifyCreate( id="38173e29-ba56-404e-84d7-71ca33d0e416", project_id="38173e29-ba56-404e-84d7-71ca33d0e416", workspace_id="38173e29-ba56-404e-84d7-71ca33d0e416", dataclass_id="38173e29-ba56-404e-84d7-71ca33d0e416", dataclass_name="Indicator", mapping_id="38173e29-ba56-404e-84d7-71ca33d0e416", direct_classifier="false", direct_classifier_type_id="38173e29-ba56-404e-84d7-71ca33d0e416", create_time="2022-06-16T10:37:50Z+0800", creator_id="r00000001", creator_name="r00000001", update_time="2022-06-16T10:37:50Z+0800", modifier_id="r00000001", modifier_name="r00000001", mapping_info=mappingInfoClassifier, classifier_item_list=listClassifierItemListClassifier ) request.body = CreateDpeClassifyRequestBody( classifier=classifierbody, description="description", data_source="CFW", dataclass_id="38173e29-ba56-404e-84d7-71ca33d0e416", name="CreateClassifier", id="38173e29-ba56-404e-84d7-71ca33d0e416" ) response = client.create_classifier(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Add a category.
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 |
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.CreateClassifierRequest{} request.WorkspaceId = "{workspace_id}" classifierIdClassifierItemList:= "38173e29-ba56-404e-84d7-71ca33d0e416" classifierTypeIdClassifierItemList:= "38173e29-ba56-404e-84d7-71ca33d0e416" mappingIdClassifierItemList:= "38173e29-ba56-404e-84d7-71ca33d0e416" classifierOrderClassifierItemList:= int32(3) expressionClassifierItemList:= "{"filter":{"conditions":[{"name":"c1","data":["title","==","xxxx"],"is_context":false}],"logics":["title"]}}javascript:void(0);" createTimeClassifierItemList:= "2022-06-16T10:37:50Z+0800" updateTimeClassifierItemList:= "2022-06-16T10:37:50Z+0800" var listClassifierItemListClassifier = []model.DpeClassifyItemDetail{ { Id: "38173e29-ba56-404e-84d7-71ca33d0e416", ClassifierId: &classifierIdClassifierItemList, ClassifierTypeId: &classifierTypeIdClassifierItemList, MappingId: &mappingIdClassifierItemList, ClassifierOrder: &classifierOrderClassifierItemList, Expression: &expressionClassifierItemList, CreateTime: &createTimeClassifierItemList, UpdateTime: &updateTimeClassifierItemList, }, } projectIdMappingInfo:= "38173e29-ba56-404e-84d7-71ca33d0e416" workspaceIdMappingInfo:= "38173e29-ba56-404e-84d7-71ca33d0e416" dataclassNameMappingInfo:= "Indicator" classifierIdMappingInfo:= "909494e3-558e-46b6-a9eb-07a8e18ca62f" statusMappingInfo:= "enabled" completeDegreeMappingInfo:= "YYY" instanceNumMappingInfo:= "0" updateTimeMappingInfo:= "2022-06-16T10:37:50Z+0800" createTimeMappingInfo:= "2022-06-16T10:37:50Z+0800" creatorIdMappingInfo:= "r00000001" creatorNameMappingInfo:= "r00000001" modifierIdMappingInfo:= "r00000001" modifierNameMappingInfo:= "r00000001" mappingInfoClassifier := &model.DpeInfo{ Id: "38173e29-ba56-404e-84d7-71ca33d0e416", Name: "CreateClassifier", ProjectId: &projectIdMappingInfo, WorkspaceId: &workspaceIdMappingInfo, DataclassId: "38173e29-ba56-404e-84d7-71ca33d0e416", DataclassName: &dataclassNameMappingInfo, ClassifierId: &classifierIdMappingInfo, Status: &statusMappingInfo, CompleteDegree: &completeDegreeMappingInfo, InstanceNum: &instanceNumMappingInfo, Description: "description", UpdateTime: &updateTimeMappingInfo, CreateTime: &createTimeMappingInfo, CreatorId: &creatorIdMappingInfo, CreatorName: &creatorNameMappingInfo, ModifierId: &modifierIdMappingInfo, ModifierName: &modifierNameMappingInfo, } projectIdClassifier:= "38173e29-ba56-404e-84d7-71ca33d0e416" workspaceIdClassifier:= "38173e29-ba56-404e-84d7-71ca33d0e416" dataclassNameClassifier:= "Indicator" mappingIdClassifier:= "38173e29-ba56-404e-84d7-71ca33d0e416" var directClassifierClassifier interface{} = "false" directClassifierTypeIdClassifier:= "38173e29-ba56-404e-84d7-71ca33d0e416" createTimeClassifier:= "2022-06-16T10:37:50Z+0800" creatorIdClassifier:= "r00000001" creatorNameClassifier:= "r00000001" updateTimeClassifier:= "2022-06-16T10:37:50Z+0800" modifierIdClassifier:= "r00000001" modifierNameClassifier:= "r00000001" classifierbody := &model.DpeClassifyCreate{ Id: "38173e29-ba56-404e-84d7-71ca33d0e416", ProjectId: &projectIdClassifier, WorkspaceId: &workspaceIdClassifier, DataclassId: "38173e29-ba56-404e-84d7-71ca33d0e416", DataclassName: &dataclassNameClassifier, MappingId: &mappingIdClassifier, DirectClassifier: &directClassifierClassifier, DirectClassifierTypeId: &directClassifierTypeIdClassifier, CreateTime: &createTimeClassifier, CreatorId: &creatorIdClassifier, CreatorName: &creatorNameClassifier, UpdateTime: &updateTimeClassifier, ModifierId: &modifierIdClassifier, ModifierName: &modifierNameClassifier, MappingInfo: mappingInfoClassifier, ClassifierItemList: &listClassifierItemListClassifier, } request.Body = &model.CreateDpeClassifyRequestBody{ Classifier: classifierbody, Description: "description", DataSource: "CFW", DataclassId: "38173e29-ba56-404e-84d7-71ca33d0e416", Name: "CreateClassifier", Id: "38173e29-ba56-404e-84d7-71ca33d0e416", } response, err := client.CreateClassifier(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 |
Response to the request for adding a classification. |
|
400 |
Returned packet for abnormal requests. |
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