Querying the Detected Intrusion List
Function
This API is used to query the detected intrusion list.
Calling Method
For details, see Calling APIs.
URI
GET /v5/{project_id}/event/events
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Definition Project ID, which is used to specify the project that an asset belongs to. After the project ID is configured, you can query assets in the project using the project ID. For details about how to obtain it, see Obtaining a Project ID. Constraints N/A Range The value contains 1 to 256 characters. Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
category |
Yes |
String |
Definition Event type. Constraints N/A Range Default Value N/A |
enterprise_project_id |
No |
String |
Definition Enterprise project ID, which is used to filter assets in different enterprise projects. For details, see Obtaining an Enterprise Project ID. To query assets in all enterprise projects, set this parameter to all_granted_eps. Constraints You need to set this parameter only after the enterprise project function is enabled. Range The value can contain 1 to 256 characters. Default Value 0: default enterprise project. |
last_days |
No |
Integer |
Definition Number of days to be queried. This parameter is manually exclusive with begin_time and end_time. Constraints N/A Range The value range is 1 to 30. Default Value N/A |
host_name |
No |
String |
Definition Server name. Constraints N/A Range The value can contain 1 to 256 characters. Default Value N/A |
host_id |
No |
String |
Definition Server ID. Constraints N/A Range The value can contain 0 to 64 characters. Default Value N/A |
private_ip |
No |
String |
Definition Server private IP address. Constraints N/A Range The value can contain 1 to 256 characters. Default Value N/A |
public_ip |
No |
String |
Definition Server EIP. Constraints N/A Range The value can contain 1 to 256 characters. Default Value N/A |
container_name |
No |
String |
Definition Container instance name. Constraints N/A Range The value can contain 1 to 512 characters. Default Value N/A |
offset |
No |
Integer |
Definition Offset, which specifies the start position of the record to be returned. Constraints N/A Range The value range is 0 to 2,000,000. Default Value N/A |
limit |
No |
Integer |
Definition Number of records displayed on each page. Constraints N/A Range The value range is 10 to 1,000. Default Value 10 |
event_types |
No |
Array of integers |
Definition Event type. Constraints N/A Range Default Value N/A |
handle_status |
No |
String |
Definition Handling status. Constraints N/A Range Default Value N/A |
severity |
No |
String |
Definition Risk level. Constraints N/A Range Default Value N/A |
begin_time |
No |
String |
Definition Customized start time of a segment. The timestamp is accurate to seconds. The end_time should be no more than two days earlier than the begin_time. This parameter is mutually exclusive with the queried duration. Constraints N/A Range The value contains 13 characters. Default Value N/A |
end_time |
No |
String |
Definition Customized end time of a query time range. The timestamp is accurate to milliseconds. The end_time should be no more than two days earlier than the begin_time. This parameter is mutually exclusive with the queried duration. Constraints N/A Range The value contains 13 characters. Default Value N/A |
event_class_ids |
No |
Array of strings |
Definition Event ID Constraints N/A Range
Default Value N/A |
severity_list |
No |
Array of strings |
Definition Risk level. Constraints N/A Range Default Value N/A |
attack_tag |
No |
String |
Definition Attack tag. Constraints N/A Range Default Value N/A |
asset_value |
No |
String |
Definition Asset importance. Constraints N/A Range Default Value N/A |
tag_list |
No |
Array of strings |
Event tag list, for example, ["hot event"]. |
att_ck |
No |
String |
Definition ATT&CK phase. Constraints N/A Range Default Value N/A |
event_name |
No |
String |
Definition Alarm name. Constraints N/A Range The value can contain 1 to 128 characters. Default Value N/A |
auto_block |
No |
Boolean |
Definition Whether to automatically block alarms. Constraints N/A Range Default Value N/A |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
Definition User token, which contains user identity and permissions. The token can be used for identity authentication when an API is called. For details about how to obtain the token, see Obtaining a User Token. Constraints N/A Range The value can contain 1 to 32,768 characters. Default Value N/A |
region |
No |
String |
Definition Region ID, which is used to query assets in the required region. For details about how to obtain a region ID, see Obtaining a Region ID. Constraints N/A Range The value can contain 0 to 128 characters. Default Value N/A |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
total_num |
Integer |
Definition Total number of alarm events. Range The value range is 0 to 2,147,483,647. |
data_list |
Array of EventManagementResponseInfo objects |
Event list |
Parameter |
Type |
Description |
---|---|---|
event_id |
String |
Definition Event ID. Range The value can contain 1 to 64 characters. |
event_class_id |
String |
Definition Event type. Range
|
event_type |
Integer |
Definition Event type. Range |
event_name |
String |
Definition Event name. Range The value can contain 1 to 256 characters. |
severity |
String |
Definition Risk level. Range |
container_name |
String |
Definition Container instance name. This parameter is available only for container alarms. Range The value can contain 1 to 256 characters. |
image_name |
String |
Definition Image name. This parameter is available only for container alarms. Range The value can contain 1 to 256 characters. |
host_name |
String |
Definition Server name. Range The value can contain 1 to 256 characters. |
host_id |
String |
Definition Server ID. Range The value can contain 1 to 64 characters. |
private_ip |
String |
Definition Server private IP address. Range The value can contain 1 to 128 characters. |
public_ip |
String |
Definition EIP. Range The value can contain 1 to 256 characters. |
os_type |
String |
Definition OS type. Range |
host_status |
String |
Definition Server status. Range |
agent_status |
String |
Definition Agent status. Range |
protect_status |
String |
Definition Protection status. Range |
asset_value |
String |
Definition Asset importance. Range |
attack_phase |
String |
Definition Attack phase. Range |
attack_tag |
String |
Definition Attack tag. Range |
occur_time |
Integer |
Definition Occurrence time, accurate to milliseconds Range The value range is 0 to 9,223,372,036,854,775,807. |
handle_time |
Integer |
Definition Handling time, in milliseconds. This parameter is available only for handled alarms. Range The value range is 0 to 9,223,372,036,854,775,807. |
handle_status |
String |
Definition Handling status. Range |
handle_method |
String |
Definition Handling method, which is available only for handled alarms. Range |
handler |
String |
Definition Remarks. This parameter is available only for handled alarms. Range The value can contain 1 to 256 characters. |
operate_accept_list |
Array of strings |
Supported processing operation |
operate_detail_list |
Array of EventDetailResponseInfo objects |
Operation details list (not displayed on the page) |
forensic_info |
Object |
Attack information, in JSON format. |
resource_info |
EventResourceResponseInfo object |
Resource information |
geo_info |
Object |
Geographical location, in JSON format. |
malware_info |
Object |
Malware information, in JSON format. |
network_info |
Object |
Network information, in JSON format. |
app_info |
Object |
Application information, in JSON format. |
system_info |
Object |
System information, in JSON format. |
extend_info |
Object |
Extended event information, in JSON format |
recommendation |
String |
Definition Suggestion. Range The value can contain 1 to 256 characters. |
description |
String |
Definition Alarm description. Range The value contains 0 to 1,024 characters. |
event_abstract |
String |
Definition Alarm summary. Range The value can contain 0 to 512 characters. |
process_info_list |
Array of EventProcessResponseInfo objects |
Process information list |
user_info_list |
Array of EventUserResponseInfo objects |
User information list |
file_info_list |
Array of EventFileResponseInfo objects |
File information list |
event_details |
String |
Definition Brief description of the event. Range The value can contain 0 to 204,800 characters. |
tag_list |
Array of strings |
Tags |
event_count |
Integer |
Definition Event occurrences. Range The value range is 0 to 2,147,483,647. |
Parameter |
Type |
Description |
---|---|---|
agent_id |
String |
Definition Agent ID Constraints N/A Range The value can contain 1 to 64 characters. Default Value N/A |
process_pid |
Integer |
Definition Process ID. Range The value range is 0 to 2,147,483,647. |
is_parent |
Boolean |
Definition Whether a process is a parent process. Range |
file_hash |
String |
Definition File hash. Range The value can contain 1 to 256 characters. |
file_path |
String |
Definition File path. Range The value can contain 1 to 256 characters. |
file_attr |
String |
Definition File attribute. Range The value can contain 1 to 256 characters. |
private_ip |
String |
Definition Server private IP address. Range The value can contain 1 to 128 characters. |
login_ip |
String |
Definition Login source IP address. Range The value can contain 1 to 256 characters. |
login_user_name |
String |
Definition Login username. Range The value can contain 1 to 256 characters. |
keyword |
String |
Alarm event keyword, which is used only for the alarm whitelist. |
hash |
String |
Alarm event hash, which is used only for the alarm whitelist. |
Parameter |
Type |
Description |
---|---|---|
domain_id |
String |
Definition Tenant account ID. Range The value can contain 1 to 256 characters. |
project_id |
String |
Definition Project ID. Range The value can contain 1 to 256 characters. |
enterprise_project_id |
String |
Definition Enterprise project ID. Range The value can contain 1 to 256 characters. |
region_name |
String |
Definition Region name. Range The value can contain 1 to 256 characters. |
vpc_id |
String |
Definition VPC ID Range The value can contain 1 to 256 characters. |
cloud_id |
String |
Definition Server ID. Range The value can contain 1 to 256 characters. |
vm_name |
String |
Definition VM name. Range The value can contain 1 to 256 characters. |
vm_uuid |
String |
Definition VM UUID, that is, the server ID. Range The value can contain 1 to 256 characters. |
container_id |
String |
Definition Container ID. Range The value can contain 1 to 256 characters. |
container_status |
String |
Definition Container status. Range The value can contain 1 to 256 characters. |
pod_uid |
String |
Definition pod uid Range The value can contain 1 to 256 characters. |
pod_name |
String |
Definition pod name Range The value can contain 1 to 256 characters. |
namespace |
String |
Definition namespace Range The value can contain 1 to 256 characters. |
cluster_id |
String |
Definition Cluster ID. Range The value can contain 1 to 256 characters. |
cluster_name |
String |
Definition Cluster name. Range The value can contain 1 to 256 characters. |
image_id |
String |
Definition Image ID. Range The value can contain 1 to 256 characters. |
image_name |
String |
Definition Image name. Range The value can contain 1 to 256 characters. |
host_attr |
String |
Definition Server attribute. Range The value can contain 1 to 256 characters. |
service |
String |
Definition Service. Range The value can contain 1 to 256 characters. |
micro_service |
String |
Definition Microservice. Range The value can contain 1 to 256 characters. |
sys_arch |
String |
Definition System CPU architecture. Range The value can contain 1 to 256 characters. |
os_bit |
String |
Definition OS bit version. Range The value can contain 1 to 256 characters. |
os_type |
String |
Definition OS type. Range The value can contain 1 to 256 characters. |
os_name |
String |
Definition OS name. Range The value can contain 1 to 256 characters. |
os_version |
String |
Definition OS version. Range The value can contain 1 to 256 characters. |
Parameter |
Type |
Description |
---|---|---|
process_name |
String |
Definition Process name. Range The value can contain 1 to 256 characters. |
process_path |
String |
Definition Process file path. Range The value can contain 1 to 256 characters. |
process_pid |
Integer |
Definition Process ID. Range The value range is 0 to 2,147,483,647. |
process_uid |
Integer |
Definition Process user ID. Range The value range is 0 to 2,147,483,647. |
process_username |
String |
Definition Process username. Range The value can contain 1 to 256 characters. |
process_cmdline |
String |
Definition Process file command line. Range The value can contain 1 to 256 characters. |
process_filename |
String |
Definition Process file name. Range The value can contain 1 to 256 characters. |
process_start_time |
Long |
Definition Process start time. Range The value range is 0 to 9,223,372,036,854,775,807. |
process_gid |
Integer |
Definition Process group ID. Range The value range is 0 to 2,147,483,647. |
process_egid |
Integer |
Definition Effective process group ID. Range The value range is 0 to 2,147,483,647. |
process_euid |
Integer |
Definition Effective process user ID. Range The value range is 0 to 2,147,483,647. |
ancestor_process_path |
String |
Definition Grandparent process file path. Range The value can contain 1 to 256 characters. |
ancestor_process_pid |
Integer |
Definition Grandparent process ID. Range The value range is 0 to 2,147,483,647. |
ancestor_process_cmdline |
String |
Definition Grandparent process file command line. Range The value can contain 1 to 512 characters. |
parent_process_name |
String |
Definition Parent process name. Range The value can contain 1 to 256 characters. |
parent_process_path |
String |
Definition Parent process file path. Range The value can contain 1 to 256 characters. |
parent_process_pid |
Integer |
Definition Parent process ID. Range The value range is 0 to 2,147,483,647. |
parent_process_uid |
Integer |
Definition Parent process user ID. Range The value range is 0 to 2,147,483,647. |
parent_process_cmdline |
String |
Definition Parent process file command line. Range The value can contain 1 to 512 characters. |
parent_process_filename |
String |
Definition Parent process file name. Range The value can contain 1 to 256 characters. |
parent_process_start_time |
Long |
Definition Parent process start time. Range The value range is 0 to 9,223,372,036,854,775,807. |
parent_process_gid |
Integer |
Definition Parent process group ID. Range The value range is 0 to 2,147,483,647. |
parent_process_egid |
Integer |
Definition Effective parent process group ID. Range The value range is 0 to 2,147,483,647. |
parent_process_euid |
Integer |
Definition Effective parent process user ID. Range The value range is 0 to 2,147,483,647. |
child_process_name |
String |
Definition Subprocess name. Range The value can contain 1 to 256 characters. |
child_process_path |
String |
Definition Subprocess file path. Range The value can contain 1 to 256 characters. |
child_process_pid |
Integer |
Definition Subprocess ID. Range The value range is 0 to 2,147,483,647. |
child_process_uid |
Integer |
Definition User ID associated with the subprocess. Range The value range is 0 to 2,147,483,647. |
child_process_cmdline |
String |
Definition Subprocess file command line. Range The value can contain 1 to 256 characters. |
child_process_filename |
String |
Definition Subprocess file name. Range The value can contain 1 to 256 characters. |
child_process_start_time |
Long |
Definition Subprocess start time. Range The value range is 0 to 9,223,372,036,854,775,807. |
child_process_gid |
Integer |
Definition Subprocess group ID. Range The value range is 0 to 2,147,483,647. |
child_process_egid |
Integer |
Definition Effective subprocess group ID. Range The value range is 0 to 2,147,483,647. |
child_process_euid |
Integer |
Definition Effective subprocess user ID. Range The value range is 0 to 2,147,483,647. |
virt_cmd |
String |
Definition Virtualization command. Range The value can contain 1 to 256 characters. |
virt_process_name |
String |
Definition Virtualization process name. Range The value can contain 1 to 256 characters. |
escape_mode |
String |
Definition Escape method. Range The value can contain 1 to 256 characters. |
escape_cmd |
String |
Definition Commands executed after escape. Range The value can contain 1 to 256 characters. |
process_hash |
String |
Definition Process startup file hash. Range The value can contain 1 to 256 characters. |
process_file_hash |
String |
Definition Process file hash. Range The value can contain 1 to 256 characters. |
parent_process_file_hash |
String |
Definition Hash of the parent process file. Range The value can contain 1 to 256 characters. |
block |
Integer |
Indicates whether the blocking is successful. 1: yes 0: no |
Parameter |
Type |
Description |
---|---|---|
user_id |
Integer |
Definition User ID (UID). Range The value range is 0 to 2,147,483,647. |
user_gid |
Integer |
Definition User GID. Range The value range is 0 to 2,147,483,647. |
user_name |
String |
Definition Username. Range The value can contain 1 to 256 characters. |
user_group_name |
String |
Definition User group name. Range The value can contain 1 to 256 characters. |
user_home_dir |
String |
Definition User home directory. Range The value can contain 1 to 256 characters. |
login_ip |
String |
Definition User login IP address. Range The value can contain 1 to 256 characters. |
service_type |
String |
Definition Service type. Range |
service_port |
Integer |
Definition Login service port. Range The value range is 0 to 2,147,483,647. |
login_mode |
Integer |
Definition Login mode. Range The value range is 0 to 2,147,483,647. |
login_last_time |
Long |
Definition Last login time of a user. Range The value range is 0 to 9,223,372,036,854,775,807. |
login_fail_count |
Integer |
Definition Number of failed login attempts. Range The value range is 0 to 2,147,483,647. |
pwd_hash |
String |
Definition Password hash. Range The value can contain 1 to 256 characters. |
pwd_with_fuzzing |
String |
Definition Anonymized password. Range The value can contain 1 to 256 characters. |
pwd_used_days |
Integer |
Definition Password age (days). Range The value range is 0 to 2,147,483,647. |
pwd_min_days |
Integer |
Definition Minimum password validity period. Range The value range is 0 to 2,147,483,647. |
pwd_max_days |
Integer |
Definition Maximum password validity period. Range The value range is 0 to 2,147,483,647. |
pwd_warn_left_days |
Integer |
Definition Advance warning of password expiration (days). Range The value range is 0 to 2,147,483,647. |
Parameter |
Type |
Description |
---|---|---|
file_path |
String |
Definition File path. Range The value can contain 1 to 256 characters. |
file_alias |
String |
Definition File alias. Range The value can contain 1 to 256 characters. |
file_size |
Integer |
Definition File size. Range The value range is 0 to 2,147,483,647. |
file_mtime |
Long |
Definition Time when the file is last modified. Range The value range is 0 to 9,223,372,036,854,775,807. |
file_atime |
Long |
Definition Time when the file is last accessed. Range The value range is 0 to 9,223,372,036,854,775,807. |
file_ctime |
Long |
Definition Time when the file status last changes. Range The value range is 0 to 9,223,372,036,854,775,807. |
file_hash |
String |
Definition File hash. The current value is sha256. Range The value can contain 1 to 256 characters. |
file_md5 |
String |
Definition File MD5 value. Range The value can contain 1 to 256 characters. |
file_sha256 |
String |
Definition SHA256 value of the file. Range The value can contain 1 to 256 characters. |
file_type |
String |
Definition File type. Range The value can contain 1 to 256 characters. |
file_content |
String |
Definition File content. Range The value can contain 1 to 256 characters. |
file_attr |
String |
Definition File attribute. Range The value can contain 1 to 256 characters. |
file_operation |
Integer |
Definition File operation type. Range The value range is 0 to 2,147,483,647. |
file_action |
String |
Definition File action. Range The value can contain 1 to 256 characters. |
file_change_attr |
String |
Definition Old/New attribute. Range The value can contain 1 to 256 characters. |
file_new_path |
String |
Definition New file path. Range The value can contain 1 to 256 characters. |
file_desc |
String |
Definition File description. Range The value can contain 1 to 256 characters. |
file_key_word |
String |
Definition File keyword. Range The value can contain 1 to 256 characters. |
is_dir |
Boolean |
Definition Whether it is a directory. Range |
fd_info |
String |
Definition File handle information. Range The value can contain 1 to 256 characters. |
fd_count |
Integer |
Definition Number of file handles. Range The value range is 0 to 2,147,483,647. |
Example Requests
Query the first 50 unprocessed server events whose enterprise project is xxx.
GET https://{endpoint}/v5/{project_id}/event/events?offset=0&limit=50&handle_status=unhandled&category=host&enterprise_project_id=xxx
Example Responses
Status code: 200
Request succeeded.
{ "total_num" : 1, "data_list" : [ { "attack_phase" : "exploit", "attack_tag" : "abnormal_behavior", "event_class_id" : "lgin_1002", "event_id" : "d8a12cf7-6a43-4cd6-92b4-aabf1e917", "event_name" : "different locations", "event_type" : 4004, "forensic_info" : { "country" : "China", "city" : "Lanzhou", "ip" : "127.0.0.1", "user" : "zhangsan", "sub_division" : "Gansu", "city_id" : 3110 }, "handle_status" : "unhandled", "host_name" : "xxx", "occur_time" : 1661593036627, "operate_accept_list" : [ "ignore" ], "operate_detail_list" : [ { "agent_id" : "c9bed5397db449ebdfba15e85fcfc36accee125c68954daf5cab0528bab59bd8", "file_hash" : "e8b50f0b91e3dce0885ccc5902846b139d28108a0a7976c9b8d43154c5dbc44d", "file_path" : "/usr/test", "process_pid" : 3123, "file_attr" : 33261, "keyword" : "file_path=/usr/test", "hash" : "e8b50f0b91e3dce0885ccc5902846b139d28108a0a7976c9b8d43154c5dbc44d", "login_ip" : "127.0.0.1", "private_ip" : "127.0.0.2", "login_user_name" : "root", "is_parent" : false } ], "private_ip" : "127.0.0.1", "resource_info" : { "region_name" : "", "project_id" : "", "enterprise_project_id" : "0", "os_type" : "Linux", "os_version" : "2.5", "vm_name" : "", "vm_uuid" : "71a15ecc", "cloud_id" : "", "container_id" : "", "container_status" : "running / terminated", "image_id" : "", "pod_uid" : "", "pod_name" : "", "namespace" : "", "cluster_id" : "", "cluster_name" : "" }, "severity" : "Medium", "extend_info" : "", "os_type" : "Linux", "agent_status" : "online", "asset_value" : "common", "protect_status" : "opened", "host_status" : "ACTIVE", "event_details" : "file_path:/root/test", "user_info_list" : [ { "login_ip" : "", "service_port" : 22, "service_type" : "ssh", "user_name" : "zhangsan", "login_mode" : 0, "login_last_time" : 1661593024, "login_fail_count" : 0 } ], "process_info_list" : [ { "process_path" : "/root/test", "process_name" : "test", "process_cmdline" : "/bin/bash", "process_hash" : "e8b50f0b91e3dce0885ccc5902846b139d28108a0a7976c9b8d43154c5dbc44d", "process_filename" : "test", "process_file_hash" : "e8b50f0b91e3dce0885ccc5902846b139d28108a0a7976c9b8d43154c5dbc44d", "process_username" : "root", "process_pid" : 372612, "process_uid" : 10000, "process_gid" : 10000, "process_egid" : 10000, "process_euid" : 10000, "process_start_time" : 1661593024, "block" : 0, "parent_process_path" : "/usr/bin/bash", "parent_process_name" : "test", "parent_process_cmdline" : "/bin/bash", "parent_process_filename" : "test", "parent_process_file_hash" : "e8b50f0b91e3dce0885ccc5902846b139d28108a0a7976c9b8d43154c5dbc44d", "parent_process_pid" : 372612, "parent_process_uid" : 10000, "parent_process_gid" : 10000, "parent_process_egid" : 10000, "parent_process_euid" : 10000, "parent_process_start_time" : 1661593024, "child_process_path" : "/usr/bin/bash", "child_process_name" : "test", "child_process_cmdline" : "/bin/bash", "child_process_filename" : "test", "child_process_pid" : 372612, "child_process_uid" : 10000, "child_process_gid" : 10000, "child_process_egid" : 10000, "child_process_euid" : 10000, "child_process_start_time" : 1661593024, "virt_process_name" : "test", "virt_cmd" : "/bin/bash", "escape_cmd" : "/bin/bash", "escape_mode" : "0", "ancestor_process_pid" : 372612, "ancestor_process_cmdline" : "/bin/bash", "ancestor_process_path" : "/usr/bin/bash" } ], "description" : "", "event_abstract" : "", "tag_list" : [ "Hot Event" ] } ] }
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 |
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.hss.v5.region.HssRegion; import com.huaweicloud.sdk.hss.v5.*; import com.huaweicloud.sdk.hss.v5.model.*; public class ListSecurityEventsSolution { 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); HssClient client = HssClient.newBuilder() .withCredential(auth) .withRegion(HssRegion.valueOf("<YOUR REGION>")) .build(); ListSecurityEventsRequest request = new ListSecurityEventsRequest(); try { ListSecurityEventsResponse response = client.listSecurityEvents(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 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkhss.v5.region.hss_region import HssRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkhss.v5 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 = HssClient.new_builder() \ .with_credentials(credentials) \ .with_region(HssRegion.value_of("<YOUR REGION>")) \ .build() try: request = ListSecurityEventsRequest() response = client.list_security_events(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 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" hss "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/hss/v5" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/hss/v5/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/hss/v5/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 := hss.NewHssClient( hss.HssClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ListSecurityEventsRequest{} response, err := client.ListSecurityEvents(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 |
Request succeeded. |
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