Solace Pubsub+ Event Portal REST API Wrapper
This module wraps the Solace PubSub+ EP REST API. This can be used to enable the creation of integrations, plugins, and component on top of the Solace PubSub+ Event API.
Dont forget to give this repo a star! ✨
Installation
npm install @solace-community/eventportal
Constructor
const EventPortal = require('@solace-community/eventportal')
const ep = new EventPortal()
// Optional: You can pass Solace Cloud Token as parameter if not defined as environment variable
const ep = new EventPortal(SOLACE_CLOUD_TOKEN)
How to use
Check out the create.js
script in the example directory for API usage.
Here is a video as well
Environment Variables
Env Variable | Description |
---|
SOLACE_CLOUD_TOKEN | Solace Cloud Token with the right EP access |
Methods
createApplicationDomain(domain)
Creates an application domain given a domain object. An example of an application domain object :
domain = {
name: "Application Domain name",
description: "Application Domain description",
uniqueTopicAddressEnforcementEnabled: true,
topicDomainEnforcementEnabled: false,
type: "ApplicationDomain"
}
Returns
Notes
- If Application Domain name exists, matching Application Domain ID is returned
createSchemaObject(schema)
Creates an EP Schema Object in the Application Domain given a schema object definition. An example of a schema object :
schema = {
applicationDomainId: domainID,
name: "Schema1",
shared: false,
contentType: "json",
schemaType: "jsonSchema"
}
Returns
Notes
- If the Schema name exists, matching Schema Object ID is returned
createSchemaVersion(schemaVersion, overwrite)
Creates a Schema version given a schema version definition. An example of a schema version object :
schemaVersion = {
schemaID: schemaID,
description: "This is the schema version description",
version: "0.0.1",
displayName: "This is the Display name of the schema",
content: JSON.stringify(schemaContent),
stateID: "1"
}
Returns
Notes
- If the Schema version exists and overwrite is not set, an error is thrown
- The schema content is in string format
- Setting the overwrite flag to true will overwrite the schema if the State is
DRAFT
otherwise throws an error
createEventObject(event)
Creates an EP Event Object in the Application Domain given an event object definition. An example of a event object :
event = {
applicationDomainId: domainID,
name: "Event Name",
shared: false
}
Returns
Notes
- If the Event name exists, matching Event Object ID is returned
createEventVersion(eventVersion, overwrite)
Creates an Event version given an event version definition. An example of an event version object :
eventVersion = {
eventID: eventID,
displayName: "Scripted Version",
version: "0.0.1",
schemaVersionId: schemaVersionID,
deliveryDescriptor:{
brokerType: "solace",
address:{
addressLevels
},
stateID:"1"
}
}
Returns
Notes
- If the Event version exists and overwrite is not set, an error is thrown
- Setting the overwrite flag to true will overwrite the event if the State is
DRAFT
otherwise throws an error - the
addressLevels
parameter is an array with the following format
let addressLevels = [
{name: "level1", addressLevelType: "literal"},
{name: "level2", addressLevelType: "variable"},
{name: "level3", addressLevelType: "literal"},
{name: "level4", addressLevelType: "variable"},
]
createApplicationObject(application)
Creates an EP Application Object in the Application Domain given an application object definition. An example of a application object :
application = {
applicationDomainId: domainID,
name: "My Scripted Application",
applicationType: "standard",
}
Returns
Notes
- If the Application name exists, matching Application Object ID is returned
createApplicationVersion(applicationVersion, overwrite)
Creates an Application version given an application version definition. An example of an application version object :
applicationVersion = {
applicationID: applicationID,
displayName: "Display Name",
description: "This is the scripted description",
version: "0.0.1",
declaredProducedEventVersionIds:[eventVersionID],
type: "application"
}
Returns
Notes
- If the Application version exists and overwrite is not set, an error is thrown
declaredProducedEventVersionIds
is an array of produced eventsdeclaredConsumedEventVersionIds
is an array of consumed events- Setting the overwrite flag to true will overwrite the application if the State is
DRAFT
otherwise throws an error
getApplicationName(applicationID)
Returns the Application Name given ApplicationID
getApplicationIDs(applicationName)
Return an array of matching applicatio name IDs
getEventName(eventID)
Returns the Event Name given EventID
getEventIDs(eventName)
Returns an array of matching event name IDs
getSchemaName(schemaID)
Returns the Schema Name given SchemaID
getSchemaIDs(schemaName)
Return an array of matching schema name IDs
getApplicationDomainID(domainName)
Returns the ApplicationDomainID given Application Domain Name
getSchemaVersionID(schemaID, schemaVersion)
Return the SchemaVersion ID given the schemaID and SchemaVersion string
getApplicationVersionID(applicationID, applicationVersion)
Return the application version IDs given the applicationID and applicationVersion
getEventVersionID(eventID, eventVersion)
Return the event version IDs given the eventID and eventVersion
getSchemaVersionID(schemaID, schemaVersion)
Return the schema version IDs given the schemaID and schemaVersion
getApplicationState(applicationID, applicationVersion)
Returns the Application State given the application ID and application version. The current states are
- DRAFT
- RELEASED
- DEPRECATED
- RETIRED
getEventState(eventID, eventVersion)
Returns the Event State given the event ID and event version. The current states are
- DRAFT
- RELEASED
- DEPRECATED
- RETIRED
getSchemaState(schemaID, schemaVersion)
Returns the Schema State given the schema ID and schema version. The current states are
- DRAFT
- RELEASED
- DEPRECATED
- RETIRED
To-Do