Constructor
new CloudEvent(UserSpecopt, UserFormatteropt)
Creates a new CloudEvent instance
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
UserSpec |
Spec |
<optional> |
A CloudEvent version specification |
UserFormatter |
Formatter |
<optional> |
Converts the event into a readable string |
- Source:
Methods
addExtension(key, value) → {CloudEvent}
Adds an extension attribute to this CloudEvent
Parameters:
Name | Type | Description |
---|---|---|
key |
* |
the name of the exteneion attribute |
value |
* |
the value of the extension attribute |
- Source:
- See:
data(data) → {CloudEvent}
Sets the data for this event
Parameters:
Name | Type | Description |
---|---|---|
data |
* |
any data associated with this event |
- Source:
- See:
dataContenttype(contenttype) → {CloudEvent}
Sets the content type of the data value for this event
Parameters:
Name | Type | Description |
---|---|---|
contenttype |
string |
per https://tools.ietf.org/html/rfc2046 |
- Source:
- See:
format() → {JSON}
Format the CloudEvent as JSON. Validates the event according to the CloudEvent specification and throws an exception if it's invalid.
- Source:
getData() → {*}
Gets any data that has been set for this event
- Source:
- See:
getDataContenttype() → {string}
Gets the content type of the data value for this event
- Source:
- See:
getExtensions() → {Object}
Gets the extension attributes, if any, associated with this event
- Source:
- See:
getFormats() → {Object}
Get the formatters available to this CloudEvent
- Source:
getId() → {string}
Gets the event id.
- Source:
getSource() → {string}
Gets the origination source of this event.
- Source:
- See:
getSpecversion() → {string}
Gets the CloudEvent specification version
- Source:
- See:
getTime() → {Date}
Gets the timestamp for this event
getType() → {String}
Gets the event type
id(id) → {CloudEvent}
Sets the event id. Source + id must be unique for each distinct event.
Parameters:
Name | Type | Description |
---|---|---|
id |
string |
source+id must be unique for each distinct event |
source(source) → {CloudEvent}
Sets the origination source of this event.
Parameters:
Name | Type | Description |
---|---|---|
source |
URI |
the context in which the event happened |
- Source:
- See:
time(time) → {CloudEvent}
Sets the timestamp for this event
Parameters:
Name | Type | Description |
---|---|---|
time |
Date |
timestamp when the event occurred |
toString() → {JSON}
Formats the CLoudEvent as JSON. No specification validation is performed.
- Source:
type(type) → {CloudEvent}
Sets the event type
Parameters:
Name | Type | Description |
---|---|---|
type |
string |
the type of event related to the originating source |