Search in sources :

Example 1 with Event

use of com.walmartlabs.concord.server.events.Event in project concord by walmartlabs.

the class OneOpsEventResource method event.

@POST
@Path("/oneops")
@Consumes(MediaType.APPLICATION_JSON)
@WithTimer
public Response event(Map<String, Object> event) {
    if (executor.isDisabled(EVENT_SOURCE)) {
        log.warn("event ['{}'] disabled", EVENT_SOURCE);
        return Response.ok().build();
    }
    if (event == null || event.isEmpty()) {
        return Response.status(Status.BAD_REQUEST).build();
    }
    if (cfg.isLogEvents()) {
        auditLog.add(AuditObject.EXTERNAL_EVENT, AuditAction.ACCESS).field("source", EVENT_SOURCE).field("eventId", String.valueOf(event.get("cmsId"))).field("payload", event).log();
    }
    List<OneOpsTriggerProcessor.Result> results = new ArrayList<>();
    processors.forEach(p -> p.process(event, results));
    for (OneOpsTriggerProcessor.Result result : results) {
        Event e = Event.builder().id(String.valueOf(event.get("cmsId"))).name(EVENT_SOURCE).attributes(result.event()).initiator(memo(new EventInitiatorSupplier("author", userManager, result.event()))).build();
        List<PartialProcessKey> processKeys = executor.execute(e, initiatorResolver, result.triggers());
        log.info("event ['{}'] -> done, {} processes started", e.id(), processKeys.size());
    }
    return Response.ok().build();
}
Also used : PartialProcessKey(com.walmartlabs.concord.server.sdk.PartialProcessKey) ArrayList(java.util.ArrayList) Event(com.walmartlabs.concord.server.events.Event) EventInitiatorSupplier(com.walmartlabs.concord.server.events.EventInitiatorSupplier) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer)

Aggregations

Event (com.walmartlabs.concord.server.events.Event)1 EventInitiatorSupplier (com.walmartlabs.concord.server.events.EventInitiatorSupplier)1 PartialProcessKey (com.walmartlabs.concord.server.sdk.PartialProcessKey)1 WithTimer (com.walmartlabs.concord.server.sdk.metrics.WithTimer)1 ArrayList (java.util.ArrayList)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1