aix-event-client v1.0.0
aix-event-client
Client library for accessing aix-event-service.
USAGE
import { Auth0Client } from './Auth0Client';
import { AIXEventClient } from 'aix-event-client';
import { Feed } from 'aix-event-client/lib/models/Feed';
let accessToken: string;
try {
const auth0Client: Auth0Client = Auth0Client.getInstance(
<string>process.env.AUTH0_TENANT
);
accessToken = await auth0Client.getAuthToken(
<string>process.env.AUTH0_CLIENT_ID,
<string>process.env.AUTH0_CLIENT_SECRET,
<string>process.env.AUTH0_AUDIENCE
);
} catch (err) {
console.error(err);
throw new Error('Failed to obtain token from Auth0');
}
const client = new AIXEventClient('http://localhost:3000', accessToken);
try {
const feeds:Feed[] = await client.getFeeds();
// ...
}
catch(err) {
console.error(err);
throw new Error('Failed to obtain feeds from aix-event-service');
}
API Docs
AIXEventClient
Client library for interacting with the aix-event-service.
Kind: global class
new AIXEventClient(baseUrl, accessToken, debug)
Param | Type | Description |
---|---|---|
baseUrl | string | base URL for the aix-event-service (exclude any version modifiers) |
accessToken | string | service-to-service access token (JWT) |
debug | boolean | optional, enable request debugging |
Example
const accessToken:string = await auth0client.getAuthToken(...);
const client:AIXEventClient = new AIXEventClient('https://localhost:3000',accessToken);
aixEventClient.heartbeat() ⇒
Ask the service for a current status
Kind: instance method of AIXEventClient
Returns: ServiceStatus
aixEventClient.handleEvent(event) ⇒
Given an Event object, search Triggers for matching Feeds and execute the associated Task.
Kind: instance method of AIXEventClient
Returns: TaskRunnerResult[] - list of results from the Tasks
Param | Type | Description |
---|---|---|
event | WebhookModel | an event used to find Triggers |
aixEventClient.testEvent(event) ⇒
Given an Event object, search Triggers for matching Feeds and return the list of Feed Ids (without executing Tasks)
Kind: instance method of AIXEventClient
Returns: string[] - list of Feed ids
Param | Type | Description |
---|---|---|
event | WebhookModel | an event use to find Triggers |
aixEventClient.getFeeds(opt) ⇒
Return a (possibly filtered) list of Feeds
Kind: instance method of AIXEventClient
Returns: Feed[]
Param | Type | Description |
---|---|---|
opt | object | |
opt.tenant | string | optional tenant name to filter by |
opt.type | string | optional feed type to filter by |
opt.active | boolean | optional active flag to filter by |
opt.includeDeleted | boolean | optional flag to include/exclude deleted Feeds |
aixEventClient.createFeed(feed) ⇒
Creates a Feed, and returns the result. The Feed you pass in should have a blank 'id'; it will be populated on return.
Kind: instance method of AIXEventClient
Returns: Feed
Param | Type | Description |
---|---|---|
feed | Feed | object to create |
aixEventClient.getFeed(feedId, opt) ⇒
Returns a specific Feed object.
Kind: instance method of AIXEventClient
Returns: Feed
Param | Type | Description |
---|---|---|
feedId | string | unique id for the Feed to find |
opt | object | |
opt.triggers | boolean | include associated Trigger objects, default: false |
opt.schedules | boolean | include associated Schedule objects, default: false |
opt.files | boolean | include associated File objects, default: false |
opt.activity | boolean | include associated Activity objects, default: false |
aixEventClient.updateFeed(feed) ⇒
Updates a Feed object
Kind: instance method of AIXEventClient
Returns: boolean
Param | Type | Description |
---|---|---|
feed | Feed | object to update |
aixEventClient.deleteFeed(feedId) ⇒
Marks a feed as deleted
Kind: instance method of AIXEventClient
Returns: boolean
Param | Type | Description |
---|---|---|
feedId | string | unique id for the Feed to remove |
aixEventClient.restoreFeed(feedId) ⇒
Restores a previously deleted Feed
Kind: instance method of AIXEventClient
Returns: Feed
Param | Type | Description |
---|---|---|
feedId | string | unique id for the Feed to restore |
4 years ago