Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The structure to represent a Data Updated Event for CPS point of view need needs to to be defined without any ambiguity. This the interface contract to be rely on for:

  • CPS Core to publish data updates
  • CPS Temporal to listen to data updates
  • Any other system listening to data updates

Here is an example of a CPS Data Updated Event is a JSON document that adheres to following JSON Schema:

Code Block
titlecps-data-updated-event.json
linenumberstrue
{
  "schema": "urn:cps:org.onap.cps:data-updated-event-schema:1.0.0-SNAPSHOT",
  "id": "38aa6cc6-264d-4ede-b534-18f5c1f403ea",
  "source": "urn:cps:org.onap.cps",
  "type": "org.onap.cps.data-updated-event",
  "correlationId": "7515984f-064a-464f-8849-4c60f886ea4f",
  "content": {
    "timestamp": "2020-12-01T00:00:00.000+0000",
    "dataspaceName": "my-dataspace",
    "schemaSetName": "my-schema-set",
    "anchorName": "my-anchor",
    "data": {
      "interface": {
        "name": "itf-1",
        "status": "up"
      }
    }
  }
}


To be more formal, here is the JSON Schema that is representing any CPS Data Event:

Code Block
titlecps-data-updated-event-schema.json
linenumberstrue
{

  "$schema": "https://json-schema.org/draft/2019-09/schema",
  "$id": "urn:cps:org.onap.cps:data-updated-event-schema:1.0.0-SNAPSHOT",

  "$ref": "#/definitions/CpsDataUpdatedEvent",

  "definitions": {

    "CpsDataUpdatedEvent": {
      "titledescription": "CpsDataUpdatedEvent",The payload      "description": "A for CPS data updated event.",
      "type": "object",
      "properties": {
        "schema": {
          "description": "The schema, including its version, that this event adheres to.",
          "const": "urn:cps:org.onap.cps:data-updated-event-schema:1.0.0-SNAPSHOT"
        },
        "id": {
          "description": "The unique schema,id includingidentifying itsthe version,event thatfor the event adheres to."
        },specified source. Producer must ensure that source + id is unique for each distinct event.",
          "idtype": {"string"
        },
        "typesource": "string",{
          "description": "The uniquesource id identifyingof the event for the specified source. Producer must ensure that source + id is unique for each distinct event.",
        },         "source"type": {"string",
          "typeformat": "string",uri"
        },
        "formattype": "uri",{
          "description": "The sourcetype of the event.",
Producer must ensure that source + id is unique for each distinct event."type": "string"
        },
        "typecorrelationId": {
          "typedescription": "stringA unique identifier that may be used to correlate and trace information between several systems.",
          "descriptiontype": "The type of the event.string"
        },
        "content": {
          "$ref": "#/definitions/Content"
        }
      },
      "required": [
        "schema",
        "id",
        "source",
        "type",
        "content"
      ],
      "additionalProperties": false
    },

    "Content": {
      "title": "Content",
      "description": "The event content.",
      "type": "object",
      "properties": {
        "timestamp": {
          "typedescription": "string"The timestamp when the data has    }been observed.",
        "coreReferences": {           "$ref"type": "#/definitions/CoreReferenceListstring"
        },
        "datadataspaceName": {
          "$refdescription": "#/definitions/Data"
        }The name of CPS Core dataspace the data belongs to.",
       },   "type": "string"
  "additionalProperties": false     },
        "CoreReferenceListschemaSetName": {
      "title": "CoreReferenceList",
      "description": "AllThe name of CPS Core referencesschema set forthe data adheres to.",
          "type": "object",string"
        },
        "propertiesanchorName": {
          "dataspacedescription": { "The name of CPS Core anchor the data is attached to.",
          "$reftype": "#/definitions/CoreReferencestring"
        },
        "schemaSetdata": {
          "$ref": "#/definitions/CoreReferenceData"
        },
      },
      "anchorrequired": [
{        "timestamp",
        "$refdataspaceName": "#/definitions/CoreReference",
        "schemaSetName",
 }       }"anchorName",
        "additionalPropertiesdata":
 false     }],
      "CoreReferenceadditionalProperties": false
  {  },

    "titleData": "CoreReference",{
      "description": "AData CPSas Core reference for datajson object.",
      "type": "object",
    }

  }

  "properties": {
        "id": {
          "type": "string",
          "description": "The unique id identifying the reference."
        },}


CPS Event API

Having CPS Data Updated Event formalized, we could be able to use at AsyncAPI specification to define CPS Event Driven APIs in similar way we are using OpenAPI to define REST APIs:

Code Block
languageyml
linenumberstrue
asyncapi: 2.0.0
info:
  title: CPS Event API
  version: 1.0.0-SNAPSHOT
  description: This specification describes CPS event driven interfaces.
channels:
  cps/data/updated:
    description:
      This channel is the one on witch CPS Core is publishing notifications when
      its data  "name": {is updated.
    subscribe:
      "type"message:
"string",        $ref:   "description": "The name of the reference."
  '#/components/messages/DataUpdated'
components:
  messages:
    DataUpdated:
     } payload:
     },   description: The payload for "additionalProperties": false
 CPS data updated event.
  },      "Data": {type: object
        "title"properties:
"Data",          "description"schema:
 "The json data content payload",       "type": "object"
    }description: The schema, including its version, that this event adheres to.
     }  }  

Following is a CPS Data Updated Event example:

Code Block
titlecps-data-updated-event.json
linenumberstrue
{   "schema"const: "urn:cps:org.onap.cps:data-updated-event-schema:1.0.0-SNAPSHOT",
          "id": "38aa6cc6-264d-4ede-b534-18f5c1f403ea",
  "source": "urn:cps:org.onap.cps",
  "type": "org.onap.cps.data-updated-event",
  "content": {
    "timestamp": "2020-12-01T00:00:00.000+0000",
    "coreReferences": {id:
            description:
              The unique id identifying the event for the specified source.
              Producer must ensure that source + id is unique for each distinct event.
            type: string
          source:
            description:
              The source of the event.
              Producer must ensure that source + id is unique for each distinct event.
            type: string
            format: uri
          type:
            description: The type of the event.
            type: string
          correlationId:
            description:
              A unique identifier that may be used to correlate and trace information
              between several systems.
            type: string
          content:
            type: object
            properties:
              timestamp:
                description: The timestamp when the data has been observed.
                "dataspace": {type: string
              "id"dataspaceName: "123",
                description: The "name": "my-dataspace"name of CPS Core dataspace the data belongs to.
         },       "schemaSet": {type: string
              "id": "456",schemaSetName:
                description: The "name": "my-schema-set"name of CPS Core schema set the data adheres to.
         },       "anchor"type: {string
              "id": "789",anchorName:
                description: The "name": "my-anchor"
  name of CPS Core anchor the data is attached to.
                type: string
   }      },     "data": {data:
                description: Data as json object.
                "interface"type: {object
            "name": "itf-1",required:
              - timestamp
              - dataspaceName
              - schemaSetName
              - anchorName
              - data
            additionalProperties: false
        "status": "up"required:
          - schema
          - id
          - source
          - type
          - }content
    }   } }additionalProperties: false

To Do

...

AsyncAPI Playground can be used to visualize the specification. To go further, it could be worth looking at documentation and code generation features.