Updated on 2026-02-05 GMT+08:00

Creating an SQL Verification

Function

This API is used to create an SQL verification.

Calling Method

For details, see Calling APIs.

URI

POST /v2/{project_id}/workspaces/{workspace_id}/siem/sql/validation

Table 1 Path Parameters

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

Workspace ID.

Request Parameters

Table 2 Request header 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

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

script

Yes

String

Job script.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

sources

Array of TableItem objects

Source table.

modes

Array of strings

Mode.

Table 5 TableItem

Parameter

Type

Description

project_id

String

Project ID.

workspace_id

String

Workspace ID.

table_id

String

UUID

table_name

String

Table name.

table_alias

String

Table alias.

directory

String

Directory group.

description

String

Table description.

category

String

Definition

Table type.

  • STREAMING: streaming

  • APPLICATION: application

  • TENANT_OBS: tenant object storage

  • LAKE: data lake

INDEX: index.

Constraints

N/A

Range

  • STREAMING

  • INDEX

  • APPLICATION

  • TENANT_OBS

  • LAKE

Default Value

N/A

lock_status

String

Definition

Table lock status.

  • LOCKED: locked

  • UNLOCKED: unlocked

Constraints

N/A

Range

  • LOCKED

  • UNLOCKED

Default Value

N/A

process_status

String

Definition

Table processing status.

  • COMPLETED: completed

  • CREATING: being created

  • UPDATING: being updated

  • DELETING: being deleted

  • TRUNCATING being cleared

  • CREATE_FAILED: creation failed

  • UPDATING_FAILED: update failed

  • DELETING_FAILED: deletion failed

  • TRUNCATE_FAILED: clearing failed

Constraints

N/A

Range

  • COMPLETED

  • CREATING

  • UPDATING

  • DELETING

  • TRUNCATING

  • CREATE_FAILED

  • UPDATING_FAILED

  • DELETING_FAILED

  • TRUNCATE_FAILED

Default Value

N/A

process_error

String

Definition

Table processing error.

  • NONE

Constraints

N/A

Range

  • NONE

Default Value

N/A

edit_type

String

Definition

Table editing type.

  • MODIFIABLE: modifiable. The table can be modified.

  • APPENDED: appendable. The original content of the table cannot be modified, but new content can be added to the table.

  • LOCKED: locked. The table is completely locked and cannot be modified.

Constraints

N/A

Range

  • MODIFIABLE

  • APPENDED

  • LOCKED

Default Value

N/A

format

String

Definition

Table format.

  • JSON: JSON

  • CSV: CSV

  • PARQUET: PARQUET

  • ORC ORC

-DEBEZIUM_JSON: Debezium JSON

Constraints

N/A

Range

  • JSON

  • DEBEZIUM_JSON

  • CSV

  • PARQUET

  • ORC

Default Value

N/A

rw_type

String

Definition

Table read/write type.

  • READ_ONLY: read-only

  • READ_WRITE: read and write

  • WRITE_ONLY: write-only

Constraints

N/A

Range

  • READ_ONLY

  • READ_WRITE

  • WRITE_ONLY

Default Value

N/A

owner_type

String

Definition

Owner type.

  • SYSTEM: system

  • USER: user

  • SYSTEM_ALLOWED_DELETE: can be deleted by the system

  • USER_ALLOWED_DELETE: can be deleted by the user

Constraints

N/A

Range

  • SYSTEM

  • USER

  • SYSTEM_ALLOWED_DELETE

  • USER_ALLOWED_DELETE

Default Value

N/A

data_layering

String

Definition

Data layers.

  • ODS: operation data storage layer

  • DWS: data warehouse service layer

  • ADS: application data service layer

Constraints

N/A

Range

  • ODS

  • DWS

  • ADS

Default Value

N/A

data_classification

String

Definition

Data classification.

  • FACTUAL_DATA: factual data

  • DIMENSION_DATA: dimension data

Constraints

N/A

Range

  • FACTUAL_DATA

  • DIMENSION_DATA

Default Value

N/A

create_time

Integer

Timestamp, in ms.

update_time

Integer

Timestamp, in ms.

delete_time

Integer

Timestamp, in ms.

store_size_in_bytes

Long

Used storage capacity.

Example Requests

{
  "script" : "select * from a"
}

Example Responses

Status code: 200

Successful.

{ }

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
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.v2.region.SecMasterRegion;
import com.huaweicloud.sdk.secmaster.v2.*;
import com.huaweicloud.sdk.secmaster.v2.model.*;


public class CreateSqlValidationSolution {

    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();
        CreateSqlValidationRequest request = new CreateSqlValidationRequest();
        request.withWorkspaceId("{workspace_id}");
        CreateSqlValidationRequestBody body = new CreateSqlValidationRequestBody();
        body.withScript("select * from a");
        request.withBody(body);
        try {
            CreateSqlValidationResponse response = client.createSqlValidation(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
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdksecmaster.v2.region.secmaster_region import SecMasterRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdksecmaster.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 = SecMasterClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(SecMasterRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = CreateSqlValidationRequest()
        request.workspace_id = "{workspace_id}"
        request.body = CreateSqlValidationRequestBody(
            script="select * from a"
        )
        response = client.create_sql_validation(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
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    secmaster "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/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 := secmaster.NewSecMasterClient(
        secmaster.SecMasterClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.CreateSqlValidationRequest{}
	request.WorkspaceId = "{workspace_id}"
	request.Body = &model.CreateSqlValidationRequestBody{
		Script: "select * from a",
	}
	response, err := client.CreateSqlValidation(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.