Adding a Data Class Type
Function
This API is used to add a data type.
Calling Method
For details, see Calling APIs.
URI
POST /v1/{project_id}/workspaces/{workspace_id}/soc/dataclasses/{dataclass_id}/types
|
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 |
|
dataclass_id |
Yes |
String |
Unique ID of a data class. |
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 |
|---|---|---|---|
|
sub_category |
No |
String |
Subtype name. This parameter is mandatory for the alert type and incident type. This parameter is not required for the threat intelligence type, vulnerability type, or custom type. |
|
sub_category_code |
No |
String |
Subtype ID. This parameter is mandatory for the alert type and incident type. This parameter is not required for the threat intelligence type, vulnerability type, or custom type. |
|
category |
No |
String |
Type name. This parameter is mandatory for the alert type, incident type, threat intelligence type, and vulnerability type. This parameter is not required for the custom type. |
|
category_code |
No |
String |
Type ID. This parameter is mandatory for the alert type, incident type, threat intelligence type, and vulnerability type. This parameter is not required for the custom type. |
|
name |
No |
String |
Name of the custom type. Name of the created type or subtype. (This parameter is mandatory for the custom type. This parameter is not required for other types.) |
|
business_code |
No |
String |
ID of the custom type. ID of the created type or subtype. (This parameter is mandatory for the custom type. This parameter is not required for other types.) |
|
dataclass_business_code |
No |
String |
Business code of the data class type. This parameter is mandatory for the custom type. (This parameter is not required for other types.) |
|
description |
No |
String |
Type description. |
|
level |
No |
Integer |
Type level. This parameter is mandatory for the custom type. The options are as follows: 1: type; 2: subtype. (This parameter is not required for other types.) |
|
enabled |
Yes |
Boolean |
Enabling status of the type. true: enabled; false: disabled. |
|
sla |
Yes |
Long |
Response duration. |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
id |
String |
Type ID. |
|
dataclass_id |
String |
Data class ID. |
|
domain_id |
String |
Account ID. |
|
project_id |
String |
Project ID. |
|
workspace_id |
String |
Workspace ID. |
|
region_id |
String |
Region ID. |
|
layout_id |
String |
Layout ID. |
|
layout_name |
String |
Layout name. |
|
category |
String |
Category of the data class type. |
|
category_code |
String |
Category code of the data class type. |
|
sub_category |
String |
Data class type name. |
|
sub_category_code |
String |
Business code of the data class type. |
|
description |
String |
Data class type description. |
|
enabled |
Boolean |
Status. |
|
level |
Integer |
Incident severity. |
|
is_built_in |
Boolean |
Built-in or not. true: Built-in; false: Custom. |
|
sla |
Long |
Response duration. |
|
creator_id |
String |
Creator ID. |
|
creator_name |
String |
Creator name. |
|
modifier_id |
String |
Modifier ID. |
|
modifier_name |
String |
Modifier name. |
|
create_time |
String |
Creation time. |
|
update_time |
String |
Modification time. |
|
dataclass_business_code |
String |
Business code of the data class. |
|
sub_count |
Integer |
Number of types under the category. |
Status code: 400
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code. |
|
error_msg |
String |
Error description. |
Example Requests
-
{ "category" : "TestCategory", "category_code" : "Test Category Code", "sub_category" : "TestSubType", "sub_category_code" : "Test Alert Type Code", "enabled" : true, "sla" : 86400000, "description" : null } -
{ "level" : 1, "name" : "TestResource", "business_code" : "Test Resource Category Code", "enabled" : true, "sla" : 0, "description" : null, "dataclass_business_code" : "Resource" }
Example Responses
Status code: 200
Response body for successful type addition requests.
{
"category" : "TestAlertCategory",
"category_code" : "Test Alert Category Code",
"create_time" : "2025-12-19T17:31:27Z+0800",
"creator_id" : "b40b54b1f27a4224aa0c95ede5b5a46a",
"creator_name" : "l00644738",
"dataclass_business_code" : "Alert",
"dataclass_id" : "",
"description" : "",
"domain_id" : "",
"enabled" : true,
"id" : "2312dad0-0fc0-314d-bf18-5a87e99c3b16",
"is_built_in" : false,
"layout_id" : "",
"layout_name" : "",
"level" : null,
"modifier_id" : "",
"modifier_name" : "",
"project_id" : "15645222e8744afa985c93dab6341da6",
"region_id" : "",
"sla" : 86400000,
"sub_category" : "TestAlertSubType",
"sub_category_code" : "Test Alert Sub Type Code",
"sub_count" : null,
"update_time" : null,
"workspace_id" : "ea956472-44a9-47d6-808b-03b95d06f355"
}
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
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.*; public class CreateDataclassTypeSolution { 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(); CreateDataclassTypeRequest request = new CreateDataclassTypeRequest(); request.withWorkspaceId("{workspace_id}"); request.withDataclassId("{dataclass_id}"); CreateDataclassTypeRequestBody body = new CreateDataclassTypeRequestBody(); body.withSla(86400000L); body.withEnabled(true); body.withCategoryCode("Test Category Code"); body.withCategory("TestCategory"); body.withSubCategoryCode("Test Alert Type Code"); body.withSubCategory("TestSubType"); request.withBody(body); try { CreateDataclassTypeResponse response = client.createDataclassType(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
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.*; public class CreateDataclassTypeSolution { 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(); CreateDataclassTypeRequest request = new CreateDataclassTypeRequest(); request.withWorkspaceId("{workspace_id}"); request.withDataclassId("{dataclass_id}"); CreateDataclassTypeRequestBody body = new CreateDataclassTypeRequestBody(); body.withSla(0L); body.withEnabled(true); body.withLevel(CreateDataclassTypeRequestBody.LevelEnum.NUMBER_1); body.withDataclassBusinessCode("Resource"); body.withBusinessCode("Test Resource Category Code"); body.withName("TestResource"); request.withBody(body); try { CreateDataclassTypeResponse response = client.createDataclassType(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
# 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 = CreateDataclassTypeRequest() request.workspace_id = "{workspace_id}" request.dataclass_id = "{dataclass_id}" request.body = CreateDataclassTypeRequestBody( sla=86400000, enabled=True, category_code="Test Category Code", category="TestCategory", sub_category_code="Test Alert Type Code", sub_category="TestSubType" ) response = client.create_dataclass_type(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
# 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 = CreateDataclassTypeRequest() request.workspace_id = "{workspace_id}" request.dataclass_id = "{dataclass_id}" request.body = CreateDataclassTypeRequestBody( sla=0, enabled=True, level=1, dataclass_business_code="Resource", business_code="Test Resource Category Code", name="TestResource" ) response = client.create_dataclass_type(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
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.CreateDataclassTypeRequest{} request.WorkspaceId = "{workspace_id}" request.DataclassId = "{dataclass_id}" categoryCodeCreateDataclassTypeRequestBody:= "Test Category Code" categoryCreateDataclassTypeRequestBody:= "TestCategory" subCategoryCodeCreateDataclassTypeRequestBody:= "Test Alert Type Code" subCategoryCreateDataclassTypeRequestBody:= "TestSubType" request.Body = &model.CreateDataclassTypeRequestBody{ Sla: int64(86400000), Enabled: true, CategoryCode: &categoryCodeCreateDataclassTypeRequestBody, Category: &categoryCreateDataclassTypeRequestBody, SubCategoryCode: &subCategoryCodeCreateDataclassTypeRequestBody, SubCategory: &subCategoryCreateDataclassTypeRequestBody, } response, err := client.CreateDataclassType(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
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
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.CreateDataclassTypeRequest{} request.WorkspaceId = "{workspace_id}" request.DataclassId = "{dataclass_id}" levelCreateDataclassTypeRequestBody:= model.GetCreateDataclassTypeRequestBodyLevelEnum().E_1 dataclassBusinessCodeCreateDataclassTypeRequestBody:= "Resource" businessCodeCreateDataclassTypeRequestBody:= "Test Resource Category Code" nameCreateDataclassTypeRequestBody:= "TestResource" request.Body = &model.CreateDataclassTypeRequestBody{ Sla: int64(0), Enabled: true, Level: &levelCreateDataclassTypeRequestBody, DataclassBusinessCode: &dataclassBusinessCodeCreateDataclassTypeRequestBody, BusinessCode: &businessCodeCreateDataclassTypeRequestBody, Name: &nameCreateDataclassTypeRequestBody, } response, err := client.CreateDataclassType(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 body for successful type addition requests. |
|
400 |
Response body for failed type addition 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