审计接口由三部分组成:
- 审计API 资源将URI和URI模板返回到审核记录集合, 以便可以通过诸如"来自特定用户的所有记录"或"来自特定应用程序的所有记录"的标准查询它们。
- 审计记录集合资源检索审计记录并启用创建新的审计记录。
- 审计记录资源表示单独查询的审计记录。
注意: 所有的PUT/POST请求必须设置accept头, 否则会返回空的应答正文。
审计信息
- 报警修改
- 操作修改
- 双因子认证登陆尝试
- 智能规则修改
- CEP模块修改
- 用户和群组权限修改
审计API
审计记录 [application/vnd.com.nsn.cumulocity.auditApi+json]
名称 | 类型 | 次数 | 描述 |
---|---|---|---|
self | URL | 1 | 资源链接。 |
auditRecords | AuditRecordCollection | 1 | 所有审计记录集合。 |
auditRecordsForType | AuditRecordCollection URI template | 1 | 特定类型的所有审计记录只读集合(占位符 {type})。 |
auditRecordsForUser | AuditRecordCollection URI template | 1 | 特定用户的所有审计记录只读集合(占位符 {user})。 |
auditRecordsForApplication | AuditRecordCollection URI template | 1 | 特定应用程序的所有审计记录只读集合(占位符 {application})。 |
auditRecordsForUserAndType | AuditRecordCollection URI template | 1 | 特定用户和类型的所有审计记录只读集合(占位符 {user} 和 {type})。 |
auditRecords ForUserAndApplication | AuditRecordCollection URI template | 1 | 特定用户和应用程序的所有审计记录只读集合(占位符 {user} 和 {application})。 |
auditRecords ForTypeAndApplication | AuditRecordCollection URI template | 1 | 特定类型和应用程序的所有审计记录只读集合(占位符 {type} 和 {application})。 |
auditRecords ForTypeAndUserAndApplication | AuditRecordCollection URI template | 1 | 特定类型, 用户和应用程序的所有审计记录只读集合(占位符 {type}, {user} 和 {application})。 |
GET - 查询审计API资源
应答正文: application/vnd.com.nsn.cumulocity.auditApi+json
所需角色: ROLE_AUDIT_READ
请求示例: 查询审计API资源
GET /audit
Host: ...
Authorization: Basic ...
应答示例:
HTTP/1.1 200 OK
Content-Type: application/vnd.com.nsn.cumulocity.auditApi+json;ver=...
Content-Length: ...
{
"self" : "<<AuditAPI URL>>",
"auditRecords" : { "self" :"<<AuditCollection URL>>" },
"auditRecordsForType" : "<<AuditCollection URL>>?type={type}",
"auditRecordsForUser" : "<<AuditCollection URL>>?user={user}",
"auditRecordsForApplication" : "<<AuditCollection URL>>?application={application}",
"auditRecordsForUserAndType" : "<<AuditCollection URL>>?user={user}&type={type}",
"auditRecordsForUserAndApplication" : "<<AuditCollection URL>>?user={user}&application={application}",
"auditRecordsForTypeAndApplication" : "<<AuditCollection URL>>?type={type}&application={application}",
"auditRecordsForTypeAndUserAndApplication" : "<<AuditCollection URL>>?type={type}&user={user}&application={application}"
}
审计记录集合
审计记录集合 [application/vnd.com.nsn.cumulocity.auditRecordCollection+json]
名称 | 类型 | 次数 | 描述 |
---|---|---|---|
self | URI | 1 | 资源链接。 |
auditRecords | AuditRecord | 0..n | 审计记录列表, 如下所示。 |
statistics | PagingStatistics | 1 | 分页统计信息。 |
prev | URI | 0..1 | 上一页链接。 |
next | URI | 0..1 | 下一页链接。 |
审计记录的"source"对象包含属性"id"和"self"。
POST - 创建新审计记录
请求正文: 审计记录
应答正文: 审计记录
所需角色: ROLE_AUDIT_ADMIN
请求示例:
POST /audit/auditRecords
Host: ...
Authorization: Basic ...
Content-Length: ...
Content-Type: application/vnd.com.nsn.cumulocity.auditRecord+json;ver=...
{
"type" : "com_cumulocity_audit_LoginFailure",
"time" : "2011-09-06T12:03:27.845Z",
"text" : "Login failed after 3 attempts.",
"user" : "Spock",
"application" : "Omniscape",
"activity" : "login",
"severity" : "warning"
}
应答示例:
HTTP/1.1 201 Created
Content-Type: application/vnd.com.nsn.cumulocity.auditRecord+json;ver=...
Content-Length: ...
Location: <<URL of new audit record>>
{
"id" : "123",
"self" : "<<URL of new audit record>>",
"creationTime" : "2011-09-06T12:03:27.927Z",
"type" : "com_cumulocity_audit_LoginFailure",
"time" : "2011-09-06T12:03:27.845Z",
"text" : "Login failed after 3 attempts.",
"user" : "Spock",
"application" : "Omniscape",
"activity" : "login",
"severity" : "warning"
}
新审计记录的"id"和"creationTime"由服务器生成, 并在对POST操作的响应中返回。
GET - 查询审计记录
应答正文: 审计记录集合
所需角色: ROLE_AUDIT_READ
请求示例: 查询审计记录
GET /audit/auditRecords
Host: ...
Authorization: Basic ...
Accept: application/vnd.com.nsn.cumulocity.auditRecordCollection+json;
应答示例:
HTTP/1.1 200 OK
Content-Type: application/vnd.com.nsn.cumulocity.auditRecordCollection+json;ver=...
Content-Length: ...
{
"self" : "",
"auditRecords" : [
{
"id" : "123",
"self" : "<<AuditRecord 123 URL>>",
"creationTime" : "2011-09-06T12:03:27.927Z",
"type" : "com_cumulocity_audit_LoginFailure",
"time" : "2011-09-06T12:03:27.845Z",
"text" : "Login failed after 3 attempts.",
"user" : "Spock",
"application" : "Omniscape",
"activity" : "login",
"severity" : "warning"
}
],
"statistics" : {
"totalPages" : 3,
"pageSize" : 5,
"currentPage" : 1
}
}
在对审核日志API执行范围查询的情况下, 例如通过dateFrom和dateTo进行查询, 审计将按从最后到最近的顺序返回。 可以通过向请求URL添加查询参数"revert=true"来更改顺序。
DELETE - 删除审计记录集合
DELETE方法允许删除审计记录集合。 适用的查询参数等同于GET方法。
请求正文: N/A
应答正文: N/A
所需角色: ROLE_AUDIT_ADMIN
请求示例:
DELETE: /audit/auditRecords ....
Host: ...
Authorization: Basic ...
应答示例:
HTTP/1.1 204 NO CONTENT
审计记录
审计记录 [application/vnd.com.nsn.cumulocity.auditRecord+json]
名称 | 类型 | 次数 | 描述 | PUT/POST |
---|---|---|---|---|
id | String | 1 | 唯一标识此审核记录。 | 否 |
self | URI | 1 | 资源链接。 | 否 |
creationTime | String | 1 | 在数据库中创建审计记录的时间。 | 否 |
type | String | 1 | 标识此审核记录的类型。 | POST: 必选 PUT: 否 |
time | String | 1 | 审计记录的时间。 | POST: 必选 PUT: 否 |
text | String | 1 | 审计记录的文本描述。 | POST: 必选 PUT: 否 |
source | ManagedObject | 1 | 审计记录源自的可选托管对象, 作为包含属性"id"和"self"的对象。 | POST: 必选 PUT: 否 |
user | String | 1 | 负责审核的操作的用户。 | 可选 |
application | String | 1 | 用于执行经审计的操作的应用程序。 | 可选 |
activity | String | 1 | 进行的活动 | POST: 必选 PUT: 可选 |
severity | String | 1 | 动作的严重级别: 严重, 主要, 次要, 警告或信息。 | POST: 必选 PUT: 可选 |
changes | Set | 0..1 | 描述所执行更改的对象的可选集合。 | 否 |
* | Object | 0..n | 审计记录的其他属性。 | 可选 |
请注意,源可以不仅包含带有id和self的ManagedObject, 而且在"Operation"类型 - 操作id和报警类型 - 报警Id的情况下。 在这种情况下, 源中的自链接是不正确的, 保留在那里以不打破预期在源中获得ManagedObject的客户端。
GET - 查询审计记录
应答正文: 审计记录
所需角色: ROLE_AUDIT_READ
请求示例: 查询特定审计记录
GET /audit/auditRecords/<<recordId>>
Host: ...
Authorization: Basic ...
Accept: application/vnd.com.nsn.cumulocity.auditRecord+json;
应答示例:
HTTP/1.1 200 OK
Content-Type: application/vnd.com.nsn.cumulocity.auditRecord+json;ver=...
Content-Length: ...
{
"id" : "123",
"self" : "<<AuditRecord URL>>",
"creationTime" : "2011-09-06T12:03:27.927Z",
"type" : "com_cumulocity_audit_LoginFailure",
"time" : "2011-09-06T12:03:27.845Z",
"text" : "Login failed after 3 attempts.",
"user" : "Spock",
"application" : "Omniscape",
"activity" : "login",
"severity" : "warning"
}