blob: 86ea869f728b28fd7029814d60e139359f4c6daf [file] [log] [blame]
import Util;
import OpenApi;
import SDKClient;
import Console;
type @sdkClient = SDKClient;
type @endpoint = string;
init(){
@endpoint = '127.0.0.1:7001';
var config = new OpenApi.Config{
endpoint = @endpoint
};
@sdkClient = new SDKClient(config);
}
/**
EventSource Controller apis:
* createEventSource *
* updateEventSource *
* deleteEventSource *
* getEventSource *
* listEventSources *
*/
async function testCreateEventSource(): void {
var request = new SDKClient.CreateEventSourceRequest{
eventBusName = 'newBus',
eventSourceName = 'newSource',
description = 'a source for test'
};
try {
var res = @sdkClient.createEventSource(request);
Console.log(Util.toJSONString(res.body));
} catch(err) {
Console.log('err!');
Console.log(err.message);
} finally {
Console.log('test end!');
}
}
async function testUpdateEventSource(): void {
var request = new SDKClient.UpdateEventSourceRequest{
eventBusName = 'newBus',
eventSourceName = 'newSource',
description = 'new description for testing Update API'
};
try {
var res = @sdkClient.updateEventSource(request);
Console.log(Util.toJSONString(res.body));
} catch(err) {
Console.log('err!');
Console.log(err.message);
} finally {
Console.log('test end!');
}
}
async function testDeleteEventSource(): void {
var request = new SDKClient.DeleteEventSourceRequest{
eventBusName = 'newBus',
eventSourceName = 'newSource'
};
try {
var res = @sdkClient.deleteEventSource(request);
Console.log(Util.toJSONString(res.body));
} catch(err) {
Console.log('err!');
Console.log(err.message);
} finally {
Console.log('test end!');
}
}
async function testGetEventSource(): void {
var request = new SDKClient.GetEventSourceRequest{
eventBusName = 'newBus',
eventSourceName = 'newSource'
};
try {
var res = @sdkClient.getEventSource(request);
Console.log(Util.toJSONString(res.body));
} catch(err) {
Console.log('err!');
Console.log(err.message);
} finally {
Console.log('test end!');
}
}
async function testListEventSources(): void {
var request = new SDKClient.ListEventSourcesRequest{
eventBusName = 'newBus',
eventSourceType = 'USER_DEFINED',
maxResults = 10,
nextToken = "0"
};
try {
var res = @sdkClient.listEventSources(request);
Console.log(Util.toJSONString(res.body));
} catch(err) {
Console.log('err!');
Console.log(err.message);
} finally {
Console.log('test end!');
}
}