Versions Compared

Key

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

...

The event V1 schema definition is strict and it is not possible to add any optional fields without breaking the old schema contract. To have the flexibility of adding optional fields in future with full compatibility, we are setting the value of 'additionalProperties' to true in both 'CpsDataUpdatedEvent' and 'Content' definitions. 

...

  • optional: It makes the event v2 backwards compatible and the user can upgrade cps-temporal before cps-core. As it is a field that should be mandatory, it should be set as mandatory in the v3 which gives the user a release to upgrade cps-core to v2.  
  • mandatory: No no compatibility with the future change. Both older version and both cps-core and cps-temporal have to be updated at the same time. 

...

The existing 'data' section in the content can should be set as null for the delete event. As we are deleting a mandatory field, the change is still backwards compatible. 

...

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

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

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

  "definitions": {

    "CpsDataUpdatedEvent": {
      "description": "The payload for CPS data updated event.",
      "type": "object",
      "properties": {
        "schema": {
          "description": "The schema, including its version, that this event adheres to. E.g. 'urn:cps:org.onap.cps:data-updated-event-schema:v99'.",
          "type": "string",
          "format": "uri"
        },
        "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"
        },
        "content": {
          "$ref": "#/definitions/Content"
        }
      },
      "required": [
        "schema",
        "id",
        "source",
        "type",
        "content"
      ],
      "additionalProperties": true
    },

    "Content": {
      "description": "The event content.",
      "type": "object",
      "properties": {
        "operation": {
          "description": "The operation supported by the ",
          "type": "string",
          "enum": ["CREATE", "UPDATE", "DELETE"]
        },
        "observedTimestamp": {
          "description": "The timestamp when the data has been observed. The expected format is 'yyyy-MM-dd'T'HH:mm:ss.SSSZ'. Ex: '2020-12-01T00:00:00.000+0000'  ",
          "type": "string"
        },
        "dataspaceName": {
          "description": "The name of CPS Core dataspace the data belongs to.",
          "type": "string"
        },
        "schemaSetName": {
          "description": "The name of CPS Core schema set the data adheres to.",
          "type": "string"
        },
        "anchorName": {
          "description": "The name of CPS Core anchor the data is attached to.",
          "type": "string"
        },
        "data": {
          "$ref": "#/definitions/Data"
        }
      },
      "required": [
        "observedTimestamp",
        "dataspaceName",
        "schemaSetName",
        "anchorName",
        "data"
      ],
      "additionalProperties": true
    },

    "Data": {
      "description": "Data as json object.",
      "type": "object"
    }

  }

}

...

In the case of the 'delete' event, the 'data' section field should not be emptysent

Code Block
languagejs
titleDelete event
{
  "schema": "urn:cps:org.onap.cps:data-updated-event-schema:v1",
  "id": "77b8f114-4562-4069-8234-6d059ff742ac",
  "source": "urn:cps:org.onap.cps",
  "type": "org.onap.cps.data-updated-event",
  "content": {
    "observedTimestamp": "2020-12-01T00:00:00.000+0000",
    "dataspaceName": "my-dataspace",
    "schemaSetName": "bookstore-schemaset",
    "anchorName": "chapters",
    "operation": "DELETE",
  }
}

CPS-Temporal

It will store the new 'operation' field in the newly added column in the network_data table. if this field is optional in the event, the default value of UPDATE will be set on the temporal side.

...