CloudEvent

CloudEvent

An CloudEvent describes event data in common formats to provide interopability across services, platforms and systems.

Constructor

new CloudEvent(options)

Creates a new CloudEvent instance

Parameters:
Name Type Description
options object

CloudEvent properties as a simple object

Properties
Name Type Attributes Description
source string

Identifies the context in which an event happened as a URI reference

type string

Describes the type of event related to the originating occurrence

id string <optional>

A unique ID for this event - if not supplied, will be autogenerated

time string <optional>

A timestamp for this event. May also be provided as a Date

subject string <optional>

Describes the subject of the event in the context of the event producer

dataContentType string <optional>

The mime content type for the event data

dataSchema string <optional>

The URI of the schema that the event data adheres to (v1.0 events)

schemaURL string <optional>

The URI of the schema that the event data adheres to (v0.3 events)

dataContentEncoding string <optional>

The content encoding for the event data (v0.3 events)

specversion string <optional>

The CloudEvent specification version for this event - default: 1.0

data * <optional>

The event payload

Source:
See:

Members

data :*

Gets or sets the data for this event

Source:
See:

dataContentEncoding :string

Gets or sets the event's data content encoding

Source:
See:

dataContentType :string

Gets or sets the content type of the data value for this event

Source:
See:

dataSchema :string

Gets or sets the event's data schema

Source:
See:

id :string

Gets or sets the event id. Source + id must be unique for each distinct event.

Source:
See:

schemaURL :string

DEPRECATED: Gets or sets the schema URL for this event. Throws {TypeError} if this is a version 1.0 event.

Source:
See:

source :string

Gets or sets the origination source of this event as a URI.

Source:
See:

specversion :string

Gets the CloudEvent specification version

Source:
See:

subject :string

Gets or sets the event subject

Source:
See:

time :string

Gets or sets the timestamp for this event as an ISO formatted date string

Source:
See:

type :string

Gets or sets the event type

Source:
See:

Methods

addExtension(key, value) → {void}

Adds an extension attribute to this CloudEvent

Parameters:
Name Type Description
key string

the name of the extension attribute

value *

the value of the extension attribute

Source:
See:

format() → {JSON}

Formats the CloudEvent as JSON. Validates the event according to the CloudEvent specification and throws an exception if it's invalid.

Source:
Throws:

if this event cannot be validated against the specification

Type
ValidationError

getExtensions() → {Object}

Gets the extension attributes, if any, associated with this event

Source:
See:

toString() → {string}

Formats the CloudEvent as JSON. No specification validation is performed.

Source: