查入侵事件列表
功能介绍
查入侵事件列表
调用方法
请参见如何调用API。
URI
GET /v5/{project_id}/event/events
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
参数解释: 项目ID,用于明确项目归属,配置后可通过该ID查询项目下资产。获取方式请参见获取项目ID。 约束限制: 不涉及 取值范围: 字符长度1-256位。 默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
category |
是 |
String |
参数解释: 事件类别 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
enterprise_project_id |
否 |
String |
参数解释: 企业项目ID,用于过滤不同企业项目下的资产。获取方式请参见获取企业项目ID。 如需查询所有企业项目下的资产请传参“all_granted_eps”。 约束限制: 开通企业项目功能后才需要配置企业项目ID参数。 取值范围: 字符长度1-256位 默认取值: 0,表示默认企业项目(default)。 |
last_days |
否 |
Integer |
参数解释: 查询时间范围天数,与自定义查询时间begin_time,end_time互斥。 约束限制: 不涉及 取值范围: 最小值1,最大值30 默认取值: 不涉及 |
host_name |
否 |
String |
参数解释: 服务器名称 约束限制: 不涉及 取值范围: 字符长度1-256位 默认取值: 不涉及 |
host_id |
否 |
String |
参数解释: 服务器ID 约束限制: 不涉及 取值范围: 字符长度0-64位 默认取值: 不涉及 |
private_ip |
否 |
String |
参数解释: 服务器私有IP 约束限制: 不涉及 取值范围: 字符长度1-256位 默认取值: 不涉及 |
public_ip |
否 |
String |
参数解释: 服务器公网IP 约束限制: 不涉及 取值范围: 字符长度1-256位 默认取值: 不涉及 |
container_name |
否 |
String |
参数解释: 容器实例名称 约束限制: 不涉及 取值范围: 字符长度1-512位 默认取值: 不涉及 |
offset |
否 |
Integer |
参数解释: 偏移量,指定返回记录的开始位置 约束限制: 不涉及 取值范围: 最小值0,最大值2000000 默认取值: 不涉及 |
limit |
否 |
Integer |
参数解释: 每页显示个数 约束限制: 不涉及 取值范围: 最小值10,最大值1000 默认取值: 10 |
event_types |
否 |
Array of integers |
参数解释: 事件类型 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
handle_status |
否 |
String |
参数解释: 处置状态 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
severity |
否 |
String |
参数解释: 威胁等级 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
begin_time |
否 |
String |
参数解释: 自定义查询时间,与查询时间范围天数互斥,查询时间段的起始时间,毫秒级时间戳,end_time减去begin_time小于等于2天,与查询时间范围天数互斥 约束限制: 不涉及 取值范围: 字符长度13位 默认取值: 不涉及 |
end_time |
否 |
String |
参数解释: 自定义时间,查询时间段的终止时间,毫秒级时间戳,end_time减去begin_time小于等于2天,与查询时间范围天数互斥 约束限制: 不涉及 取值范围: 字符长度13位 默认取值: 不涉及 |
event_class_ids |
否 |
Array of strings |
参数解释: 事件标识 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
severity_list |
否 |
Array of strings |
参数解释: 威胁等级 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
attack_tag |
否 |
String |
参数解释: 攻击标识 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
asset_value |
否 |
String |
参数解释: 资产重要性 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
tag_list |
否 |
Array of strings |
事件标签列表,例如:["热点事件"] |
att_ck |
否 |
String |
参数解释: ATT&CK攻击阶段 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
event_name |
否 |
String |
参数解释: 告警名称 约束限制: 不涉及 取值范围: 字符长度1-128位 默认取值: 不涉及 |
auto_block |
否 |
Boolean |
参数解释: 是否自动阻断告警 约束限制: 不涉及 取值范围:
默认取值: 不涉及 |
请求参数
响应参数
状态码:200
参数 |
参数类型 |
描述 |
---|---|---|
total_num |
Integer |
参数解释: 告警事件总数 取值范围: 最小值0,最大值2147483647 |
data_list |
Array of EventManagementResponseInfo objects |
事件列表详情 |
参数 |
参数类型 |
描述 |
---|---|---|
event_id |
String |
参数解释: 事件ID 取值范围: 字符长度1-64位 |
event_class_id |
String |
参数解释: 事件分类 取值范围:
|
event_type |
Integer |
参数解释: 事件类型 取值范围:
|
event_name |
String |
参数解释: 事件名称 取值范围: 字符长度1-256位 |
severity |
String |
参数解释: 威胁等级 取值范围:
|
container_name |
String |
参数解释: 容器实例名称,只有容器类型的告警有 取值范围: 字符长度1-256位 |
image_name |
String |
参数解释: 镜像名称,只有容器类型的告警有 取值范围: 字符长度1-256位 |
host_name |
String |
参数解释: 服务器名称 取值范围: 字符长度1-256位 |
host_id |
String |
参数解释: 主机ID 取值范围: 字符长度1-64位 |
private_ip |
String |
参数解释: 服务器私有IP 取值范围: 字符长度1-128位 |
public_ip |
String |
参数解释: 弹性公网IP地址 取值范围: 字符长度1-256位 |
os_type |
String |
参数解释: 操作系统类型 取值范围:
|
host_status |
String |
参数解释: 服务器状态 取值范围:
|
agent_status |
String |
参数解释: Agent状态 取值范围:
|
protect_status |
String |
参数解释: 防护状态 取值范围:
|
asset_value |
String |
参数解释: 资产重要性 取值范围:
|
attack_phase |
String |
参数解释: 攻击阶段 取值范围:
|
attack_tag |
String |
参数解释: 攻击标识 取值范围:
|
occur_time |
Integer |
参数解释: 发生时间,毫秒 取值范围: 最小值0,最大值9223372036854775807 |
handle_time |
Integer |
参数解释: 处置时间,毫秒,已处理的告警才有 取值范围: 最小值0,最大值9223372036854775807 |
handle_status |
String |
参数解释: 处理状态 取值范围:
|
handle_method |
String |
参数解释: 处理方式,已处理的告警才有 取值范围:
|
handler |
String |
参数解释: 备注信息,已处理的告警才有 取值范围: 字符长度1-256位 |
operate_accept_list |
Array of strings |
支持的处理操作 |
operate_detail_list |
Array of EventDetailResponseInfo objects |
操作详情信息列表(页面不展示) |
forensic_info |
Object |
取证信息,json格式 |
resource_info |
EventResourceResponseInfo object |
资源信息 |
geo_info |
Object |
地理位置信息,json格式 |
malware_info |
Object |
恶意软件信息,json格式 |
network_info |
Object |
网络信息,json格式 |
app_info |
Object |
应用信息,json格式 |
system_info |
Object |
系统信息,json格式 |
extend_info |
Object |
事件扩展信息,json格式 |
recommendation |
String |
参数解释: 处置建议 取值范围: 字符长度1-256位 |
description |
String |
参数解释: 告警说明 取值范围: 字符长度0-1024位 |
event_abstract |
String |
参数解释: 告警摘要 取值范围: 字符长度0-512位 |
process_info_list |
Array of EventProcessResponseInfo objects |
进程信息列表 |
user_info_list |
Array of EventUserResponseInfo objects |
用户信息列表 |
file_info_list |
Array of EventFileResponseInfo objects |
文件信息列表 |
event_details |
String |
参数解释: 事件信息的简述 取值范围: 字符长度0-204800位 |
tag_list |
Array of strings |
标签列表 |
event_count |
Integer |
参数解释: 事件发生次数 取值范围: 最小值0,最大值2147483647 |
参数 |
参数类型 |
描述 |
---|---|---|
agent_id |
String |
参数解释: Agent ID 约束限制: 不涉及 取值范围: 字符长度1-64位 默认取值: 不涉及 |
process_pid |
Integer |
参数解释: 进程ID 取值范围: 最小值0,最大值2147483647 |
is_parent |
Boolean |
参数解释: 是否是父进程 取值范围:
|
file_hash |
String |
参数解释: 文件哈希 取值范围: 字符长度1-256位 |
file_path |
String |
参数解释: 文件路径 取值范围: 字符长度1-256位 |
file_attr |
String |
参数解释: 文件属性 取值范围: 字符长度1-256位 |
private_ip |
String |
参数解释: 服务器私有IP 取值范围: 字符长度1-128位 |
login_ip |
String |
参数解释: 登录源IP 取值范围: 字符长度1-256位 |
login_user_name |
String |
参数解释: 登录用户名 取值范围: 字符长度1-256位 |
keyword |
String |
告警事件关键字,仅用于告警白名单 |
hash |
String |
告警事件hash,仅用于告警白名单 |
参数 |
参数类型 |
描述 |
---|---|---|
domain_id |
String |
参数解释: 租户账号ID 取值范围: 字符长度1-256位 |
project_id |
String |
参数解释: 项目ID 取值范围: 字符长度1-256位 |
enterprise_project_id |
String |
参数解释: 企业项目ID 取值范围: 字符长度1-256位 |
region_name |
String |
参数解释: Region名称 取值范围: 字符长度1-256位 |
vpc_id |
String |
参数解释: VPC ID 取值范围: 字符长度1-256位 |
cloud_id |
String |
参数解释: 云主机ID 取值范围: 字符长度1-256位 |
vm_name |
String |
参数解释: 虚拟机名称 取值范围: 字符长度1-256位 |
vm_uuid |
String |
参数解释: 虚拟机UUID,即主机ID 取值范围: 字符长度1-256位 |
container_id |
String |
参数解释: 容器ID 取值范围: 字符长度1-256位 |
container_status |
String |
参数解释: 容器状态 取值范围: 字符长度1-256位 |
pod_uid |
String |
参数解释: pod uid 取值范围: 字符长度1-256位 |
pod_name |
String |
参数解释: pod name 取值范围: 字符长度1-256位 |
namespace |
String |
参数解释: namespace 取值范围: 字符长度1-256位 |
cluster_id |
String |
参数解释: 集群ID 取值范围: 字符长度1-256位 |
cluster_name |
String |
参数解释: 集群名称 取值范围: 字符长度1-256位 |
image_id |
String |
参数解释: 镜像ID 取值范围: 字符长度1-256位 |
image_name |
String |
参数解释: 镜像名称 取值范围: 字符长度1-256位 |
host_attr |
String |
参数解释: 主机属性 取值范围: 字符长度1-256位 |
service |
String |
参数解释: 业务服务 取值范围: 字符长度1-256位 |
micro_service |
String |
参数解释: 微服务 取值范围: 字符长度1-256位 |
sys_arch |
String |
参数解释: 系统CPU架构 取值范围: 字符长度1-256位 |
os_bit |
String |
参数解释: 操作系统位数 取值范围: 字符长度1-256位 |
os_type |
String |
参数解释: 操作系统类型 取值范围: 字符长度1-256位 |
os_name |
String |
参数解释: 操作系统名称 取值范围: 字符长度1-256位 |
os_version |
String |
参数解释: 操作系统版本 取值范围: 字符长度1-256位 |
参数 |
参数类型 |
描述 |
---|---|---|
process_name |
String |
参数解释: 进程名称 取值范围: 字符长度1-256位 |
process_path |
String |
参数解释: 进程文件路径 取值范围: 字符长度1-256位 |
process_pid |
Integer |
参数解释: 进程ID 取值范围: 最小值0,最大值2147483647 |
process_uid |
Integer |
参数解释: 进程用户ID 取值范围: 最小值0,最大值2147483647 |
process_username |
String |
参数解释: 运行进程的用户名 取值范围: 字符长度1-256位 |
process_cmdline |
String |
参数解释: 进程文件命令行 取值范围: 字符长度1-256位 |
process_filename |
String |
参数解释: 进程文件名 取值范围: 字符长度1-256位 |
process_start_time |
Long |
参数解释: 进程启动时间 取值范围: 最小值0,最大值9223372036854775807 |
process_gid |
Integer |
参数解释: 进程组ID 取值范围: 最小值0,最大值2147483647 |
process_egid |
Integer |
参数解释: 进程有效组ID 取值范围: 最小值0,最大值2147483647 |
process_euid |
Integer |
参数解释: 进程有效用户ID 取值范围: 最小值0,最大值2147483647 |
ancestor_process_path |
String |
参数解释: 祖父进程文件路径 取值范围: 字符长度1-256位 |
ancestor_process_pid |
Integer |
参数解释: 祖父进程ID 取值范围: 最小值0,最大值2147483647 |
ancestor_process_cmdline |
String |
参数解释: 祖父进程文件命令行 取值范围: 字符长度1-512位 |
parent_process_name |
String |
参数解释: 父进程名称 取值范围: 字符长度1-256位 |
parent_process_path |
String |
参数解释: 父进程文件路径 取值范围: 字符长度1-256位 |
parent_process_pid |
Integer |
参数解释: 父进程ID 取值范围: 最小值0,最大值2147483647 |
parent_process_uid |
Integer |
参数解释: 父进程用户ID 取值范围: 最小值0,最大值2147483647 |
parent_process_cmdline |
String |
参数解释: 父进程文件命令行 取值范围: 字符长度1-512位 |
parent_process_filename |
String |
参数解释: 父进程文件名 取值范围: 字符长度1-256位 |
parent_process_start_time |
Long |
参数解释: 父进程启动时间 取值范围: 最小值0,最大值9223372036854775807 |
parent_process_gid |
Integer |
参数解释: 父进程组ID 取值范围: 最小值0,最大值2147483647 |
parent_process_egid |
Integer |
参数解释: 父进程有效组ID 取值范围: 最小值0,最大值2147483647 |
parent_process_euid |
Integer |
参数解释: 父进程有效用户ID 取值范围: 最小值0,最大值2147483647 |
child_process_name |
String |
参数解释: 子进程名称 取值范围: 字符长度1-256位 |
child_process_path |
String |
参数解释: 子进程文件路径 取值范围: 字符长度1-256位 |
child_process_pid |
Integer |
参数解释: 子进程id 取值范围: 最小值0,最大值2147483647 |
child_process_uid |
Integer |
参数解释: 子进程用户id 取值范围: 最小值0,最大值2147483647 |
child_process_cmdline |
String |
参数解释: 子进程文件命令行 取值范围: 字符长度1-256位 |
child_process_filename |
String |
参数解释: 子进程文件名 取值范围: 字符长度1-256位 |
child_process_start_time |
Long |
参数解释: 子进程启动时间 取值范围: 最小值0,最大值9223372036854775807 |
child_process_gid |
Integer |
参数解释: 子进程组ID 取值范围: 最小值0,最大值2147483647 |
child_process_egid |
Integer |
参数解释: 子进程有效组ID 取值范围: 最小值0,最大值2147483647 |
child_process_euid |
Integer |
参数解释: 子进程有效用户ID 取值范围: 最小值0,最大值2147483647 |
virt_cmd |
String |
参数解释: 虚拟化命令 取值范围: 字符长度1-256位 |
virt_process_name |
String |
参数解释: 虚拟化进程名称 取值范围: 字符长度1-256位 |
escape_mode |
String |
参数解释: 逃逸方式 取值范围: 字符长度1-256位 |
escape_cmd |
String |
参数解释: 逃逸后执行的命令 取值范围: 字符长度1-256位 |
process_hash |
String |
参数解释: 进程启动文件hash 取值范围: 字符长度1-256位 |
process_file_hash |
String |
参数解释: 进程文件hash 取值范围: 字符长度1-256位 |
parent_process_file_hash |
String |
参数解释: 父进程文件hash 取值范围: 字符长度1-256位 |
block |
Integer |
是否阻断成功,1阻断成功 0阻断失败 |
参数 |
参数类型 |
描述 |
---|---|---|
user_id |
Integer |
参数解释: 用户uid 取值范围: 最小值0,最大值2147483647 |
user_gid |
Integer |
参数解释: 用户gid 取值范围: 最小值0,最大值2147483647 |
user_name |
String |
参数解释: 用户名称 取值范围: 字符长度1-256位 |
user_group_name |
String |
参数解释: 用户组名称 取值范围: 字符长度1-256位 |
user_home_dir |
String |
参数解释: 用户home目录 取值范围: 字符长度1-256位 |
login_ip |
String |
参数解释: 用户登录IP 取值范围: 字符长度1-256位 |
service_type |
String |
参数解释: 服务类型 取值范围:
|
service_port |
Integer |
参数解释: 登录服务端口 取值范围: 最小值0,最大值2147483647 |
login_mode |
Integer |
参数解释: 登录方式 取值范围: 最小值0,最大值2147483647 |
login_last_time |
Long |
参数解释: 用户最后一次登录时间 取值范围: 最小值0,最大值9223372036854775807 |
login_fail_count |
Integer |
参数解释: 用户登录失败次数 取值范围: 最小值0,最大值2147483647 |
pwd_hash |
String |
参数解释: 口令hash 取值范围: 字符长度1-256位 |
pwd_with_fuzzing |
String |
参数解释: 匿名化处理后的口令 取值范围: 字符长度1-256位 |
pwd_used_days |
Integer |
参数解释: 密码使用的天数 取值范围: 最小值0,最大值2147483647 |
pwd_min_days |
Integer |
参数解释: 口令的最短有效期限 取值范围: 最小值0,最大值2147483647 |
pwd_max_days |
Integer |
参数解释: 口令的最长有效期限 取值范围: 最小值0,最大值2147483647 |
pwd_warn_left_days |
Integer |
参数解释: 口令无效时提前告警天数 取值范围: 最小值0,最大值2147483647 |
参数 |
参数类型 |
描述 |
---|---|---|
file_path |
String |
参数解释: 文件路径 取值范围: 字符长度1-256位 |
file_alias |
String |
参数解释: 文件别名 取值范围: 字符长度1-256位 |
file_size |
Integer |
参数解释: 文件大小 取值范围: 最小值0,最大值2147483647 |
file_mtime |
Long |
参数解释: 文件最后一次修改时间 取值范围: 最小值0,最大值9223372036854775807 |
file_atime |
Long |
参数解释: 文件最后一次访问时间 取值范围: 最小值0,最大值9223372036854775807 |
file_ctime |
Long |
参数解释: 文件最后一次状态改变时间 取值范围: 最小值0,最大值9223372036854775807 |
file_hash |
String |
参数解释: 文件hash,当前为sha256 取值范围: 字符长度1-256位 |
file_md5 |
String |
参数解释: 文件md5 取值范围: 字符长度1-256位 |
file_sha256 |
String |
参数解释: 文件sha256 取值范围: 字符长度1-256位 |
file_type |
String |
参数解释: 文件类型 取值范围: 字符长度1-256位 |
file_content |
String |
参数解释: 文件内容 取值范围: 字符长度1-256位 |
file_attr |
String |
参数解释: 文件属性 取值范围: 字符长度1-256位 |
file_operation |
Integer |
参数解释: 文件操作类型 取值范围: 最小值0,最大值2147483647 |
file_action |
String |
参数解释: 文件动作 取值范围: 字符长度1-256位 |
file_change_attr |
String |
参数解释: 变更前后的属性 取值范围: 字符长度1-256位 |
file_new_path |
String |
参数解释: 新文件路径 取值范围: 字符长度1-256位 |
file_desc |
String |
参数解释: 文件描述 取值范围: 字符长度1-256位 |
file_key_word |
String |
参数解释: 文件关键字 取值范围: 字符长度1-256位 |
is_dir |
Boolean |
参数解释: 是否目录 取值范围:
|
fd_info |
String |
参数解释: 文件句柄信息 取值范围: 字符长度1-256位 |
fd_count |
Integer |
参数解释: 文件句柄数量 取值范围: 最小值0,最大值2147483647 |
请求示例
查询前50条企业项目为xxx下未处理的主机事件信息
GET https://{endpoint}/v5/{project_id}/event/events?offset=0&limit=50&handle_status=unhandled&category=host&enterprise_project_id=xxx
响应示例
状态码:200
请求已成功
{ "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" : "中国", "city" : "兰州市", "ip" : "127.0.0.1", "user" : "zhangsan", "sub_division" : "甘肃省", "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" : [ "热点事件" ] } ] }
SDK代码示例
SDK代码示例如下。
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) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
请求已成功 |
错误码
请参见错误码。