$ npm install @adobe/aio-lib-events
- Initialize the SDK
const sdk = require('@adobe/aio-lib-events')
async function sdkTest() {
//initialize sdk
const client = await sdk.init('<organization id>', 'x-api-key', '<valid auth token>', '<options>')
}
- Call methods using the initialized SDK
const sdk = require('@adobe/aio-lib-events')
async function sdkTest() {
// initialize sdk
const client = await sdk.init('<organization id>', 'x-api-key', '<valid auth token>', '<options>')
// call methods
try {
// use one of the get methods
const result = await client.getSomething({})
console.log(result)
} catch (e) {
console.error(e)
}
}
- Using the poller for journalling
const sdk = require('@adobe/aio-lib-events')
async function sdkTest() {
// initialize sdk
const client = await sdk.init('<organization id>', 'x-api-key', '<valid auth token>', '<http options>')
// get the journalling observable
const journalling = client.getEventsObservableFromJournal('<journal url>', '<journalling options>')
// call methods
const subscription = journalling.subscribe({
next: (v) => console.log(v), // Action to be taken on event
error: (e) => console.log(e), // Action to be taken on error
complete: () => console.log('Complete') // Action to be taken on complete
})
// To stop receiving events from this subscription based on a timeout
setTimeout(() => subscription.unsubscribe(), <timeout in ms>)
}
One observable can have multiple subscribers. Each subscription can be handled differently. For more details on using the poller for Journalling check getEventsObservableFromJournal
- EventsCoreAPI
This class provides methods to call your Adobe I/O Events APIs. Before calling any method initialize the instance by calling the
init
method on it with valid values for organizationId, apiKey, accessToken and optional http options such as timeout and max number of retries
- init(organizationId, apiKey, accessToken, [httpOptions]) ⇒
Promise.<EventsCoreAPI>
Returns a Promise that resolves with a new EventsCoreAPI object.
- EventsCoreAPIOptions :
object
- EventsJournalOptions :
object
- EventsJournalPollingOptions :
object
This class provides methods to call your Adobe I/O Events APIs.
Before calling any method initialize the instance by calling the init
method on it
with valid values for organizationId, apiKey, accessToken and optional http options such as timeout
and max number of retries
Kind: global class
- EventsCoreAPI
- .httpOptions
- .organizationId
- .apiKey
- .accessToken
- .init(organizationId, apiKey, accessToken, [httpOptions]) ⇒
Promise.<EventsCoreAPI>
- .getAllProviders(consumerOrgId) ⇒
Promise.<object>
- .getProvider(providerId, [fetchEventMetadata]) ⇒
Promise.<object>
- .createProvider(consumerOrgId, projectId, workspaceId, body) ⇒
Promise.<object>
- .updateProvider(consumerOrgId, projectId, workspaceId, providerId, body) ⇒
Promise.<object>
- .deleteProvider(consumerOrgId, projectId, workspaceId, providerId) ⇒
Promise.<object>
- .getAllEventMetadataForProvider(providerId) ⇒
Promise.<object>
- .getEventMetadataForProvider(providerId, eventCode) ⇒
Promise.<object>
- .createEventMetadataForProvider(consumerOrgId, projectId, workspaceId, providerId, body) ⇒
Promise.<object>
- .updateEventMetadataForProvider(consumerOrgId, projectId, workspaceId, providerId, eventCode, body) ⇒
Promise.<object>
- .deleteEventMetadata(consumerOrgId, projectId, workspaceId, providerId, eventCode) ⇒
Promise.<object>
- .deleteAllEventMetadata(consumerOrgId, projectId, workspaceId, providerId) ⇒
Promise.<object>
- .createWebhookRegistration(consumerOrgId, integrationId, body) ⇒
Promise.<object>
- .getWebhookRegistration(consumerOrgId, integrationId, registrationId) ⇒
Promise.<object>
- .getAllWebhookRegistrations(consumerOrgId, integrationId) ⇒
Promise.<object>
- .deleteWebhookRegistration(consumerOrgId, integrationId, registrationId) ⇒
Promise.<object>
- .publishEvent(cloudEvent) ⇒
Promise.<string>
- .getEventsFromJournal(journalUrl, [eventsJournalOptions]) ⇒
Promise.<object>
- .getEventsObservableFromJournal(journalUrl, [eventsJournalOptions], [eventsJournalPollingOptions]) ⇒
Observable
- .verifySignatureForEvent(event, clientSecret, signatureHeaderValue) ⇒
boolean
Http options {retries, timeout}
Kind: instance property of EventsCoreAPI
The organization id from your integration
Kind: instance property of EventsCoreAPI
The api key from your integration
Kind: instance property of EventsCoreAPI
The JWT Token for the integration with IO Management API scope
Kind: instance property of EventsCoreAPI
eventsCoreAPI.init(organizationId, apiKey, accessToken, [httpOptions]) ⇒ Promise.<EventsCoreAPI>
Initialize SDK.
Kind: instance method of EventsCoreAPI
Returns: Promise.<EventsCoreAPI>
- returns object of the class EventsCoreAPI
Param | Type | Description |
---|---|---|
organizationId | string |
The organization id from your integration |
apiKey | string |
The api key from your integration |
accessToken | string |
JWT Token for the integration with IO Management API scope |
[httpOptions] | EventsCoreAPIOptions |
Options to configure API calls |
Fetch all the providers
Kind: instance method of EventsCoreAPI
Returns: Promise.<object>
- Returns list of providers for the org
Param | Type | Description |
---|---|---|
consumerOrgId | string |
Consumer Org Id from the console |
Fetch a provider
Kind: instance method of EventsCoreAPI
Returns: Promise.<object>
- Returns the provider specified by the provider id
Param | Type | Default | Description |
---|---|---|---|
providerId | string |
The id that uniquely identifies the provider to be fetched | |
[fetchEventMetadata] | boolean |
false |
Set this to true if you want to fetch the associated eventmetadata of the provider |
Create a new provider given the provider details
Kind: instance method of EventsCoreAPI
Returns: Promise.<object>
- Returns the details of the provider created
Param | Type | Description |
---|---|---|
consumerOrgId | string |
Consumer Org Id from the console |
projectId | string |
Project Id from the console |
workspaceId | string |
Workspace Id from the console |
body | object |
Json data that describes the provider |
eventsCoreAPI.updateProvider(consumerOrgId, projectId, workspaceId, providerId, body) ⇒ Promise.<object>
Update a provider given the id and provider details
Kind: instance method of EventsCoreAPI
Returns: Promise.<object>
- Returns the details of the provider updated
Param | Type | Description |
---|---|---|
consumerOrgId | string |
Consumer Org Id from the console |
projectId | string |
Project Id from the console |
workspaceId | string |
Workspace Id from the console |
providerId | string |
The id that uniquely identifies the provider to be updated |
body | object |
Json data that describes the provider |
Delete a provider given the id
Kind: instance method of EventsCoreAPI
Returns: Promise.<object>
- Returns an empty object if the deletion was successful
Param | Type | Description |
---|---|---|
consumerOrgId | string |
Consumer Org Id from the console |
projectId | string |
Project Id from the console |
workspaceId | string |
Workspace Id from the console |
providerId | string |
The id that uniquely identifies the provider to be deleted |
Get all event metadata for a provider
Kind: instance method of EventsCoreAPI
Returns: Promise.<object>
- List of all event metadata of the provider
Param | Type | Description |
---|---|---|
providerId | string |
The id that uniquely identifies the provider whose event metadata is to be fetched |
Get an event metadata for given provider and event code
Kind: instance method of EventsCoreAPI
Returns: Promise.<object>
- Event metadata that corresponds to the specified event code
Param | Type | Description |
---|---|---|
providerId | string |
The id that uniquely identifies the provider whose event metadata is to be fetched |
eventCode | string |
The specific event code for which the details of the event metadata is to be fetched |
eventsCoreAPI.createEventMetadataForProvider(consumerOrgId, projectId, workspaceId, providerId, body) ⇒ Promise.<object>
Create an event metadata for a provider
Kind: instance method of EventsCoreAPI
Returns: Promise.<object>
- Details of the event metadata created
Param | Type | Description |
---|---|---|
consumerOrgId | string |
Consumer Org Id from the console |
projectId | string |
Project Id from the console |
workspaceId | string |
Workspace Id from the console |
providerId | string |
provider for which the event metadata is to be added |
body | object |
Json data that describes the event metadata |
eventsCoreAPI.updateEventMetadataForProvider(consumerOrgId, projectId, workspaceId, providerId, eventCode, body) ⇒ Promise.<object>
Update the event metadata for a provider
Kind: instance method of EventsCoreAPI
Returns: Promise.<object>
- Details of the event metadata updated
Param | Type | Description |
---|---|---|
consumerOrgId | string |
Consumer Org Id from the console |
projectId | string |
Project Id from the console |
workspaceId | string |
Workspace Id from the console |
providerId | string |
provider for which the event metadata is to be updated |
eventCode | string |
eventCode of the event metadata to be updated |
body | object |
Json data that describes the event metadata |
eventsCoreAPI.deleteEventMetadata(consumerOrgId, projectId, workspaceId, providerId, eventCode) ⇒ Promise.<object>
Delete an event metadata of a provider
Kind: instance method of EventsCoreAPI
Returns: Promise.<object>
- Empty object if deletion was successful
Param | Type | Description |
---|---|---|
consumerOrgId | string |
Consumer Org Id from the console |
projectId | string |
Project Id from the console |
workspaceId | string |
Workspace Id from the console |
providerId | string |
provider for which the event metadata is to be updated |
eventCode | string |
eventCode of the event metadata to be updated |
eventsCoreAPI.deleteAllEventMetadata(consumerOrgId, projectId, workspaceId, providerId) ⇒ Promise.<object>
Delete all event metadata of a provider
Kind: instance method of EventsCoreAPI
Returns: Promise.<object>
- Empty object if deletion was successful
Param | Type | Description |
---|---|---|
consumerOrgId | string |
Consumer Org Id from the console |
projectId | string |
Project Id from the console |
workspaceId | string |
Workspace Id from the console |
providerId | string |
provider for which the event metadata is to be updated |
Create a webhook or journal registration
Kind: instance method of EventsCoreAPI
Returns: Promise.<object>
- Details of the webhook/journal registration created
Param | Type | Description |
---|---|---|
consumerOrgId | string |
Consumer Org Id from the console |
integrationId | string |
integration Id from the console |
body | object |
Json data contains details of the registration |
eventsCoreAPI.getWebhookRegistration(consumerOrgId, integrationId, registrationId) ⇒ Promise.<object>
Get registration details for a given registration
Kind: instance method of EventsCoreAPI
Returns: Promise.<object>
- Details of the webhook/journal registration
Param | Type | Description |
---|---|---|
consumerOrgId | string |
Consumer Org Id from the console |
integrationId | string |
Integration Id from the console |
registrationId | string |
Registration id whose details are to be fetched |
Get all registration details for a given integration
Kind: instance method of EventsCoreAPI
Returns: Promise.<object>
- List of all webhook/journal registrations
Param | Type | Description |
---|---|---|
consumerOrgId | string |
Consumer Org Id from the console |
integrationId | string |
Integration Id from the console |
eventsCoreAPI.deleteWebhookRegistration(consumerOrgId, integrationId, registrationId) ⇒ Promise.<object>
Delete webhook registration
Kind: instance method of EventsCoreAPI
Returns: Promise.<object>
- Empty object if deletion was successful
Param | Type | Description |
---|---|---|
consumerOrgId | string |
Consumer Org Id from the console |
integrationId | string |
Integration Id from the console |
registrationId | string |
Id of the registration to be deleted |
Publish Cloud Events
Event publishers can publish events to the Adobe I/O Events using this SDK. The events should follow Cloud Events 1.0 specification: https://github.com/cloudevents/spec/blob/v1.0/spec.md. As of now, only application/json is accepted as the content-type for the "data" field of the cloud event. If retries are set, publish events are retried on network issues, 5xx and 429 error response codes.
Kind: instance method of EventsCoreAPI
Returns: Promise.<string>
- Returns OK/ undefined in case of success and error in case of failure
Param | Type | Description |
---|---|---|
cloudEvent | object |
Object to be published to event receiver in cloud event format |
Get events from a journal.
Kind: instance method of EventsCoreAPI
Returns: Promise.<object>
- with the response json includes events and links (if available)
Param | Type | Description |
---|---|---|
journalUrl | string |
URL of the journal or 'next' link to read from (required) |
[eventsJournalOptions] | EventsJournalOptions |
Query options to send with the URL |
eventsCoreAPI.getEventsObservableFromJournal(journalUrl, [eventsJournalOptions], [eventsJournalPollingOptions]) ⇒ Observable
getEventsObservableFromJournal returns an RxJS Observable
One can go through the extensive documentation on RxJS in order to learn more and leverage the various RxJS Operators to act on emitted events.
Kind: instance method of EventsCoreAPI
Returns: Observable
- observable to which the user can subscribe to in order to listen to events
Param | Type | Description |
---|---|---|
journalUrl | string |
URL of the journal or 'next' link to read from (required) |
[eventsJournalOptions] | EventsJournalOptions |
Query options to send with the Journal URL |
[eventsJournalPollingOptions] | EventsJournalPollingOptions |
Journal polling options |
Authenticating events by verifying signature
Kind: instance method of EventsCoreAPI
Returns: boolean
- If signature matches return true else return false
Param | Type | Description |
---|---|---|
event | object |
JSON payload delivered to the registered webhook URL |
clientSecret | string |
Client secret can be retrieved from the Adobe I/O Console integration |
signatureHeaderValue | string |
Value of x-adobe-signature header in each POST request to the registered webhook URL |
init(organizationId, apiKey, accessToken, [httpOptions]) ⇒ Promise.<EventsCoreAPI>
Returns a Promise that resolves with a new EventsCoreAPI object.
Kind: global function
Returns: Promise.<EventsCoreAPI>
- returns object of the class EventsCoreAPI
Param | Type | Description |
---|---|---|
organizationId | string |
The organization id from your integration |
apiKey | string |
The api key from your integration |
accessToken | string |
JWT Token for the integration with IO Management API scope |
[httpOptions] | EventsCoreAPIOptions |
Options to configure API calls |
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
[timeout] | number |
Http request timeout in ms (optional) |
[retries] | number |
Number of retries in case of 5xx errors. Default 0 (optional) |
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
[latest] | boolean |
Retrieve latest events (optional) |
[since] | string |
Position at which to start fetching the events from (optional) |
[limit] | number |
Maximum number of events to retrieve (optional) |
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
[interval] | number |
Interval at which to poll the journal; If not provided, a default value will be used (optional) |
LOG_LEVEL=debug <your_call_here>
Prepend the LOG_LEVEL
environment variable and debug
value to the call that invokes your function, on the command line. This should output a lot of debug data for your SDK calls.
Contributions are welcome! Read the Contributing Guide for more information.
This project is licensed under the Apache V2 License. See LICENSE for more information.