用例-动词-通知

背景

通知谓词,由 OAGi 定义为 OAGIS BOD 消息库的一部分。根据定义,通知意味着根据事件从发布者发送到订阅者的消息。HROS 中的通知已使用 OAGIS 业务对象文档 (BOD) 体系结构作为包装消息的方法。

此模板的目标是将 XML 中的通知 BOD 映射到在没有 BOD 的 REST 体系结构中使用 JSON。由于 REST 是使用请求/响应无状态通信的体系结构,这意味着服务器在没有请求的情况下无法向客户端发送信息。因此,建议为通知提供单独的资源。生产者将 POST 通知到单独的资源,使用者使用 GET 请求通知。

特定资源类型的 URI
https://api.ats-company.com/v4/assessments/catalog?packageId=123456具有第二个用于通知的URI https://api.ats-company.com/v4/notifications/assessments/catalog?packageId=123456

当需要通知的资源发生事件时,第二个资源需要单独的 POST。

通知类型架构

{
  "title": "NotificationType",
  "description": "A notification message to be sent. The URI for the resource must uniquely identify the resource. ",
  "type": "object",
  "properties": {
    "id": {
      "description": "Identifier for a resource that an event occurred.",
      "$ref": "./Common/base.json#IdentifierType"
    },
    "action": {
      "description": "Action code for the resource event.",
      "$ref": "./Common/codelist/action.json"
    },
    "message": {
      "description": "Text description.",
      "type": "string"
    },
    "resourceLink": {
      "description": "Link to the resource that an event occurred.",
      "type": "string",
      "format": "uri"
    }
  }
}

通知实例

{
  "id": "123456",
  "action": "update",
  "message": "The assessment package data was updated",
  "resourceLink": "https://api.ats-company.com/v4/notifications/assessments/catalog?packageId=123456"
}

方案 1:更新是独立的

0 |            resource      notify/resource
1 |-----POST------>|                |
2 |<-----200-------|                | 
3 |-----POST-------|--------------->| 
4 |<-----200-------|----------------| 
5 |-----GET--------|--------------->|
6 |<-----200-------|----------------| 

方案 2 资源更新通知/资源

0 |            resource      notify/resource
1 |-----POST------>|                |
2 |<-----200-------|                | 
3 |                |--------------->| 
4 |                |<-----200-------| 
5 |-----GET--------|--------------->|
6 |<-----200-------|----------------|